bot.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:Chiaki-Nanami 作者: Ikusaba-san 项目源码 文件源码
def __init__(self):
        super().__init__(command_prefix=_callable_prefix,
                         formatter=_chiaki_formatter,
                         description=config.description,
                         pm_help=None)

        # loop is needed to prevent outside coro errors
        self.session = aiohttp.ClientSession(loop=self.loop)
        self.table_base = None

        try:
            with open('data/command_image_urls.json') as f:
                self.command_image_urls = __import__('json').load(f)
        except FileNotFoundError:
            self.command_image_urls = {}

        self.message_counter = 0
        self.command_counter = collections.Counter()
        self.custom_prefixes = JSONFile('customprefixes.json')
        self.cog_aliases = {}

        self.reset_requested = False

        psql = f'postgresql://{config.psql_user}:{config.psql_pass}@{config.psql_host}/{config.psql_db}'
        self.db = asyncqlio.DatabaseInterface(psql)
        self.loop.run_until_complete(self._connect_to_db())

        self.db_scheduler = DatabaseScheduler(self.db, timefunc=datetime.utcnow)
        self.db_scheduler.add_callback(self._dispatch_from_scheduler)

        for ext in config.extensions:
            # Errors should never pass silently, if there's a bug in an extension,
            # better to know now before the bot logs in, because a restart
            # can become extremely expensive later on, especially with the
            # 1000 IDENTIFYs a day limit.
            self.load_extension(ext)

        self._game_task = self.loop.create_task(self.change_game())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号