forked from TgCatUB/catuserbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__main__.py
More file actions
55 lines (46 loc) · 1.54 KB
/
__main__.py
File metadata and controls
55 lines (46 loc) · 1.54 KB
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
47
48
49
50
51
52
53
54
55
import glob
from pathlib import Path
from sys import argv
import telethon.utils
from telethon import TelegramClient
from . import LOGS, bot
from .Config import Config
from .utils import load_module
async def add_bot(bot_token):
await bot.start(bot_token)
bot.me = await bot.get_me()
bot.uid = telethon.utils.get_peer_id(bot.me)
if len(argv) not in (1, 3, 4):
bot.disconnect()
else:
bot.tgbot = None
if Config.TG_BOT_USER_NAME_BF_HER is not None:
LOGS.info("Initiating Inline Bot")
# ForTheGreatrerGood of beautification
bot.tgbot = TelegramClient(
"TG_BOT_TOKEN", api_id=Config.APP_ID, api_hash=Config.API_HASH
).start(bot_token=Config.TG_BOT_TOKEN_BF_HER)
LOGS.info("Initialisation finished with no errors")
LOGS.info("Starting Userbot")
bot.loop.run_until_complete(add_bot(Config.TG_BOT_USER_NAME_BF_HER))
LOGS.info("Startup Completed")
else:
bot.start()
path = "userbot/plugins/*.py"
files = glob.glob(path)
for name in files:
with open(name) as f:
path1 = Path(f.name)
shortname = path1.stem
if shortname.replace(".py", "") not in Config.NO_LOAD:
load_module(shortname.replace(".py", ""))
LOGS.info("Yay your userbot is officially working.!!!")
LOGS.info(
"Congratulation, now type .alive to see message if bot is live\n"
"If you need assistance, head to https://t.me/catuserbot_support"
)
if len(argv) not in (1, 3, 4):
bot.disconnect()
else:
bot.tgbot = None
bot.run_until_disconnected()