-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
52 lines (41 loc) · 2.16 KB
/
Copy pathconfig.py
File metadata and controls
52 lines (41 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Config.ini parser for discord modular bot
# Copyright (C) 2024 adversarial
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
from configparser import ConfigParser
import json
import argparse
parser = argparse.ArgumentParser(prog='Discord bot skeleton',
description='Module based python bot.')
parser.add_argument('configfilename', nargs = '?', default = 'config.ini', help = 'Specify an optional config file.')
args = parser.parse_args()
config = { }
configfile = ConfigParser()
configfile.read(args.configfilename)
config['filename'] = args.configfilename
# constants
config['command_prefix'] = configfile['constants']['command_prefix']
config['bot_name'] = configfile['constants']['bot_name']
config['log_file_name'] = configfile['constants']['log_file']
# privileged command access
config['owner_ids'] = json.loads(configfile['settings']['owner_ids'])
config['mod_ids'] = json.loads(configfile['settings']['mod_ids'])
# plugin loading settings
config['plugin_directory'] = configfile['plugins']['plugin_directory']
config['plugin_whitelist_only'] = configfile.getboolean('plugins', 'whitelist_only')
config['plugin_whitelist'] = json.loads(configfile['plugins']['plugin_whitelist'])
# whitelists
config['guild_whitelist'] = json.loads(configfile['whitelists']['guild_ids'])
config['user_whitelist'] = json.loads(configfile['whitelists']['user_ids'])
# blacklists
config['guild_blacklist'] = json.loads(configfile['blacklists']['guild_ids'])
config['user_blacklist'] = json.loads(configfile['blacklists']['user_ids'])
# bans
config['guild_banlist'] = json.loads(configfile['banlists']['guild_ids'])
config['user_banlist'] = json.loads(configfile['banlists']['user_ids'])