-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.lua
2079 lines (2013 loc) · 94.6 KB
/
cli.lua
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
991
992
993
994
995
996
997
998
999
1000
bot = dofile('/home/username/inlinePV/utils.lua')
json = dofile('/home/username/inlinePV/JSON.lua')
URL = require "socket.url"
serpent = require("serpent")
http = require "socket.http"
https = require "ssl.https"
redis = require('redis')
db = redis.connect('127.0.0.1', 6379)
BASE = '/home/username/inlinePV/'
SUDO = 372897257 -- sudo id
sudo_users = {372897257,Userid}
BOTS = 249464384 -- bot id
bot_id = db:get(SUDO..'bot_id')
db:set(SUDO..'bot_on',"on")
function vardump(value)
print(serpent.block(value, {comment=false}))
end
function dl_cb(arg, data)
-- vardump(data)
--vardump(arg)
end
function is_sudo(msg)
local var = false
for k,v in pairs(sudo_users) do
if msg.sender_user_id_ == v then
var = true
end
end
return var
end
---------------------chek gp-------------------------------#MehTi
function chackgp(msg)
local hash = db:sismember('bot:gps', msg.chat_id_)
if hash then
return true
else
return false
end
end
---------------------sudos---------------------------------#MehTi
function is_sudoers(msg)
local hash = db:sismember(SUDO..'helpsudo:',msg.sender_user_id_)
if hash or is_sudo(msg) then
return true
else
return false
end
end
-----------------------------------------------------------
function is_master(msg)
local hash = db:sismember(SUDO..'masters:',msg.sender_user_id_)
if hash or is_sudo(msg) or is_sudoers(msg) then
return true
else
return false
end
end
------------------------------------------------------------
function is_bot(msg)
if tonumber(BOTS) == 330376543 then
return true
else
return false
end
end
------------------------------------------------------------
function is_owner(msg)
local hash = db:sismember(SUDO..'owners:'..msg.chat_id_,msg.sender_user_id_)
if hash or is_sudo(msg) or is_sudoers(msg) then
return true
else
return false
end
end
------------------------------------------------------------
function is_mod(msg)
local hash = db:sismember(SUDO..'mods:'..msg.chat_id_,msg.sender_user_id_)
if hash or is_sudo(msg) or is_owner(msg) or is_sudoers(msg) then
return true
else
return false
end
end
------------------------------------------------------------
function is_banned(chat,user)
local hash = db:sismember(SUDO..'banned'..chat,user)
if hash then
return true
else
return false
end
end
----------------------banall-------------------------------
function is_banall(chat,user)
local hash = db:sismember(SUDO..'banalled',user)
if hash then
return true
else
return false
end
end
------------------------------------------------------------
function is_filter(msg, value)
local hash = db:smembers(SUDO..'filters:'..msg.chat_id_)
if hash then
local names = db:smembers(SUDO..'filters:'..msg.chat_id_)
local text = ''
for i=1, #names do
if string.match(value:lower(), names[i]:lower()) and not is_mod(msg) then
local id = msg.id_
local msgs = {[0] = id}
local chat = msg.chat_id_
delete_msg(chat,msgs)
end
end
end
end
------------------------------------------------------------
function is_muted(chat,user)
local hash = db:sismember(SUDO..'mutes'..chat,user)
if hash then
return true
else
return false
end
end
-----------------------------------------------------------------------------------------------
function pin(channel_id, message_id, disable_notification)
tdcli_function ({
ID = "PinChannelMessage",
channel_id_ = getChatId(channel_id).ID,
message_id_ = message_id,
disable_notification_ = disable_notification
}, dl_cb, nil)
end
-----------------------------------------------------------------------------------------------
function priv(chat,user)
local ohash = db:sismember(SUDO..'owners:'..chat,user)
local mhash = db:sismember(SUDO..'mods:'..chat,user)
local shash = db:sismember(SUDO..'helpsudo:',user)
local mahash = db:sismember(SUDO..'master:',user)
if tonumber(SUDO) == tonumber(user) or mhash or ohash or shash or mahash then
return true
else
return false
end
end
------------------------------------------------------------
function kick(msg,chat,user)
if tonumber(user) == tonumber(bot_id) then
return false
end
if priv(chat,user) then
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>شما نمیتوانید دیگر مدیران را اخراج کنید!</code>', 'html')
else
bot.changeChatMemberStatus(chat, user, "Kicked")
end
end
------------------------------------------------------------
function ban(msg,chat,user)
if tonumber(user) == tonumber(bot_id) then
return false
end
if priv(chat,user) then
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>شما نمیتوانید دیگر مدیران را از گروه مسدود کنید!</code>', 'html')
else
bot.changeChatMemberStatus(chat, user, "Kicked")
db:sadd(SUDO..'banned'..chat,user)
local t = '<code>✅ ĐØ₦Ɇ </code>\n<code>▫️Ʉ₴ɆⱤ</code>🎗[<b>'..user..'</b>]🎗<code>нαѕ вєєи вαииє∂.</code>'
bot.sendMessage(msg.chat_id_, msg.id_, 1, t, 1, 'html')
end
end
---------------------------ban all -------------------------------
function banall(msg,chat,user)
if tonumber(user) == tonumber(bot_id) then
return false
end
if priv(chat,user) then
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>شما نمیتوانید دیگر مدیران را از گروه مسدود کنید!</code>', 'html')
else
bot.changeChatMemberStatus(chat, user, "Kicked")
db:sadd(SUDO..'banalled',user)
local t = '<code>>کاربر</code> [<b>'..user..'</b>] <code>به لیست گلوبال بن ربات اضافه شد و دیگر نمیتواند در گروه هایی که ربات است وارد شود</code>'
bot.sendMessage(msg.chat_id_, msg.id_, 1, t, 1, 'html')
end
end
-----------------------------------------------------------
function mute(msg,chat,user)
if tonumber(user) == tonumber(bot_id) then
return false
end
if priv(chat,user) then
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>شما نمیتوانید توانایی گفتگو در گروه را از دیگر مدیران سلب کنید!</code>', 'html')
else
db:sadd(SUDO..'mutes'..chat,user)
local t = '<code>>کاربر</code> [<b>'..user..'</b>] <code>به حالت سکوت کاربران افزوده گردید.</code>'
bot.sendMessage(msg.chat_id_, msg.id_, 1, t,1, 'html')
end
end
------------------------------------------------------------
function unban(msg,chat,user)
if tonumber(user) == tonumber(bot_id) then
return false
end
db:srem(SUDO..'banned'..chat,user)
local t = '<code>✅ ĐØ₦Ɇ </code>\n<code>▫️Ʉ₴ɆⱤ</code>🎗[<b>'..user..'</b>]🎗<code>нαѕ вєєи υивαииє∂.</code>'
bot.sendMessage(msg.chat_id_, msg.id_, 1, t,1, 'html')
end
------------------------------------------------------------
function unbanall(msg,chat,user)
if tonumber(user) == tonumber(bot_id) then
return false
end
db:srem(SUDO..'banalled',user)
local t = '<code>>کاربر</code> [<b>'..user..'</b>] <code>از لیست گلوبال بن حذف شد و میتواند در تمامی گروه هایی که ربات در آن ادمین است فعالیت داشته باشد</code>'
bot.sendMessage(msg.chat_id_, msg.id_, 1, t,1, 'html')
end
------------------------------------------------------------
function unmute(msg,chat,user)
if tonumber(user) == tonumber(bot_id) then
return false
end
db:srem(SUDO..'mutes'..chat,user)
local t = '<code>>کاربر</code> [<b>'..user..'</b>] <code>از حالت سکوت کاربران حذف گردید.</code>'
bot.sendMessage(msg.chat_id_, msg.id_, 1, t,1, 'html')
end
------------------------------------------------------------
function delete_msg(chatid,mid)
tdcli_function ({ID="DeleteMessages", chat_id_=chatid, message_ids_=mid}, dl_cb, nil)
end
------------------------------------------------------------
function user(msg,chat,text,user)
entities = {}
if text:match('<user>') and text:match('<user>') then
local x = string.len(text:match('(.*)<user>'))
local offset = x
local y = string.len(text:match('<user>(.*)</user>'))
local length = y
text = text:gsub('<user>','')
text = text:gsub('</user>','')
table.insert(entities,{ID="MessageEntityMentionName", offset_=offset, length_=length, user_id_=user})
end
entities[0] = {ID='MessageEntityBold', offset_=0, length_=0}
return tdcli_function ({ID="SendMessage", chat_id_=chat, reply_to_message_id_=msg.id_, disable_notification_=0, from_background_=1, reply_markup_=nil, input_message_content_={ID="InputMessageText", text_=text, disable_web_page_preview_=1, clear_draft_=0, entities_=entities}}, dl_cb, nil)
end
----------------------------------------------------------
function settings(msg,value,lock)
local hash = SUDO..'settings:'..msg.chat_id_..':'..value
if value == 'file' then
text = '📂File Has Been'
elseif value == 'keyboard' then
text = '⛓Inline Keyboard Has Been'
elseif value == 'link' then
text = '🌐Links Has Been'
elseif value == 'game' then
text = '🎮Game Has Been'
elseif value == 'username' then
text = '🆔UserName Has Been'
elseif value == 'pin' then
text = '🔰Pin Has Been'
elseif value == 'photo' then
text = '🌠Photos Has Been'
elseif value == 'gif' then
text = '🖼Gifs Has Been'
elseif value == 'video' then
text = '🎥Videos Has Been'
elseif value == 'audio' then
text = '🎤Audio & Voice Has Been'
elseif value == 'music' then
text = '🎶Music Has Been'
elseif value == 'text' then
text = '📝Text Has Been'
elseif value == 'sticker' then
text = '🌅Stickers Has Been'
elseif value == 'contact' then
text = '☎️Contacts Has Been'
elseif value == 'forward' then
text = '🔗Forward Has Been'
elseif value == 'persian' then
text = '🇮🇷Persian Has Been'
elseif value == 'english' then
text = '🇳🇿English Has Been'
elseif value == 'bot' then
text = '🤖Bots Has Been'
elseif value == 'tgservice' then
text = '⚙️TGService Has Been'
else return false
end
if lock then
db:set(hash,true)
local id = msg.sender_user_id_
local lmsg = '✔️Click See Locker✔️\n➖➖➖➖➖➖➖➖➖\n'..text..' 》 Locked🔐\n➖➖➖➖➖➖➖➖➖\n👉 @PVTeaM'
tdcli_function ({
ID="SendMessage",
chat_id_=msg.chat_id_,
reply_to_message_id_=msg.id_,
disable_notification_=0,
from_background_=1,
reply_markup_=nil,
input_message_content_={ID="InputMessageText",
text_=lmsg,
disable_web_page_preview_=1,
clear_draft_=0,
parse_mode_ = md,
entities_={[0] = {ID="MessageEntityMentionName",
offset_=0,
length_=20,
user_id_=id
}}}}, dl_cb, nil)
else
db:del(hash)
local id = msg.sender_user_id_
local Umsg = '✔️Click TO See UnLocker✔️\n➖➖➖➖➖➖➖➖➖\n'..text..' 》 UnLocked🔓\n➖➖➖➖➖➖➖➖➖\n👉 @PVTeaM'
tdcli_function ({
ID="SendMessage",
chat_id_=msg.chat_id_,
reply_to_message_id_=msg.id_,
disable_notification_=0,
from_background_=1,
reply_markup_=nil,
input_message_content_={ID="InputMessageText",
text_=Umsg,
disable_web_page_preview_=1,
clear_draft_=0,
entities_={[0] = {ID="MessageEntityMentionName",
offset_=0,
length_=36,
user_id_=id
}}}}, dl_cb, nil)
end
end
------------------------------------------------------------
function is_lock(msg,value)
local hash = SUDO..'settings:'..msg.chat_id_..':'..value
if db:get(hash) then
return true
else
return false
end
end
-----------------------------fanection warn------------------------------
function warn(msg,chat,user)
local ch = msg.chat_id_
local type = db:hget("warn:settings:"..ch,"swarn")
if type == "kick" then
kick(msg,chat,user)
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>>کاربر</code> [<b>'..user..'</b>] <code>به دلیل دریافت اخطار بیش ار حد(بیش از حد مجاز) از گروه اخراج گردید و ارتباط آن با گروه قطع گردید.</code>', 1,'html')
end
if type == "ban" then
if is_banned(chat,user) then else
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>>کاربر</code> [<b>'..user..'</b>] <code>به دلیل دریافت اخطار بیش از حداز گروه مسدود گردید و ارتباط آن با گروه قطع گردید.</code>', 1,'html')
end
bot.changeChatMemberStatus(chat, user, "Kicked")
db:sadd(SUDO..'banned'..msg.chat_id_,user)
end
if type == "mute" then
if is_muted(msg.chat_id_,user) then else
bot.sendMessage(msg.chat_id_, msg.id_, 1, '>کاربر ['..user..'] به دلیل دریافت اخطار (بیش از حد مجاز) به حالت سکوت منتقل شد\nبرای خارج شدن از لیست سکوت کاربران به مدیریت مراجعه کنید', 1,'md')
end
db:sadd(SUDO..'mutes'..msg.chat_id_,user)
end
end
------------------------------------------------------------
function trigger_anti_spam(msg,type)
if type == "kick" then
kick(msg,msg.chat_id_,msg.sender_user_id_)
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>>کاربر</code> [<b>'..msg.sender_user_id_..'</b>] <code>به دلیل ارسال پیام مکرر(بیش از حد مجاز) از گروه اخراج گردید و ارتباط آن با گروه قطع گردید.</code>', 1,'html')
end
if type == "ban" then
if is_banned(msg.chat_id_,msg.sender_user_id_) then else
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>>کاربر</code> [<b>'..msg.sender_user_id_..'</b>] <code>به دلیل ارسال پیام مکرر(بیش از حد مجاز) از گروه مسدود گردید و ارتباط آن با گروه قطع گردید.</code>', 1,'html')
end
bot.changeChatMemberStatus(msg.chat_id_, msg.sender_user_id_, "Kicked")
db:sadd(SUDO..'banned'..msg.chat_id_,msg.sender_user_id_)
end
if type == "mute" then
if is_muted(msg.chat_id_,msg.sender_user_id_) then else
bot.sendMessage(msg.chat_id_, msg.id_, 1, '>کاربر ['..msg.sender_user_id_..'] به دلیل ارسال پیام مکرر(بیش از حد مجاز) به حالت سکوت منتقل شد\nبرای خارج شدن از لیست سکوت کاربران به مدیریت مراجعه کنید', 1,'md')
end
db:sadd(SUDO..'mutes'..msg.chat_id_,msg.sender_user_id_)
end
end
function televardump(msg,value)
local text = json:encode(value)
bot.sendMessage(msg.chat_id_, msg.id_, 1, text, 'html')
end
------------------------------------------------------------
function run(msg,data)
--vardump(data)
--televardump(msg,data)
if msg then
db:incr(SUDO..'total:messages:'..msg.chat_id_..':'..msg.sender_user_id_)
if msg.send_state_.ID == "MessageIsSuccessfullySent" then
return false
end
end
if msg.chat_id_ then
local id = tostring(msg.chat_id_)
if id:match('-100(%d+)') then
chat_type = 'super'
elseif id:match('^(%d+)') then
chat_type = 'user'
else
chat_type = 'group'
end
end
local text = msg.content_.text_
if text and text:match('[qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM]') then
text = text
end
--------- messages type -------------------
if msg.content_.ID == "MessageText" then
msg_type = 'text'
end
if msg.content_.ID == "MessageChatAddMembers" then
print("NEW ADD")
msg_type = 'MSG:NewUserAdd'
end
if msg.content_.ID == "MessageChatJoinByLink" then
msg_type = 'join'
end
if msg.content_.ID == "MessagePhoto" then
msg_type = 'photo'
end
-------------------------------------------
if msg_type == 'text' and text then
if text:match('^[/!]') then
text = text:gsub('^[/!]','')
end
end
if text then
if not db:get(SUDO..'bot_id') then
function cb(a,b,c)
db:set(SUDO..'bot_id',b.id_)
end
bot.getMe(cb)
end
end
------------------------------------------------------------
if chat_type == 'super' then
--------------------------gp add -------------------------
if text == 'add' and is_sudoers(msg) then
db:sadd('bot:gps', msg.chat_id_)
bot.sendMessage(msg.chat_id_, msg.id_, 1,'<code>>✅ ĐØ₦Ɇ</code>\n<code>▫️gяσυρ нαѕ вєєи α∂∂є∂ ρℓєαѕє ѕєт gяσυρ ℓιик тσ α¢тιναтє тнє яσвσт `setlink Link`</code>', 1, 'html')
end
--------------------------rem add -------------------------
if text == 'rem' and is_sudoers(msg) then
db:srem('bot:gps', msg.chat_id_)
db:del(SUDO..'mods:'..msg.chat_id_)
db:del(SUDO..'owners:'..msg.chat_id_)
db:del(SUDO..'banned'..msg.chat_id_)
db:del('bot:rules'..msg.chat_id_)
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>>`DoNe ✅`</code>\n<code>`The GroUp WaS DeLeTeD FroM The LiSt oF BoT GrouPs 🎯`</code>', 1, 'html')
end
--------------------------set link -----------------------
if text and text:match('^setlink (.*)') and is_owner(msg) then
local link = text:match('setlink (.*)')
db:set(SUDO..'grouplink'..msg.chat_id_, link)
bot.sendMessage(msg.chat_id_, msg.id_, 1,'<code>>لینک جدید با موفقیت ذخیره و تغییر یافت.</code>\n <code>سوپر گروه با موفقیت فعال شد </code>', 1, 'html')
end
----------------------start prozhect ----------------------
if chackgp(msg) then
local chcklink = db:get(SUDO..'grouplink'..msg.chat_id_)
if not chcklink and is_owner(msg) then
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>>✔️DoNe\n💠**Please register the group link,** `otherwise the idle robot will remain in your group🔹`</code>', 1, 'html')
else
local ch = msg.chat_id_
local user_id = msg.sender_user_id_
floods = db:hget("flooding:settings:"..ch,"flood") or 'nil'
max_msg = db:hget("flooding:settings:"..ch,"floodmax") or 5
max_time = db:hget("flooding:settings:"..ch,"floodtime") or 5
------------------Flooding----------------------------#Mehti
if db:hget("flooding:settings:"..ch,"flood") then
if not is_mod(msg) then
if msg.content_.ID == "MessageChatAddMembers" then
return false
else
local post_count = tonumber(db:get('floodc:'..msg.sender_user_id_..':'..msg.chat_id_) or 0)
if post_count > tonumber(db:hget("flooding:settings:"..ch,"floodmax") or 5) then
local ch = msg.chat_id_
local type = db:hget("flooding:settings:"..ch,"flood")
trigger_anti_spam(msg,type)
end
db:setex('floodc:'..msg.sender_user_id_..':'..msg.chat_id_, tonumber(db:hget("flooding:settings:"..msg.chat_id_,"floodtime") or 3), post_count+1)
end
end
end
local edit_id = data.text_ or 'nil' --bug #behrad
local ch = msg.chat_id_
max_msg = 5
if db:hget("flooding:settings:"..ch,"floodmax") then
max_msg = db:hget("flooding:settings:"..ch,"floodmax")
end
if db:hget("flooding:settings:"..ch,"floodtime") then
max_time = db:hget("flooding:settings:"..ch,"floodtime")
end
-- save pin message id
if msg.content_.ID == 'MessagePinMessage' then
if is_lock(msg,'pin') and is_owner(msg) then
db:set(SUDO..'pinned'..msg.chat_id_, msg.content_.message_id_)
elseif not is_lock(msg,'pin') then
db:set(SUDO..'pinned'..msg.chat_id_, msg.content_.message_id_)
end
end
-- check filters
if text and not is_mod(msg) then
if is_filter(msg,text) then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
end
-- end charge expire --
local exp = tonumber(db:get('bot:charge:'..msg.chat_id_))
if exp == 0 then
exp_dat = 'Unlimited'
else
local now = tonumber(os.time())
if not now then
now = 0
end
if not exp then
exp = 0
end
exp_dat = (math.floor((tonumber(exp) - tonumber(now)) / 86400) + 1)
end
if exp_dat == 1 and is_owner(msg) and not is_sudo(msg) and not is_sudoers(msg) then
local texter = 'Group expiry date ends in 1 day⚠️\nCharging Group to apply❗️\n`Otherwise the robot within 24 hours of the Left🔅`\n💯 PriVaTe TM'
bot.sendMessage(msg.chat_id_,0,1,texter,0,'md')
end
if exp_dat == 0 and is_owner(msg) and not is_sudo(msg) and not is_sudoers(msg) then
db:del('bot:charge:'..msg.chat_id_)
bot.changeChatMemberStatus(msg.chat_id_, 249464384, "Left")
local texter = 'Group ended expiration date⚠️\n`The group removed from a Group List❗️\nPlease admins to extend to one of the following channels are presented in the message manager🔅`\n💯PriVaTe TM'
bot.sendMessage(msg.chat_id_,0,1,texter,0,'md')
end
----------------------------------
-- check settings
-- lock tgservice
if is_lock(msg,'tgservice') then
if msg.content_.ID == "MessageChatJoinByLink" or msg.content_.ID == "MessageChatAddMembers" or msg.content_.ID == "MessageChatDeleteMember" then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
end
---------------edit masg----------------#MehTi
-- lock pin
if is_owner(msg) then else
if is_lock(msg,'pin') then
if msg.content_.ID == 'MessagePinMessage' then
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>>قفل پیغام پین شده فعال است</code>\n<code>شما دارای مقام نمیباشید و امکان پین کردن پیامی را ندارید</code>',1, 'html')
bot.unpinChannelMessage(msg.chat_id_)
local PinnedMessage = db:get(SUDO..'pinned'..msg.chat_id_)
if PinnedMessage then
bot.pinChannelMessage(msg.chat_id_, tonumber(PinnedMessage), 0)
end
end
end
end
if is_mod(msg) then
else
-- lock link
if is_lock(msg,'link') then
if text then
if msg.content_.entities_ and msg.content_.entities_[0] and msg.content_.entities_[0].ID == 'MessageEntityUrl' or msg.content_.text_.web_page_ then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
end
if msg.content_.caption_ then
local text = msg.content_.caption_
local is_link = text:match("[Tt][Ee][Ll][Ee][Gg][Rr][Aa][Mm].[Mm][Ee]/") or text:match("[Tt][Ll][Gg][Rr][Mm].[Mm][Ee]/") or text:match("[Jj][Oo][Ii][Nn][Cc][Hh][Aa][Tt]/") or text:match("[Tt].[Mm][Ee]/")
if is_link then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
end
end
-- lock username
if is_lock(msg,'username') then
if text then
local is_username = text:match("@[%a%d]")
if is_username then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
end
if msg.content_.caption_ then
local text = msg.content_.caption_
local is_username = text:match("@[%a%d]")
if is_username then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
end
end
-- lock sticker
if is_lock(msg,'sticker') then
if msg.content_.ID == 'MessageSticker' then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
end
-- lock forward
if is_lock(msg,'forward') then
if msg.forward_info_ then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
end
-- lock photo
if is_lock(msg,'photo') then
if msg.content_.ID == 'MessagePhoto' then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
end
-- lock file
if is_lock(msg,'file') then
if msg.content_.ID == 'MessageDocument' then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
end
-- lock file
if is_lock(msg,'keyboard') then
if msg.reply_markup_ and msg.reply_markup_.ID == 'ReplyMarkupInlineKeyboard' then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
end
-- lock game
if is_lock(msg,'game') then
if msg.content_.game_ then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
end
-- lock music
if is_lock(msg,'music') then
if msg.content_.ID == 'MessageAudio' then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
end
-- lock voice
if is_lock(msg,'audio') then
if msg.content_.ID == 'MessageVoice' then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
end
-- lock gif
if is_lock(msg,'gif') then
if msg.content_.ID == 'MessageAnimation' then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
end
-- lock contact
if is_lock(msg,'contact') then
if msg.content_.ID == 'MessageContact' then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
end
-- lock video
if is_lock(msg,'video') then
if msg.content_.ID == 'MessageVideo' then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
end
-- lock text
if is_lock(msg,'text') then
if msg.content_.ID == 'MessageText' then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
end
-- lock persian
if is_lock(msg,'persian') then
if text:match('[ضصثقفغعهخحجچپشسیبلاتنمکگظطزرذدئو]') then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
if msg.content_.caption_ then
local text = msg.content_.caption_
local is_persian = text:match("[ضصثقفغعهخحجچپشسیبلاتنمکگظطزرذدئو]")
if is_persian then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
end
end
-- lock english
if is_lock(msg,'english') then
if text:match('[qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM]') then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
if msg.content_.caption_ then
local text = msg.content_.caption_
local is_english = text:match("[qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM]")
if is_english then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
end
end
-- lock bot
if is_lock(msg,'bot') then
if msg.content_.ID == "MessageChatAddMembers" then
if msg.content_.members_[0].type_.ID == 'UserTypeBot' then
kick(msg,msg.chat_id_,msg.content_.members_[0].id_)
end
end
end
end
-- check mutes
local muteall = db:get(SUDO..'muteall'..msg.chat_id_)
if msg.sender_user_id_ and muteall and not is_mod(msg) then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
if msg.sender_user_id_ and is_muted(msg.chat_id_,msg.sender_user_id_) then
delete_msg(msg.chat_id_, {[0] = msg.id_})
end
-- check bans
if msg.sender_user_id_ and is_banned(msg.chat_id_,msg.sender_user_id_) then
kick(msg,msg.chat_id_,msg.sender_user_id_)
end
if msg.content_ and msg.content_.members_ and msg.content_.members_[0] and msg.content_.members_[0].id_ and is_banned(msg.chat_id_,msg.content_.members_[0].id_) then
kick(msg,msg.chat_id_,msg.content_.members_[0].id_)
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>کاربر مورد نظر مسدود نمیباشد!</code>',1, 'html')
end
-- check banalls
if msg.sender_user_id_ and is_banall(msg.chat_id_,msg.sender_user_id_) then
kick(msg,msg.chat_id_,msg.sender_user_id_)
end
if msg.content_ and msg.content_.members_ and msg.content_.members_[0] and msg.content_.members_[0].id_ and is_banall(msg.chat_id_,msg.content_.members_[0].id_) then
kick(msg,msg.chat_id_,msg.content_.members_[0].id_)
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>کاربرا مورد نظر گلوبال بن میباشد</code>',1, 'html')
end
-- welcome
local status_welcome = (db:get(SUDO..'status:welcome:'..msg.chat_id_) or 'disable')
if status_welcome == 'enable' then
if msg.content_.ID == "MessageChatJoinByLink" then
if not is_banned(msg.chat_id_,msg.sender_user_id_) and not is_banall(msg.chat_id_,msg.sender_user_id_) then
function wlc(extra,result,success)
if db:get(SUDO..'welcome:'..msg.chat_id_) then
t = db:get(SUDO..'welcome:'..msg.chat_id_)
else
t = 'سلام {name}\nخوش آمدید!'
end
local t = t:gsub('{name}',result.first_name_)
bot.sendMessage(msg.chat_id_, msg.id_, 1, t,0)
end
bot.getUser(msg.sender_user_id_,wlc)
end
end
if msg.content_.members_ and msg.content_.members_[0] and msg.content_.members_[0].type_.ID == 'UserTypeGeneral' then
if msg.content_.ID == "MessageChatAddMembers" then
if not is_banned(msg.chat_id_,msg.content_.members_[0].id_) and not is_banall(msg.chat_id_,msg.content_.members_[0].id_) then
if db:get(SUDO..'welcome:'..msg.chat_id_) then
t = db:get(SUDO..'welcome:'..msg.chat_id_)
else
t = 'سلام {name}\nخوش آمدید!'
end
local t = t:gsub('{name}',msg.content_.members_[0].first_name_)
bot.sendMessage(msg.chat_id_, msg.id_, 1, t,0)
end
end
end
end
-- locks
if text and is_owner(msg) then
local lock = text:match('^lock pin$')
local unlock = text:match('^unlock pin$')
if lock then
settings(msg,'pin','lock')
end
if unlock then
settings(msg,'pin')
end
end
if text and is_mod(msg) then
---------------lock by #MehTi---------------
if text:match('^lock (.*)$') then
local lock = text:match('^lock (.*)$')
local locks = {"all","Flood","Spam","Link","markdown","tag","username","english","arabic","fwd","reply","emoji","edit","Pin","Cmd","Addmember","Joinmember","Bot","photo","video","gif","sticker","document","inline","text","audio","location","contact"}
local suc = 0
for i,v in pairs(locks) do
if lock == v:lower() then
suc = 1
settings(msg,lock,'lock')
end
end
if suc == 0 then
local text = "*❗️خطا*\n_⚠️ قفل پیدا نشد\n_*🔅Locks List:*\n"
for i,v in pairs(locks) do
text = text..'_'..i..' - '..v..'_\n'
end
bot.sendMessage(msg.chat_id_, msg.id_, 1,text, 1, 'md')
end
end
------------------------------------------------
if text:match('^edite (lock)$') then
local locking = text:match('^edite (lock)$')
db:set('edit:Lock:'..msg.chat_id_,'lock')
textedit = "ok"
bot.sendMessage(msg.chat_id_, msg.id_, 1,textedit, 1, 'md')
end
----------------Lock By #MehTi-----------------
if text:match('^unlock (.*)$') then
local unlock = text:match('^unlock (.*)$')
local locks = {"all","Flood","Spam","Link","markdown","tag","username","english","arabic","fwd","reply","emoji","edit","Pin","Cmd","Addmember","Joinmember","Bot","photo","video","gif","sticker","document","inline","text","audio","location","contact"}
local suc = 0
for i,v in pairs(locks) do
if unlock == v:lower() then
suc = 1
settings(msg,unlock)
end
end
if suc == 0 then
local text = "*❗️خطا*\n_⚠️ قفل پیدا نشد\n_*🔅Locks List:*\n"
for i,v in pairs(locks) do
text = text..'_'..i..' - '..v..'_\n'
end
bot.sendMessage(msg.chat_id_, msg.id_, 1,text, 1, 'md')
end
end
-------------------end lock ---------------------------#MehTi
local unlock = text:match('^unlock (.*)$')
local pin = text:match('^lock pin$') or text:match('^unlock pin$')
if pin and is_owner(msg) then
elseif pin and not is_owner(msg) then
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>انجام این دستور برای شما مجاز نمیباشد!</code>',1, 'html')
end
end
-- lock flood settings
if text and is_owner(msg) then
local ch = msg.chat_id_
if text == 'flood kick' then
db:hset("flooding:settings:"..ch ,"flood",'kick')
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>قفل ارسال پیام مکرر فعال گردید!</code> \n<code>وضعیت</code> > <i>اخراج(کاربر)</i>',1, 'html')
elseif text == 'flood ban' then
db:hset("flooding:settings:"..ch ,"flood",'ban')
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>قفل ارسال پیام مکرر فعال گردید!</code> \n<code>وضعیت</code> > <i>مسدود-سازی(کاربر)</i>',1, 'html')
elseif text == 'flood mute' then
db:hset("flooding:settings:"..ch ,"flood",'mute')
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>قفل ارسال پیام مکرر فعال گردید!</code> \n<code>وضعیت</code> > <i>سکوت(کاربر)</i>',1, 'html')
elseif text == 'unlock flood' then
db:hdel("flooding:settings:"..ch ,"flood")
bot.sendMessage(msg.chat_id_, msg.id_, 1, ' <code>قفل ارسال پیام مکرر غیرفعال گردید!</code> ',1, 'html')
end
end
-- sudo
if text then
-------------------info------------------------#MehTi
if text and text:match('^info') then
local ch = msg.chat_id_
local user = msg.sender_user_id_
local name = db:hget("mehti:info:"..user, "name")
if not name then
name = '----'
end
local lastname = db:hget('mehti:info'..user, 'lname')
if not lastname then
lastname = '----'
end
local sex = db:hget('mehti:info'..user, 'sex')
local bio = db:hget('mehti:info'..user, 'bio')
local hiphop = db:hget("mehti:info"..user, "hiphop")
local cstm = db:hget('mehti:info'..user, 'cstm')
local usermsg = db:get(SUDO..'total:messages:'..msg.chat_id_..':'..msg.sender_user_id_)
local url , res = http.request('http://irapi.ir/time')
if res ~= 200 then
return "No connection"
end
local jdat = json:decode(url)
if is_sudo(msg) then
t = 'FullSudo'
elseif is_sudoers(msg) then
t = 'HelpSudo'
elseif is_owner(msg) then
t = 'Group Owner'
elseif is_mod(msg) then
t = 'Moderator'
else
t = 'Member'
end
if cstm and sex and hiphop and bio then
local text = '🔅Name : '..name..'\n🔅Last Name : '..lastname..'\n🔅User ID : '..user..'\n🔅Gp ID : '..ch..'\n🔅Your Msg Sender : '..usermsg..'\n🔅Rank : '..t..'\n➖➖custom info➖➖\n🔅Sex : '..sex..'\n🔅Bio : '..bio..'\n🔅Age : '..hiphop..'\n➖➖Time and Date➖➖\n⌚️Time : '..jdat.FAtime..'\n🗓Date : '..jdat.FAdate..''
bot.sendMessage(msg.chat_id_, msg.id_, 1, text,0)
elseif cstm and sex and hiphop and not bio then
local text = '🔅Name : '..name..'\n🔅Last Name : '..lastname..'\n🔅User ID : '..user..'\n🔅Gp ID : '..ch..'\n🔅Your Msg Sender : '..usermsg..'\n🔅Rank : '..t..'\n➖➖custom info➖➖\n🔅Sex : '..sex..'\n🔅Age : '..hiphop..'\n➖➖Time and Date➖➖\n⌚️Time : '..jdat.FAtime..'\n🗓Date : '..jdat.FAdate..''
bot.sendMessage(msg.chat_id_, msg.id_, 1, text,0)
elseif cstm and hiphop and bio and not sex then
local text = '🔅Name : '..name..'\n🔅Last Name : '..lastname..'\n🔅User ID : '..user..'\n🔅Gp ID : '..ch..'\n🔅Your Msg Sender : '..usermsg..'\n🔅Rank : '..t..'\n➖➖custom info➖➖\n🔅Bio : '..bio..'\n🔅Age : '..hiphop..'\n➖➖Time and Date➖➖\n⌚️Time : '..jdat.FAtime..'\n🗓Date : '..jdat.FAdate..''
bot.sendMessage(msg.chat_id_, msg.id_, 1, text,0)
elseif cstm and sex and bio and not hiphop then
local text = '🔅Name : '..name..'\n🔅Last Name : '..lastname..'\n🔅User ID : '..user..'\n🔅Gp ID : '..ch..'\n🔅Your Msg Sender : '..usermsg..'\n🔅Rank : '..t..'\n➖➖custom info➖➖\n🔅Sex : '..sex..'\n🔅Bio : '..bio..'\n➖➖Time and Date➖➖\n⌚️Time : '..jdat.FAtime..'\n🗓Date : '..jdat.FAdate..''
bot.sendMessage(msg.chat_id_, msg.id_, 1, text,0)
elseif cstm and sex and not hiphop and not bio then
local text = '🔅Name : '..name..'\n🔅Last Name : '..lastname..'\n🔅User ID : '..user..'\n🔅Gp ID : '..ch..'\n🔅Your Msg Sender : '..usermsg..'\n🔅Rank : '..t..'\n➖➖custom info➖➖\n🔅Sex : '..sex..'\n➖➖Time and Date➖➖\n⌚️Time : '..jdat.FAtime..'\n🗓Date : '..jdat.FAdate..''
bot.sendMessage(msg.chat_id_, msg.id_, 1, text,0)
elseif cstm and not sex and hiphop and not bio then
local text = '🔅Name : '..name..'\n🔅Last Name : '..lastname..'\n🔅User ID : '..user..'\n🔅Gp ID : '..ch..'\n🔅Your Msg Sender : '..usermsg..'\n🔅Rank : '..t..'\n➖➖custom info➖➖\n🔅Age : '..hiphop..'\n➖➖Time and Date➖➖\n⌚️Time : '..jdat.FAtime..'\n🗓Date : '..jdat.FAdate..''
bot.sendMessage(msg.chat_id_, msg.id_, 1, text,0)
elseif cstm and not sex and not hiphop and bio then
local text = '🔅Name : '..name..'\n🔅Last Name : '..lastname..'\n🔅User ID : '..user..'\n🔅Gp ID : '..ch..'\n🔅Your Msg Sender : '..usermsg..'\n🔅Rank : '..t..'\n➖➖custom info➖➖\n🔅Bio : '..bio..'\n➖➖Time and Date➖➖\n⌚️Time : '..jdat.FAtime..'\n🗓Date : '..jdat.FAdate..''
bot.sendMessage(msg.chat_id_, msg.id_, 1, text,0)
else
local text = '🔅Name : '..name..'\n🔅Last Name : '..lastname..'\n🔅User ID : '..user..'\n🔅Gp ID : '..ch..'\n🔅Your Msg Sender : '..usermsg..'\n🔅Rank : '..t..'\n➖➖Time and Date➖➖\n⌚️Time : '..jdat.FAtime..'\n🗓Date : '..jdat.FAdate..''
bot.sendMessage(msg.chat_id_, msg.id_, 1, text,0)
end
end
-------------------id+pro------------------------#MehTi
if text == 'id' then
local function getpro(extra, result, success)
local msgs = db:get(SUDO..'total:messages:'..msg.chat_id_..':'..msg.sender_user_id_)
if is_sudo(msg) then
t = 'FullSudo'
elseif is_sudoers(msg) then
t = 'HelpSudo'
elseif is_owner(msg) then
t = 'Group Owner'
elseif is_mod(msg) then
t = 'Moderator'
else
t = 'Member'
end
ch = '@PVTeaM'
if result.photos_[0] then
bot.sendPhoto(msg.chat_id_, msg.id_, 0, 1, nil, result.photos_[0].sizes_[1].photo_.persistent_id_,'👥 Supergroup ID: '..msg.chat_id_:gsub('-100','')..'\n👤 Your ID: '..msg.sender_user_id_..'\n🏅Your Rank: '..t..'\n➰User Msg Send :'..msgs..'\n💯Channel :'..ch)
else
bot.sendMessage(msg.chat_id_, msg.id_, 1, "You Have'nt Profile Photo!!\n\n👥 *Supergroup ID:* `"..msg.chat_id_.."`\n*👤 Your ID:* `"..msg.sender_user_id_.."`\n*🗣 Number of your Msgs: *`"..msgs.."`", 1, 'md')
end
end
tdcli_function ({
ID = "GetUserProfilePhotos",
user_id_ = msg.sender_user_id_,
offset_ = 0,
limit_ = 1
}, getpro, nil)
end
----------------- set sudoers -------------------- #MehTi
if text == 'setsudo' and is_sudo(msg) then
function sudo_reply(extra, result, success)
db:sadd(SUDO..'helpsudo:',result.sender_user_id_)
db:srem(SUDO..'owners:'..result.chat_id_,result.sender_user_id_)
local user = result.sender_user_id_
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>>کاربر</code> [<b>'..user..'</b>] <code>به لیست سودو های ربات افزوده گردید.</code>', 1, 'html')
end
if tonumber(tonumber(msg.reply_to_message_id_)) == 0 then
else
bot.getMessage(msg.chat_id_, tonumber(msg.reply_to_message_id_),sudo_reply)
end
end
if text and is_sudo(msg) and text:match('^setsudo (%d+)') then
local user = text:match('setsudo (%d+)')
db:sadd(SUDO..'helpsudo:',user)
db:srem(SUDO..'owners:'..msg.chat_id_,user)
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>>کاربر</code> [<b>'..user..'</b>] <code>به لیست سودو های ربات افزوده گردید.</code>', 1, 'html')
end
--------------- dem sudoers -----------------------#MehTi
if text == 'demsudo' and is_sudo(msg) then
function sudo_reply(extra, result, success)
db:srem(SUDO..'helpsudo:',result.sender_user_id_)
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>>کاربر</code> [<b>'..result.sender_user_id_..'</b>] <code>از لیست سودوهای ربات حذف گردید .</code>', 1, 'html')
end
if tonumber(msg.reply_to_message_id_) == 0 then
else
bot.getMessage(msg.chat_id_, tonumber(msg.reply_to_message_id_),sudo_reply)
end
end
if text and text:match('^demsudo (%d+)') and is_sudo(msg) then
local user = text:match('demsudo (%d+)')
db:srem(SUDO..'helpsudo:',user)
bot.sendMessage(msg.chat_id_, msg.id_, 1, '<code>>کاربر</code> [<b>'..user..'</b>] <code>از لیست سودوهای ربات حذف گردید .</code>', 1, 'html')
end
--------------- text -----------------------------------
if is_sudoers(msg) then
-----------ban all ------------------
if text == 'sikall' then
if msg.reply_to_message_id_ == 0 then
local user = msg.sender_user_id_
bot.sendMessage(msg.chat_id_, msg.id_, 1, "*wtf? reply kn gole man:)*", 1, 'md')
else
function banreply(extra, result, success)
banall(msg,msg.chat_id_,result.sender_user_id_)
end
end
bot.getMessage(msg.chat_id_, tonumber(msg.reply_to_message_id_),banreply)
end
if text and text:match('^banall (%d+)') then
banall(msg,msg.chat_id_,text:match('^banall (%d+)'))
end