mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-10 21:50:59 -05:00
cleanup
This commit is contained in:
parent
75d38194ca
commit
070b637253
@ -132,7 +132,7 @@ class BotCommands():
|
||||
logs.log('SpiceBot_CommandsQuery', "sopel_modules not loaded :" + str(e))
|
||||
|
||||
# Extra directories
|
||||
for directory in botconfig.config.core.extra:
|
||||
for directory in botconfig.extra:
|
||||
filepathlisting.append(directory)
|
||||
|
||||
return filepathlisting
|
||||
|
||||
@ -5,7 +5,6 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
|
||||
from sopel.cli.run import build_parser, get_configuration
|
||||
|
||||
import sys
|
||||
import configparser
|
||||
|
||||
|
||||
class BotConfig():
|
||||
@ -22,29 +21,14 @@ class BotConfig():
|
||||
opts = parser.parse_args(argv)
|
||||
self.config = get_configuration(opts)
|
||||
|
||||
# Filename
|
||||
self.filename = self.config.filename
|
||||
|
||||
# load as dict
|
||||
config = configparser.ConfigParser()
|
||||
config.read(self.filename)
|
||||
for each_section in config.sections():
|
||||
if each_section.lower() not in self.dict.keys():
|
||||
self.dict[each_section.lower()] = dict()
|
||||
for (each_key, each_val) in config.items(each_section):
|
||||
if each_key.lower() not in self.dict[each_section.lower()].keys():
|
||||
self.dict[each_section.lower()][each_key.lower()] = each_val
|
||||
|
||||
def define_section(self, name, cls_, validate=True):
|
||||
return self.config.define_section(name, cls_, validate)
|
||||
|
||||
def __getattr__(self, name):
|
||||
''' will only get called for undefined attributes '''
|
||||
"""We will try to find a core value, or return None"""
|
||||
if hasattr(self.config.core, name):
|
||||
if hasattr(self.config, name):
|
||||
return eval("self.config.core." + name)
|
||||
elif name.lower() in self.dict["core"].keys():
|
||||
return self.dict["core"][str(name).lower()]
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ class BotLogs():
|
||||
logtitle = "[" + logtype + "]"
|
||||
logmessage = logtitle + " " + logentry
|
||||
|
||||
if botconfig.config.core.logging_channel:
|
||||
if botconfig.logging_channel:
|
||||
self.dict["queue"].append(logmessage)
|
||||
|
||||
if stdio:
|
||||
@ -57,7 +57,7 @@ class BotLogs():
|
||||
for logtype in self.dict["list"].keys():
|
||||
stdio_ignore.append("[" + logtype + "]")
|
||||
|
||||
logfile = os.path.os.path.join(botconfig.config.core.logdir, 'stdio.log')
|
||||
logfile = os.path.os.path.join(botconfig.logdir, 'stdio.log')
|
||||
|
||||
try:
|
||||
log_file_lines = []
|
||||
@ -105,12 +105,12 @@ class BotLogs():
|
||||
|
||||
def get_running_pid(self):
|
||||
try:
|
||||
filename = "/run/sopel/sopel-" + str(botconfig.config.core.nick) + ".pid"
|
||||
filename = "/run/sopel/sopel-" + str(botconfig.nick) + ".pid"
|
||||
with open(filename, 'r') as pid_file:
|
||||
pidnum = int(pid_file.read())
|
||||
except Exception as e:
|
||||
pidnum = e
|
||||
pidnum = str(os.popen("systemctl show " + str(botconfig.config.core.nick) + " --property=MainPID").read()).split("=")[-1]
|
||||
pidnum = str(os.popen("systemctl show " + str(botconfig.nick) + " --property=MainPID").read()).split("=")[-1]
|
||||
return pidnum
|
||||
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ github_dict = {
|
||||
def bot_privs(privtype):
|
||||
if privtype == 'owners':
|
||||
privtype = 'owner'
|
||||
botpriveval = eval("botconfig.config.config.core." + privtype)
|
||||
botpriveval = eval("botconfig." + privtype)
|
||||
if not isinstance(botpriveval, list):
|
||||
botpriveval = [botpriveval]
|
||||
return botpriveval
|
||||
|
||||
@ -10,4 +10,4 @@ import sopel_modules.SpiceBot as SpiceBot
|
||||
|
||||
@sopel.module.nickname_commands('database')
|
||||
def bot_command_gender(bot, trigger):
|
||||
bot.osd("Database is " + SpiceBot.config.dict["core"]["db_type"])
|
||||
bot.osd("Database is " + SpiceBot.config.db_type)
|
||||
|
||||
@ -55,7 +55,7 @@ def setup(bot):
|
||||
dir_to_scan.append(api_dir)
|
||||
|
||||
bot.config.define_section("SopelGifSearch", GifAPIMainSection, validate=False)
|
||||
SpiceBot.config.config.define_section("SopelGifSearch", GifAPIMainSection, validate=False)
|
||||
SpiceBot.config.define_section("SopelGifSearch", GifAPIMainSection, validate=False)
|
||||
if bot.config.SopelGifSearch.extra:
|
||||
dir_to_scan.append(bot.config.SopelGifSearch.extra)
|
||||
|
||||
@ -63,7 +63,7 @@ def setup(bot):
|
||||
|
||||
for gif_api in valid_gif_api_dict.keys():
|
||||
bot.config.define_section(gif_api, GifAPISection, validate=False)
|
||||
SpiceBot.config.config.define_section(gif_api, GifAPISection, validate=False)
|
||||
SpiceBot.config.define_section(gif_api, GifAPISection, validate=False)
|
||||
apikey = eval("bot.config." + gif_api + ".apikey")
|
||||
if apikey:
|
||||
valid_gif_api_dict[gif_api]["apikey"] = apikey
|
||||
|
||||
@ -42,7 +42,7 @@ def setup(bot):
|
||||
# verify config settings for server
|
||||
SpiceBot.logs.log('SpiceBot_Kick', "Checking for config settings")
|
||||
bot.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False)
|
||||
SpiceBot.config.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False)
|
||||
SpiceBot.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False)
|
||||
|
||||
|
||||
@module.event('005')
|
||||
|
||||
@ -18,7 +18,7 @@ def setup(bot):
|
||||
@sopel.module.rule('.*')
|
||||
def join_log_channel(bot, trigger):
|
||||
|
||||
if SpiceBot.config.config.core.logging_channel:
|
||||
if SpiceBot.config.logging_channel:
|
||||
channel = bot.config.core.logging_channel
|
||||
if channel not in bot.channels.keys():
|
||||
bot.write(('JOIN', bot.nick, channel))
|
||||
|
||||
@ -25,7 +25,7 @@ def configure(config):
|
||||
def setup(bot):
|
||||
SpiceBot.logs.log('SpiceBot_Update', "Initial Setup processing")
|
||||
bot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False)
|
||||
SpiceBot.config.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False)
|
||||
SpiceBot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False)
|
||||
|
||||
|
||||
@SpiceBot.prerun.prerun('nickname')
|
||||
|
||||
@ -50,7 +50,7 @@ def setup(bot):
|
||||
# verify config settings for server
|
||||
SpiceBot.logs.log('SpiceBot_OSD', "Checking for config settings")
|
||||
bot.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False)
|
||||
SpiceBot.config.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False)
|
||||
SpiceBot.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False)
|
||||
|
||||
|
||||
@module.event('005')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user