forked from xditya/TeleBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__main__.py
83 lines (71 loc) · 2.5 KB
/
__main__.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import glob
from telebot import bot
from sys import argv
from telethon import TelegramClient
from telebot.telebotConfig import Var
from telebot.utils import load_module, start_mybot, load_pmbot
from pathlib import Path
import telethon.utils
from telebot import CMD_HNDLR
TELE = Var.PRIVATE_GROUP_ID
BOTNAME = Var.TG_BOT_USER_NAME_BF_HER
LOAD_MYBOT = Var.LOAD_MYBOT
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)
async def startup_log_all_done():
try:
await bot.send_message(TELE, f"**TeleBot has been deployed.\nSend** `{CMD_HNDLR}alive` **to see if the bot is working.\n\nAdd** @{BOTNAME} **to this group and make it admin for enabling all the features of TeleBot**")
except BaseException:
print("Either PRIVATE_GROUP_ID is wrong or you have left the group.")
if len(argv) not in (1, 3, 4):
bot.disconnect()
else:
bot.tgbot = None
if Var.TG_BOT_USER_NAME_BF_HER is not None:
print("Initiating Inline Bot")
# ForTheGreatrerGood of beautification
bot.tgbot = TelegramClient(
"TG_BOT_TOKEN",
api_id=Var.APP_ID,
api_hash=Var.API_HASH
).start(bot_token=Var.TG_BOT_TOKEN_BF_HER)
print("Initialisation finished, no errors")
print("Starting Userbot")
bot.loop.run_until_complete(add_bot(Var.TG_BOT_USER_NAME_BF_HER))
print("Startup Completed")
else:
bot.start()
path = 'telebot/plugins/*.py'
files = glob.glob(path)
for name in files:
with open(name) as f:
path1 = Path(f.name)
shortname = path1.stem
load_module(shortname.replace(".py", ""))
print("TeleBot has been deployed! ")
print("Setting up TGBot")
path = "telebot/plugins/mybot/*.py"
files = glob.glob(path)
for name in files:
with open(name) as f:
path1 = Path(f.name)
shortname = path1.stem
start_mybot(shortname.replace(".py", ""))
if LOAD_MYBOT == "True":
path = "telebot/plugins/mybot/pmbot/*.py"
files = glob.glob(path)
for name in files:
with open(name) as f:
path1 = Path(f.name)
shortname = path1.stem
load_pmbot(shortname.replace(".py", ""))
print("TGBot set up completely!")
print("TGBot set up - Level - Basic")
print("TeleBot has been fully deployed! Do Visit @TeleBotSupport")
bot.loop.run_until_complete(startup_log_all_done())
if len(argv) not in (1, 3, 4):
bot.disconnect()
else:
bot.run_until_disconnected()