-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
155 lines (143 loc) · 7.63 KB
/
bot.py
File metadata and controls
155 lines (143 loc) · 7.63 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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#(©)Codexbotz
from aiohttp import web
from plugins import web_server
import pyromod.listen
from pyrogram import Client
from pyrogram.enums import ParseMode
import sys
from datetime import datetime
from config import API_HASH, APP_ID, LOGGER, TG_BOT_TOKEN, TG_BOT_WORKERS, FORCE_SUB_CHANNEL, CHANNEL_ID, PORT
name ="""
░█████╗░░█████╗░██████╗░███████╗██╗░░██╗██████╗░░█████╗░████████╗███████╗
██╔══██╗██╔══██╗██╔══██╗██╔════╝╚██╗██╔╝██╔══██╗██╔══██╗╚══██╔══╝╚════██║
██║░░╚═╝██║░░██║██║░░██║█████╗░░░╚███╔╝░██████╦╝██║░░██║░░░██║░░░░░███╔═╝
██║░░██╗██║░░██║██║░░██║██╔══╝░░░██╔██╗░██╔══██╗██║░░██║░░░██║░░░██╔══╝░░
╚█████╔╝╚█████╔╝██████╔╝███████╗██╔╝╚██╗██████╦╝╚█████╔╝░░░██║░░░███████╗
░╚════╝░░╚════╝░╚═════╝░╚══════╝╚═╝░░╚═╝╚═════╝░░╚════╝░░░░╚═╝░░░╚══════╝
"""
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):
await super().start()
usr_bot_me = await self.get_me()
self.uptime = datetime.now()
if FORCE_SUB_1:
try:
info = await self.get_chat(FORCE_SUB_1)
link = info.invite_link
if not link:
await self.export_chat_invite_link(FORCE_SUB_1)
link = info.invite_link
self.invitelink = link
self.LOGGER(__name__).info(
"FORCE_SUB_1 Detected!\n"
f" Title: {info.title}\n"
f" Chat ID: {info.id}\n\n"
)
except Exception as a:
self.LOGGER(__name__).warning(a)
self.LOGGER(__name__).warning(
f"Pastikan @{self.username} "
"menjadi Admin di FORCE_SUB_1\n\n"
)
sys.exit()
if FORCE_SUB_2:
try:
info = await self.get_chat(FORCE_SUB_2)
link = info.invite_link
if not link:
await self.export_chat_invite_link(FORCE_SUB_2)
link = info.invite_link
self.invitelink2 = link
self.LOGGER(__name__).info(
"FORCE_SUB_2 Detected!\n"
f" Title: {info.title}\n"
f" Chat ID: {info.id}\n\n"
)
except Exception as a:
self.LOGGER(__name__).warning(a)
self.LOGGER(__name__).warning(
f"Pastikan @{self.username} "
"menjadi Admin di FORCE_SUB_2\n\n"
)
sys.exit()
if FORCE_SUB_3:
try:
info = await self.get_chat(FORCE_SUB_3)
link = info.invite_link
if not link:
await self.export_chat_invite_link(FORCE_SUB_1)
link = info.invite_link
self.invitelink3 = link
self.LOGGER(__name__).info(
"FORCE_SUB_3 Detected!\n"
f" Title: {info.title}\n"
f" Chat ID: {info.id}\n\n"
)
except Exception as a:
self.LOGGER(__name__).warning(a)
self.LOGGER(__name__).warning(
f"Pastikan @{self.username} "
"menjadi Admin di FORCE_SUB_3\n\n"
)
sys.exit()
if FORCE_SUB_4:
try:
info = await self.get_chat(FORCE_SUB_4)
link = info.invite_link
if not link:
await self.export_chat_invite_link(FORCE_SUB_4)
link = info.invite_link
self.invitelink4 = link
self.LOGGER(__name__).info(
"FORCE_SUB_4 Detected!\n"
f" Title: {info.title}\n"
f" Chat ID: {info.id}\n\n"
)
except Exception as a:
self.LOGGER(__name__).warning(a)
self.LOGGER(__name__).warning(
f"Pastikan @{self.username} "
"menjadi Admin di FORCE_SUB_4\n\n"
)
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")
await test.delete()
except Exception as e:
self.LOGGER(__name__).warning(e)
self.LOGGER(__name__).warning(f"Make Sure bot is Admin in DB Channel, and Double check the CHANNEL_ID Value, Current Value {CHANNEL_ID}")
self.LOGGER(__name__).info("\nBot Stopped. Join https://t.me/CodeXBotzSupport for support")
sys.exit()
self.set_parse_mode(ParseMode.HTML)
self.LOGGER(__name__).info(f"Bot Running..!\n\nCreated by \nhttps://t.me/CodeXBotz")
self.LOGGER(__name__).info(f""" \n\n
░█████╗░░█████╗░██████╗░███████╗██╗░░██╗██████╗░░█████╗░████████╗███████╗
██╔══██╗██╔══██╗██╔══██╗██╔════╝╚██╗██╔╝██╔══██╗██╔══██╗╚══██╔══╝╚════██║
██║░░╚═╝██║░░██║██║░░██║█████╗░░░╚███╔╝░██████╦╝██║░░██║░░░██║░░░░░███╔═╝
██║░░██╗██║░░██║██║░░██║██╔══╝░░░██╔██╗░██╔══██╗██║░░██║░░░██║░░░██╔══╝░░
╚█████╔╝╚█████╔╝██████╔╝███████╗██╔╝╚██╗██████╦╝╚█████╔╝░░░██║░░░███████╗
░╚════╝░░╚════╝░╚═════╝░╚══════╝╚═╝░░╚═╝╚═════╝░░╚════╝░░░░╚═╝░░░╚══════╝
""")
self.username = usr_bot_me.username
#web-response
app = web.AppRunner(await web_server())
await app.setup()
bind_address = "0.0.0.0"
await web.TCPSite(app, bind_address, PORT).start()
async def stop(self, *args):
await super().stop()
self.LOGGER(__name__).info("Bot stopped.")