-
Notifications
You must be signed in to change notification settings - Fork 1
/
callbacks.py
1273 lines (1153 loc) · 41.6 KB
/
callbacks.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
991
992
993
994
995
996
997
998
999
1000
# Raven - UserBot
import ast
import asyncio
import re
import sys, os
import time
from asyncio.exceptions import TimeoutError as AsyncTimeOut
from os import execl, remove
from random import choice
from bs4 import BeautifulSoup as bs
from core import HNDLR, udB, LOGS, Var
from database.helpers import get_random_color
# try:
# from pyUltroid.fns.gDrive import GDriveManager
# except ImportError:
# GDriveManager = None
from telegraph import upload_file as upl
from telethon import Button, events
from telethon.tl.types import MessageMediaWebPage
from telethon.utils import get_peer_id
from localization import get_string
from utilities.helper import fast_download, progress
from utilities.tools import Carbon, async_searcher #, get_paste, telegraph_client
#from pyUltroid.startup.loader import Loader
from telethon.tl import types
from . import callback, get_back_button, asst
# --------------------------------------------------------------------#
# telegraph = telegraph_client()
# GDrive = GDriveManager() if GDriveManager else None
# --------------------------------------------------------------------#
async def setit(_, key, value):
udB.set_key(key, value)
def text_to_url(event):
"""function to get media url (with|without) Webpage"""
if isinstance(event.media, MessageMediaWebPage):
webpage = event.media.webpage
if not isinstance(webpage, types.WebPageEmpty) and webpage.type in ["photo"]:
return webpage.display_url
return event.text
# --------------------------------------------------------------------#
_buttons = {
"otvars": {
"text": "Other Variables to set for Raven:",
"buttons": [
[
Button.inline("Tᴀɢ Lᴏɢɢᴇʀ", data="taglog"),
Button.inline("SᴜᴘᴇʀFʙᴀɴ", data="cbs_sfban"),
],
[
Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ", data="sudo"),
Button.inline("Hᴀɴᴅʟᴇʀ", data="hhndlr"),
],
[
Button.inline("Exᴛʀᴀ Pʟᴜɢɪɴs", data="plg"),
Button.inline("Aᴅᴅᴏɴs", data="eaddon"),
],
[
Button.inline("Eᴍᴏᴊɪ ɪɴ Hᴇʟᴘ", data="emoj"),
Button.inline("Sᴇᴛ ɢDʀɪᴠᴇ", data="gdrive"),
],
[
Button.inline("Iɴʟɪɴᴇ Pɪᴄ", data="inli_pic"),
Button.inline("Sᴜᴅᴏ HNDLR", data="shndlr"),
],
[Button.inline("Dᴜᴀʟ Mᴏᴅᴇ", "cbs_oofdm")],
[Button.inline("« Bᴀᴄᴋ", data="setter")],
],
},
"sfban": {
"text": "SuperFban Settings:",
"buttons": [
[Button.inline("FBᴀɴ Gʀᴏᴜᴘ", data="sfgrp")],
[Button.inline("Exᴄʟᴜᴅᴇ Fᴇᴅs", data="abs_sfexf")],
[Button.inline("« Bᴀᴄᴋ", data="cbs_otvars")],
],
},
"apauto": {
"text": "This'll auto approve on outgoing messages",
"buttons": [
[Button.inline("Aᴜᴛᴏ Aᴘᴘʀᴏᴠᴇ ON", data="apon")],
[Button.inline("Aᴜᴛᴏ Aᴘᴘʀᴏᴠᴇ OFF", data="apof")],
[Button.inline("« Bᴀᴄᴋ", data="cbs_pmcstm")],
],
},
"alvcstm": {
"text": f"Customise your {HNDLR}alive. Choose from the below options -",
"buttons": [
[Button.inline("Aʟɪᴠᴇ Tᴇxᴛ", data="abs_alvtx")],
[Button.inline("Aʟɪᴠᴇ ᴍᴇᴅɪᴀ", data="alvmed")],
[Button.inline("Dᴇʟᴇᴛᴇ Aʟɪᴠᴇ Mᴇᴅɪᴀ", data="delmed")],
[Button.inline("« Bᴀᴄᴋ", data="setter")],
],
},
"pmcstm": {
"text": "Customise your PMPERMIT Settings -",
"buttons": [
[
Button.inline("Pᴍ Tᴇxᴛ", data="pmtxt"),
Button.inline("Pᴍ Mᴇᴅɪᴀ", data="pmmed"),
],
[
Button.inline("Aᴜᴛᴏ Aᴘᴘʀᴏᴠᴇ", data="cbs_apauto"),
Button.inline("PMLOGGER", data="pml"),
],
[
Button.inline("Sᴇᴛ Wᴀʀɴs", data="swarn"),
Button.inline("Dᴇʟᴇᴛᴇ Pᴍ Mᴇᴅɪᴀ", data="delpmmed"),
],
[Button.inline("PMPermit Type", data="cbs_pmtype")],
[Button.inline("« Bᴀᴄᴋ", data="cbs_ppmset")],
],
},
"pmtype": {
"text": "Select the type of PMPermit needed.",
"buttons": [
[Button.inline("Inline", data="inpm_in")],
[Button.inline("Normal", data="inpm_no")],
[Button.inline("« Bᴀᴄᴋ", data="cbs_pmcstm")],
],
},
"ppmset": {
"text": "PMPermit Settings:",
"buttons": [
[Button.inline("Tᴜʀɴ PMPᴇʀᴍɪᴛ Oɴ", data="pmon")],
[Button.inline("Tᴜʀɴ PMPᴇʀᴍɪᴛ Oғғ", data="pmoff")],
[Button.inline("Cᴜsᴛᴏᴍɪᴢᴇ PMPᴇʀᴍɪᴛ", data="cbs_pmcstm")],
[Button.inline("« Bᴀᴄᴋ", data="setter")],
],
},
"chatbot": {
"text": "From This Feature U can chat with ppls Via ur Assistant Bot.\n[More info](https://t.me/UltroidUpdates/2)",
"buttons": [
[
Button.inline("Cʜᴀᴛ Bᴏᴛ Oɴ", data="onchbot"),
Button.inline("Cʜᴀᴛ Bᴏᴛ Oғғ", data="ofchbot"),
],
[
Button.inline("Bᴏᴛ Wᴇʟᴄᴏᴍᴇ", data="bwel"),
Button.inline("Bᴏᴛ Wᴇʟᴄᴏᴍᴇ Mᴇᴅɪᴀ", data="botmew"),
],
[Button.inline("Bᴏᴛ Iɴғᴏ Tᴇxᴛ", data="botinfe")],
[Button.inline("Fᴏʀᴄᴇ Sᴜʙsᴄʀɪʙᴇ", data="pmfs")],
[Button.inline("« Bᴀᴄᴋ", data="setter")],
],
},
"vcb": {
"text": "From This Feature U can play songs in group voice chat\n\n[moreinfo](https://t.me/UltroidUpdates/4)",
"buttons": [
[Button.inline("VC Sᴇssɪᴏɴ", data="abs_vcs")],
[Button.inline("« Bᴀᴄᴋ", data="setter")],
],
},
"oofdm": {
"text": "About [Dual Mode](https://t.me/UltroidUpdates/18)",
"buttons": [
[
Button.inline("Dᴜᴀʟ Mᴏᴅᴇ Oɴ", "dmof"),
Button.inline("Dᴜᴀʟ Mᴏᴅᴇ Oғғ", "dmof"),
],
[Button.inline("Dᴜᴀʟ Mᴏᴅᴇ Hɴᴅʟʀ", "dmhn")],
[Button.inline("« Back", data="cbs_otvars")],
],
},
"apiset": {
"text": get_string("ast_1"),
"buttons": [
[Button.inline("Remove.bg API", data="abs_rmbg")],
[Button.inline("DEEP API", data="abs_dapi")],
[Button.inline("OCR API", data="abs_oapi")],
[Button.inline("« Back", data="setter")],
],
},
}
_convo = {
"rmbg": {
"var": "RMBG_API",
"name": "Remove.bg API Key",
"text": get_string("ast_2"),
"back": "cbs_apiset",
},
"dapi": {
"var": "DEEP_AI",
"name": "Deep AI Api Key",
"text": "Get Your Deep Api from deepai.org and send here.",
"back": "cbs_apiset",
},
"oapi": {
"var": "OCR_API",
"name": "Ocr Api Key",
"text": "Get Your OCR api from ocr.space and send that Here.",
"back": "cbs_apiset",
},
"pmlgg": {
"var": "PMLOGGROUP",
"name": "Pm Log Group",
"text": "Send chat id of chat which you want to save as Pm log Group.",
"back": "pml",
},
"vcs": {
"var": "VC_SESSION",
"name": "Vc Session",
"text": "**Vc session**\nEnter the New session u generated for vc bot.\n\nUse /cancel to terminate the operation.",
"back": "cbs_vcb",
},
"settag": {
"var": "TAG_LOG",
"name": "Tag Log Group",
"text": f"Make a group, add your assistant and make it admin.\nGet the `{HNDLR}id` of that group and send it here for tag logs.\n\nUse /cancel to cancel.",
"back": "taglog",
},
"alvtx": {
"var": "ALIVE_TEXT",
"name": "Alive Text",
"text": "**Alive Text**\nEnter the new alive text.\n\nUse /cancel to terminate the operation.",
"back": "cbs_alvcstm",
},
"sfexf": {
"var": "EXCLUDE_FED",
"name": "Excluded Fed",
"text": "Send the Fed IDs you want to exclude in the ban. Split by a space.\neg`id1 id2 id3`\nSet is as `None` if you dont want any.\nUse /cancel to go back.",
"back": "cbs_sfban",
},
}
TOKEN_FILE = "resources/auths/auth_token.txt"
@callback(
re.compile(
"sndplug_(.*)",
),
owner=True,
)
async def send(eve):
key, name = (eve.data_match.group(1)).decode("UTF-8").split("_")
thumb = "resources/extras/inline.jpg"
await eve.answer("■ Sending ■")
data = f"uh_{key}_"
index = None
if "|" in name:
name, index = name.split("|")
key = "plugins" if key == "Official" else key.lower()
plugin = f"{key}/{name}.py"
_ = f"pasta-{plugin}"
if index is not None:
data += f"|{index}"
_ += f"|{index}"
buttons = [
[
Button.inline(
"« Pᴀsᴛᴇ »",
data=_,
)
],
[
Button.inline("« Bᴀᴄᴋ", data=data),
],
]
try:
await eve.edit(file=plugin, thumb=thumb, buttons=buttons)
except Exception as er:
await eve.answer(str(er), alert=True)
heroku_api, app_name = Var.HEROKU_API, Var.HEROKU_APP_NAME
@callback("updatenow", owner=True)
async def update(eve):
repo = Repo()
ac_br = repo.active_branch
ups_rem = repo.remote("upstream")
if heroku_api:
import heroku3
try:
heroku = heroku3.from_key(heroku_api)
heroku_app = None
heroku_applications = heroku.apps()
except BaseException as er:
LOGS.exception(er)
return await eve.edit("`Wrong HEROKU_API.`")
for app in heroku_applications:
if app.name == app_name:
heroku_app = app
if not heroku_app:
await eve.edit("`Wrong HEROKU_APP_NAME.`")
repo.__del__()
return
await eve.edit(get_string("clst_1"))
ups_rem.fetch(ac_br)
repo.git.reset("--hard", "FETCH_HEAD")
heroku_git_url = heroku_app.git_url.replace(
"https://", f"https://api:{heroku_api}@"
)
if "heroku" in repo.remotes:
remote = repo.remote("heroku")
remote.set_url(heroku_git_url)
else:
remote = repo.create_remote("heroku", heroku_git_url)
try:
remote.push(refspec=f"HEAD:refs/heads/{ac_br}", force=True)
except GitCommandError as error:
await eve.edit(f"`Here is the error log:\n{error}`")
repo.__del__()
return
await eve.edit("`Successfully Updated!\nRestarting, please wait...`")
else:
await eve.edit(get_string("clst_1"))
call_back()
await bash("git pull && pip3 install -r requirements.txt")
execl(sys.executable, sys.executable, "-m", "pyOreo")
@callback(
re.compile(
"pasta-(.*)",
),
owner=True,
)
async def _(e):
ok = (e.data_match.group(1)).decode("UTF-8")
index = None
if "|" in ok:
ok, index = ok.split("|")
with open(ok, "r") as hmm:
_, key = await get_paste(hmm.read())
link = f"https://spaceb.in/{key}"
raw = f"https://spaceb.in/api/v1/documents/{key}/raw"
if not _:
return await e.answer(key[:30], alert=True)
if ok.startswith("addons"):
key = "Addons"
elif ok.startswith("vcbot"):
key = "VCBot"
else:
key = "Official"
data = f"uh_{key}_"
if index is not None:
data += f"|{index}"
await e.edit(
"",
buttons=[
[Button.url("Lɪɴᴋ", link), Button.url("Rᴀᴡ", raw)],
[Button.inline("« Bᴀᴄᴋ", data=data)],
],
)
@callback(re.compile("cbs_(.*)"), owner=True)
async def _edit_to(event):
match = event.data_match.group(1).decode("utf-8")
data = _buttons.get(match)
if not data:
return
await event.edit(data["text"], buttons=data["buttons"], link_preview=False)
@callback(re.compile("abs_(.*)"), owner=True)
async def convo_handler(event: events.CallbackQuery):
match = event.data_match.group(1).decode("utf-8")
if not _convo.get(match):
return
await event.delete()
get_ = _convo[match]
back = get_["back"]
async with event.client.conversation(event.sender_id) as conv:
await conv.send_message(get_["text"])
response = await conv.get_response()
themssg = response.message
try:
themssg = ast.literal_eval(themssg)
except Exception:
pass
if themssg == "/cancel":
return await conv.send_message(
"Cancelled!!",
buttons=get_back_button(back),
)
await setit(event, get_["var"], themssg)
await conv.send_message(
f"{get_['name']} changed to `{themssg}`",
buttons=get_back_button(back),
)
@callback("authorise", owner=True)
async def _(e):
if not e.is_private:
return
url = GDrive._create_token_file()
await e.edit("Go to the below link and send the code!")
async with asst.conversation(e.sender_id) as conv:
await conv.send_message(url)
code = await conv.get_response()
if GDrive._create_token_file(code=code.text):
await conv.send_message(
"`Success!\nYou are all set to use Google Drive with Raven Userbot.`",
buttons=Button.inline("Main Menu", data="setter"),
)
else:
await conv.send_message("Wrong code! Click authorise again.")
@callback("folderid", owner=True, func=lambda x: x.is_private)
async def _(e):
if not e.is_private:
return
msg = (
"Send your FOLDER ID\n\n"
+ "For FOLDER ID:\n"
+ "1. Open Google Drive App.\n"
+ "2. Create Folder.\n"
+ "3. Make that folder public.\n"
+ "4. Send link of that folder."
)
await e.delete()
async with asst.conversation(e.sender_id, timeout=150) as conv:
await conv.send_message(msg)
repl = await conv.get_response()
id = repl.text
if id.startswith("https"):
id = id.split("?id=")[-1]
udB.set_key("GDRIVE_FOLDER_ID", id)
await repl.reply(
"`Success.`",
buttons=get_back_button("gdrive"),
)
@callback("gdrive", owner=True)
async def _(e):
if not e.is_private:
return
await e.edit(
"Click Authorise and send the code.\n\nYou can use your own CLIENT ID and SECRET by [this](https://t.me/UltroidUpdates/37)",
buttons=[
[
Button.inline("Folder ID", data="folderid"),
Button.inline("Authorise", data="authorise"),
],
[Button.inline("« Back", data="cbs_otvars")],
],
link_preview=False,
)
@callback("dmof", owner=True)
async def rhwhe(e):
if udB.get_key("DUAL_MODE"):
udB.del_key("DUAL_MODE")
key = "Off"
else:
udB.set_key("DUAL_MODE", "True")
key = "On"
Msg = f"Dual Mode : {key}"
await e.edit(Msg, buttons=get_back_button("cbs_otvars"))
@callback("dmhn", owner=True)
async def hndlrr(event):
await event.delete()
pru = event.sender_id
var = "DUAL_HNDLR"
name = "Dual Handler"
CH = udB.get_key(var) or "/"
async with event.client.conversation(pru) as conv:
await conv.send_message(
f"Send The Symbol Which u want as Handler/Trigger to use your Assistant bot\nUr Current Handler is [ `{CH}` ]\n\n use /cancel to cancel.",
)
response = conv.wait_event(events.NewMessage(chats=pru))
response = await response
themssg = response.message.message
if themssg == "/cancel":
await conv.send_message(
"Cancelled!!",
buttons=get_back_button("cbs_otvars"),
)
elif len(themssg) > 1:
await conv.send_message(
"Incorrect Handler",
buttons=get_back_button("cbs_otvars"),
)
else:
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("cbs_otvars"),
)
@callback("emoj", owner=True)
async def emoji(event):
await event.delete()
pru = event.sender_id
var = "EMOJI_IN_HELP"
name = f"Emoji in `{HNDLR}help` menu"
async with event.client.conversation(pru) as conv:
await conv.send_message("Send emoji u want to set 🙃.\n\nUse /cancel to cancel.")
response = conv.wait_event(events.NewMessage(chats=pru))
response = await response
themssg = response.message.message
if themssg == "/cancel":
await conv.send_message(
"Cancelled!!",
buttons=get_back_button("cbs_otvars"),
)
elif themssg.startswith(("/", HNDLR)):
await conv.send_message(
"Incorrect Emoji",
buttons=get_back_button("cbs_otvars"),
)
else:
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}\n",
buttons=get_back_button("cbs_otvars"),
)
@callback("plg", owner=True)
async def pluginch(event):
await event.delete()
pru = event.sender_id
var = "PLUGIN_CHANNEL"
name = "Plugin Channel"
async with event.client.conversation(pru) as conv:
await conv.send_message(
"Send id or username of a channel from where u want to install all plugins\n\nOur Channel~ @ultroidplugins\n\nUse /cancel to cancel.",
)
response = conv.wait_event(events.NewMessage(chats=pru))
response = await response
themssg = response.message.message
if themssg == "/cancel":
await conv.send_message(
"Cancelled!!",
buttons=get_back_button("cbs_otvars"),
)
elif themssg.startswith(("/", HNDLR)):
await conv.send_message(
"Incorrect channel",
buttons=get_back_button("cbs_otvars"),
)
else:
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}\n After Setting All Things Do Restart",
buttons=get_back_button("cbs_otvars"),
)
@callback("hhndlr", owner=True)
async def hndlrr(event):
await event.delete()
pru = event.sender_id
var = "HNDLR"
name = "Handler/ Trigger"
async with event.client.conversation(pru) as conv:
await conv.send_message(
f"Send The Symbol Which u want as Handler/Trigger to use bot\nUr Current Handler is [ `{HNDLR}` ]\n\n use /cancel to cancel.",
)
response = conv.wait_event(events.NewMessage(chats=pru))
response = await response
themssg = response.message.message
if themssg == "/cancel":
await conv.send_message(
"Cancelled!!",
buttons=get_back_button("cbs_otvars"),
)
elif len(themssg) > 1:
await conv.send_message(
"Incorrect Handler",
buttons=get_back_button("cbs_otvars"),
)
elif themssg.startswith(("/", "#", "@")):
await conv.send_message(
"This cannot be used as handler",
buttons=get_back_button("cbs_otvars"),
)
else:
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("cbs_otvars"),
)
@callback("shndlr", owner=True)
async def hndlrr(event):
await event.delete()
pru = event.sender_id
var = "SUDO_HNDLR"
name = "Sudo Handler"
async with event.client.conversation(pru) as conv:
await conv.send_message(
"Send The Symbol Which u want as Sudo Handler/Trigger to use bot\n\n use /cancel to cancel."
)
response = conv.wait_event(events.NewMessage(chats=pru))
response = await response
themssg = response.message.message
if themssg == "/cancel":
await conv.send_message(
"Cancelled!!",
buttons=get_back_button("cbs_otvars"),
)
elif len(themssg) > 1:
await conv.send_message(
"Incorrect Handler",
buttons=get_back_button("cbs_otvars"),
)
elif themssg.startswith(("/", "#", "@")):
await conv.send_message(
"This cannot be used as handler",
buttons=get_back_button("cbs_otvars"),
)
else:
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("cbs_otvars"),
)
@callback("taglog", owner=True)
async def tagloggrr(e):
BUTTON = [
[Button.inline("SET TAG LOG", data="abs_settag")],
[Button.inline("DELETE TAG LOG", data="deltag")],
get_back_button("cbs_otvars"),
]
await e.edit(
"Choose Options",
buttons=BUTTON,
)
@callback("deltag", owner=True)
async def _(e):
udB.del_key("TAG_LOG")
await e.answer("Done!!! Tag Logger has been turned Off")
@callback("eaddon", owner=True)
async def pmset(event):
BT = (
[Button.inline("Aᴅᴅᴏɴs Oғғ", data="edof")]
if udB.get_key("ADDONS")
else [Button.inline("Aᴅᴅᴏɴs Oɴ", data="edon")]
)
await event.edit(
"ADDONS~ Extra Plugins:",
buttons=[
BT,
[Button.inline("« Bᴀᴄᴋ", data="cbs_otvars")],
],
)
@callback("edon", owner=True)
async def eddon(event):
var = "ADDONS"
await setit(event, var, "True")
await event.edit(
"Done! ADDONS has been turned on!!\n\n After Setting All Things Do Restart",
buttons=get_back_button("eaddon"),
)
@callback("edof", owner=True)
async def eddof(event):
udB.set_key("ADDONS", "False")
await event.edit(
"Done! ADDONS has been turned off!! After Setting All Things Do Restart",
buttons=get_back_button("eaddon"),
)
@callback("sudo", owner=True)
async def pmset(event):
BT = (
[Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ Oғғ", data="ofsudo")]
if udB.get_key("SUDO")
else [Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ Oɴ", data="onsudo")]
)
await event.edit(
f"SUDO MODE ~ Some peoples can use ur Bot which u selected. To know More use `{HNDLR}help sudo`",
buttons=[
BT,
[Button.inline("« Bᴀᴄᴋ", data="cbs_otvars")],
],
)
@callback("onsudo", owner=True)
async def eddon(event):
var = "SUDO"
await setit(event, var, "True")
await event.edit(
"Done! SUDO MODE has been turned on!!\n\n After Setting All Things Do Restart",
buttons=get_back_button("sudo"),
)
@callback("ofsudo", owner=True)
async def eddof(event):
var = "SUDO"
await setit(event, var, "False")
await event.edit(
"Done! SUDO MODE has been turned off!! After Setting All Things Do Restart",
buttons=get_back_button("sudo"),
)
@callback("sfgrp", owner=True)
async def sfgrp(event):
await event.delete()
name = "FBan Group ID"
var = "FBAN_GROUP_ID"
pru = event.sender_id
async with asst.conversation(pru) as conv:
await conv.send_message(
f"Make a group, add @MissRose_Bot, send `{HNDLR}id`, copy that and send it here.\nUse /cancel to go back.",
)
response = conv.wait_event(events.NewMessage(chats=pru))
response = await response
themssg = response.message.message
if themssg == "/cancel":
return await conv.send_message(
"Cancelled!!",
buttons=get_back_button("cbs_sfban"),
)
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("cbs_sfban"),
)
@callback("alvmed", owner=True)
async def media(event):
await event.delete()
pru = event.sender_id
var = "ALIVE_PIC"
name = "Alive Media"
async with event.client.conversation(pru) as conv:
await conv.send_message(
"**Alive Media**\nSend me a pic/gif/media to set as alive media.\n\nUse /cancel to terminate the operation.",
)
response = await conv.get_response()
try:
themssg = response.message
if themssg == "/cancel":
return await conv.send_message(
"Operation cancelled!!",
buttons=get_back_button("cbs_alvcstm"),
)
except BaseException as er:
LOGS.exception(er)
if (
not (response.text).startswith("/")
and response.text != ""
and (not response.media or isinstance(response.media, MessageMediaWebPage))
):
url = text_to_url(response)
elif response.sticker:
url = response.file.id
else:
media = await event.client.download_media(response, "alvpc")
try:
x = upl(media)
url = f"https://graph.org/{x[0]}"
remove(media)
except BaseException as er:
LOGS.exception(er)
return await conv.send_message(
"Terminated.",
buttons=get_back_button("cbs_alvcstm"),
)
await setit(event, var, url)
await conv.send_message(
f"{name} has been set.",
buttons=get_back_button("cbs_alvcstm"),
)
@callback("delmed", owner=True)
async def dell(event):
try:
udB.del_key("ALIVE_PIC")
return await event.edit(
get_string("clst_5"), buttons=get_back_button("cbs_alabs_vcstm")
)
except BaseException as er:
LOGS.exception(er)
return await event.edit(
get_string("clst_4"),
buttons=get_back_button("cbs_alabs_vcstm"),
)
@callback("inpm_in", owner=True)
async def inl_on(event):
var = "INLINE_PM"
await setit(event, var, "True")
await event.edit(
"Done!! PMPermit type has been set to inline!",
buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_pmtype")]],
)
@callback("inpm_no", owner=True)
async def inl_on(event):
var = "INLINE_PM"
await setit(event, var, "False")
await event.edit(
"Done!! PMPermit type has been set to normal!",
buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_pmtype")]],
)
@callback("pmtxt", owner=True)
async def name(event):
await event.delete()
pru = event.sender_id
var = "PM_TEXT"
name = "PM Text"
async with event.client.conversation(pru) as conv:
await conv.send_message(
"**PM Text**\nEnter the new Pmpermit text.\n\nu can use `{name}` `{fullname}` `{count}` `{mention}` `{username}` to get this from user Too\n\nUse /cancel to terminate the operation.",
)
response = conv.wait_event(events.NewMessage(chats=pru))
response = await response
themssg = response.message.message
if themssg == "/cancel":
return await conv.send_message(
"Cancelled!!",
buttons=get_back_button("cbs_pmcstm"),
)
if len(themssg) > 4090:
return await conv.send_message(
"Message too long!\nGive a shorter message please!!",
buttons=get_back_button("cbs_pmcstm"),
)
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}\n\nAfter Setting All Things Do restart",
buttons=get_back_button("cbs_pmcstm"),
)
@callback("swarn", owner=True)
async def name(event):
m = range(1, 10)
tultd = [Button.inline(f"{x}", data=f"wrns_{x}") for x in m]
lst = list(zip(tultd[::3], tultd[1::3], tultd[2::3]))
lst.append([Button.inline("« Bᴀᴄᴋ", data="cbs_pmcstm")])
await event.edit(
"Select the number of warnings for a user before getting blocked in PMs.",
buttons=lst,
)
@callback(re.compile(b"wrns_(.*)"), owner=True)
async def set_wrns(event):
value = int(event.data_match.group(1).decode("UTF-8"))
if dn := udB.set_key("PMWARNS", value):
await event.edit(
f"PM Warns Set to {value}.\nNew users will have {value} chances in PMs before getting banned.",
buttons=get_back_button("cbs_pmcstm"),
)
else:
await event.edit(
f"Something went wrong, please check your {HNDLR}logs!",
buttons=get_back_button("cbs_pmcstm"),
)
@callback("pmmed", owner=True)
async def media(event):
await event.delete()
pru = event.sender_id
var = "PMPIC"
name = "PM Media"
async with event.client.conversation(pru) as conv:
await conv.send_message(
"**PM Media**\nSend me a pic/gif/sticker/link to set as pmpermit media.\n\nUse /cancel to terminate the operation.",
)
response = await conv.get_response()
try:
themssg = response.message
if themssg == "/cancel":
return await conv.send_message(
"Operation cancelled!!",
buttons=get_back_button("cbs_pmcstm"),
)
except BaseException as er:
LOGS.exception(er)
media = await event.client.download_media(response, "pmpc")
if (
not (response.text).startswith("/")
and response.text != ""
and (not response.media or isinstance(response.media, MessageMediaWebPage))
):
url = text_to_url(response)
elif response.sticker:
url = response.file.id
else:
try:
x = upl(media)
url = f"https://graph.org/{x[0]}"
remove(media)
except BaseException as er:
LOGS.exception(er)
return await conv.send_message(
"Terminated.",
buttons=get_back_button("cbs_pmcstm"),
)
await setit(event, var, url)
await conv.send_message(
f"{name} has been set.",
buttons=get_back_button("cbs_pmcstm"),
)
@callback("delpmmed", owner=True)
async def dell(event):
try:
udB.del_key("PMPIC")
return await event.edit(
get_string("clst_5"), buttons=get_back_button("cbs_pmcstm")
)
except BaseException as er:
LOGS.exception(er)
return await event.edit(
get_string("clst_4"),
buttons=[[Button.inline("« Sᴇᴛᴛɪɴɢs", data="setter")]],
)
@callback("apon", owner=True)
async def apon(event):
var = "AUTOAPPROVE"
await setit(event, var, "True")
await event.edit(
"Done!! AUTOAPPROVE Started!!",
buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_apauto")]],
)
@callback("apof", owner=True)
async def apof(event):
try:
udB.set_key("AUTOAPPROVE", "False")
return await event.edit(
"Done! AUTOAPPROVE Stopped!!",
buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_apauto")]],
)
except BaseException as er:
LOGS.exception(er)
return await event.edit(
get_string("clst_4"),
buttons=[[Button.inline("« Sᴇᴛᴛɪɴɢs", data="setter")]],
)
@callback("pml", owner=True)
async def l_vcs(event):
BT = (
[Button.inline("PMLOGGER OFF", data="pmlogof")]
if udB.get_key("PMLOG")
else [Button.inline("PMLOGGER ON", data="pmlog")]
)
await event.edit(
"PMLOGGER This Will Forward Ur Pm to Ur Private Group -",
buttons=[
BT,
[Button.inline("PᴍLᴏɢɢᴇʀ Gʀᴏᴜᴘ", "abs_pmlgg")],
[Button.inline("« Bᴀᴄᴋ", data="cbs_pmcstm")],
],
)