def __init__(self, main_loop, notrealy=False): super().__init__(loop=main_loop) ioloop = AsyncIOMainLoop() ioloop.asyncio_loop = main_loop ioloop.install() self.notrealy = notrealy self.tornado_loop = ioloop self.config = config.Config() self.admins = self.config.get('discord.admins', []) self._next_restart = 0 self.disconnect = False self.tasks = [] self.http_client = http.init(self) if not self.http_client: raise EnvironmentError('Can not start without http lib.') self.scheduler = scheduler.Scheduler(self) self.sqlcon = sql.init(self) self.modules = BotModules(self) token = self.config.get('discord.token', None) self.user_token = None if token: self.user_token = token else: self.user_login = self.config.get('discord.login') self.user_password = self.config.get('discord.password') self.unflip = self.config.get('discord.unflip', False) self.ifnfo_line = ifnfo_line % self.config.get('version') @self.event async def on_message(message): logger.debug('New message %s', message) await self.msg_proc(message) @self.event async def on_message_edit(old_message, message): logger.debug('Message edited ftom %s to %s', old_message, message) await self.msg_proc(message) @self.event async def on_ready(): logger.debug('Logged in as %s (%s)', self.user.name, self.user.id) waiters = [] for upd in self.modules.updates: waiters.append(upd.ready(self)) for one_wait in waiters: await one_wait
def _get_event_loop(): from tornado.platform.asyncio import AsyncIOMainLoop loop = AsyncIOMainLoop() loop.install() return loop
def _get_event_loop(): from tornado.platform.asyncio import AsyncIOMainLoop loop = AsyncIOMainLoop() loop.install() return loop