mirror of
https://github.com/Nick80835/microbot
synced 2025-09-01 06:55:51 +00:00
gracefully handle keyboardinterrupt
This commit is contained in:
@@ -35,7 +35,6 @@ class MicroBot():
|
|||||||
|
|
||||||
async def _initialize_bot(self):
|
async def _initialize_bot(self):
|
||||||
global ldr
|
global ldr
|
||||||
global micro_bot
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.client = await telethon.TelegramClient(
|
self.client = await telethon.TelegramClient(
|
||||||
@@ -55,7 +54,6 @@ class MicroBot():
|
|||||||
self.me = await self.client.get_me()
|
self.me = await self.client.get_me()
|
||||||
self.loader = Loader(self)
|
self.loader = Loader(self)
|
||||||
ldr = self.loader
|
ldr = self.loader
|
||||||
micro_bot = self
|
|
||||||
self.loader.load_all_modules()
|
self.loader.load_all_modules()
|
||||||
logger.info("Bot successfully started.")
|
logger.info("Bot successfully started.")
|
||||||
|
|
||||||
@@ -79,4 +77,9 @@ class MicroBot():
|
|||||||
|
|
||||||
|
|
||||||
telethon.events.NewMessage.Event = ExtendedEvent
|
telethon.events.NewMessage.Event = ExtendedEvent
|
||||||
loop.run_until_complete(MicroBot().run_until_done())
|
micro_bot = MicroBot()
|
||||||
|
|
||||||
|
try:
|
||||||
|
loop.run_until_complete(micro_bot.run_until_done())
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
loop.run_until_complete(micro_bot.stop_client())
|
||||||
|
Reference in New Issue
Block a user