Exemple #1
0
    def test_load_file(self):
        here = path.dirname(__file__)
        filename = path.join(here, 'files/sample.yml')
        root = Root()
        root.load_file(filename)
        self.assertEqual(2, root.a.b)

        with self.assertRaises(FileNotFoundError):
            root.load_file('not/exists')
Exemple #2
0
    def test_load_file(self):
        here = path.dirname(__file__)
        filename = path.join(here, 'files/sample.yml')
        root = Root()
        root.load_file(filename)
        assert root.a.b == 2

        with pytest.raises(FileNotFoundError):
            root.load_file('not/exists')
Exemple #3
0
def init_config(config_file=None):
    global _cfg
    if not path.exists(data_dir):
        mkdir(data_dir)

    _cfg = Root(__builtin_config__,
                context=dict(data_dir=data_dir,
                             time_format='"%Y-%m-%d %H:%M"',
                             date_format='"%Y-%m-%d"'))

    if path.exists(user_config_file):
        _cfg.load_file(user_config_file)

    if config_file:
        _cfg.load_file(config_file)
Exemple #4
0
from discord.ext import commands
from urssediscord.commands.StandardCommands import StandardCommands
from urssediscord.commands.SkillTreeCommands import SkillTreeCommands
from urssediscord.events.imagebomb.ImageBomb import ImageBomb
from urssediscord.utilities.Roles import has_role
from urssediscord.events.OnReady import on_ready
from urssediscord.events.OnJoin import on_join

from pymlconf import Root

config = Root()
config.load_file('config/app.yaml')


class SSEBot(commands.Bot):
    def __init__(self,
                 command_prefix,
                 formatter=None,
                 description=None,
                 pm_help=False,
                 **options):
        super().__init__(command_prefix, formatter, description, pm_help,
                         **options)
        self.add_cog(StandardCommands(self))
        self.add_cog(SkillTreeCommands(self))

    async def on_ready(self):
        # This command is commented out for now.
        # When starting the bot, this will give any user without a text channel their own text channel.
        #
        await on_ready(self)