-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
990 lines (942 loc) · 44.7 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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
from cProfile import run
import pstats
from pyobigram.utils import sizeof_fmt,get_file_size,createID,nice_time
from pyobigram.client import ObigramClient,inlineQueryResultArticle
from MoodleClient import MoodleClient
from JDatabase import JsonDatabase
import zipfile
import os
import infos
import xdlink
import mediafire
import datetime
import time
import youtube
import NexCloudClient
from pydownloader.downloader import Downloader
from ProxyCloud import ProxyCloud
import ProxyCloud
import socket
import tlmedia
import S5Crypto
import asyncio
import aiohttp
from yarl import URL
import re
from draft_to_calendar import send_calendar
def sign_url(token: str, url: URL):
query: dict = dict(url.query)
query["token"] = token
path = "webservice" + url.path
return url.with_path(path).with_query(query)
def downloadFile(downloader,filename,currentBits,totalBits,speed,time,args):
try:
bot = args[0]
message = args[1]
thread = args[2]
if thread.getStore('stop'):
downloader.stop()
downloadingInfo = infos.createDownloading(filename,totalBits,currentBits,speed,time,tid=thread.id)
bot.editMessageText(message,downloadingInfo)
except Exception as ex: print(str(ex))
pass
def uploadFile(filename,currentBits,totalBits,speed,time,args):
try:
bot = args[0]
message = args[1]
originalfile = args[2]
thread = args[3]
downloadingInfo = infos.createUploading(filename,totalBits,currentBits,speed,time,originalfile)
bot.editMessageText(message,downloadingInfo)
except Exception as ex: print(str(ex))
pass
def processUploadFiles(filename,filesize,files,update,bot,message,thread=None,jdb=None):
try:
bot.editMessageText(message,'📦Preparing for upload☁️...')
evidence = None
fileid = None
user_info = jdb.get_user(update.message.sender.username)
cloudtype = user_info['cloudtype']
proxy = ProxyCloud.parse(user_info['proxy'])
if cloudtype == 'moodle':
client = MoodleClient(user_info['moodle_user'],
user_info['moodle_password'],
user_info['moodle_host'],
user_info['moodle_repo_id'],
proxy=proxy)
loged = client.login()
itererr = 0
if loged:
if user_info['uploadtype'] == 'evidence':
evidences = client.getEvidences()
evidname = str(filename).split('.')[0]
for evid in evidences:
if evid['name'] == evidname:
evidence = evid
break
if evidence is None:
evidence = client.createEvidence(evidname)
originalfile = ''
if len(files)>1:
originalfile = filename
draftlist = []
for f in files:
f_size = get_file_size(f)
resp = None
iter = 0
tokenize = False
if user_info['tokenize']!=0:
tokenize = True
while resp is None:
if user_info['uploadtype'] == 'evidence':
fileid,resp = client.upload_file(f,evidence,fileid,progressfunc=uploadFile,args=(bot,message,originalfile,thread),tokenize=tokenize)
elif user_info['uploadtype'] == 'draft':
fileid,resp = client.upload_file_draft(f,progressfunc=uploadFile,args=(bot,message,originalfile,thread),tokenize=tokenize)
draftlist.append(resp)
elif user_info['uploadtype'] == 'perfil':
fileid,resp = client.upload_file_perfil(f,progressfunc=uploadFile,args=(bot,message,originalfile,thread),tokenize=tokenize)
draftlist.append(resp)
elif user_info['uploadtype'] == 'blog':
fileid,resp = client.upload_file_blog(f,progressfunc=uploadFile,args=(bot,message,originalfile,thread),tokenize=tokenize)
draftlist.append(resp)
elif user_info['uploadtype'] == 'calendar':
fileid,resp = client.upload_file_calendar(f,progressfunc=uploadFile,args=(bot,message,originalfile,thread),tokenize=tokenize)
draftlist.append(resp)
iter += 1
if iter>=10:
break
os.unlink(f)
if user_info['uploadtype'] == 'evidence':
try:
client.saveEvidence(evidence)
except:pass
return draftlist
else:
bot.editMessageText(message,'⚠️Cloud error⚠️')
elif cloudtype == 'cloud':
tokenize = False
if user_info['tokenize']!=0:
tokenize = True
bot.editMessageText(message,'🚀Uploading please wait')
host = user_info['moodle_host']
user = user_info['moodle_user']
passw = user_info['moodle_password']
remotepath = user_info['dir']
client = NexCloudClient.NexCloudClient(user,passw,host,proxy=proxy)
loged = client.login()
if loged:
originalfile = ''
if len(files)>1:
originalfile = filename
filesdata = []
for f in files:
data = client.upload_file(f,path=remotepath,progressfunc=uploadFile,args=(bot,message,originalfile,thread),tokenize=tokenize)
filesdata.append(data)
os.unlink(f)
return filesdata
return None
except Exception as ex:
bot.editMessageText(message,f'⚠️Error {str(ex)}⚠️')
def processFile(update,bot,message,file,thread=None,jdb=None):
file_size = get_file_size(file)
getUser = jdb.get_user(update.message.sender.username)
max_file_size = 1024 * 1024 * getUser['zips']
file_upload_count = 0
client = None
findex = 0
if file_size > max_file_size:
compresingInfo = infos.createCompresing(file,file_size,max_file_size)
bot.editMessageText(message,compresingInfo)
zipname = str(file).split('.')[0] + createID()
mult_file = zipfile.MultiFile(zipname,max_file_size)
zip = zipfile.ZipFile(mult_file, mode='w', compression=zipfile.ZIP_DEFLATED)
zip.write(file)
zip.close()
mult_file.close()
client = processUploadFiles(file,file_size,mult_file.files,update,bot,message,jdb=jdb)
try:
os.unlink(file)
except:pass
file_upload_count = len(zipfile.files)
else:
client = processUploadFiles(file,file_size,[file],update,bot,message,jdb=jdb)
file_upload_count = 1
bot.editMessageText(message,'📦Preparing file📄...')
evidname = ''
files = []
if client:
if getUser['cloudtype'] == 'moodle':
if getUser['uploadtype'] == 'evidence':
try:
evidname = str(file).split('.')[0]
txtname = evidname + '.txt'
evidences = client.getEvidences()
for ev in evidences:
if ev['name'] == evidname:
files = ev['files']
break
if len(ev['files'])>0:
findex+=1
client.logout()
except:pass
if getUser['uploadtype'] == 'draft' or getUser['uploadtype'] == 'blog' or getUser['uploadtype'] == 'calendar' or getUser['uploadtype'] == 'perfil':
for draft in client:
files.append({'name':draft['file'],'directurl':draft['url']})
else:
for data in client:
files.append({'name':data['name'],'directurl':data['url']})
bot.deleteMessage(message.chat.id,message.message_id)
finishInfo = infos.createFinishUploading(file,file_size,max_file_size,file_upload_count,file_upload_count,findex)
filesInfo = infos.createFileMsg(file,files)
bot.sendMessage(message.chat.id,finishInfo+'\n'+filesInfo,parse_mode='html')
if len(files)>0:
txtname = str(file).split('/')[-1].split('.')[0] + '.txt'
sendTxt(txtname,files,update,bot)
try:
import urllib
user_info = jdb.get_user(update.message.sender.username)
cloudtype = user_info['cloudtype']
proxy = ProxyCloud.parse(user_info['proxy'])
if cloudtype == 'moodle':
client = MoodleClient(user_info['moodle_user'],
user_info['moodle_password'],
user_info['moodle_host'],
user_info['moodle_repo_id'],
proxy=proxy)
host = user_info['moodle_host']
user = user_info['moodle_user']
passw = user_info['moodle_password']
if getUser['uploadtype'] == 'calendar' or getUser['uploadtype'] == 'draft':
nuevo = []
#if len(files)>0:
#for f in files:
#url = urllib.parse.unquote(f['directurl'],encoding='utf-8', errors='replace')
#nuevo.append(str(url))
fi = 0
for f in files:
separator = ''
if fi < len(files)-1:
separator += '\n'
nuevo.append(f['directurl']+separator)
fi += 1
urls = asyncio.run(send_calendar(host,user,passw,nuevo))
loged = client.login()
if loged:
token = client.userdata
modif = token['token']
client.logout()
nuevito = []
for url in urls:
url_signed = (str(sign_url(modif, URL(url))))
nuevito.append(url_signed)
loco = '\n'.join(map(str, nuevito))
fname = str(txtname)
with open(fname, "w") as f:
f.write(str(loco))
#fname = str(randint(100000000, 9999999999)) + ".txt"
bot.sendMessage(message.chat.id,'📅Calendar direct link/s🔗')
bot.sendFile(update.message.chat.id,fname)
else:
return
except:
bot.sendMessage(message.chat.id,'💢Could not move to calendar💢')
else:
bot.editMessageText(message,'⚠️Cloud error⚠️')
def ddl(update,bot,message,url,file_name='',thread=None,jdb=None):
downloader = Downloader()
file = downloader.download_url(url,progressfunc=downloadFile,args=(bot,message,thread))
if not downloader.stoping:
if file:
processFile(update,bot,message,file,jdb=jdb)
def sendTxt(name,files,update,bot):
txt = open(name,'w')
fi = 0
for f in files:
separator = ''
if fi < len(files)-1:
separator += '\n'
txt.write(f['directurl']+separator)
fi += 1
txt.close()
bot.sendFile(update.message.chat.id,name)
os.unlink(name)
def onmessage(update,bot:ObigramClient):
try:
thread = bot.this_thread
username = update.message.sender.username
#tl_admin_user = os.environ.get('tl_admin_user')
#set in debug
tl_admin_user = 'JAGB2021'
jdb = JsonDatabase('database')
jdb.check_create()
jdb.load()
user_info = jdb.get_user(username)
if username == tl_admin_user or user_info: # validate user
if user_info is None:
if username == tl_admin_user:
jdb.create_admin(username)
else:
jdb.create_user(username)
user_info = jdb.get_user(username)
jdb.save()
else:
mensaje = "🎐No tiene acceso.\n👨🏻💻Contacta a : @shadowalh\n"
intento_msg = "💢El usuario @"+username+ " está solicitando permiso para usar bot💢"
bot.sendMessage(update.message.chat.id,mensaje)
bot.sendMessage(1618347551,intento_msg)
return
msgText = ''
try: msgText = update.message.text
except:pass
# comandos de admin
if '/add' in msgText:
isadmin = jdb.is_admin(username)
if isadmin:
try:
user = str(msgText).split(' ')[1]
jdb.create_user(user)
jdb.save()
msg = '✅ @'+user+' has being added to the bot!'
bot.sendMessage(update.message.chat.id,msg)
except:
bot.sendMessage(update.message.chat.id,f'⚠️Command error /add username')
else:
bot.sendMessage(update.message.chat.id,'👮You do not have administrator permissions👮')
return
if '/admin' in msgText:
isadmin = jdb.is_admin(username)
if isadmin:
try:
user = str(msgText).split(' ')[1]
jdb.create_admin(user)
jdb.save()
msg = '✅Now @'+user+' is a bot administrator too!'
bot.sendMessage(update.message.chat.id,msg)
except:
bot.sendMessage(update.message.chat.id,f'⚠️Command error /admin username⚠️')
else:
bot.sendMessage(update.message.chat.id,'👮You do not have administrator permissions👮')
return
if '/preview' in msgText:
isadmin = jdb.is_admin(username)
if isadmin:
try:
user = str(msgText).split(' ')[1]
jdb.create_user_evea_preview(user)
jdb.save()
msg = '✅The user @'+user+' now is in test mode.'
bot.sendMessage(update.message.chat.id,msg)
except:
bot.sendMessage(update.message.chat.id,f'⚠️Command error /preview username⚠️')
else:
bot.sendMessage(update.message.chat.id,'👮You do not have administrator permissions👮')
return
if '/ban' in msgText:
isadmin = jdb.is_admin(username)
if isadmin:
try:
user = str(msgText).split(' ')[1]
if user == username:
bot.sendMessage(update.message.chat.id,'⚠️You can not ban yourself⚠️')
return
jdb.remove(user)
jdb.save()
msg = '𝚃𝚑𝚎 𝚞𝚜𝚎𝚛 @'+user+' 𝚑𝚊𝚜 𝚋𝚎𝚒𝚗𝚐 𝚋𝚊𝚗𝚗𝚎𝚍 𝚏𝚛𝚘𝚖 𝚝𝚑𝚎 𝚋𝚘𝚝!'
bot.sendMessage(update.message.chat.id,msg)
except:
bot.sendMessage(update.message.chat.id,'⚠️Command error /ban username⚠️')
else:
bot.sendMessage(update.message.chat.id,'👮You do not have administrator permissions👮')
return
if '/Keima4244' in msgText:
isadmin = jdb.is_admin(username)
if isadmin:
sms1 = bot.sendMessage(update.message.chat.id,'⏫Sending database...')
sms2 = bot.sendMessage(update.message.chat.id,'📦Database:')
bot.editMessageText(sms1,sms2)
bot.sendFile(update.message.chat.id,'database.jdb')
else:
bot.sendMessage(update.message.chat.id,'👮You do not have administrator permissions👮')
return
if '/Keima4242' in msgText:
isadmin = jdb.is_admin(username)
if isadmin:
database = open('database.jdb','r')
bot.sendMessage(update.message.chat.id,database.read())
database.close()
else:
bot.sendMessage(update.message.chat.id,'👮You do not have administrator permissions👮')
return
if '/useradm' in msgText:
isadmin = jdb.is_admin(username)
if isadmin:
message = bot.sendMessage(update.message.chat.id,'📄')
message = bot.sendMessage(update.message.chat.id,'🦾You are bot administrator, so you have total control over itself✅')
else:
message = bot.sendMessage(update.message.chat.id,'📄')
message = bot.sendMessage(update.message.chat.id,'🙁You are just an user, for now you have limitated control❎')
return
# end
# comandos de usuario
if '/help' in msgText:
message = bot.sendMessage(update.message.chat.id,'📄Guía de Usuario:')
tuto = open('tuto.txt','r')
bot.sendMessage(update.message.chat.id,tuto.read())
tuto.close()
return
if '/xdlink' in msgText:
try:
urls = str(msgText).split(' ')[1]
channelid = getUser['channelid']
xdlinkdd = xdlink.parse(urls, username)
msg = f'**Aquí está su link encriptado en xdlink:** `{xdlinkdd}`'
msgP = f'**Aquí está su link encriptado en xdlink protegido:** `{xdlinkdd}`'
if channelid == 0:
bot.sendMessage(chat_id = chatid, parse_mode = 'Markdown', text = msg)
else:
bot.sendMessage(chat_id = chatid, parse_mode = 'Markdown', text = msgP)
except:
msg = f'》*El comando debe ir acompañado de un link moodle*'
bot.sendMessage(chat_id = chatid, parse_mode = 'Markdown', text = msg)
return
if '/xdon' in msgText:
getUser = user_info
if getUser:
getUser['xdlink'] = 1
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.sendMessage(update.message.chat.id,statInfo)
return
if '/xdoff' in msgText:
getUser = user_info
if getUser:
getUser['xdlink'] = 0
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.sendMessage(update.message.chat.id,statInfo)
return
if '/channelid' in msgText:
channelId = str(msgText).split(' ')[1]
getUser = user_info
try:
if getUser:
getUser['channelid'] = str(msgText).split(' ')[1]
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.sendMessage(update.message.chat.id,statInfo)
except:
msg = f'》*El comando debe ir acompañado de un id de canal*\n\n*Ejemplo: -100XXXXXXXXXX*'
bot.sendMessage(chat_id = chatid, parse_mode = 'Markdown', text = msg)
return
if '/delChannel' in msgText:
getUser = user_info
if getUser:
getUser['channelid'] = 0
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.sendMessage(update.message.chat.id,statInfo)
return
if '/about' in msgText:
message = bot.sendMessage(update.message.chat.id,'📄')
información = open('información.txt','r')
bot.sendMessage(update.message.chat.id,información.read())
información.close()
return
if '/commands' in msgText:
message = bot.sendMessage(update.message.chat.id,'📄/setcommands to @BotFather')
comandos = open('comandos.txt','r')
bot.sendMessage(update.message.chat.id,comandos.read())
información.close()
return
if '/myuser' in msgText:
getUser = user_info
if getUser:
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.sendMessage(update.message.chat.id,statInfo)
return
if '/zips' in msgText:
getUser = user_info
if getUser:
try:
size = int(str(msgText).split(' ')[1])
getUser['zips'] = size
jdb.save_data_user(username,getUser)
jdb.save()
msg = '🗜️Perfect now the zips will be of '+ sizeof_fmt(size*1024*1024)+' the parts📚'
bot.sendMessage(update.message.chat.id,msg)
except:
bot.sendMessage(update.message.chat.id,'⚠️Command error /zips zips_size⚠️')
return
if '/gen' in msgText:
pass444
if '/acc' in msgText:
try:
account = str(msgText).split(' ',2)[1].split(',')
user = account[0]
passw = account[1]
getUser = user_info
if getUser:
getUser['moodle_user'] = user
getUser['moodle_password'] = passw
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.sendMessage(update.message.chat.id,statInfo)
except:
bot.sendMessage(update.message.chat.id,'⚠️Command error /acc user,password⚠️')
return
if '/host' in msgText:
try:
cmd = str(msgText).split(' ',2)
host = cmd[1]
getUser = user_info
if getUser:
getUser['moodle_host'] = host
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.sendMessage(update.message.chat.id,statInfo)
except:
bot.sendMessage(update.message.chat.id,'⚠️Command error /host cloud_url⚠️')
return
if '/repo' in msgText:
try:
cmd = str(msgText).split(' ',2)
repoid = int(cmd[1])
getUser = user_info
if getUser:
getUser['moodle_repo_id'] = repoid
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.sendMessage(update.message.chat.id,statInfo)
except:
bot.sendMessage(update.message.chat.id,'⚠️Command error /repo moodle_repo_id⚠️')
return
if '/encrypt_on' in msgText:
try:
getUser = user_info
if getUser:
getUser['tokenize'] = 1
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.sendMessage(update.message.chat.id,'🔒Encrypt download link/s.')
except:
bot.sendMessage(update.message.chat.id,'⚠️Command error /encrypt_on encrypt_state⚠️')
return
if '/encrypt_off' in msgText:
try:
getUser = user_info
if getUser:
getUser['tokenize'] = 0
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.sendMessage(update.message.chat.id,'🔒No encrypt download link/s.')
except:
bot.sendMessage(update.message.chat.id,'⚠️Command error /encript_off encrypt_state⚠️')
return
if '/cloud' in msgText:
try:
cmd = str(msgText).split(' ',2)
repoid = cmd[1]
getUser = user_info
if getUser:
getUser['cloudtype'] = repoid
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.sendMessage(update.message.chat.id,statInfo)
except:
bot.sendMessage(update.message.chat.id,'⚠️Command error /cloud (moodle or cloud)⚠️')
return
if '/uptype' in msgText:
try:
cmd = str(msgText).split(' ',2)
type = cmd[1]
getUser = user_info
if getUser:
getUser['uploadtype'] = type
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.sendMessage(update.message.chat.id,statInfo)
except:
bot.sendMessage(update.message.chat.id,'⚠️Command error /uptype (evidence,draft,blog,calendar)⚠️')
return
if '/search_proxy' in msgText:
msg_start = 'Buscando proxy, esto puede tardar de una a dos horas...'
bot.sendMessage(update.message.chat.id,msg_start)
print("Buscando proxy...")
for port in range(3029,3032):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(('152.206.139.117:',port))
if result == 0:
print ("Puerto abierto!")
print (f"Puerto: {port}")
proxy = f'152.206.139.117:{port}'
proxy_new = S5Crypto.encrypt(f'{proxy}')
msg = 'Su nuevo proxy es:\n\nsocks5://' + proxy_new
bot.sendMessage(update.message.chat.id,msg)
break
else:
print ("Error...Buscando...")
print (f"Buscando en el puerto: {port}")
sock.close()
return
if '/proxy' in msgText:
try:
cmd = str(msgText).split(' ',2)
proxy = cmd[1]
getUser = user_info
if getUser:
getUser['proxy'] = proxy
jdb.save_data_user(username,getUser)
jdb.save()
msg = '🧬Perfect, proxy equipped successfuly.'
bot.sendMessage(update.message.chat.id,msg)
except:
if user_info:
user_info['proxy'] = ''
statInfo = infos.createStat(username,user_info,jdb.is_admin(username))
bot.sendMessage(update.message.chat.id,'🧬Error equipping proxy.')
return
if '/cript' in msgText:
proxy_sms = str(msgText).split(' ')[1]
proxy = S5Crypto.encrypt(f'{proxy_sms}')
bot.sendMessage(update.message.chat.id, f'🧬Proxy encrypted:\n{proxy}')
return
if '/decript' in msgText:
proxy_sms = str(msgText).split(' ')[1]
proxy_de = S5Crypto.decrypt(f'{proxy_sms}')
bot.sendMessage(update.message.chat.id, f'🧬Proxy decrypted:\n{proxy_de}')
return
if '/off_proxy' in msgText:
try:
getUser = user_info
if getUser:
getUser['proxy'] = ''
jdb.save_data_user(username,getUser)
jdb.save()
msg = '🧬Alrigth, proxy unequipped successfuly.\n'
bot.sendMessage(update.message.chat.id,msg)
except:
if user_info:
user_info['proxy'] = ''
statInfo = infos.createStat(username,user_info,jdb.is_admin(username))
bot.sendMessage(update.message.chat.id,'🧬Error encrypting proxy.')
return
if '/view_proxy' in msgText:
try:
getUser = user_info
if getUser:
proxy = getUser['proxy']
message = bot.sendMessage(update.message.chat.id,'🧬The proxy that you are using now is:')
bot.sendMessage(update.message.chat.id,proxy)
except:
message = bot.sendMessage(update.message.chat.id,'🧬The proxy that you are using now is:')
bot.sendMessage(update.message.chat.id,proxy)
return
if '/dir' in msgText:
try:
cmd = str(msgText).split(' ',2)
repoid = cmd[1]
getUser = user_info
if getUser:
getUser['dir'] = repoid + '/'
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.sendMessage(update.message.chat.id,statInfo)
except:
bot.sendMessage(update.message.chat.id,'⚠️Command error /dir destiny_folder⚠️')
return
if '/cancel_' in msgText:
try:
cmd = str(msgText).split('_',2)
tid = cmd[1]
tcancel = bot.threads[tid]
msg = tcancel.getStore('msg')
tcancel.store('stop',True)
time.sleep(3)
bot.editMessageText(msg,'🚫Task cancelled🚫')
except Exception as ex:
print(str(ex))
return
#end
message = bot.sendMessage(update.message.chat.id,'🎐Analizyng...')
thread.store('msg',message)
if '/start' in msgText:
start_msg = '╭───ⓘ🎐Hola @' + str(username)+'─〄\n│\n'
start_msg+= '├🔗 Enlaces soportados enlaces directos\n│\n'
start_msg+= '├❔ Como Descargar\n│\n'
start_msg+= '├1. Envía el enlace directo.\n'
start_msg+= '├2. Usa el TXT de descarga que se\n│genera y los abres con el XDownloader\n│\n'
start_msg+= '├👨🏻💻Activar comandos /commands \n'
start_msg+= '├🤖Para saber más del bot /about \n'
start_msg+= '├👩🏻💻Para saber los comandos es /help\n│\n'
start_msg+= '╰ⓘQue disfutes del bot─〄\n'
bot.editMessageText(message,start_msg)
elif '/files' == msgText and user_info['cloudtype']=='moodle':
proxy = ProxyCloud.parse(user_info['proxy'])
client = MoodleClient(user_info['moodle_user'],
user_info['moodle_password'],
user_info['moodle_host'],
user_info['moodle_repo_id'],proxy=proxy)
loged = client.login()
if loged:
List = client.getEvidences()
List1=List[:45]
total=len(List)
List2=List[46:]
info1 = f'<b>Archivos: {str(total)}</b>\n\n'
info = f'<b>Archivos: {str(total)}</b>\n\n'
i = 0
for item in List1:
info += '<b>/del_'+str(i)+'</b> /txt_'+str(i)+'\n'
#info += '<b>'+item['name']+':</b>\n'
for file in item['files']:
info += '<a href="'+file['directurl']+'">\t'+file['name']+'</a>\n'
info+='\n'
i+=1
bot.editMessageText(message, f'{info}',parse_mode="html")
if len(List2)>0:
bot.sendMessage(update.message.chat.id,'⏳Conecting with the list number 2...')
for item in List2:
info1 += '<b>/del_'+str(i)+'</b> /txt_'+str(i)+'\n'
#info1 += '<b>'+item['name']+':</b>\n'
for file in item['files']:
info1 += '<a href="'+file['url']+'">\t'+file['name']+'</a>\n'
info1+='\n'
i+=1
bot.editMessageText(message, f'{info1}',parse_mode="html")
elif '/txt_' in msgText and user_info['cloudtype']=='moodle':
findex = str(msgText).split('_')[1]
findex = int(findex)
proxy = ProxyCloud.parse(user_info['proxy'])
client = MoodleClient(user_info['moodle_user'],
user_info['moodle_password'],
user_info['moodle_host'],
user_info['moodle_repo_id'],proxy=proxy)
loged = client.login()
if loged:
evidences = client.getEvidences()
evindex = evidences[findex]
txtname = evindex['name']+'.txt'
sendTxt(txtname,evindex['files'],update,bot)
client.logout()
bot.editMessageText(message,'TXT here📃')
else:
bot.editMessageText(message,'🤔')
message = bot.sendMessage(update.message.chat.id,'⚠️Error and possible causes:\n1-Check your account\n2-Server disabled: '+client.path)
pass
elif '/token' in msgText:
message2 = bot.editMessageText(message,'🤖Getting token, please wait...')
try:
proxy = ProxyCloud.parse(user_info['proxy'])
client = MoodleClient(user_info['moodle_user'],
user_info['moodle_password'],
user_info['moodle_host'],
user_info['moodle_repo_id'],proxy=proxy)
loged = client.login()
if loged:
token = client.userdata
modif = token['token']
bot.editMessageText(message2,'🤖Your token is: '+modif)
client.logout()
else:
bot.editMessageText(message2,'⚠️The moodle '+client.path+' does not have token⚠️')
except Exception as ex:
bot.editMessageText(message2,'⚠️The moodle '+client.path+' does not have token or check out your account⚠️')
elif '/del_' in msgText and user_info['cloudtype']=='moodle':
findex = int(str(msgText).split('_')[1])
proxy = ProxyCloud.parse(user_info['proxy'])
client = MoodleClient(user_info['moodle_user'],
user_info['moodle_password'],
user_info['moodle_host'],
user_info['moodle_repo_id'],
proxy=proxy)
loged = client.login()
if loged:
evfile = client.getEvidences()[findex]
client.deleteEvidence(evfile)
client.logout()
bot.editMessageText(message,'File deleted🗑️')
else:
bot.editMessageText(message,'🤔')
message = bot.sendMessage(update.message.chat.id,'⚠️Error and possible causes:\n1-Check your account\n2-Server disabled: '+client.path)
elif '/delall' in msgText and user_info['cloudtype']=='moodle':
proxy = ProxyCloud.parse(user_info['proxy'])
client = MoodleClient(user_info['moodle_user'],
user_info['moodle_password'],
user_info['moodle_host'],
user_info['moodle_repo_id'],
proxy=proxy)
loged = client.login()
if loged:
evfiles = client.getEvidences()
for item in evfiles:
client.deleteEvidence(item)
client.logout()
bot.editMessageText(message,'Files deleted🗑️')
else:
bot.editMessageText(message,'🤔')
message = bot.sendMessage(update.message.chat.id,'⚠️Error and possible causes:\n1-Check your account\n2-Server disabled: '+client.path)
elif '/delete' in msgText:
enlace = msgText.split('/delete')[-1]
proxy = ProxyCloud.parse(user_info['proxy'])
client = MoodleClient(user_info['moodle_user'],
user_info['moodle_password'],
user_info['moodle_host'],
user_info['moodle_repo_id'],
proxy=proxy)
loged= client.login()
if loged:
#update.message.chat.id
deleted = client.delete(enlace)
bot.sendMessage(update.message.chat.id, "Archivo eliminado con exito...")
elif '/aulacened' in msgText:
getUser = user_info
getUser['moodle_host'] = "https://aulacened.uci.cu/"
getUser['uploadtype'] = "draft"
getUser['moodle_user'] = "---"
getUser['moodle_password'] = "---"
getUser['moodle_repo_id'] = 5
getUser['zips'] = 120
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.editMessageText(message,"✅Aulacened configuration loaded")
elif '/uclv' in msgText:
getUser = user_info
getUser['moodle_host'] = "https://moodle.uclv.edu.cu/"
getUser['uploadtype'] = "calendar"
getUser['moodle_user'] = "---"
getUser['moodle_password'] = "---"
getUser['moodle_repo_id'] = 4
getUser['zips'] = 200
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.editMessageText(message,"✅Uclv configuration loaded")
elif '/aula_uclv' in msgText:
getUser = user_info
getUser['moodle_host'] = "https://aula.uclv.edu.cu/"
getUser['uploadtype'] = "evidence"
getUser['moodle_user'] = "---"
getUser['moodle_password'] = "---"
getUser['moodle_repo_id'] = 5
getUser['zips'] = 60
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.editMessageText(message,"✅Aula Uclv configuration loaded")
elif '/eva' in msgText:
getUser = user_info
getUser['moodle_host'] = "https://eva.uo.edu.cu/"
getUser['uploadtype'] = "draft"
getUser['moodle_user'] = "---"
getUser['moodle_password'] = "---"
getUser['moodle_repo_id'] = 4
getUser['zips'] = 50
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.editMessageText(message,"✅Eva configuration loaded")
elif '/cursos' in msgText:
getUser = user_info
getUser['moodle_host'] = "https://cursos.uo.edu.cu/"
getUser['uploadtype'] = "draft"
getUser['moodle_user'] = "---"
getUser['moodle_password'] = "---"
getUser['moodle_repo_id'] = 4
getUser['zips'] = 50
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.editMessageText(message,"✅Cursos configuration loaded")
elif '/posgrado' in msgText:
getUser = user_info
getUser['moodle_host'] = "https://posgrado.unica.cu/"
getUser['uploadtype'] = "calendar"
getUser['moodle_user'] = "---"
getUser['moodle_password'] = "---"
getUser['moodle_repo_id'] = 3
getUser['zips'] = 15
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.editMessageText(message,"✅Posgrado unica configuration loaded")
elif '/ismm' in msgText:
getUser = user_info
getUser['moodle_host'] = "http://moodle.ismm.edu.cu/"
getUser['uploadtype'] = "evidence"
getUser['moodle_user'] = "---"
getUser['moodle_password'] = "---"
getUser['moodle_repo_id'] = 4
getUser['zips'] = 50
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.editMessageText(message,"✅Ismm configuration loaded")
elif '/uvs' in msgText:
getUser = user_info
getUser['moodle_host'] = "https://uvs.ucm.cmw.sld.cu/"
getUser['uploadtype'] = "draft"
getUser['moodle_user'] = "---"
getUser['moodle_password'] = "---"
getUser['moodle_repo_id'] = 5
getUser['zips'] = 25
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.editMessageText(message,"✅Uvs configuration loaded")
elif '/eduvirtual' in msgText:
getUser = user_info
getUser['moodle_host'] = "https://eduvirtual.uho.edu.cu/"
getUser['uploadtype'] = "evidence"
getUser['moodle_user'] = "---"
getUser['moodle_password'] = "---"
getUser['moodle_repo_id'] = 3
getUser['zips'] = 50
jdb.save_data_user(username,getUser)
jdb.save()
statInfo = infos.createStat(username,getUser,jdb.is_admin(username))
bot.editMessageText(message,"✅Eduvirtual configuration loaded")
elif 'http' in msgText:
url = msgText
ddl(update,bot,message,url,file_name='',thread=thread,jdb=jdb)
else:
#if update:
# api_id = os.environ.get('api_id')
# api_hash = os.environ.get('api_hash')
# bot_token = os.environ.get('bot_token')
#
# set in debug
# api_id = 19811436
# api_hash = 'c38c42f5cf7eda2c68444fd877e20300'
# bot_token = '5488982155:AAEyElar_IrmZgDXuIa4vQ4Yrp1b3mPTxIw'
# chat_id = int(update.message.chat.id)
# message_id = int(update.message.message_id)
# import asyncio
# asyncio.run(tlmedia.download_media(api_id,api_hash,bot_token,chat_id,message_id))
# return
bot.editMessageText(message,'⚠️Error analizyng⚠️')
except Exception as ex:
print(str(ex))
def main():
bot_token = '5672164417:AAEuc0wjk4i_zKtSOyi0OFoz799Jg3v0JCs'
bot = ObigramClient(bot_token)
bot.onMessage(onmessage)
bot.run()
asyncio.run()
if __name__ == '__main__':
try:
main()
except:
main()