-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsessionbot.py
More file actions
29 lines (21 loc) · 852 Bytes
/
sessionbot.py
File metadata and controls
29 lines (21 loc) · 852 Bytes
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
import os, logging
from telethon import TelegramClient
from telethon.sessions import MemorySession
async def start_session_bot(asst=None):
if not asst:
from core import asst, LOGS
else:
logging.basicConfig(level=logging.INFO)
LOGS = logging.getLogger()
# Clean UP
for i,e in asst.list_event_handlers():
asst.remove_event_handler(i, e)
# TODO: add session bot handlers to asst
if __name__ == "__main__":
BOT_TOKEN = os.getenv("BOT_TOKEN", input("Enter BOT TOKEN: "))
API_ID = int(os.getenv("API_ID", input("Enter API ID: ")))
API_HASH = os.getenv("API_HASH", input("Enter API Hash: "))
client = TelegramClient(MemorySession(), api_id=API_ID, api_hash=API_HASH)
client.start()
client.loop.run_until_complete(start_session_bot(client))
client.run_until_disconnected()