-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathbot.py
99 lines (89 loc) · 3.49 KB
/
bot.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# (©)Codexbotz
# Recode by @mrismanaziz
# t.me/SharingUserbot & t.me/Lunatic0de
import pyromod.listen
import sys
from pyrogram import Client, enums
from config import (
API_HASH,
APP_ID,
CHANNEL_ID,
FORCE_SUB,
LOGGER,
OWNER,
TG_BOT_TOKEN,
TG_BOT_WORKERS,
)
class Bot(Client):
def __init__(self):
super().__init__(
name="Bot",
api_hash=API_HASH,
api_id=APP_ID,
plugins={"root": "plugins"},
workers=TG_BOT_WORKERS,
bot_token=TG_BOT_TOKEN,
)
self.LOGGER = LOGGER
async def start(self):
try:
await super().start()
usr_bot_me = await self.get_me()
self.username = usr_bot_me.username
self.namebot = usr_bot_me.first_name
self.LOGGER(__name__).info(
f"TG_BOT_TOKEN detected!\n┌ First Name: {self.namebot}\n└ Username: @{self.username}\n——"
)
except Exception as a:
self.LOGGER(__name__).warning(a)
self.LOGGER(__name__).info(
"Bot Berhenti. Gabung Group https://t.me/SharingUserbot untuk Bantuan"
)
sys.exit()
for key, channel_id in FORCE_SUB.items():
try:
info = await self.get_chat(channel_id)
link = info.invite_link
if not link:
await self.export_chat_invite_link(channel_id)
link = info.invite_link
setattr(self, f"invitelink{key}", link)
self.LOGGER(__name__).info(
f"FORCE_SUB{key} detected!\n┌ Title: {info.title}\n└ Chat ID: {info.id}\n——"
)
except Exception as a:
self.LOGGER(__name__).warning(a)
self.LOGGER(__name__).warning(
f"Bot tidak dapat Mengambil link invite dari FORCE_SUB{key}!"
)
self.LOGGER(__name__).warning(
f"Pastikan @{self.username} adalah admin di Channel Tersebut, Chat ID untuk FORCE_SUB{key}: {channel_id}"
)
self.LOGGER(__name__).info(
"Bot Berhenti. Gabung Group https://t.me/SharingUserbot untuk Bantuan"
)
sys.exit()
try:
db_channel = await self.get_chat(CHANNEL_ID)
self.db_channel = db_channel
test = await self.send_message(chat_id=db_channel.id, text="Test Message", disable_notification=True)
await test.delete()
self.LOGGER(__name__).info(
f"CHANNEL_ID Database detected!\n┌ Title: {db_channel.title}\n└ Chat ID: {db_channel.id}\n——"
)
except Exception as e:
self.LOGGER(__name__).warning(e)
self.LOGGER(__name__).warning(
f"Pastikan @{self.username} adalah admin di Channel DataBase anda, CHANNEL_ID Saat Ini: {CHANNEL_ID}"
)
self.LOGGER(__name__).info(
"Bot Berhenti. Gabung Group https://t.me/SharingUserbot untuk Bantuan"
)
sys.exit()
self.set_parse_mode(enums.ParseMode.HTML)
self.LOGGER(__name__).info(
f"[🔥 BERHASIL DIAKTIFKAN! 🔥]\n\nBOT Dibuat oleh @{OWNER}\nJika @{OWNER} Membutuhkan Bantuan, Silahkan Tanyakan di Grup https://t.me/SharingUserbot"
)
async def stop(self, *args):
await super().stop()
self.LOGGER(__name__).info("Bot stopped.")