forked from 39bit/spoilerobot
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathspoilerobot.py
46 lines (30 loc) · 1014 Bytes
/
spoilerobot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import asyncio
import importlib
import logging
import os
from telethon import TelegramClient, utils
import database
import proxy
from config import ADMIN_ID, BOT_TOKEN
from message_serializer import deserialize_to_params
import file_id
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('main')
def load_handler_module(name):
proxy.logger = logging.getLogger(name)
return importlib.import_module(name)
async def main():
await database.init()
client = TelegramClient('spoilerobot', 6, 'eb06d4abfb49dc3eeb1aeb98ae0f581e')
client.parse_mode = 'html'
await client.start(bot_token=BOT_TOKEN)
me = await client.get_me()
logger.info(f'Running as @{me.username}')
# Assign some vars to the proxy module so handlers have access to it
proxy.client = client
proxy.me = await client.get_me()
load_handler_module('handlers_inline')
load_handler_module('handlers_callback')
load_handler_module('handlers_pm')
await client.run_until_disconnected()
asyncio.run(main())