рефактор
This commit is contained in:
46
src/config/BotConfig.py
Normal file
46
src/config/BotConfig.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import configparser
|
||||
import os
|
||||
from typing import List
|
||||
import pandas
|
||||
|
||||
from src.model.MumbleChannel import MumbleChannel
|
||||
|
||||
|
||||
class BotConfig:
|
||||
config: configparser.ConfigParser
|
||||
adminList: List
|
||||
userList: configparser.ConfigParser
|
||||
channelList: List[MumbleChannel]
|
||||
|
||||
def __init__(self):
|
||||
self.load_settings()
|
||||
self.channelList = []
|
||||
self.load_channel_list()
|
||||
|
||||
def load_settings(self):
|
||||
self.config = configparser.ConfigParser()
|
||||
self.config.read('settings.ini', encoding="utf-8")
|
||||
self.adminList = self.config['Bot']['admins'].rsplit(sep=';')
|
||||
|
||||
if not os.path.exists(self.config['Bot']['userlist']):
|
||||
f = open(self.config['Bot']['userlist'], 'tw', encoding='utf-8')
|
||||
f.close()
|
||||
|
||||
self.userList = configparser.ConfigParser()
|
||||
self.userList.read(self.config['Bot']['userlist'])
|
||||
|
||||
def load_channel_list(self):
|
||||
data = pandas.read_csv('channels.csv', delimiter=";")
|
||||
data = data.reset_index()
|
||||
for index, row in data.iterrows():
|
||||
self.channelList.append(MumbleChannel(row['path'], row['message']))
|
||||
|
||||
|
||||
|
||||
|
||||
# bot = BotConfig()
|
||||
# config = bot.config
|
||||
# adminList = bot.adminList
|
||||
# userList = bot.userList
|
||||
#for ch in bot.channelList:
|
||||
# print(ch.__str__())
|
||||
Reference in New Issue
Block a user