mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 06:59:53 -05:00
test configure and setup migration
This commit is contained in:
parent
12737d5381
commit
81acd5ae49
@ -36,10 +36,15 @@ class BotConfig():
|
|||||||
if each_key.lower() not in self.dict[each_section.lower()].keys():
|
if each_key.lower() not in self.dict[each_section.lower()].keys():
|
||||||
self.dict[each_section.lower()][each_key.lower()] = each_val
|
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):
|
def __getattr__(self, name):
|
||||||
''' will only get called for undefined attributes '''
|
''' will only get called for undefined attributes '''
|
||||||
"""We will try to find a core value, or return None"""
|
"""We will try to find a core value, or return None"""
|
||||||
if name.lower() in self.dict["core"].keys():
|
if hasattr(self.config.core, name):
|
||||||
|
return eval("self.config.core." + name)
|
||||||
|
elif name.lower() in self.dict["core"].keys():
|
||||||
return self.dict["core"][str(name).lower()]
|
return self.dict["core"][str(name).lower()]
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|||||||
@ -6,6 +6,9 @@ These are the core SpiceBot Classes
|
|||||||
This module contains references only for other modules to utilize.
|
This module contains references only for other modules to utilize.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from .configure import *
|
||||||
|
from .setup import *
|
||||||
|
|
||||||
from .Config import *
|
from .Config import *
|
||||||
from .Tools import *
|
from .Tools import *
|
||||||
from .Logs import *
|
from .Logs import *
|
||||||
|
|||||||
22
sopel_modules/SpiceBot/configure.py
Normal file
22
sopel_modules/SpiceBot/configure.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# coding=utf8
|
||||||
|
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||||
|
"""Configuration for SpiceBot"""
|
||||||
|
|
||||||
|
import sopel.module
|
||||||
|
from sopel.config.types import StaticSection, ValidatedAttribute, ListAttribute
|
||||||
|
|
||||||
|
|
||||||
|
class SpiceBot_Channels_MainSection(StaticSection):
|
||||||
|
announcenew = ValidatedAttribute('announcenew', default=False)
|
||||||
|
joinall = ValidatedAttribute('joinall', default=False)
|
||||||
|
operadmin = ValidatedAttribute('operadmin', default=False)
|
||||||
|
chanignore = ListAttribute('chanignore')
|
||||||
|
|
||||||
|
|
||||||
|
def configure(config):
|
||||||
|
|
||||||
|
config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False)
|
||||||
|
config.SpiceBot_Channels.configure_setting('announcenew', 'SpiceBot_Channels Announce New Channels')
|
||||||
|
config.SpiceBot_Channels.configure_setting('joinall', 'SpiceBot_Channels JOIN New Channels')
|
||||||
|
config.SpiceBot_Channels.configure_setting('operadmin', 'SpiceBot_Channels OPER ADMIN MODE')
|
||||||
|
config.SpiceBot_Channels.configure_setting('chanignore', 'SpiceBot_Channels Ignore JOIN for channels')
|
||||||
19
sopel_modules/SpiceBot/setup.py
Normal file
19
sopel_modules/SpiceBot/setup.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# coding=utf8
|
||||||
|
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||||
|
"""Configuration for SpiceBot"""
|
||||||
|
|
||||||
|
import sopel.module
|
||||||
|
|
||||||
|
from .Logs import logs
|
||||||
|
from .Events import events
|
||||||
|
from .Config import config as botconfig
|
||||||
|
|
||||||
|
from .configure import SpiceBot_Channels_MainSection
|
||||||
|
|
||||||
|
|
||||||
|
def setup(bot):
|
||||||
|
|
||||||
|
logs.log('SpiceBot_Channels', "Starting setup procedure")
|
||||||
|
events.startup_add([events.BOT_CHANNELS])
|
||||||
|
bot.config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False)
|
||||||
|
botconfig.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False)
|
||||||
@ -4,7 +4,6 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
|
|||||||
|
|
||||||
# sopel imports
|
# sopel imports
|
||||||
import sopel.module
|
import sopel.module
|
||||||
from sopel.config.types import StaticSection, ValidatedAttribute, ListAttribute
|
|
||||||
|
|
||||||
import sopel_modules.SpiceBot as SpiceBot
|
import sopel_modules.SpiceBot as SpiceBot
|
||||||
|
|
||||||
@ -13,28 +12,6 @@ import spicemanip
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
class SpiceBot_Channels_MainSection(StaticSection):
|
|
||||||
announcenew = ValidatedAttribute('announcenew', default=False)
|
|
||||||
joinall = ValidatedAttribute('joinall', default=False)
|
|
||||||
operadmin = ValidatedAttribute('operadmin', default=False)
|
|
||||||
chanignore = ListAttribute('chanignore')
|
|
||||||
|
|
||||||
|
|
||||||
def configure(config):
|
|
||||||
config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False)
|
|
||||||
config.SpiceBot_Channels.configure_setting('announcenew', 'SpiceBot_Channels Announce New Channels')
|
|
||||||
config.SpiceBot_Channels.configure_setting('joinall', 'SpiceBot_Channels JOIN New Channels')
|
|
||||||
config.SpiceBot_Channels.configure_setting('operadmin', 'SpiceBot_Channels OPER ADMIN MODE')
|
|
||||||
config.SpiceBot_Channels.configure_setting('chanignore', 'SpiceBot_Channels Ignore JOIN for channels')
|
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
|
||||||
SpiceBot.logs.log('SpiceBot_Channels', "Starting setup procedure")
|
|
||||||
SpiceBot.events.startup_add([SpiceBot.events.BOT_CHANNELS])
|
|
||||||
bot.config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False)
|
|
||||||
SpiceBot.config.config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False)
|
|
||||||
|
|
||||||
|
|
||||||
@sopel.module.event(SpiceBot.events.RPL_WELCOME)
|
@sopel.module.event(SpiceBot.events.RPL_WELCOME)
|
||||||
@sopel.module.rule('.*')
|
@sopel.module.rule('.*')
|
||||||
def unkickable_bot(bot, trigger):
|
def unkickable_bot(bot, trigger):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user