kemoverse/bot/config.py
2025-06-12 13:25:04 +09:00

39 lines
1.3 KiB
Python

'''Essentials for the bot to function'''
import configparser
config = configparser.ConfigParser()
config.read('config.ini')
# Username for the bot
USER = config['application']['BotUser']
# API key for the bot
KEY = config['application']['ApiKey']
# Bot's Misskey instance URL
INSTANCE = config['application']['InstanceUrl']
# SQLite Database location
DB_PATH = config['application']['DatabaseLocation']
# Instance type validation
if 'InstanceType' not in config['application']:
raise ValueError("InstanceType must be specified in config.ini")
instance_type = config['application']['InstanceType'].lower()
if instance_type not in ('misskey', 'pleroma'):
raise ValueError("InstanceType must be either 'misskey' or 'pleroma'")
INSTANCE_TYPE = instance_type
# Web server port
WEB_PORT = config['application'].getint('WebPort', 5000)
# Trusted instances
trusted_instances_str = config['application'].get('TrustedInstances', '')
TRUSTED_INSTANCES = [instance.strip() for instance in trusted_instances_str.split(',') if instance.strip()]
# Extra stuff for control of the bot
# TODO: move this to db
# Fedi handles in the traditional 'user@domain.tld' style, allows these users
# to use extra admin exclusive commands with the bot'''
ADMINS = config['application']['DefaultAdmins']