Delete app.py
Browse files
app.py
DELETED
@@ -1,480 +0,0 @@
|
|
1 |
-
try:
|
2 |
-
import os,re,json,random,aiocron,asyncio
|
3 |
-
from telethon.sync import TelegramClient,events,functions,types
|
4 |
-
except ModuleNotFoundError:
|
5 |
-
os.system('pip install --upgrade pip && pip install telethon && pip install asyncio && pip install aiocron && clear')
|
6 |
-
os.sys.exit('installed the required packages !')
|
7 |
-
|
8 |
-
def get(file):
|
9 |
-
with open(file,'r') as r:
|
10 |
-
return json.load(r)
|
11 |
-
|
12 |
-
def put(file,data):
|
13 |
-
with open(file,'w') as w:
|
14 |
-
json.dump(data,w)
|
15 |
-
|
16 |
-
def font(text):
|
17 |
-
if isinstance(text,str):
|
18 |
-
text = text.lower()
|
19 |
-
return text.translate(text.maketrans('qwertyuiopasdfghjklzxcvbnm-0123456789','ǫᴡᴇʀᴛʏᴜɪᴏᴘᴀsᴅғɢʜᴊᴋʟᴢxᴄᴠʙɴᴍ-𝟎𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗'))
|
20 |
-
else:
|
21 |
-
return None
|
22 |
-
|
23 |
-
api_id = 11724276
|
24 |
-
api_hash = '0b7fd91855bf2ed8dd40e0d8cb685b86'
|
25 |
-
session = input('enter the session name : ')
|
26 |
-
|
27 |
-
bot = TelegramClient(session,api_id,api_hash)
|
28 |
-
|
29 |
-
dev = 5682758308
|
30 |
-
|
31 |
-
if not os.path.exists('data') or not os.path.isdir('data'):
|
32 |
-
os.mkdir('data')
|
33 |
-
|
34 |
-
if not os.path.exists(f'data/{session}.json') or not os.path.isfile(f'data/{session}.json'):
|
35 |
-
data = {'bot':'on','autojoin':'off','contact':'off','secretary':'off','forward':'off','forwardauthor':'off','forwardtime':10,'forwardid':0,'forwardchat':None,'forwardtype':None,'forwardreply':None,'subscription':30,'admins':[],'groups':[],'secretarytext':[]}
|
36 |
-
put(f'data/{session}.json',data)
|
37 |
-
|
38 |
-
async def forward_message(to_peer,id,from_peer,reply_text,drop_author):
|
39 |
-
message = await bot(functions.messages.ForwardMessagesRequest(from_peer = from_peer,id = [id],to_peer = to_peer,drop_author = drop_author))
|
40 |
-
if reply_text:
|
41 |
-
await bot.send_message(to_peer,reply_text,reply_to = message.updates[0].id)
|
42 |
-
|
43 |
-
forwardtime = get(f'data/{session}.json')['forwardtime']
|
44 |
-
|
45 |
-
@aiocron.crontab(f'*/{forwardtime} * * * *')
|
46 |
-
async def clock():
|
47 |
-
data = get(f'data/{session}.json')
|
48 |
-
if data['bot'] == 'on' and data['subscription'] != 0:
|
49 |
-
if data['forward'] == 'on':
|
50 |
-
if data['forwardid'] and data['forwardchat'] and data['forwardtype']:
|
51 |
-
i = 0
|
52 |
-
async for dialog in bot.iter_dialogs():
|
53 |
-
if (data['forwardtype'] == 'privates' and isinstance(dialog.entity,types.User)) or (data['forwardtype'] == 'groups' and isinstance(dialog.entity,types.Chat)) or (data['forwardtype'] == 'super groups' and isinstance(dialog.entity,types.Channel) and dialog.entity.megagroup):
|
54 |
-
try:
|
55 |
-
await forward_message(dialog.id,data['forwardid'],data['forwardchat'],data['forwardreply'],data['forwardauthor'] == 'off')
|
56 |
-
i += 1
|
57 |
-
except Exception as e:
|
58 |
-
await bot.send_message(dev,font(e))
|
59 |
-
await bot.send_message(dev,font(f'Sent to {i} of ' + data['forwardtype'] + ' !'))
|
60 |
-
|
61 |
-
@aiocron.crontab(f'12 12 * * *')
|
62 |
-
async def subscription():
|
63 |
-
data = get(f'data/{session}.json')
|
64 |
-
if data['subscription'] > 0:
|
65 |
-
data['subscription'] -= 1
|
66 |
-
put(f'data/{session}.json',data)
|
67 |
-
else:
|
68 |
-
await bot.send_message(dev,font('The subscription to this tabchi has ended !'))
|
69 |
-
|
70 |
-
@bot.on(events.NewMessage())
|
71 |
-
async def updateMessage(event):
|
72 |
-
data = get(f'data/{session}.json')
|
73 |
-
text = event.raw_text
|
74 |
-
chat_id = event.chat_id
|
75 |
-
from_id = event.sender_id
|
76 |
-
if from_id == dev or from_id in data['admins'] or chat_id in data['groups']:
|
77 |
-
if from_id == dev:
|
78 |
-
if match := re.match(r'AddSubscription (\d+)',text):
|
79 |
-
time = int(match.group(1))
|
80 |
-
data['subscription'] += time
|
81 |
-
put(f'data/{session}.json',data)
|
82 |
-
await event.reply(font('The subscription of the robot has been successfully increased !'))
|
83 |
-
elif match := re.match(r'LowSubscription (\d+)',text):
|
84 |
-
time = int(match.group(1))
|
85 |
-
data['subscription'] -= time
|
86 |
-
put(f'data/{session}.json',data)
|
87 |
-
await event.reply(font('The subscription of the robot has been successfully reduced !'))
|
88 |
-
if from_id != dev and data['subscription'] == 0:
|
89 |
-
return await event.reply(font('Your subscription has ended !'))
|
90 |
-
if match := re.match(r'(Bot|Secretary|Contact|AutoJoin|Forward|ForwardAuthor) ([Oo][Nn]|[Oo][Ff][Ff])',text):
|
91 |
-
index = match.group(1).lower()
|
92 |
-
status = match.group(2).lower()
|
93 |
-
data[index] = status
|
94 |
-
put(f'data/{session}.json',data)
|
95 |
-
await event.reply(font(f'{index} now is {status} !'))
|
96 |
-
elif data['bot'] == 'on':
|
97 |
-
if text == 'Help':
|
98 |
-
await event.reply(f'''
|
99 |
-
خاموش و روشن کردن ربات :
|
100 |
-
Bot on | off
|
101 |
-
خاموش و روشن کردن حالت منشی :
|
102 |
-
Secretary on | off
|
103 |
-
خاموش و روشن کردن حالت ذخیره خودکار مخاطب :
|
104 |
-
Contact on | off
|
105 |
-
خاموش و روشن کردن حالت عضو شدن خودکار لینک های خصوصی :
|
106 |
-
AutoJoin on | off
|
107 |
-
خاموش و روشن کردن فوروارد خودکار :
|
108 |
-
Forward on | off
|
109 |
-
فوروارد بدون نقل قول یا با نقل قول :
|
110 |
-
ForwardAuthor on | off
|
111 |
-
اطلاع از آنلاین بودن ربات :
|
112 |
-
Ping
|
113 |
-
گرفتن اطلاعات ربات :
|
114 |
-
Info
|
115 |
-
بدست آوردن اطلاعات یک فرد :
|
116 |
-
Id (REPLY)
|
117 |
-
اضافه کردن ادمین به ربات :
|
118 |
-
AddSudo (ID)
|
119 |
-
حذف ادمین از ربات :
|
120 |
-
DeleteSudo (ID)
|
121 |
-
گرفتن لیست ادمین ها :
|
122 |
-
SudoList
|
123 |
-
تغییر نام اکانت :
|
124 |
-
SetFirstName
|
125 |
-
تغییر نام خانوادگی اکانت :
|
126 |
-
SetLastName
|
127 |
-
تغییر بیوگرافی اکانت :
|
128 |
-
SetBiography
|
129 |
-
تغییر یوزرنیم اکانت :
|
130 |
-
SetUserName
|
131 |
-
تنظیم عکس برای عکس پروفایل اکانت :
|
132 |
-
SetPhoto (REPLY)
|
133 |
-
حذف تمام عکس های پروفایل ربات :
|
134 |
-
DeletePhoto
|
135 |
-
اضافه کردن متن منشی رندوم :
|
136 |
-
AddSecretary (TEXT)
|
137 |
-
حذف متن منشی :
|
138 |
-
DeleteSecretary (TEXT)
|
139 |
-
لیست متن های منشی رندوم :
|
140 |
-
SecretaryList
|
141 |
-
استارت کردن ربات :
|
142 |
-
Start (@username)
|
143 |
-
عضو شدن در یک گروه یا کانال :
|
144 |
-
Join (@username)
|
145 |
-
لفت دادن از یک گروه یا کانال :
|
146 |
-
Left (@username)
|
147 |
-
پاکسازی لیست مخاطبین :
|
148 |
-
CleanContactsList
|
149 |
-
اشتراک گزاری شماره اکانت :
|
150 |
-
Share
|
151 |
-
تنظیم زمان فوروارد خودکار :
|
152 |
-
ForwardTime (TIME)
|
153 |
-
اد کردن یه کاربر به همهی گروه ها :
|
154 |
-
AddAll (REPLY)
|
155 |
-
فوروارد برای همه :
|
156 |
-
ForwardAll (REPLY)
|
157 |
-
فوروارد برای پیوی ها :
|
158 |
-
ForwardPrivates (REPLY)
|
159 |
-
فوروارد برای گروه های عادی :
|
160 |
-
ForwardGroups (REPLY)
|
161 |
-
فوروارد برای سوپر گروه ها :
|
162 |
-
ForwardSuperGroups (REPLY)
|
163 |
-
تنظیم فوروارد خودکار :
|
164 |
-
SetForward privates | super groups | groups
|
165 |
-
تنظیم متن ریپلی کردن روی پیام فوروارد شده :
|
166 |
-
SetForwardReply (REPLY)
|
167 |
-
حذف متن ریپلی شده روی پیام فوروارد شده :
|
168 |
-
DeleteForwardReply
|
169 |
-
اضافه کردن یک گروه به عنوان گروه مدیریت اکانت :
|
170 |
-
AddGp (IN GROUP)
|
171 |
-
حذف کردن یک گروه از لیست گروه های مدیریت اکانت :
|
172 |
-
DeleteGp (IN GROUP)
|
173 |
-
|
174 |
-
اشتراک ربات : {data['subscription']}
|
175 |
-
''')
|
176 |
-
elif text == 'Ping':
|
177 |
-
await event.reply(font('I am Online !'))
|
178 |
-
elif text == 'Info':
|
179 |
-
private_chats = 0
|
180 |
-
bots = 0
|
181 |
-
groups = 0
|
182 |
-
broadcast_channels = 0
|
183 |
-
admin_in_groups = 0
|
184 |
-
creator_in_groups = 0
|
185 |
-
admin_in_broadcast_channels = 0
|
186 |
-
creator_in_channels = 0
|
187 |
-
unread_mentions = 0
|
188 |
-
unread = 0
|
189 |
-
largest_group_member_count = 0
|
190 |
-
largest_group_with_admin = 0
|
191 |
-
async for dialog in bot.iter_dialogs():
|
192 |
-
entity = dialog.entity
|
193 |
-
if isinstance(entity,types.Channel):
|
194 |
-
if entity.broadcast:
|
195 |
-
broadcast_channels += 1
|
196 |
-
if entity.creator or entity.admin_rights:
|
197 |
-
admin_in_broadcast_channels += 1
|
198 |
-
if entity.creator:
|
199 |
-
creator_in_channels += 1
|
200 |
-
elif entity.megagroup:
|
201 |
-
groups += 1
|
202 |
-
if entity.creator or entity.admin_rights:
|
203 |
-
admin_in_groups += 1
|
204 |
-
if entity.creator:
|
205 |
-
creator_in_groups += 1
|
206 |
-
elif isinstance(entity,types.User):
|
207 |
-
private_chats += 1
|
208 |
-
if entity.bot:
|
209 |
-
bots += 1
|
210 |
-
elif isinstance(entity,types.Chat):
|
211 |
-
groups += 1
|
212 |
-
if entity.creator or entity.admin_rights:
|
213 |
-
admin_in_groups += 1
|
214 |
-
if entity.creator:
|
215 |
-
creator_in_groups += 1
|
216 |
-
unread_mentions += dialog.unread_mentions_count
|
217 |
-
unread += dialog.unread_count
|
218 |
-
list = f'status !'
|
219 |
-
list += f'\nprivate chats : {private_chats}'
|
220 |
-
list += f'\nbots : {bots}'
|
221 |
-
list += f'\ngroups : {groups}'
|
222 |
-
list += f'\nbroadcast channels : {broadcast_channels}'
|
223 |
-
list += f'\nadmin in groups : {admin_in_groups}'
|
224 |
-
list += f'\ncreator in groups : {creator_in_groups}'
|
225 |
-
list += f'\nadmin in broadcast channels : {admin_in_broadcast_channels}'
|
226 |
-
list += f'\ncreator in channels : {creator_in_channels}'
|
227 |
-
list += f'\nunread mentions : {unread_mentions}'
|
228 |
-
list += f'\nunread : {unread}'
|
229 |
-
list += f'\nlargest group member count : {largest_group_member_count}'
|
230 |
-
list += f'\nlargest group with admin : {largest_group_with_admin}'
|
231 |
-
await event.reply(font(list))
|
232 |
-
elif match := re.match(r'AddSudo (\d+)',text):
|
233 |
-
id = int(match.group(1))
|
234 |
-
data['admins'].append(id)
|
235 |
-
put(f'data/{session}.json',data)
|
236 |
-
await event.respond(font(f'{id} was successfully added to the list of admins !'))
|
237 |
-
elif match := re.match(r'DeleteSudo (\d+)',text):
|
238 |
-
id = int(match.group(1))
|
239 |
-
data['admins'].remove(id)
|
240 |
-
put(f'data/{session}.json',data)
|
241 |
-
await event.respond(font(f'{id} was successfully removed from the list of admins !'))
|
242 |
-
elif text == 'SudoList':
|
243 |
-
list = font('Sudo List :')
|
244 |
-
for id in data['admins']:
|
245 |
-
list += f'\n• [ᴜsᴇʀ](tg://user?id={id})'
|
246 |
-
await event.respond(font(list))
|
247 |
-
elif text == 'CleanSudoList':
|
248 |
-
data['admins'] = []
|
249 |
-
put(f'data/{session}.json',data)
|
250 |
-
elif match := re.match(r'SetFirstName (.*)',text):
|
251 |
-
try:
|
252 |
-
await bot(functions.account.UpdateProfileRequest(first_name = match.group(1)))
|
253 |
-
await event.reply(font('Your first name has been successfully changed !'))
|
254 |
-
except Exception as e:
|
255 |
-
await event.reply(font(e))
|
256 |
-
elif match := re.match(r'SetLastName (.*)',text):
|
257 |
-
try:
|
258 |
-
await bot(functions.account.UpdateProfileRequest(last_name = match.group(1)))
|
259 |
-
await event.reply(font('Your last name has been successfully changed !'))
|
260 |
-
except Exception as e:
|
261 |
-
await event.reply(font(e))
|
262 |
-
elif match := re.match(r'SetBiography (.*)',text):
|
263 |
-
try:
|
264 |
-
await bot(functions.account.UpdateProfileRequest(about = match.group(1)))
|
265 |
-
await event.reply(font('Your Biography has been successfully changed !'))
|
266 |
-
except Exception as e:
|
267 |
-
await event.reply(font(e))
|
268 |
-
elif match := re.match(r'SetUserName (.*)',text):
|
269 |
-
try:
|
270 |
-
await bot(functions.account.UpdateUsernameRequest(username = match.group(1)))
|
271 |
-
await event.reply(font('Your username has been successfully changed !'))
|
272 |
-
except Exception as e:
|
273 |
-
await event.reply(font(e))
|
274 |
-
elif text == 'DeletePhoto':
|
275 |
-
try:
|
276 |
-
photos = await bot.get_profile_photos('me')
|
277 |
-
for photo in photos:
|
278 |
-
await bot(functions.photos.DeletePhotosRequest(id = [types.InputPhoto(id = photo.id,access_hash = photo.access_hash,file_reference = photo.file_reference)]))
|
279 |
-
await event.reply(font('All your photos have been deleted !'))
|
280 |
-
except Exception as e:
|
281 |
-
await event.reply(font(e))
|
282 |
-
elif match := re.match(r'AddSecretary (.*)',text):
|
283 |
-
if match.group(1) in data['secretarytext']:
|
284 |
-
await event.respond(font('This text is already saved !'))
|
285 |
-
else:
|
286 |
-
data['secretarytext'].append(match.group(1))
|
287 |
-
put(f'data/{session}.json',data)
|
288 |
-
await event.respond(font('This text has been successfully added !'))
|
289 |
-
elif match := re.match(r'DeleteSecretary (.*)',text):
|
290 |
-
if match.group(1) in data['secretarytext']:
|
291 |
-
data['secretarytext'].remove(match.group(1))
|
292 |
-
put(f'data/{session}.json',data)
|
293 |
-
await event.respond(font('This text has been successfully removed !'))
|
294 |
-
else:
|
295 |
-
await event.respond(font('This text does not exist !'))
|
296 |
-
elif text == 'SecretaryList':
|
297 |
-
list = font('Secretary List :')
|
298 |
-
for text in data['secretarytext']:
|
299 |
-
list += f'\n• {text}'
|
300 |
-
await event.respond(font(list))
|
301 |
-
elif match := re.match(r'Start (.*)',text):
|
302 |
-
try:
|
303 |
-
await bot.send_message(match.group(1),'/start')
|
304 |
-
await event.reply(font('The bot started successfully !'))
|
305 |
-
except Exception as e:
|
306 |
-
await event.reply(font(e))
|
307 |
-
elif match := re.match(r'Join (.*)',text):
|
308 |
-
invitelink = match.group(1)
|
309 |
-
explode = invitelink.split('/')
|
310 |
-
if len(explode) > 1:
|
311 |
-
try:
|
312 |
-
await bot(functions.messages.ImportChatInviteRequest(explode[-1]))
|
313 |
-
await event.reply(font('I became a member !'))
|
314 |
-
except Exception as e:
|
315 |
-
await event.reply(font(e))
|
316 |
-
else:
|
317 |
-
try:
|
318 |
-
await bot(functions.channels.JoinChannelRequest(invitelink))
|
319 |
-
await event.reply(font('I became a member !'))
|
320 |
-
except Exception as e:
|
321 |
-
await event.reply(font(e))
|
322 |
-
elif match := re.match(r'Left (.*)',text):
|
323 |
-
invitelink = match.group(1)
|
324 |
-
explode = invitelink.split('/')
|
325 |
-
if len(explode) > 1:
|
326 |
-
try:
|
327 |
-
group = await client.get_entity(invitelink)
|
328 |
-
await bot(functions.messages.DeleteExportedChatInviteRequest(int('-100' + str(group.id))))
|
329 |
-
event.reply(font('I became a member !'))
|
330 |
-
except Exception as e:
|
331 |
-
await event.reply(font(e))
|
332 |
-
else:
|
333 |
-
try:
|
334 |
-
await bot(functions.channels.LeaveChannelRequest(invitelink))
|
335 |
-
await event.reply(font('I became a member !'))
|
336 |
-
except Exception as e:
|
337 |
-
await event.reply(font(e))
|
338 |
-
elif text == 'CleanContactsList':
|
339 |
-
try:
|
340 |
-
contacts = await bot(functions.contacts.GetContactsRequest(hash = 0))
|
341 |
-
await bot(functions.contacts.DeleteContactsRequest(id = [contact.id for contact in contacts.users]))
|
342 |
-
await event.reply(font('All your contacts have been deleted !'))
|
343 |
-
except Exception as e:
|
344 |
-
await event.reply(font(e))
|
345 |
-
elif text == 'Share':
|
346 |
-
me = await bot.get_me()
|
347 |
-
await bot.send_file(event.chat_id,types.InputMediaContact(phone_number = me.phone,first_name = me.first_name,last_name = me.last_name or str(),vcard = str()))
|
348 |
-
elif match := re.match(r'ForwardTime (\d+)',text):
|
349 |
-
time = int(match.group(1))
|
350 |
-
clock.spec = f'*/{time} * * * *'
|
351 |
-
clock.start()
|
352 |
-
data['forwardtime'] = time
|
353 |
-
put(f'data/{session}.json',data)
|
354 |
-
await event.respond(font(f'The forwarding time was automatically set to {time} minute !'))
|
355 |
-
elif text == 'DeleteForwardReply':
|
356 |
-
data['forwardreply'] = None
|
357 |
-
put(f'data/{session}.json',data)
|
358 |
-
await event.reply(font(f'Replay on the forwarded message was successfully deleted !'))
|
359 |
-
elif event.is_reply:
|
360 |
-
if text == 'Id':
|
361 |
-
getMessage = await event.get_reply_message()
|
362 |
-
sender = getMessage.sender
|
363 |
-
id = sender.id
|
364 |
-
first_name = sender.first_name
|
365 |
-
last_name = sender.last_name
|
366 |
-
username = sender.username
|
367 |
-
phone = sender.phone
|
368 |
-
list = f'id : {id}'
|
369 |
-
list += f'\nfirst name : {first_name}'
|
370 |
-
list += f'\nlast name : {last_name}'
|
371 |
-
list += f'\nusername : {username}'
|
372 |
-
list += f'\nphone : {phone}'
|
373 |
-
await event.reply(font(list))
|
374 |
-
elif text == 'SetPhoto':
|
375 |
-
try:
|
376 |
-
message = await event.get_reply_message()
|
377 |
-
media = await bot.download_media(message)
|
378 |
-
await bot(functions.photos.UploadProfilePhotoRequest(await bot.upload_file(media)))
|
379 |
-
os.remove(media)
|
380 |
-
await event.reply(font('Your photo has been successfully changed !'))
|
381 |
-
except Exception as e:
|
382 |
-
await event.reply(font(e))
|
383 |
-
elif text == 'AddAll':
|
384 |
-
getMessage = await event.get_reply_message()
|
385 |
-
id = getMessage.sender.id
|
386 |
-
i = 0
|
387 |
-
async for dialog in bot.iter_dialogs():
|
388 |
-
if isinstance(dialog.entity,types.Chat) or (isinstance(dialog.entity,types.Channel) and dialog.entity.megagroup):
|
389 |
-
try:
|
390 |
-
await bot(functions.channels.InviteToChannelRequest(dialog.entity,[id]))
|
391 |
-
i += 1
|
392 |
-
except Exception as e:
|
393 |
-
await event.reply(font(e))
|
394 |
-
await event.reply(font(f'User {id} was successfully added to {i} groups !'))
|
395 |
-
elif text == 'ForwardAll':
|
396 |
-
i = 0
|
397 |
-
async for dialog in bot.iter_dialogs():
|
398 |
-
if isinstance(dialog.entity,(types.Chat,types.User)) or (isinstance(dialog.entity,types.Channel) and dialog.entity.megagroup):
|
399 |
-
try:
|
400 |
-
await forward_message(dialog.id,event.reply_to_msg_id,event.chat_id,data['forwardreply'],data['forwardauthor'] == 'off')
|
401 |
-
i += 1
|
402 |
-
except Exception as e:
|
403 |
-
await event.reply(font(e))
|
404 |
-
await event.reply(font(f'Sent to {i} of groups and super groups and privates !'))
|
405 |
-
elif text == 'ForwardPrivates':
|
406 |
-
i = 0
|
407 |
-
async for dialog in bot.iter_dialogs():
|
408 |
-
if isinstance(dialog.entity,types.User):
|
409 |
-
try:
|
410 |
-
await forward_message(dialog.id,event.reply_to_msg_id,event.chat_id,data['forwardreply'],data['forwardauthor'] == 'off')
|
411 |
-
i += 1
|
412 |
-
except Exception as e:
|
413 |
-
await event.reply(font(e))
|
414 |
-
await event.reply(font(f'Sent to {i} of privates !'))
|
415 |
-
elif text == 'ForwardGroups':
|
416 |
-
i = 0
|
417 |
-
async for dialog in bot.iter_dialogs():
|
418 |
-
if isinstance(dialog.entity,types.Chat):
|
419 |
-
try:
|
420 |
-
await forward_message(dialog.id,event.reply_to_msg_id,event.chat_id,data['forwardreply'],data['forwardauthor'] == 'off')
|
421 |
-
i += 1
|
422 |
-
except Exception as e:
|
423 |
-
await event.reply(font(e))
|
424 |
-
await event.reply(font(f'Sent to {i} of groups !'))
|
425 |
-
elif text == 'ForwardSuperGroups':
|
426 |
-
i = 0
|
427 |
-
async for dialog in bot.iter_dialogs():
|
428 |
-
if isinstance(dialog.entity,types.Channel) and dialog.entity.megagroup:
|
429 |
-
try:
|
430 |
-
await forward_message(dialog.id,event.reply_to_msg_id,event.chat_id,data['forwardreply'],data['forwardauthor'] == 'off')
|
431 |
-
i += 1
|
432 |
-
except Exception as e:
|
433 |
-
await event.reply(font(e))
|
434 |
-
await event.reply(font(f'Sent to {i} of super groups !'))
|
435 |
-
elif match := re.match(r'SetForward (privates|super groups|groups)',text):
|
436 |
-
data['forwardid'] = event.reply_to_msg_id
|
437 |
-
data['forwardchat'] = event.chat_id
|
438 |
-
data['forwardtype'] = match.group(1)
|
439 |
-
put(f'data/{session}.json',data)
|
440 |
-
await event.reply(font('Automatic forwarding has been successfully set !'))
|
441 |
-
elif text == 'SetForwardReply':
|
442 |
-
getMessage = await event.get_reply_message()
|
443 |
-
if getMessage.raw_text:
|
444 |
-
data['forwardreply'] = getMessage.raw_text
|
445 |
-
put(f'data/{session}.json',data)
|
446 |
-
await event.reply(font(f'The replay text was successfully set on the forwarded message !'))
|
447 |
-
else:
|
448 |
-
await event.reply(font(f'Please only reply to the text message !'))
|
449 |
-
elif event.is_group:
|
450 |
-
if text == 'AddGp':
|
451 |
-
data['groups'].append(int(chat_id))
|
452 |
-
put(f'data/{session}.json',data)
|
453 |
-
await event.reply(font('This group was added to the list of bot management groups !'))
|
454 |
-
elif text == 'DeleteGp':
|
455 |
-
data['groups'].remove(int(chat_id))
|
456 |
-
put(f'data/{session}.json',data)
|
457 |
-
await event.reply(font('This group was removed from the list of bot management groups !'))
|
458 |
-
elif text == 'AddContact':
|
459 |
-
try:
|
460 |
-
contacts = await bot(functions.contacts.GetContactsRequest(hash = 0))
|
461 |
-
await bot(functions.channels.InviteToChannelRequest(event.chat_id,[contact.id for contact in contacts.users]))
|
462 |
-
except Exception as e:
|
463 |
-
await event.reply(font(e))
|
464 |
-
await event.reply(font('I added most of my contacts to this group !'))
|
465 |
-
elif data['bot'] == 'on' and data['subscription'] != 0:
|
466 |
-
if data['secretary'] == 'on' and event.is_private:
|
467 |
-
if len(data['secretarytext']) > 0:
|
468 |
-
await event.reply(random.choice(data['secretarytext']))
|
469 |
-
if data['contact'] == 'on' and event.contact:
|
470 |
-
await bot(functions.contacts.AddContactRequest(id = event.contact.user_id,first_name = event.contact.first_name,last_name = event.contact.last_name,phone = event.contact.phone_number,add_phone_privacy_exception = False))
|
471 |
-
if data['autojoin'] == 'on':
|
472 |
-
if links := re.findall('(?:https?://)?(t|telegram)\.me/(?:\+|joinchat/)([\w\-]+)',text):
|
473 |
-
for link in links:
|
474 |
-
await bot(functions.messages.ImportChatInviteRequest(link[-1]))
|
475 |
-
|
476 |
-
bot.start()
|
477 |
-
clock.start()
|
478 |
-
subscription.start()
|
479 |
-
bot.run_until_disconnected()
|
480 |
-
asyncio.get_event_loop().run_forever()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|