teamx-cloner commited on
Commit
e30a913
·
1 Parent(s): e9a08c6

Add files via upload

Browse files
assistant/__init__.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2021-2023 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ from telethon import Button, custom
9
+
10
+ from plugins import ATRA_COL, InlinePlugin
11
+ from xteam import *
12
+ from xteam import _ult_cache
13
+ from xteam._misc import owner_and_sudos
14
+ from xteam._misc._assistant import asst_cmd, callback, in_pattern
15
+ from xteam.fns.helper import *
16
+ from xteam.fns.tools import get_stored_file
17
+ from strings import get_languages, get_string
18
+
19
+ OWNER_NAME = ultroid_bot.full_name
20
+ OWNER_ID = ultroid_bot.uid
21
+
22
+ AST_PLUGINS = {}
23
+
24
+
25
+ async def setit(event, name, value):
26
+ try:
27
+ udB.set_key(name, value)
28
+ except BaseException as er:
29
+ LOGS.exception(er)
30
+ return await event.edit("`Something Went Wrong`")
31
+
32
+
33
+ def get_back_button(name):
34
+ return [Button.inline("« Bᴀᴄᴋ", data=f"{name}")]
assistant/callbackstuffs.py ADDED
@@ -0,0 +1,1318 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2021-2023 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ import ast
9
+ import asyncio
10
+ import re
11
+ import sys
12
+ import time
13
+ from asyncio.exceptions import TimeoutError as AsyncTimeOut
14
+ from os import execl, remove
15
+ from random import choice
16
+
17
+ from bs4 import BeautifulSoup as bs
18
+
19
+ try:
20
+ from xteam.fns.gDrive import GDriveManager
21
+ except ImportError:
22
+ GDriveManager = None
23
+ from telegraph import upload_file as upl
24
+ from telethon import Button, events
25
+ from telethon.tl.types import MessageMediaWebPage
26
+ from telethon.utils import get_peer_id
27
+
28
+ from xteam.fns.helper import fast_download, progress
29
+ from xteam.fns.tools import Carbon, async_searcher, get_paste, telegraph_client
30
+ from xteam.startup.loader import Loader
31
+
32
+ from . import *
33
+
34
+ # --------------------------------------------------------------------#
35
+ telegraph = telegraph_client()
36
+ GDrive = GDriveManager() if GDriveManager else None
37
+ # --------------------------------------------------------------------#
38
+
39
+
40
+ def text_to_url(event):
41
+ """function to get media url (with|without) Webpage"""
42
+ if isinstance(event.media, MessageMediaWebPage):
43
+ webpage = event.media.webpage
44
+ if not isinstance(webpage, types.WebPageEmpty) and webpage.type in ["photo"]:
45
+ return webpage.display_url
46
+ return event.text
47
+
48
+
49
+ # --------------------------------------------------------------------#
50
+
51
+ _buttons = {
52
+ "otvars": {
53
+ "text": "Other Variables to set for @TeamUltroid:",
54
+ "buttons": [
55
+ [
56
+ Button.inline("Tᴀɢ Lᴏɢɢᴇʀ", data="taglog"),
57
+ Button.inline("SᴜᴘᴇʀFʙᴀɴ", data="cbs_sfban"),
58
+ ],
59
+ [
60
+ Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ", data="sudo"),
61
+ Button.inline("Hᴀɴᴅʟᴇʀ", data="hhndlr"),
62
+ ],
63
+ [
64
+ Button.inline("Exᴛʀᴀ Pʟᴜɢɪɴs", data="plg"),
65
+ Button.inline("Aᴅᴅᴏɴs", data="eaddon"),
66
+ ],
67
+ [
68
+ Button.inline("Eᴍᴏᴊɪ ɪɴ Hᴇʟᴘ", data="emoj"),
69
+ Button.inline("Sᴇᴛ ɢDʀɪᴠᴇ", data="gdrive"),
70
+ ],
71
+ [
72
+ Button.inline("Iɴʟɪɴᴇ Pɪᴄ", data="inli_pic"),
73
+ Button.inline("Sᴜᴅᴏ HNDLR", data="shndlr"),
74
+ ],
75
+ [Button.inline("Dᴜᴀʟ Mᴏᴅᴇ", "cbs_oofdm")],
76
+ [Button.inline("« Bᴀᴄᴋ", data="setter")],
77
+ ],
78
+ },
79
+ "sfban": {
80
+ "text": "SuperFban Settings:",
81
+ "buttons": [
82
+ [Button.inline("FBᴀɴ Gʀᴏᴜᴘ", data="sfgrp")],
83
+ [Button.inline("Exᴄʟᴜᴅᴇ Fᴇᴅs", data="abs_sfexf")],
84
+ [Button.inline("« Bᴀᴄᴋ", data="cbs_otvars")],
85
+ ],
86
+ },
87
+ "apauto": {
88
+ "text": "This'll auto approve on outgoing messages",
89
+ "buttons": [
90
+ [Button.inline("Aᴜᴛᴏ Aᴘᴘʀᴏᴠᴇ ON", data="apon")],
91
+ [Button.inline("Aᴜᴛᴏ Aᴘᴘʀᴏᴠᴇ OFF", data="apof")],
92
+ [Button.inline("« Bᴀᴄᴋ", data="cbs_pmcstm")],
93
+ ],
94
+ },
95
+ "alvcstm": {
96
+ "text": f"Customise your {HNDLR}alive. Choose from the below options -",
97
+ "buttons": [
98
+ [Button.inline("Aʟɪᴠᴇ Tᴇxᴛ", data="abs_alvtx")],
99
+ [Button.inline("Aʟɪᴠᴇ ᴍᴇᴅɪᴀ", data="alvmed")],
100
+ [Button.inline("Dᴇʟᴇᴛᴇ Aʟɪᴠᴇ Mᴇᴅɪᴀ", data="delmed")],
101
+ [Button.inline("« Bᴀᴄᴋ", data="setter")],
102
+ ],
103
+ },
104
+ "pmcstm": {
105
+ "text": "Customise your PMPERMIT Settings -",
106
+ "buttons": [
107
+ [
108
+ Button.inline("Pᴍ Tᴇxᴛ", data="pmtxt"),
109
+ Button.inline("Pᴍ Mᴇᴅɪᴀ", data="pmmed"),
110
+ ],
111
+ [
112
+ Button.inline("Aᴜᴛᴏ Aᴘᴘʀᴏᴠᴇ", data="cbs_apauto"),
113
+ Button.inline("PMLOGGER", data="pml"),
114
+ ],
115
+ [
116
+ Button.inline("Sᴇᴛ Wᴀʀɴs", data="swarn"),
117
+ Button.inline("Dᴇʟᴇᴛᴇ Pᴍ Mᴇᴅɪᴀ", data="delpmmed"),
118
+ ],
119
+ [Button.inline("PMPermit Type", data="cbs_pmtype")],
120
+ [Button.inline("« Bᴀᴄᴋ", data="cbs_ppmset")],
121
+ ],
122
+ },
123
+ "pmtype": {
124
+ "text": "Select the type of PMPermit needed.",
125
+ "buttons": [
126
+ [Button.inline("Inline", data="inpm_in")],
127
+ [Button.inline("Normal", data="inpm_no")],
128
+ [Button.inline("« Bᴀᴄᴋ", data="cbs_pmcstm")],
129
+ ],
130
+ },
131
+ "ppmset": {
132
+ "text": "PMPermit Settings:",
133
+ "buttons": [
134
+ [Button.inline("Tᴜʀɴ PMPᴇʀᴍɪᴛ Oɴ", data="pmon")],
135
+ [Button.inline("Tᴜʀɴ PMPᴇʀᴍɪᴛ Oғғ", data="pmoff")],
136
+ [Button.inline("Cᴜsᴛᴏᴍɪᴢᴇ PMPᴇʀᴍɪᴛ", data="cbs_pmcstm")],
137
+ [Button.inline("« Bᴀᴄᴋ", data="setter")],
138
+ ],
139
+ },
140
+ "chatbot": {
141
+ "text": "From This Feature U can chat with ppls Via ur Assistant Bot.\n[More info](https://t.me/UltroidUpdates/2)",
142
+ "buttons": [
143
+ [
144
+ Button.inline("Cʜᴀᴛ Bᴏᴛ Oɴ", data="onchbot"),
145
+ Button.inline("Cʜᴀᴛ Bᴏᴛ Oғғ", data="ofchbot"),
146
+ ],
147
+ [
148
+ Button.inline("Bᴏᴛ Wᴇʟᴄᴏᴍᴇ", data="bwel"),
149
+ Button.inline("Bᴏᴛ Wᴇʟᴄᴏᴍᴇ Mᴇᴅɪᴀ", data="botmew"),
150
+ ],
151
+ [Button.inline("Bᴏᴛ Iɴғᴏ Tᴇxᴛ", data="botinfe")],
152
+ [Button.inline("Fᴏʀᴄᴇ Sᴜʙsᴄʀɪʙᴇ", data="pmfs")],
153
+ [Button.inline("« Bᴀᴄᴋ", data="setter")],
154
+ ],
155
+ },
156
+ "vcb": {
157
+ "text": "From This Feature U can play songs in group voice chat\n\n[moreinfo](https://t.me/UltroidUpdates/4)",
158
+ "buttons": [
159
+ [Button.inline("VC Sᴇssɪᴏɴ", data="abs_vcs")],
160
+ [Button.inline("« Bᴀᴄᴋ", data="setter")],
161
+ ],
162
+ },
163
+ "oofdm": {
164
+ "text": "About [Dual Mode](https://t.me/UltroidUpdates/18)",
165
+ "buttons": [
166
+ [
167
+ Button.inline("Dᴜᴀʟ Mᴏᴅᴇ Oɴ", "dmof"),
168
+ Button.inline("Dᴜᴀʟ Mᴏᴅᴇ Oғғ", "dmof"),
169
+ ],
170
+ [Button.inline("Dᴜᴀʟ Mᴏᴅᴇ Hɴᴅʟʀ", "dmhn")],
171
+ [Button.inline("« Back", data="cbs_otvars")],
172
+ ],
173
+ },
174
+ "apiset": {
175
+ "text": get_string("ast_1"),
176
+ "buttons": [
177
+ [Button.inline("Remove.bg API", data="abs_rmbg")],
178
+ [Button.inline("DEEP API", data="abs_dapi")],
179
+ [Button.inline("OCR API", data="abs_oapi")],
180
+ [Button.inline("« Back", data="setter")],
181
+ ],
182
+ },
183
+ }
184
+
185
+ _convo = {
186
+ "rmbg": {
187
+ "var": "RMBG_API",
188
+ "name": "Remove.bg API Key",
189
+ "text": get_string("ast_2"),
190
+ "back": "cbs_apiset",
191
+ },
192
+ "dapi": {
193
+ "var": "DEEP_AI",
194
+ "name": "Deep AI Api Key",
195
+ "text": "Get Your Deep Api from deepai.org and send here.",
196
+ "back": "cbs_apiset",
197
+ },
198
+ "oapi": {
199
+ "var": "OCR_API",
200
+ "name": "Ocr Api Key",
201
+ "text": "Get Your OCR api from ocr.space and send that Here.",
202
+ "back": "cbs_apiset",
203
+ },
204
+ "pmlgg": {
205
+ "var": "PMLOGGROUP",
206
+ "name": "Pm Log Group",
207
+ "text": "Send chat id of chat which you want to save as Pm log Group.",
208
+ "back": "pml",
209
+ },
210
+ "vcs": {
211
+ "var": "VC_SESSION",
212
+ "name": "Vc Session",
213
+ "text": "**Vc session**\nEnter the New session u generated for vc bot.\n\nUse /cancel to terminate the operation.",
214
+ "back": "cbs_vcb",
215
+ },
216
+ "settag": {
217
+ "var": "TAG_LOG",
218
+ "name": "Tag Log Group",
219
+ "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.",
220
+ "back": "taglog",
221
+ },
222
+ "alvtx": {
223
+ "var": "ALIVE_TEXT",
224
+ "name": "Alive Text",
225
+ "text": "**Alive Text**\nEnter the new alive text.\n\nUse /cancel to terminate the operation.",
226
+ "back": "cbs_alvcstm",
227
+ },
228
+ "sfexf": {
229
+ "var": "EXCLUDE_FED",
230
+ "name": "Excluded Fed",
231
+ "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.",
232
+ "back": "cbs_sfban",
233
+ },
234
+ }
235
+
236
+
237
+ TOKEN_FILE = "resources/auths/auth_token.txt"
238
+
239
+
240
+ @callback(
241
+ re.compile(
242
+ "sndplug_(.*)",
243
+ ),
244
+ owner=True,
245
+ )
246
+ async def send(eve):
247
+ key, name = (eve.data_match.group(1)).decode("UTF-8").split("_")
248
+ thumb = "resources/extras/inline.jpg"
249
+ await eve.answer("■ Sending ■")
250
+ data = f"uh_{key}_"
251
+ index = None
252
+ if "|" in name:
253
+ name, index = name.split("|")
254
+ key = "plugins" if key == "Official" else key.lower()
255
+ plugin = f"{key}/{name}.py"
256
+ _ = f"pasta-{plugin}"
257
+ if index is not None:
258
+ data += f"|{index}"
259
+ _ += f"|{index}"
260
+ buttons = [
261
+ [
262
+ Button.inline(
263
+ "« Pᴀsᴛᴇ »",
264
+ data=_,
265
+ )
266
+ ],
267
+ [
268
+ Button.inline("« Bᴀᴄᴋ", data=data),
269
+ ],
270
+ ]
271
+ try:
272
+ await eve.edit(file=plugin, thumb=thumb, buttons=buttons)
273
+ except Exception as er:
274
+ await eve.answer(str(er), alert=True)
275
+
276
+
277
+ heroku_api, app_name = Var.HEROKU_API, Var.HEROKU_APP_NAME
278
+
279
+
280
+ @callback("updatenow", owner=True)
281
+ async def update(eve):
282
+ repo = Repo()
283
+ ac_br = repo.active_branch
284
+ ups_rem = repo.remote("upstream")
285
+ if heroku_api:
286
+ import heroku3
287
+
288
+ try:
289
+ heroku = heroku3.from_key(heroku_api)
290
+ heroku_app = None
291
+ heroku_applications = heroku.apps()
292
+ except BaseException as er:
293
+ LOGS.exception(er)
294
+ return await eve.edit("`Wrong HEROKU_API.`")
295
+ for app in heroku_applications:
296
+ if app.name == app_name:
297
+ heroku_app = app
298
+ if not heroku_app:
299
+ await eve.edit("`Wrong HEROKU_APP_NAME.`")
300
+ repo.__del__()
301
+ return
302
+ await eve.edit(get_string("clst_1"))
303
+ ups_rem.fetch(ac_br)
304
+ repo.git.reset("--hard", "FETCH_HEAD")
305
+ heroku_git_url = heroku_app.git_url.replace(
306
+ "https://", f"https://api:{heroku_api}@"
307
+ )
308
+
309
+ if "heroku" in repo.remotes:
310
+ remote = repo.remote("heroku")
311
+ remote.set_url(heroku_git_url)
312
+ else:
313
+ remote = repo.create_remote("heroku", heroku_git_url)
314
+ try:
315
+ remote.push(refspec=f"HEAD:refs/heads/{ac_br}", force=True)
316
+ except GitCommandError as error:
317
+ await eve.edit(f"`Here is the error log:\n{error}`")
318
+ repo.__del__()
319
+ return
320
+ await eve.edit("`Successfully Updated!\nRestarting, please wait...`")
321
+ else:
322
+ await eve.edit(get_string("clst_1"))
323
+ call_back()
324
+ await bash("git pull && pip3 install -r requirements.txt")
325
+ execl(sys.executable, sys.executable, "-m", "xteam")
326
+
327
+
328
+ @callback(re.compile("changes(.*)"), owner=True)
329
+ async def changes(okk):
330
+ match = okk.data_match.group(1).decode("utf-8")
331
+ await okk.answer(get_string("clst_3"))
332
+ repo = Repo.init()
333
+ button = [[Button.inline("Update Now", data="updatenow")]]
334
+ changelog, tl_chnglog = await gen_chlog(
335
+ repo, f"HEAD..upstream/{repo.active_branch}"
336
+ )
337
+ cli = "\n\nClick the below button to update!"
338
+ if not match:
339
+ try:
340
+ if len(tl_chnglog) > 700:
341
+ tl_chnglog = f"{tl_chnglog[:700]}..."
342
+ button.append([Button.inline("View Complete", "changesall")])
343
+ await okk.edit("• Writing Changelogs 📝 •")
344
+ img = await Carbon(
345
+ file_name="changelog",
346
+ code=tl_chnglog,
347
+ backgroundColor=choice(ATRA_COL),
348
+ language="md",
349
+ )
350
+ return await okk.edit(
351
+ f"**• Ultroid Userbot •**{cli}", file=img, buttons=button
352
+ )
353
+ except Exception as er:
354
+ LOGS.exception(er)
355
+ changelog_str = changelog + cli
356
+ if len(changelog_str) > 1024:
357
+ await okk.edit(get_string("upd_4"))
358
+ await asyncio.sleep(2)
359
+ with open("ultroid_updates.txt", "w+") as file:
360
+ file.write(tl_chnglog)
361
+ await okk.edit(
362
+ get_string("upd_5"),
363
+ file="ultroid_updates.txt",
364
+ buttons=button,
365
+ )
366
+ remove("ultroid_updates.txt")
367
+ return
368
+ await okk.edit(
369
+ changelog_str,
370
+ buttons=button,
371
+ parse_mode="html",
372
+ )
373
+
374
+
375
+ @callback(
376
+ re.compile(
377
+ "pasta-(.*)",
378
+ ),
379
+ owner=True,
380
+ )
381
+ async def _(e):
382
+ ok = (e.data_match.group(1)).decode("UTF-8")
383
+ index = None
384
+ if "|" in ok:
385
+ ok, index = ok.split("|")
386
+ with open(ok, "r") as hmm:
387
+ _, key = await get_paste(hmm.read())
388
+ link = f"https://spaceb.in/{key}"
389
+ raw = f"https://spaceb.in/api/v1/documents/{key}/raw"
390
+ if not _:
391
+ return await e.answer(key[:30], alert=True)
392
+ if ok.startswith("addons"):
393
+ key = "Addons"
394
+ elif ok.startswith("vcbot"):
395
+ key = "VCBot"
396
+ else:
397
+ key = "Official"
398
+ data = f"uh_{key}_"
399
+ if index is not None:
400
+ data += f"|{index}"
401
+ await e.edit(
402
+ "",
403
+ buttons=[
404
+ [Button.url("Lɪɴᴋ", link), Button.url("Rᴀᴡ", raw)],
405
+ [Button.inline("« Bᴀᴄᴋ", data=data)],
406
+ ],
407
+ )
408
+
409
+
410
+ @callback(re.compile("cbs_(.*)"), owner=True)
411
+ async def _edit_to(event):
412
+ match = event.data_match.group(1).decode("utf-8")
413
+ data = _buttons.get(match)
414
+ if not data:
415
+ return
416
+ await event.edit(data["text"], buttons=data["buttons"], link_preview=False)
417
+
418
+
419
+ @callback(re.compile("abs_(.*)"), owner=True)
420
+ async def convo_handler(event: events.CallbackQuery):
421
+ match = event.data_match.group(1).decode("utf-8")
422
+ if not _convo.get(match):
423
+ return
424
+ await event.delete()
425
+ get_ = _convo[match]
426
+ back = get_["back"]
427
+ async with event.client.conversation(event.sender_id) as conv:
428
+ await conv.send_message(get_["text"])
429
+ response = await conv.get_response()
430
+ themssg = response.message
431
+ try:
432
+ themssg = ast.literal_eval(themssg)
433
+ except Exception:
434
+ pass
435
+ if themssg == "/cancel":
436
+ return await conv.send_message(
437
+ "Cancelled!!",
438
+ buttons=get_back_button(back),
439
+ )
440
+ await setit(event, get_["var"], themssg)
441
+ await conv.send_message(
442
+ f"{get_['name']} changed to `{themssg}`",
443
+ buttons=get_back_button(back),
444
+ )
445
+
446
+
447
+ @callback("authorise", owner=True)
448
+ async def _(e):
449
+ if not e.is_private:
450
+ return
451
+ url = GDrive._create_token_file()
452
+ await e.edit("Go to the below link and send the code!")
453
+ async with asst.conversation(e.sender_id) as conv:
454
+ await conv.send_message(url)
455
+ code = await conv.get_response()
456
+ if GDrive._create_token_file(code=code.text):
457
+ await conv.send_message(
458
+ "`Success!\nYou are all set to use Google Drive with Ultroid Userbot.`",
459
+ buttons=Button.inline("Main Menu", data="setter"),
460
+ )
461
+ else:
462
+ await conv.send_message("Wrong code! Click authorise again.")
463
+
464
+
465
+ @callback("folderid", owner=True, func=lambda x: x.is_private)
466
+ async def _(e):
467
+ if not e.is_private:
468
+ return
469
+ msg = (
470
+ "Send your FOLDER ID\n\n"
471
+ + "For FOLDER ID:\n"
472
+ + "1. Open Google Drive App.\n"
473
+ + "2. Create Folder.\n"
474
+ + "3. Make that folder public.\n"
475
+ + "4. Send link of that folder."
476
+ )
477
+ await e.delete()
478
+ async with asst.conversation(e.sender_id, timeout=150) as conv:
479
+ await conv.send_message(msg)
480
+ repl = await conv.get_response()
481
+ id = repl.text
482
+ if id.startswith("https"):
483
+ id = id.split("?id=")[-1]
484
+ udB.set_key("GDRIVE_FOLDER_ID", id)
485
+ await repl.reply(
486
+ "`Success.`",
487
+ buttons=get_back_button("gdrive"),
488
+ )
489
+
490
+
491
+ @callback("gdrive", owner=True)
492
+ async def _(e):
493
+ if not e.is_private:
494
+ return
495
+ await e.edit(
496
+ "Click Authorise and send the code.\n\nYou can use your own CLIENT ID and SECRET by [this](https://t.me/UltroidUpdates/37)",
497
+ buttons=[
498
+ [
499
+ Button.inline("Folder ID", data="folderid"),
500
+ Button.inline("Authorise", data="authorise"),
501
+ ],
502
+ [Button.inline("« Back", data="cbs_otvars")],
503
+ ],
504
+ link_preview=False,
505
+ )
506
+
507
+
508
+ @callback("dmof", owner=True)
509
+ async def rhwhe(e):
510
+ if udB.get_key("DUAL_MODE"):
511
+ udB.del_key("DUAL_MODE")
512
+ key = "Off"
513
+ else:
514
+ udB.set_key("DUAL_MODE", "True")
515
+ key = "On"
516
+ Msg = f"Dual Mode : {key}"
517
+ await e.edit(Msg, buttons=get_back_button("cbs_otvars"))
518
+
519
+
520
+ @callback("dmhn", owner=True)
521
+ async def hndlrr(event):
522
+ await event.delete()
523
+ pru = event.sender_id
524
+ var = "DUAL_HNDLR"
525
+ name = "Dual Handler"
526
+ CH = udB.get_key(var) or "/"
527
+ async with event.client.conversation(pru) as conv:
528
+ await conv.send_message(
529
+ 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.",
530
+ )
531
+ response = conv.wait_event(events.NewMessage(chats=pru))
532
+ response = await response
533
+ themssg = response.message.message
534
+ if themssg == "/cancel":
535
+ await conv.send_message(
536
+ "Cancelled!!",
537
+ buttons=get_back_button("cbs_otvars"),
538
+ )
539
+ elif len(themssg) > 1:
540
+ await conv.send_message(
541
+ "Incorrect Handler",
542
+ buttons=get_back_button("cbs_otvars"),
543
+ )
544
+ else:
545
+ await setit(event, var, themssg)
546
+ await conv.send_message(
547
+ f"{name} changed to {themssg}",
548
+ buttons=get_back_button("cbs_otvars"),
549
+ )
550
+
551
+
552
+ @callback("emoj", owner=True)
553
+ async def emoji(event):
554
+ await event.delete()
555
+ pru = event.sender_id
556
+ var = "EMOJI_IN_HELP"
557
+ name = f"Emoji in `{HNDLR}help` menu"
558
+ async with event.client.conversation(pru) as conv:
559
+ await conv.send_message("Send emoji u want to set 🙃.\n\nUse /cancel to cancel.")
560
+ response = conv.wait_event(events.NewMessage(chats=pru))
561
+ response = await response
562
+ themssg = response.message.message
563
+ if themssg == "/cancel":
564
+ await conv.send_message(
565
+ "Cancelled!!",
566
+ buttons=get_back_button("cbs_otvars"),
567
+ )
568
+ elif themssg.startswith(("/", HNDLR)):
569
+ await conv.send_message(
570
+ "Incorrect Emoji",
571
+ buttons=get_back_button("cbs_otvars"),
572
+ )
573
+ else:
574
+ await setit(event, var, themssg)
575
+ await conv.send_message(
576
+ f"{name} changed to {themssg}\n",
577
+ buttons=get_back_button("cbs_otvars"),
578
+ )
579
+
580
+
581
+ @callback("plg", owner=True)
582
+ async def pluginch(event):
583
+ await event.delete()
584
+ pru = event.sender_id
585
+ var = "PLUGIN_CHANNEL"
586
+ name = "Plugin Channel"
587
+ async with event.client.conversation(pru) as conv:
588
+ await conv.send_message(
589
+ "Send id or username of a channel from where u want to install all plugins\n\nOur Channel~ @ultroidplugins\n\nUse /cancel to cancel.",
590
+ )
591
+ response = conv.wait_event(events.NewMessage(chats=pru))
592
+ response = await response
593
+ themssg = response.message.message
594
+ if themssg == "/cancel":
595
+ await conv.send_message(
596
+ "Cancelled!!",
597
+ buttons=get_back_button("cbs_otvars"),
598
+ )
599
+ elif themssg.startswith(("/", HNDLR)):
600
+ await conv.send_message(
601
+ "Incorrect channel",
602
+ buttons=get_back_button("cbs_otvars"),
603
+ )
604
+ else:
605
+ await setit(event, var, themssg)
606
+ await conv.send_message(
607
+ f"{name} changed to {themssg}\n After Setting All Things Do Restart",
608
+ buttons=get_back_button("cbs_otvars"),
609
+ )
610
+
611
+
612
+ @callback("hhndlr", owner=True)
613
+ async def hndlrr(event):
614
+ await event.delete()
615
+ pru = event.sender_id
616
+ var = "HNDLR"
617
+ name = "Handler/ Trigger"
618
+ async with event.client.conversation(pru) as conv:
619
+ await conv.send_message(
620
+ f"Send The Symbol Which u want as Handler/Trigger to use bot\nUr Current Handler is [ `{HNDLR}` ]\n\n use /cancel to cancel.",
621
+ )
622
+ response = conv.wait_event(events.NewMessage(chats=pru))
623
+ response = await response
624
+ themssg = response.message.message
625
+ if themssg == "/cancel":
626
+ await conv.send_message(
627
+ "Cancelled!!",
628
+ buttons=get_back_button("cbs_otvars"),
629
+ )
630
+ elif len(themssg) > 1:
631
+ await conv.send_message(
632
+ "Incorrect Handler",
633
+ buttons=get_back_button("cbs_otvars"),
634
+ )
635
+ elif themssg.startswith(("/", "#", "@")):
636
+ await conv.send_message(
637
+ "This cannot be used as handler",
638
+ buttons=get_back_button("cbs_otvars"),
639
+ )
640
+ else:
641
+ await setit(event, var, themssg)
642
+ await conv.send_message(
643
+ f"{name} changed to {themssg}",
644
+ buttons=get_back_button("cbs_otvars"),
645
+ )
646
+
647
+
648
+ @callback("shndlr", owner=True)
649
+ async def hndlrr(event):
650
+ await event.delete()
651
+ pru = event.sender_id
652
+ var = "SUDO_HNDLR"
653
+ name = "Sudo Handler"
654
+ async with event.client.conversation(pru) as conv:
655
+ await conv.send_message(
656
+ "Send The Symbol Which u want as Sudo Handler/Trigger to use bot\n\n use /cancel to cancel."
657
+ )
658
+
659
+ response = conv.wait_event(events.NewMessage(chats=pru))
660
+ response = await response
661
+ themssg = response.message.message
662
+ if themssg == "/cancel":
663
+ await conv.send_message(
664
+ "Cancelled!!",
665
+ buttons=get_back_button("cbs_otvars"),
666
+ )
667
+ elif len(themssg) > 1:
668
+ await conv.send_message(
669
+ "Incorrect Handler",
670
+ buttons=get_back_button("cbs_otvars"),
671
+ )
672
+ elif themssg.startswith(("/", "#", "@")):
673
+ await conv.send_message(
674
+ "This cannot be used as handler",
675
+ buttons=get_back_button("cbs_otvars"),
676
+ )
677
+ else:
678
+ await setit(event, var, themssg)
679
+ await conv.send_message(
680
+ f"{name} changed to {themssg}",
681
+ buttons=get_back_button("cbs_otvars"),
682
+ )
683
+
684
+
685
+ @callback("taglog", owner=True)
686
+ async def tagloggrr(e):
687
+ BUTTON = [
688
+ [Button.inline("SET TAG LOG", data="abs_settag")],
689
+ [Button.inline("DELETE TAG LOG", data="deltag")],
690
+ get_back_button("cbs_otvars"),
691
+ ]
692
+ await e.edit(
693
+ "Choose Options",
694
+ buttons=BUTTON,
695
+ )
696
+
697
+
698
+ @callback("deltag", owner=True)
699
+ async def _(e):
700
+ udB.del_key("TAG_LOG")
701
+ await e.answer("Done!!! Tag Logger has been turned Off")
702
+
703
+
704
+ @callback("eaddon", owner=True)
705
+ async def pmset(event):
706
+ BT = (
707
+ [Button.inline("Aᴅᴅᴏɴs Oғғ", data="edof")]
708
+ if udB.get_key("ADDONS")
709
+ else [Button.inline("Aᴅᴅᴏɴs Oɴ", data="edon")]
710
+ )
711
+
712
+ await event.edit(
713
+ "ADDONS~ Extra Plugins:",
714
+ buttons=[
715
+ BT,
716
+ [Button.inline("« Bᴀᴄᴋ", data="cbs_otvars")],
717
+ ],
718
+ )
719
+
720
+
721
+ @callback("edon", owner=True)
722
+ async def eddon(event):
723
+ var = "ADDONS"
724
+ await setit(event, var, "True")
725
+ await event.edit(
726
+ "Done! ADDONS has been turned on!!\n\n After Setting All Things Do Restart",
727
+ buttons=get_back_button("eaddon"),
728
+ )
729
+
730
+
731
+ @callback("edof", owner=True)
732
+ async def eddof(event):
733
+ udB.set_key("ADDONS", "False")
734
+ await event.edit(
735
+ "Done! ADDONS has been turned off!! After Setting All Things Do Restart",
736
+ buttons=get_back_button("eaddon"),
737
+ )
738
+
739
+
740
+ @callback("sudo", owner=True)
741
+ async def pmset(event):
742
+ BT = (
743
+ [Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ Oғғ", data="ofsudo")]
744
+ if udB.get_key("SUDO")
745
+ else [Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ Oɴ", data="onsudo")]
746
+ )
747
+
748
+ await event.edit(
749
+ f"SUDO MODE ~ Some peoples can use ur Bot which u selected. To know More use `{HNDLR}help sudo`",
750
+ buttons=[
751
+ BT,
752
+ [Button.inline("« Bᴀᴄᴋ", data="cbs_otvars")],
753
+ ],
754
+ )
755
+
756
+
757
+ @callback("onsudo", owner=True)
758
+ async def eddon(event):
759
+ var = "SUDO"
760
+ await setit(event, var, "True")
761
+ await event.edit(
762
+ "Done! SUDO MODE has been turned on!!\n\n After Setting All Things Do Restart",
763
+ buttons=get_back_button("sudo"),
764
+ )
765
+
766
+
767
+ @callback("ofsudo", owner=True)
768
+ async def eddof(event):
769
+ var = "SUDO"
770
+ await setit(event, var, "False")
771
+ await event.edit(
772
+ "Done! SUDO MODE has been turned off!! After Setting All Things Do Restart",
773
+ buttons=get_back_button("sudo"),
774
+ )
775
+
776
+
777
+ @callback("sfgrp", owner=True)
778
+ async def sfgrp(event):
779
+ await event.delete()
780
+ name = "FBan Group ID"
781
+ var = "FBAN_GROUP_ID"
782
+ pru = event.sender_id
783
+ async with asst.conversation(pru) as conv:
784
+ await conv.send_message(
785
+ f"Make a group, add @MissRose_Bot, send `{HNDLR}id`, copy that and send it here.\nUse /cancel to go back.",
786
+ )
787
+ response = conv.wait_event(events.NewMessage(chats=pru))
788
+ response = await response
789
+ themssg = response.message.message
790
+ if themssg == "/cancel":
791
+ return await conv.send_message(
792
+ "Cancelled!!",
793
+ buttons=get_back_button("cbs_sfban"),
794
+ )
795
+ await setit(event, var, themssg)
796
+ await conv.send_message(
797
+ f"{name} changed to {themssg}",
798
+ buttons=get_back_button("cbs_sfban"),
799
+ )
800
+
801
+
802
+ @callback("alvmed", owner=True)
803
+ async def media(event):
804
+ await event.delete()
805
+ pru = event.sender_id
806
+ var = "ALIVE_PIC"
807
+ name = "Alive Media"
808
+ async with event.client.conversation(pru) as conv:
809
+ await conv.send_message(
810
+ "**Alive Media**\nSend me a pic/gif/media to set as alive media.\n\nUse /cancel to terminate the operation.",
811
+ )
812
+ response = await conv.get_response()
813
+ try:
814
+ themssg = response.message
815
+ if themssg == "/cancel":
816
+ return await conv.send_message(
817
+ "Operation cancelled!!",
818
+ buttons=get_back_button("cbs_alvcstm"),
819
+ )
820
+ except BaseException as er:
821
+ LOGS.exception(er)
822
+ if (
823
+ not (response.text).startswith("/")
824
+ and response.text != ""
825
+ and (not response.media or isinstance(response.media, MessageMediaWebPage))
826
+ ):
827
+ url = text_to_url(response)
828
+ elif response.sticker:
829
+ url = response.file.id
830
+ else:
831
+ media = await event.client.download_media(response, "alvpc")
832
+ try:
833
+ x = upl(media)
834
+ url = f"https://graph.org/{x[0]}"
835
+ remove(media)
836
+ except BaseException as er:
837
+ LOGS.exception(er)
838
+ return await conv.send_message(
839
+ "Terminated.",
840
+ buttons=get_back_button("cbs_alvcstm"),
841
+ )
842
+ await setit(event, var, url)
843
+ await conv.send_message(
844
+ f"{name} has been set.",
845
+ buttons=get_back_button("cbs_alvcstm"),
846
+ )
847
+
848
+
849
+ @callback("delmed", owner=True)
850
+ async def dell(event):
851
+ try:
852
+ udB.del_key("ALIVE_PIC")
853
+ return await event.edit(
854
+ get_string("clst_5"), buttons=get_back_button("cbs_alabs_vcstm")
855
+ )
856
+ except BaseException as er:
857
+ LOGS.exception(er)
858
+ return await event.edit(
859
+ get_string("clst_4"),
860
+ buttons=get_back_button("cbs_alabs_vcstm"),
861
+ )
862
+
863
+
864
+ @callback("inpm_in", owner=True)
865
+ async def inl_on(event):
866
+ var = "INLINE_PM"
867
+ await setit(event, var, "True")
868
+ await event.edit(
869
+ "Done!! PMPermit type has been set to inline!",
870
+ buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_pmtype")]],
871
+ )
872
+
873
+
874
+ @callback("inpm_no", owner=True)
875
+ async def inl_on(event):
876
+ var = "INLINE_PM"
877
+ await setit(event, var, "False")
878
+ await event.edit(
879
+ "Done!! PMPermit type has been set to normal!",
880
+ buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_pmtype")]],
881
+ )
882
+
883
+
884
+ @callback("pmtxt", owner=True)
885
+ async def name(event):
886
+ await event.delete()
887
+ pru = event.sender_id
888
+ var = "PM_TEXT"
889
+ name = "PM Text"
890
+ async with event.client.conversation(pru) as conv:
891
+ await conv.send_message(
892
+ "**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.",
893
+ )
894
+ response = conv.wait_event(events.NewMessage(chats=pru))
895
+ response = await response
896
+ themssg = response.message.message
897
+ if themssg == "/cancel":
898
+ return await conv.send_message(
899
+ "Cancelled!!",
900
+ buttons=get_back_button("cbs_pmcstm"),
901
+ )
902
+ if len(themssg) > 4090:
903
+ return await conv.send_message(
904
+ "Message too long!\nGive a shorter message please!!",
905
+ buttons=get_back_button("cbs_pmcstm"),
906
+ )
907
+ await setit(event, var, themssg)
908
+ await conv.send_message(
909
+ f"{name} changed to {themssg}\n\nAfter Setting All Things Do restart",
910
+ buttons=get_back_button("cbs_pmcstm"),
911
+ )
912
+
913
+
914
+ @callback("swarn", owner=True)
915
+ async def name(event):
916
+ m = range(1, 10)
917
+ tultd = [Button.inline(f"{x}", data=f"wrns_{x}") for x in m]
918
+ lst = list(zip(tultd[::3], tultd[1::3], tultd[2::3]))
919
+ lst.append([Button.inline("« Bᴀᴄᴋ", data="cbs_pmcstm")])
920
+ await event.edit(
921
+ "Select the number of warnings for a user before getting blocked in PMs.",
922
+ buttons=lst,
923
+ )
924
+
925
+
926
+ @callback(re.compile(b"wrns_(.*)"), owner=True)
927
+ async def set_wrns(event):
928
+ value = int(event.data_match.group(1).decode("UTF-8"))
929
+ if dn := udB.set_key("PMWARNS", value):
930
+ await event.edit(
931
+ f"PM Warns Set to {value}.\nNew users will have {value} chances in PMs before getting banned.",
932
+ buttons=get_back_button("cbs_pmcstm"),
933
+ )
934
+ else:
935
+ await event.edit(
936
+ f"Something went wrong, please check your {HNDLR}logs!",
937
+ buttons=get_back_button("cbs_pmcstm"),
938
+ )
939
+
940
+
941
+ @callback("pmmed", owner=True)
942
+ async def media(event):
943
+ await event.delete()
944
+ pru = event.sender_id
945
+ var = "PMPIC"
946
+ name = "PM Media"
947
+ async with event.client.conversation(pru) as conv:
948
+ await conv.send_message(
949
+ "**PM Media**\nSend me a pic/gif/sticker/link to set as pmpermit media.\n\nUse /cancel to terminate the operation.",
950
+ )
951
+ response = await conv.get_response()
952
+ try:
953
+ themssg = response.message
954
+ if themssg == "/cancel":
955
+ return await conv.send_message(
956
+ "Operation cancelled!!",
957
+ buttons=get_back_button("cbs_pmcstm"),
958
+ )
959
+ except BaseException as er:
960
+ LOGS.exception(er)
961
+ media = await event.client.download_media(response, "pmpc")
962
+ if (
963
+ not (response.text).startswith("/")
964
+ and response.text != ""
965
+ and (not response.media or isinstance(response.media, MessageMediaWebPage))
966
+ ):
967
+ url = text_to_url(response)
968
+ elif response.sticker:
969
+ url = response.file.id
970
+ else:
971
+ try:
972
+ x = upl(media)
973
+ url = f"https://graph.org/{x[0]}"
974
+ remove(media)
975
+ except BaseException as er:
976
+ LOGS.exception(er)
977
+ return await conv.send_message(
978
+ "Terminated.",
979
+ buttons=get_back_button("cbs_pmcstm"),
980
+ )
981
+ await setit(event, var, url)
982
+ await conv.send_message(
983
+ f"{name} has been set.",
984
+ buttons=get_back_button("cbs_pmcstm"),
985
+ )
986
+
987
+
988
+ @callback("delpmmed", owner=True)
989
+ async def dell(event):
990
+ try:
991
+ udB.del_key("PMPIC")
992
+ return await event.edit(
993
+ get_string("clst_5"), buttons=get_back_button("cbs_pmcstm")
994
+ )
995
+ except BaseException as er:
996
+ LOGS.exception(er)
997
+ return await event.edit(
998
+ get_string("clst_4"),
999
+ buttons=[[Button.inline("« Sᴇᴛᴛɪɴɢs", data="setter")]],
1000
+ )
1001
+
1002
+
1003
+ @callback("apon", owner=True)
1004
+ async def apon(event):
1005
+ var = "AUTOAPPROVE"
1006
+ await setit(event, var, "True")
1007
+ await event.edit(
1008
+ "Done!! AUTOAPPROVE Started!!",
1009
+ buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_apauto")]],
1010
+ )
1011
+
1012
+
1013
+ @callback("apof", owner=True)
1014
+ async def apof(event):
1015
+ try:
1016
+ udB.set_key("AUTOAPPROVE", "False")
1017
+ return await event.edit(
1018
+ "Done! AUTOAPPROVE Stopped!!",
1019
+ buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_apauto")]],
1020
+ )
1021
+ except BaseException as er:
1022
+ LOGS.exception(er)
1023
+ return await event.edit(
1024
+ get_string("clst_4"),
1025
+ buttons=[[Button.inline("« Sᴇᴛᴛɪɴɢs", data="setter")]],
1026
+ )
1027
+
1028
+
1029
+ @callback("pml", owner=True)
1030
+ async def l_vcs(event):
1031
+ BT = (
1032
+ [Button.inline("PMLOGGER OFF", data="pmlogof")]
1033
+ if udB.get_key("PMLOG")
1034
+ else [Button.inline("PMLOGGER ON", data="pmlog")]
1035
+ )
1036
+
1037
+ await event.edit(
1038
+ "PMLOGGER This Will Forward Ur Pm to Ur Private Group -",
1039
+ buttons=[
1040
+ BT,
1041
+ [Button.inline("PᴍLᴏɢɢᴇʀ Gʀᴏᴜᴘ", "abs_pmlgg")],
1042
+ [Button.inline("« Bᴀᴄᴋ", data="cbs_pmcstm")],
1043
+ ],
1044
+ )
1045
+
1046
+
1047
+ @callback("pmlog", owner=True)
1048
+ async def pmlog(event):
1049
+ await setit(event, "PMLOG", "True")
1050
+ await event.edit(
1051
+ "Done!! PMLOGGER Started!!",
1052
+ buttons=[[Button.inline("« Bᴀᴄᴋ", data="pml")]],
1053
+ )
1054
+
1055
+
1056
+ @callback("pmlogof", owner=True)
1057
+ async def pmlogof(event):
1058
+ try:
1059
+ udB.del_key("PMLOG")
1060
+ return await event.edit(
1061
+ "Done! PMLOGGER Stopped!!",
1062
+ buttons=[[Button.inline("« Bᴀᴄᴋ", data="pml")]],
1063
+ )
1064
+ except BaseException as er:
1065
+ LOGS.exception(er)
1066
+ return await event.edit(
1067
+ get_string("clst_4"),
1068
+ buttons=[[Button.inline("« Sᴇᴛᴛɪɴɢs", data="setter")]],
1069
+ )
1070
+
1071
+
1072
+ @callback("pmon", owner=True)
1073
+ async def pmonn(event):
1074
+ var = "PMSETTING"
1075
+ await setit(event, var, "True")
1076
+ await event.edit(
1077
+ "Done! PMPermit has been turned on!!",
1078
+ buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_ppmset")]],
1079
+ )
1080
+
1081
+
1082
+ @callback("pmoff", owner=True)
1083
+ async def pmofff(event):
1084
+ var = "PMSETTING"
1085
+ await setit(event, var, "False")
1086
+ await event.edit(
1087
+ "Done! PMPermit has been turned off!!",
1088
+ buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_ppmset")]],
1089
+ )
1090
+
1091
+
1092
+ @callback("botmew", owner=True)
1093
+ async def hhh(e):
1094
+ async with e.client.conversation(e.chat_id) as conv:
1095
+ await conv.send_message("Send Any Media to keep at your Bot's welcome ")
1096
+ msg = await conv.get_response()
1097
+ if not msg.media or msg.text.startswith("/"):
1098
+ return await conv.send_message(
1099
+ "Terminated!", buttons=get_back_button("cbs_chatbot")
1100
+ )
1101
+ udB.set_key("STARTMEDIA", msg.file.id)
1102
+ await conv.send_message("Done!", buttons=get_back_button("cbs_chatbot"))
1103
+
1104
+
1105
+ @callback("botinfe", owner=True)
1106
+ async def hhh(e):
1107
+ async with e.client.conversation(e.chat_id) as conv:
1108
+ await conv.send_message(
1109
+ "Send message to set to Display, when user Press Info button in Bot Welcome!\n\nsend `False` to completely remove that button.."
1110
+ )
1111
+ msg = await conv.get_response()
1112
+ if msg.media or msg.text.startswith("/"):
1113
+ return await conv.send_message(
1114
+ "Terminated!", buttons=get_back_button("cbs_chatbot")
1115
+ )
1116
+ udB.set_key("BOT_INFO_START", msg.text)
1117
+ await conv.send_message("Done!", buttons=get_back_button("cbs_chatbot"))
1118
+
1119
+
1120
+ @callback("pmfs", owner=True)
1121
+ async def heheh(event):
1122
+ Ll = []
1123
+ err = ""
1124
+ async with event.client.conversation(event.chat_id) as conv:
1125
+ await conv.send_message(
1126
+ "• Send The Chat Id(s), which you want user to Join Before using Chat/Pm Bot\n\n• Send /clear to disable PmBot Force sub..\n• • Send /cancel to stop this process.."
1127
+ )
1128
+ await conv.send_message(
1129
+ "Example : \n`-1001234567\n-100778888`\n\nFor Multiple Chat(s)."
1130
+ )
1131
+ try:
1132
+ msg = await conv.get_response()
1133
+ except AsyncTimeOut:
1134
+ return await conv.send_message("**• TimeUp!**\nStart from /start back.")
1135
+ if not msg.text or msg.text.startswith("/"):
1136
+ timyork = "Cancelled!"
1137
+ if msg.text == "/clear":
1138
+ udB.del_key("PMBOT_FSUB")
1139
+ timyork = "Done! Force Subscribe Stopped\nRestart your Bot!"
1140
+ return await conv.send_message(
1141
+ "Cancelled!", buttons=get_back_button("cbs_chatbot")
1142
+ )
1143
+ for chat in msg.message.split("\n"):
1144
+ if chat.startswith("-") or chat.isdigit():
1145
+ chat = int(chat)
1146
+ try:
1147
+ CHSJSHS = await event.client.get_entity(chat)
1148
+ Ll.append(get_peer_id(CHSJSHS))
1149
+ except Exception as er:
1150
+ err += f"**{chat}** : {er}\n"
1151
+ if err:
1152
+ return await conv.send_message(err)
1153
+ udB.set_key("PMBOT_FSUB", str(Ll))
1154
+ await conv.send_message(
1155
+ "Done!\nRestart Your Bot.", buttons=get_back_button("cbs_chatbot")
1156
+ )
1157
+
1158
+
1159
+ @callback("bwel", owner=True)
1160
+ async def name(event):
1161
+ await event.delete()
1162
+ pru = event.sender_id
1163
+ var = "STARTMSG"
1164
+ name = "Bot Welcome Message:"
1165
+ async with event.client.conversation(pru) as conv:
1166
+ await conv.send_message(
1167
+ "**BOT WELCOME MSG**\nEnter the msg which u want to show when someone start your assistant Bot.\nYou Can use `{me}` , `{mention}` Parameters Too\nUse /cancel to terminate the operation.",
1168
+ )
1169
+ response = conv.wait_event(events.NewMessage(chats=pru))
1170
+ response = await response
1171
+ themssg = response.message.message
1172
+ if themssg == "/cancel":
1173
+ return await conv.send_message(
1174
+ "Cancelled!!",
1175
+ buttons=get_back_button("cbs_chatbot"),
1176
+ )
1177
+ await setit(event, var, themssg)
1178
+ await conv.send_message(
1179
+ f"{name} changed to {themssg}",
1180
+ buttons=get_back_button("cbs_chatbot"),
1181
+ )
1182
+
1183
+
1184
+ @callback("onchbot", owner=True)
1185
+ async def chon(event):
1186
+ var = "PMBOT"
1187
+ await setit(event, var, "True")
1188
+ Loader(path="assistant/pmbot.py", key="PM Bot").load()
1189
+ if AST_PLUGINS.get("pmbot"):
1190
+ for i, e in AST_PLUGINS["pmbot"]:
1191
+ event.client.remove_event_handler(i)
1192
+ for i, e in AST_PLUGINS["pmbot"]:
1193
+ event.client.add_event_handler(i, events.NewMessage(**e))
1194
+ await event.edit(
1195
+ "Done! Now u Can Chat With People Via This Bot",
1196
+ buttons=[Button.inline("« Bᴀᴄᴋ", data="cbs_chatbot")],
1197
+ )
1198
+
1199
+
1200
+ @callback("ofchbot", owner=True)
1201
+ async def chon(event):
1202
+ var = "PMBOT"
1203
+ await setit(event, var, "False")
1204
+ if AST_PLUGINS.get("pmbot"):
1205
+ for i, e in AST_PLUGINS["pmbot"]:
1206
+ event.client.remove_event_handler(i)
1207
+ await event.edit(
1208
+ "Done! Chat People Via This Bot Stopped.",
1209
+ buttons=[Button.inline("« Bᴀᴄᴋ", data="cbs_chatbot")],
1210
+ )
1211
+
1212
+
1213
+ @callback("inli_pic", owner=True)
1214
+ async def media(event):
1215
+ await event.delete()
1216
+ pru = event.sender_id
1217
+ var = "INLINE_PIC"
1218
+ name = "Inline Media"
1219
+ async with event.client.conversation(pru) as conv:
1220
+ await conv.send_message(
1221
+ "**Inline Media**\nSend me a pic/gif/ or link to set as inline media.\n\nUse /cancel to terminate the operation.",
1222
+ )
1223
+ response = await conv.get_response()
1224
+ try:
1225
+ themssg = response.message
1226
+ if themssg == "/cancel":
1227
+ return await conv.send_message(
1228
+ "Operation cancelled!!",
1229
+ buttons=get_back_button("setter"),
1230
+ )
1231
+ except BaseException as er:
1232
+ LOGS.exception(er)
1233
+ media = await event.client.download_media(response, "inlpic")
1234
+ if (
1235
+ not (response.text).startswith("/")
1236
+ and response.text != ""
1237
+ and (not response.media or isinstance(response.media, MessageMediaWebPage))
1238
+ ):
1239
+ url = text_to_url(response)
1240
+ else:
1241
+ try:
1242
+ x = upl(media)
1243
+ url = f"https://graph.org/{x[0]}"
1244
+ remove(media)
1245
+ except BaseException as er:
1246
+ LOGS.exception(er)
1247
+ return await conv.send_message(
1248
+ "Terminated.",
1249
+ buttons=get_back_button("setter"),
1250
+ )
1251
+ await setit(event, var, url)
1252
+ await conv.send_message(
1253
+ f"{name} has been set.",
1254
+ buttons=get_back_button("setter"),
1255
+ )
1256
+
1257
+
1258
+ FD_MEDIA = {}
1259
+
1260
+
1261
+ @callback(re.compile("fd(.*)"), owner=True)
1262
+ async def fdroid_dler(event):
1263
+ uri = event.data_match.group(1).decode("utf-8")
1264
+ if FD_MEDIA.get(uri):
1265
+ return await event.edit(file=FD_MEDIA[uri])
1266
+ await event.answer("• Starting Download •", alert=True)
1267
+ await event.edit("• Downloading.. •")
1268
+ URL = f"https://f-droid.org/packages/{uri}"
1269
+ conte = await async_searcher(URL, re_content=True)
1270
+ BSC = bs(conte, "html.parser", from_encoding="utf-8")
1271
+ dl_ = BSC.find("p", "package-version-download").find("a")["href"]
1272
+ title = BSC.find("h3", "package-name").text.strip()
1273
+ thumb = BSC.find("img", "package-icon")["src"]
1274
+ if thumb.startswith("/"):
1275
+ thumb = f"https://f-droid.org{thumb}"
1276
+ thumb, _ = await fast_download(thumb, filename=f"{uri}.png")
1277
+ s_time = time.time()
1278
+ file, _ = await fast_download(
1279
+ dl_,
1280
+ filename=f"{title}.apk",
1281
+ progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
1282
+ progress(
1283
+ d,
1284
+ t,
1285
+ event,
1286
+ s_time,
1287
+ "Downloading...",
1288
+ )
1289
+ ),
1290
+ )
1291
+
1292
+ time.time()
1293
+ n_file = await event.client.fast_uploader(
1294
+ file, show_progress=True, event=event, message="Uploading...", to_delete=True
1295
+ )
1296
+ buttons = Button.switch_inline("Search Back", query="fdroid", same_peer=True)
1297
+ try:
1298
+ msg = await event.edit(
1299
+ f"**• [{title}]({URL}) •**", file=n_file, thumb=thumb, buttons=buttons
1300
+ )
1301
+ except Exception as er:
1302
+ LOGS.exception(er)
1303
+ try:
1304
+ msg = await event.client.edit_message(
1305
+ await event.get_input_chat(),
1306
+ event.message_id,
1307
+ f"**• [{title}]({URL}) •**",
1308
+ buttons=buttons,
1309
+ thumb=thumb,
1310
+ file=n_file,
1311
+ )
1312
+ except Exception as er:
1313
+ os.remove(thumb)
1314
+ LOGS.exception(er)
1315
+ return await event.edit(f"**ERROR**: `{er}`", buttons=buttons)
1316
+ if msg and hasattr(msg, "media"):
1317
+ FD_MEDIA.update({uri: msg.media})
1318
+ os.remove(thumb)
assistant/initial.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2021-2023 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ import re
9
+
10
+ from . import *
11
+
12
+ STRINGS = {
13
+ 1: """🎇 **Thanks for Deploying Ultroid Userbot!**
14
+
15
+ • Here, are the Some Basic stuff from, where you can Know, about its Usage.""",
16
+ 2: """🎉** About Ultroid**
17
+
18
+ 🧿 Ultroid is Pluggable and powerful Telethon Userbot, made in Python from Scratch. It is Aimed to Increase Security along with Addition of Other Useful Features.
19
+
20
+ ❣ Made by **@TeamUltroid**""",
21
+ 3: """**💡• FAQs •**
22
+
23
+ -> [Username Tracker](https://t.me/UltroidUpdates/24)
24
+ -> [Keeping Custom Addons Repo](https://t.me/UltroidUpdates/28)
25
+ -> [Disabling Deploy message](https://t.me/UltroidUpdates/27)
26
+ -> [Setting up TimeZone](https://t.me/UltroidUpdates/22)
27
+ -> [About Inline PmPermit](https://t.me/UltroidUpdates/21)
28
+ -> [About Dual Mode](https://t.me/UltroidUpdates/18)
29
+ -> [Custom Thumbnail](https://t.me/UltroidUpdates/13)
30
+ -> [About FullSudo](https://t.me/UltroidUpdates/11)
31
+ -> [Setting Up PmBot](https://t.me/UltroidUpdates/2)
32
+ -> [Also Check](https://t.me/UltroidUpdates/14)
33
+
34
+ **• To Know About Updates**
35
+ - Join @TeamUltroid.""",
36
+ 4: f"""• `To Know All Available Commands`
37
+
38
+ - `{HNDLR}help`
39
+ - `{HNDLR}cmds`""",
40
+ 5: """• **For Any Other Query or Suggestion**
41
+ - Move to **@UltroidSupportChat**.
42
+
43
+ • Thanks for Reaching till END.""",
44
+ }
45
+
46
+
47
+ @callback(re.compile("initft_(\\d+)"))
48
+ async def init_depl(e):
49
+ CURRENT = int(e.data_match.group(1))
50
+ if CURRENT == 5:
51
+ return await e.edit(
52
+ STRINGS[5],
53
+ buttons=Button.inline("<< Back", "initbk_4"),
54
+ link_preview=False,
55
+ )
56
+
57
+ await e.edit(
58
+ STRINGS[CURRENT],
59
+ buttons=[
60
+ Button.inline("<<", f"initbk_{str(CURRENT - 1)}"),
61
+ Button.inline(">>", f"initft_{str(CURRENT + 1)}"),
62
+ ],
63
+ link_preview=False,
64
+ )
65
+
66
+
67
+ @callback(re.compile("initbk_(\\d+)"))
68
+ async def ineiq(e):
69
+ CURRENT = int(e.data_match.group(1))
70
+ if CURRENT == 1:
71
+ return await e.edit(
72
+ STRINGS[1],
73
+ buttons=Button.inline("Start Back >>", "initft_2"),
74
+ link_preview=False,
75
+ )
76
+
77
+ await e.edit(
78
+ STRINGS[CURRENT],
79
+ buttons=[
80
+ Button.inline("<<", f"initbk_{str(CURRENT - 1)}"),
81
+ Button.inline(">>", f"initft_{str(CURRENT + 1)}"),
82
+ ],
83
+ link_preview=False,
84
+ )
assistant/inlinestuff.py ADDED
@@ -0,0 +1,736 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2021-2023 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ import base64
9
+ import inspect
10
+ import asyncio
11
+ import os
12
+ import sys
13
+ import time
14
+ from datetime import datetime
15
+ from html import unescape
16
+ from random import choice
17
+ from re import compile as re_compile
18
+ from platform import python_version as pyver
19
+ from telethon import __version__
20
+ from xteam.version import __version__ as UltVer
21
+ from bs4 import BeautifulSoup as bs
22
+ from telethon import Button
23
+ from telethon.tl.alltlobjects import LAYER, tlobjects
24
+ from telethon.tl.types import DocumentAttributeAudio as Audio
25
+ from telethon.tl.types import InputWebDocument as wb
26
+ from secrets import choice
27
+ from telethon.tl.types import InputMessagesFilterVideo, InputMessagesFilterVoice
28
+ from telethon.tl.types import InputMessagesFilterPhotos
29
+ from xteam.fns.misc import google_search
30
+ from xteam.fns.tools import (
31
+ _webupload_cache,
32
+ async_searcher,
33
+ get_ofox,
34
+ saavn_search,
35
+ webuploader,
36
+ )
37
+
38
+ from . import *
39
+ from . import _ult_cache
40
+ from plugins import (
41
+ ATRA_COL,
42
+ LOGS,
43
+ OWNER_NAME,
44
+ ULTROID_IMAGES,
45
+ ALIVE_TEXT,
46
+ ALIVE_NAME,
47
+ stickers,
48
+ Button,
49
+ Carbon,
50
+ Telegraph,
51
+ Var,
52
+ allcmds,
53
+ asst,
54
+ bash,
55
+ call_back,
56
+ callback,
57
+ def_logs,
58
+ eor,
59
+ get_string,
60
+ heroku_logs,
61
+ in_pattern,
62
+ inline_pic,
63
+ restart,
64
+ shutdown,
65
+ start_time,
66
+ time_formatter,
67
+ udB,
68
+ ultroid_cmd,
69
+ ultroid_version,
70
+ updater,
71
+ )
72
+
73
+ SUP_BUTTONS = [
74
+ [
75
+ Button.url("• Repo •", url="https://github.com/TeamUltroid/Ultroid"),
76
+ Button.url("• Support •", url="t.me/UltroidSupportChat"),
77
+ ],
78
+ ]
79
+
80
+ PING_ALIVE = [
81
+ [
82
+ Button.inline("PING", data="ping"),
83
+ Button.inline("ALIVE", data="alive"),
84
+ ],
85
+ [
86
+ Button.inline("CLOSE", data="close"),
87
+ ],
88
+ ]
89
+
90
+
91
+ ofox = "https://graph.org/file/231f0049fcd722824f13b.jpg"
92
+ gugirl = "https://graph.org/file/0df54ae4541abca96aa11.jpg"
93
+ ultpic = "https://telegra.ph/file/8d7b534e34e13316a7dd2.jpg"
94
+ xteam = "https://telegra.ph/file/8d7b534e34e13316a7dd2.jpg"
95
+ apis = [
96
+ "QUl6YVN5QXlEQnNZM1dSdEI1WVBDNmFCX3c4SkF5NlpkWE5jNkZV",
97
+ "QUl6YVN5QkYwenhMbFlsUE1wOXh3TVFxVktDUVJxOERnZHJMWHNn",
98
+ "QUl6YVN5RGRPS253blB3VklRX2xiSDVzWUU0Rm9YakFLSVFWMERR",
99
+ ]
100
+
101
+
102
+
103
+ @in_pattern(owner=False, func=lambda x: not x.text)
104
+ async def help(e):
105
+ TLINK = inline_pic() or "https://telegra.ph/file/cad7038fe82e47f79c609.jpg"
106
+ MSG = "═════════════♢.✰.♢═════════════"
107
+ WEB0 = wb(
108
+ "https://telegra.ph/file/8d7b534e34e13316a7dd2.jpg", 0, "image/jpg", []
109
+ )
110
+ res = [
111
+ await e.builder.article(
112
+ type="photo",
113
+ text=MSG,
114
+ include_media=True,
115
+ buttons=PING_ALIVE,
116
+ title="Inline",
117
+ description="Userbot",
118
+ url=TLINK,
119
+ thumb=WEB0,
120
+ content=wb(TLINK, 0, "image/jpg", []),
121
+ )
122
+ ]
123
+ await e.answer(
124
+ res,
125
+ private=True,
126
+ cache_time=300,
127
+ switch_pm="xteam-userbot",
128
+ switch_pm_param="start",
129
+ )
130
+
131
+ @callback("ping", owner=False)
132
+ async def _(event):
133
+ start = datetime.now()
134
+ end = datetime.now()
135
+ uptime = time_formatter((time.time() - start_time) * 1000)
136
+ ms = (end - start).microseconds
137
+ pin = f"🎯 Pong = {ms} ms\n⏰ Uptime = {uptime}"
138
+ await event.answer(pin, cache_time=0, alert=True)
139
+
140
+
141
+
142
+ alive_txt = """
143
+ ━━━━✿ ᴜꜱᴇʀʙᴏᴛ ɪꜱ ᴀʟɪᴠᴇ ✿━━━
144
+ ❍ ᴜꜱᴇʀʙᴏᴛ - {}
145
+ ❍ ᴅᴀᴛᴀʙᴀꜱᴇ - {}
146
+ ❍ ᴛᴇʟᴇᴛʜᴏɴ - {}
147
+ ━━━━✿ ᴜꜱᴇʀʙᴏᴛ ɪꜱ ᴀʟɪᴠᴇ ✿━━━
148
+ """
149
+
150
+
151
+ @callback("alive")
152
+ async def alive(event):
153
+ text = alive_txt.format(ultroid_version, UltVer, __version__)
154
+ await event.answer(text, alert=True)
155
+
156
+
157
+ @callback("close", owner=False)
158
+ async def on_plug_in_callback_query_handler(event):
159
+ await event.edit(
160
+ get_string("inline_5"),
161
+ buttons=Button.inline("Oᴘᴇɴ Aɢᴀɪɴ", data="open"),
162
+ )
163
+
164
+ @in_pattern("ofox", owner=True)
165
+ async def _(e):
166
+ try:
167
+ match = e.text.split(" ", maxsplit=1)[1]
168
+ except IndexError:
169
+ kkkk = e.builder.article(
170
+ title="Enter Device Codename",
171
+ thumb=wb(ofox, 0, "image/jpeg", []),
172
+ text="**OFᴏx🦊Rᴇᴄᴏᴠᴇʀʏ**\n\nYou didn't search anything",
173
+ buttons=Button.switch_inline("Sᴇᴀʀᴄʜ Aɢᴀɪɴ", query="ofox ", same_peer=True),
174
+ )
175
+ return await e.answer([kkkk])
176
+ device, releases = await get_ofox(match)
177
+ if device.get("detail") is None:
178
+ fox = []
179
+ fullname = device["full_name"]
180
+ codename = device["codename"]
181
+ str(device["supported"])
182
+ maintainer = device["maintainer"]["name"]
183
+ link = f"https://orangefox.download/device/{codename}"
184
+ for data in releases["data"]:
185
+ release = data["type"]
186
+ version = data["version"]
187
+ size = humanbytes(data["size"])
188
+ release_date = datetime.utcfromtimestamp(data["date"]).strftime("%Y-%m-%d")
189
+ text = f"[\xad]({ofox})**OʀᴀɴɢᴇFᴏx Rᴇᴄᴏᴠᴇʀʏ Fᴏʀ**\n\n"
190
+ text += f"` Fᴜʟʟ Nᴀᴍᴇ: {fullname}`\n"
191
+ text += f"` Cᴏᴅᴇɴᴀᴍᴇ: {codename}`\n"
192
+ text += f"` Mᴀɪɴᴛᴀɪɴᴇʀ: {maintainer}`\n"
193
+ text += f"` Bᴜɪʟᴅ Tʏᴘᴇ: {release}`\n"
194
+ text += f"` Vᴇʀsɪᴏɴ: {version}`\n"
195
+ text += f"` Sɪᴢᴇ: {size}`\n"
196
+ text += f"` Bᴜɪʟᴅ Dᴀᴛᴇ: {release_date}`"
197
+ fox.append(
198
+ await e.builder.article(
199
+ title=f"{fullname}",
200
+ description=f"{version}\n{release_date}",
201
+ text=text,
202
+ thumb=wb(ofox, 0, "image/jpeg", []),
203
+ link_preview=True,
204
+ buttons=[
205
+ Button.url("Dᴏᴡɴʟᴏᴀᴅ", url=f"{link}"),
206
+ Button.switch_inline(
207
+ "Sᴇᴀʀᴄʜ Aɢᴀɪɴ", query="ofox ", same_peer=True
208
+ ),
209
+ ],
210
+ )
211
+ )
212
+ await e.answer(
213
+ fox, switch_pm="OrangeFox Recovery Search.", switch_pm_param="start"
214
+ )
215
+ else:
216
+ await e.answer(
217
+ [], switch_pm="OrangeFox Recovery Search.", switch_pm_param="start"
218
+ )
219
+
220
+
221
+ @in_pattern("fl2lnk ?(.*)", owner=True)
222
+ async def _(e):
223
+ match = e.pattern_match.group(1)
224
+ chat_id, msg_id = match.split(":")
225
+ filename = _webupload_cache[int(chat_id)][int(msg_id)]
226
+ if "/" in filename:
227
+ filename = filename.split("/")[-1]
228
+ __cache = f"{chat_id}:{msg_id}"
229
+ buttons = [
230
+ [
231
+ Button.inline("anonfiles", data=f"flanonfiles//{__cache}"),
232
+ Button.inline("transfer", data=f"fltransfer//{__cache}"),
233
+ ],
234
+ [
235
+ Button.inline("bayfiles", data=f"flbayfiles//{__cache}"),
236
+ Button.inline("x0.at", data=f"flx0.at//{__cache}"),
237
+ ],
238
+ [
239
+ Button.inline("file.io", data=f"flfile.io//{__cache}"),
240
+ Button.inline("siasky", data=f"flsiasky//{__cache}"),
241
+ ],
242
+ ]
243
+ try:
244
+ lnk = [
245
+ await e.builder.article(
246
+ title=f"Upload {filename}",
247
+ text=f"**File:**\n{filename}",
248
+ buttons=buttons,
249
+ )
250
+ ]
251
+ except BaseException as er:
252
+ LOGS.exception(er)
253
+ lnk = [
254
+ await e.builder.article(
255
+ title="fl2lnk",
256
+ text="File not found",
257
+ )
258
+ ]
259
+ await e.answer(lnk, switch_pm="File to Link.", switch_pm_param="start")
260
+
261
+
262
+ @callback(
263
+ re_compile(
264
+ "fl(.*)",
265
+ ),
266
+ owner=True,
267
+ )
268
+ async def _(e):
269
+ t = (e.data).decode("UTF-8")
270
+ data = t[2:]
271
+ host = data.split("//")[0]
272
+ chat_id, msg_id = data.split("//")[1].split(":")
273
+ filename = _webupload_cache[int(chat_id)][int(msg_id)]
274
+ if "/" in filename:
275
+ filename = filename.split("/")[-1]
276
+ await e.edit(f"Uploading `{filename}` on {host}")
277
+ link = (await webuploader(chat_id, msg_id, host)).strip().replace("\n", "")
278
+ await e.edit(f"Uploaded `{filename}` on {host}.", buttons=Button.url("View", link))
279
+
280
+
281
+ @in_pattern("repo", owner=True)
282
+ async def repo(e):
283
+ res = [
284
+ await e.builder.article(
285
+ title="Ultroid Userbot",
286
+ description="Userbot | Telethon",
287
+ thumb=wb(ultpic, 0, "image/jpeg", []),
288
+ text="• **ULTROID USERBOT** •",
289
+ buttons=SUP_BUTTONS,
290
+ ),
291
+ ]
292
+ await e.answer(res, switch_pm="Ultroid Repo.", switch_pm_param="start")
293
+
294
+
295
+ @in_pattern("go", owner=True)
296
+ async def gsearch(q_event):
297
+ try:
298
+ match = q_event.text.split(maxsplit=1)[1]
299
+ except IndexError:
300
+ return await q_event.answer(
301
+ [], switch_pm="Google Search. Enter a query!", switch_pm_param="start"
302
+ )
303
+ searcher = []
304
+ gresults = await google_search(match)
305
+ for i in gresults:
306
+ try:
307
+ title = i["title"]
308
+ link = i["link"]
309
+ desc = i["description"]
310
+ searcher.append(
311
+ await q_event.builder.article(
312
+ title=title,
313
+ description=desc,
314
+ thumb=wb(gugirl, 0, "image/jpeg", []),
315
+ text=f"**Gᴏᴏɢʟᴇ Sᴇᴀʀᴄʜ**\n\n**••Tɪᴛʟᴇ••**\n`{title}`\n\n**••Dᴇsᴄʀɪᴘᴛɪᴏɴ••**\n`{desc}`",
316
+ link_preview=False,
317
+ buttons=[
318
+ [Button.url("Lɪɴᴋ", url=f"{link}")],
319
+ [
320
+ Button.switch_inline(
321
+ "Sᴇᴀʀᴄʜ Aɢᴀɪɴ",
322
+ query="go ",
323
+ same_peer=True,
324
+ ),
325
+ Button.switch_inline(
326
+ "Sʜᴀʀᴇ",
327
+ query=f"go {match}",
328
+ same_peer=False,
329
+ ),
330
+ ],
331
+ ],
332
+ ),
333
+ )
334
+ except IndexError:
335
+ break
336
+ await q_event.answer(searcher, switch_pm="Google Search.", switch_pm_param="start")
337
+
338
+
339
+ @in_pattern("mods", owner=True)
340
+ async def _(e):
341
+ try:
342
+ quer = e.text.split(" ", maxsplit=1)[1]
343
+ except IndexError:
344
+ return await e.answer(
345
+ [], switch_pm="Mod Apps Search. Enter app name!", switch_pm_param="start"
346
+ )
347
+ start = 0 * 3 + 1
348
+ da = base64.b64decode(choice(apis)).decode("ascii")
349
+ url = f"https://www.googleapis.com/customsearch/v1?key={da}&cx=25b3b50edb928435b&q={quer}&start={start}"
350
+ data = await async_searcher(url, re_json=True)
351
+ search_items = data.get("items", [])
352
+ modss = []
353
+ for a in search_items:
354
+ title = a.get("title")
355
+ desc = a.get("snippet")
356
+ link = a.get("link")
357
+ text = f"**••Tɪᴛʟᴇ••** `{title}`\n\n"
358
+ text += f"**Dᴇsᴄʀɪᴘᴛɪᴏɴ** `{desc}`"
359
+ modss.append(
360
+ await e.builder.article(
361
+ title=title,
362
+ description=desc,
363
+ text=text,
364
+ link_preview=True,
365
+ buttons=[
366
+ [Button.url("Dᴏᴡɴʟᴏᴀᴅ", url=f"{link}")],
367
+ [
368
+ Button.switch_inline(
369
+ "Mᴏʀᴇ Mᴏᴅs",
370
+ query="mods ",
371
+ same_peer=True,
372
+ ),
373
+ Button.switch_inline(
374
+ "Sʜᴀʀᴇ",
375
+ query=f"mods {quer}",
376
+ same_peer=False,
377
+ ),
378
+ ],
379
+ ],
380
+ ),
381
+ )
382
+ await e.answer(modss, switch_pm="Search Mod Applications.", switch_pm_param="start")
383
+
384
+
385
+ APP_CACHE = {}
386
+ RECENTS = {}
387
+ PLAY_API = "https://googleplay.onrender.com/api/apps?q="
388
+
389
+
390
+ @in_pattern("app", owner=True)
391
+ async def _(e):
392
+ try:
393
+ f = e.text.split(maxsplit=1)[1].lower()
394
+ except IndexError:
395
+ get_string("instu_1")
396
+ res = []
397
+ if APP_CACHE and RECENTS.get(e.sender_id):
398
+ res.extend(
399
+ APP_CACHE[a][0] for a in RECENTS[e.sender_id] if APP_CACHE.get(a)
400
+ )
401
+ return await e.answer(
402
+ res, switch_pm=get_string("instu_2"), switch_pm_param="start"
403
+ )
404
+ try:
405
+ return await e.answer(
406
+ APP_CACHE[f], switch_pm="Application Searcher.", switch_pm_param="start"
407
+ )
408
+ except KeyError:
409
+ pass
410
+ foles = []
411
+ url = PLAY_API + f.replace(" ", "+")
412
+ aap = await async_searcher(url, re_json=True)
413
+ for z in aap["results"][:50]:
414
+ url = "https://play.google.com/store/apps/details?id=" + z["appId"]
415
+ name = z["title"]
416
+ desc = unescape(z["summary"])[:300].replace("<br>", "\n") + "..."
417
+ dev = z["developer"]["devId"]
418
+ text = f"**••Aᴘᴘ Nᴀᴍᴇ••** [{name}]({url})\n"
419
+ text += f"**••Dᴇᴠᴇʟᴏᴘᴇʀ••** `{dev}`\n"
420
+ text += f"**••Dᴇsᴄʀɪᴘᴛɪᴏɴ••**\n`{desc}`"
421
+ foles.append(
422
+ await e.builder.article(
423
+ title=name,
424
+ description=dev,
425
+ thumb=wb(z["icon"], 0, "image/jpeg", []),
426
+ text=text,
427
+ link_preview=True,
428
+ buttons=[
429
+ [Button.url("Lɪɴᴋ", url=url)],
430
+ [
431
+ Button.switch_inline(
432
+ "Mᴏʀᴇ Aᴘᴘs",
433
+ query="app ",
434
+ same_peer=True,
435
+ ),
436
+ Button.switch_inline(
437
+ "Sʜᴀʀᴇ",
438
+ query=f"app {f}",
439
+ same_peer=False,
440
+ ),
441
+ ],
442
+ ],
443
+ ),
444
+ )
445
+ APP_CACHE.update({f: foles})
446
+ if RECENTS.get(e.sender_id):
447
+ RECENTS[e.sender_id].append(f)
448
+ else:
449
+ RECENTS.update({e.sender_id: [f]})
450
+ await e.answer(foles, switch_pm="Application Searcher.", switch_pm_param="start")
451
+
452
+
453
+ PISTON_URI = "https://emkc.org/api/v2/piston/"
454
+ PISTON_LANGS = {}
455
+
456
+
457
+ @in_pattern("run", owner=True)
458
+ async def piston_run(event):
459
+ try:
460
+ lang = event.text.split()[1]
461
+ code = event.text.split(maxsplit=2)[2]
462
+ except IndexError:
463
+ result = await event.builder.article(
464
+ title="Bad Query",
465
+ description="Usage: [Language] [code]",
466
+ thumb=wb(
467
+ "https://graph.org/file/e33c57fc5f1044547e4d8.jpg", 0, "image/jpeg", []
468
+ ),
469
+ text=f'**Inline Usage**\n\n`@{asst.me.username} run python print("hello world")`\n\n[Language List](https://graph.org/Ultroid-09-01-6)',
470
+ )
471
+ return await event.answer([result])
472
+ if not PISTON_LANGS:
473
+ se = await async_searcher(f"{PISTON_URI}runtimes", re_json=True)
474
+ PISTON_LANGS.update({lang.pop("language"): lang for lang in se})
475
+ if lang in PISTON_LANGS.keys():
476
+ version = PISTON_LANGS[lang]["version"]
477
+ else:
478
+ result = await event.builder.article(
479
+ title="Unsupported Language",
480
+ description="Usage: [Language] [code]",
481
+ thumb=wb(
482
+ "https://graph.org/file/e33c57fc5f1044547e4d8.jpg", 0, "image/jpeg", []
483
+ ),
484
+ text=f'**Inline Usage**\n\n`@{asst.me.username} run python print("hello world")`\n\n[Language List](https://graph.org/Ultroid-09-01-6)',
485
+ )
486
+ return await event.answer([result])
487
+ output = await async_searcher(
488
+ f"{PISTON_URI}execute",
489
+ post=True,
490
+ json={
491
+ "language": lang,
492
+ "version": version,
493
+ "files": [{"content": code}],
494
+ },
495
+ re_json=True,
496
+ )
497
+
498
+ output = output["run"]["output"] or get_string("instu_4")
499
+ if len(output) > 3000:
500
+ output = f"{output[:3000]}..."
501
+ result = await event.builder.article(
502
+ title="Result",
503
+ description=output,
504
+ text=f"• **Language:**\n`{lang}`\n\n• **Code:**\n`{code}`\n\n• **Result:**\n`{output}`",
505
+ thumb=wb(
506
+ "https://graph.org/file/871ee4a481f58117dccc4.jpg", 0, "image/jpeg", []
507
+ ),
508
+ buttons=Button.switch_inline("Fork", query=event.text, same_peer=True),
509
+ )
510
+ await event.answer([result], switch_pm="• Piston •", switch_pm_param="start")
511
+
512
+
513
+ FDROID_ = {}
514
+
515
+
516
+ @in_pattern("fdroid", owner=True)
517
+ async def do_magic(event):
518
+ try:
519
+ match = event.text.split(" ", maxsplit=1)[1].lower()
520
+ except IndexError:
521
+ return await event.answer(
522
+ [], switch_pm="Enter Query to Search", switch_pm_param="start"
523
+ )
524
+ if FDROID_.get(match):
525
+ return await event.answer(
526
+ FDROID_[match], switch_pm=f"• Results for {match}", switch_pm_param="start"
527
+ )
528
+ link = "https://search.f-droid.org/?q=" + match.replace(" ", "+")
529
+ content = await async_searcher(link, re_content=True)
530
+ BSC = bs(content, "html.parser", from_encoding="utf-8")
531
+ ress = []
532
+ for dat in BSC.find_all("a", "package-header")[:10]:
533
+ image = dat.find("img", "package-icon")["src"]
534
+ if image.endswith("/"):
535
+ image = "https://graph.org/file/a8dd4a92c5a53a89d0eff.jpg"
536
+ title = dat.find("h4", "package-name").text.strip()
537
+ desc = dat.find("span", "package-summary").text.strip()
538
+ text = f"• **Name :** `{title}`\n\n"
539
+ text += f"• **Description :** `{desc}`\n"
540
+ text += f"• **License :** `{dat.find('span', 'package-license').text.strip()}`"
541
+ imga = wb(image, 0, "image/jpeg", [])
542
+ ress.append(
543
+ await event.builder.article(
544
+ title=title,
545
+ type="photo",
546
+ description=desc,
547
+ text=text,
548
+ content=imga,
549
+ thumb=imga,
550
+ include_media=True,
551
+ buttons=[
552
+ Button.inline(
553
+ "• Download •", "fd" + dat["href"].split("packages/")[-1]
554
+ ),
555
+ Button.switch_inline("• Share •", query=event.text),
556
+ ],
557
+ )
558
+ )
559
+ msg = f"Showing {len(ress)} Results!" if ress else "No Results Found"
560
+ FDROID_.update({match: ress})
561
+ await event.answer(ress, switch_pm=msg, switch_pm_param="start")
562
+
563
+
564
+ # Thanks to OpenSource
565
+ _bearer_collected = [
566
+ "AAAAAAAAAAAAAAAAAAAAALIKKgEAAAAA1DRuS%2BI7ZRKiagD6KHYmreaXomo%3DP5Vaje4UTtEkODg0fX7nCh5laSrchhtLxeyEqxXpv0w9ZKspLD",
567
+ "AAAAAAAAAAAAAAAAAAAAAL5iUAEAAAAAmo6FYRjqdKlI3cNziIm%2BHUQB9Xs%3DS31pj0mxARMTOk2g9dvQ1yP9wknvY4FPBPUlE00smJcncw4dPR",
568
+ "AAAAAAAAAAAAAAAAAAAAAN6sVgEAAAAAMMjMMWrwgGyv7YQOWN%2FSAsO5SGM%3Dg8MG9Jq93Rlllaok6eht7HvRCruN4Vpzp4NaVsZaaHHWSTzKI8",
569
+ ]
570
+
571
+
572
+ @in_pattern("twitter", owner=True)
573
+ async def twitter_search(event):
574
+ try:
575
+ match = event.text.split(maxsplit=1)[1].lower()
576
+ except IndexError:
577
+ return await event.answer(
578
+ [], switch_pm="Enter Query to Search", switch_pm_param="start"
579
+ )
580
+ try:
581
+ return await event.answer(
582
+ _ult_cache["twitter"][match],
583
+ switch_pm="• Twitter Search •",
584
+ switch_pm_param="start",
585
+ )
586
+ except KeyError:
587
+ pass
588
+ headers = {"Authorization": f"bearer {choice(_bearer_collected)}"}
589
+ res = await async_searcher(
590
+ f"https://api.twitter.com/1.1/users/search.json?q={match}",
591
+ headers=headers,
592
+ re_json=True,
593
+ )
594
+ reso = []
595
+ for user in res:
596
+ thumb = wb(user["profile_image_url_https"], 0, "image/jpeg", [])
597
+ if user.get("profile_banner_url"):
598
+ url = user["profile_banner_url"]
599
+ text = f"[\xad]({url})• **Name :** `{user['name']}`\n"
600
+ else:
601
+ text = f"• **Name :** `{user['name']}`\n"
602
+ text += f"• **Description :** `{user['description']}`\n"
603
+ text += f"• **Username :** `@{user['screen_name']}`\n"
604
+ text += f"• **Followers :** `{user['followers_count']}` • **Following :** `{user['friends_count']}`\n"
605
+ pro_ = "https://twitter.com/" + user["screen_name"]
606
+ text += f"• **Link :** [Click Here]({pro_})\n_"
607
+ reso.append(
608
+ await event.builder.article(
609
+ title=user["name"],
610
+ description=user["description"],
611
+ url=pro_,
612
+ text=text,
613
+ thumb=thumb,
614
+ )
615
+ )
616
+ swi_ = f"🐦 Showing {len(reso)} Results!" if reso else "No User Found :("
617
+ await event.answer(reso, switch_pm=swi_, switch_pm_param="start")
618
+ if _ult_cache.get("twitter"):
619
+ _ult_cache["twitter"].update({match: reso})
620
+ else:
621
+ _ult_cache.update({"twitter": {match: reso}})
622
+
623
+
624
+ _savn_cache = {}
625
+
626
+
627
+ @in_pattern("saavn", owner=True)
628
+ async def savn_s(event):
629
+ try:
630
+ query = event.text.split(maxsplit=1)[1].lower()
631
+ except IndexError:
632
+ return await event.answer(
633
+ [], switch_pm="Enter Query to search 🔍", switch_pm_param="start"
634
+ )
635
+ if query in _savn_cache:
636
+ return await event.answer(
637
+ _savn_cache[query],
638
+ switch_pm=f"Showing Results for {query}",
639
+ switch_pm_param="start",
640
+ )
641
+ results = await saavn_search(query)
642
+ swi = "🎵 Saavn Search" if results else "No Results Found!"
643
+ res = []
644
+ for song in results:
645
+ thumb = wb(song["image"], 0, "image/jpeg", [])
646
+ text = f"• **Title :** {song['title']}"
647
+ text += f"\n• **Year :** {song['year']}"
648
+ text += f"\n• **Lang :** {song['language']}"
649
+ text += f"\n• **Artist :** {song['artists']}"
650
+ text += f"\n• **Release Date :** {song['release_date']}"
651
+ res.append(
652
+ await event.builder.article(
653
+ title=song["title"],
654
+ description=song["artists"],
655
+ type="audio",
656
+ text=text,
657
+ include_media=True,
658
+ buttons=Button.switch_inline(
659
+ "Search Again 🔍", query="saavn", same_peer=True
660
+ ),
661
+ thumb=thumb,
662
+ content=wb(
663
+ song["url"],
664
+ 0,
665
+ "audio/mp4",
666
+ [
667
+ Audio(
668
+ title=song["title"],
669
+ duration=int(song["duration"]),
670
+ performer=song["artists"],
671
+ )
672
+ ],
673
+ ),
674
+ )
675
+ )
676
+ await event.answer(res, switch_pm=swi, switch_pm_param="start")
677
+ _savn_cache.update({query: res})
678
+
679
+
680
+ @in_pattern("tl", owner=True)
681
+ async def inline_tl(ult):
682
+ try:
683
+ match = ult.text.split(maxsplit=1)[1]
684
+ except IndexError:
685
+ text = f"**Telegram TlObjects Searcher.**\n__(Don't use if you don't know what it is!)__\n\n• Example Usage\n`@{asst.me.username} tl GetFullUserRequest`"
686
+ return await ult.answer(
687
+ [
688
+ await ult.builder.article(
689
+ title="How to Use?",
690
+ description="Tl Searcher by Ultroid",
691
+ url="https://t.me/TeamUltroid",
692
+ text=text,
693
+ )
694
+ ],
695
+ switch_pm="Tl Search 🔍",
696
+ switch_pm_param="start",
697
+ )
698
+ res = []
699
+ for key in tlobjects.values():
700
+ if match.lower() in key.__name__.lower():
701
+ tyyp = "Function" if "tl.functions." in str(key) else "Type"
702
+ text = f"**Name:** `{key.__name__}`\n"
703
+ text += f"**Category:** `{tyyp}`\n"
704
+ text += f"\n`from {key.__module__} import {key.__name__}`\n\n"
705
+ if args := str(inspect.signature(key))[1:][:-1]:
706
+ text += "**Parameter:**\n"
707
+ for para in args.split(","):
708
+ text += " " * 4 + "`" + para + "`\n"
709
+ text += f"\n**Layer:** `{LAYER}`"
710
+ res.append(
711
+ await ult.builder.article(
712
+ title=key.__name__,
713
+ description=tyyp,
714
+ url="https://t.me/TeamUltroid",
715
+ text=text[:4000],
716
+ )
717
+ )
718
+ mo = f"Showing {len(res)} results!" if res else f"No Results for {match}!"
719
+ await ult.answer(res[:50], switch_pm=mo, switch_pm_param="start")
720
+
721
+
722
+ InlinePlugin.update(
723
+ {
724
+ "Pʟᴀʏ Sᴛᴏʀᴇ Aᴘᴘs": "app telegram",
725
+ "Mᴏᴅᴅᴇᴅ Aᴘᴘs": "mods minecraft",
726
+ "Sᴇᴀʀᴄʜ Oɴ Gᴏᴏɢʟᴇ": "go TeamUltroid",
727
+ "WʜɪSᴘᴇʀ": "wspr @username Hello🎉",
728
+ "YᴏᴜTᴜʙᴇ Dᴏᴡɴʟᴏᴀᴅᴇʀ": "yt Ed Sheeran Perfect",
729
+ "Piston Eval": "run javascript console.log('Hello Ultroid')",
730
+ "OʀᴀɴɢᴇFᴏx🦊": "ofox beryllium",
731
+ "Tᴡɪᴛᴛᴇʀ Usᴇʀ": "twitter theultroid",
732
+ "Fᴅʀᴏɪᴅ Sᴇᴀʀᴄʜ": "fdroid telegram",
733
+ "Sᴀᴀᴠɴ sᴇᴀʀᴄʜ": "saavn",
734
+ "Tʟ Sᴇᴀʀᴄʜ": "tl",
735
+ }
736
+ )
assistant/localization.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2021-2023 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ import re
9
+
10
+ from . import (
11
+ Button,
12
+ ULTConfig,
13
+ callback,
14
+ get_back_button,
15
+ get_languages,
16
+ get_string,
17
+ udB,
18
+ )
19
+
20
+
21
+ @callback("lang", owner=True)
22
+ async def setlang(event):
23
+ languages = get_languages()
24
+ tultd = [
25
+ Button.inline(
26
+ f"{languages[ult]['natively']} [{ult.lower()}]",
27
+ data=f"set_{ult}",
28
+ )
29
+ for ult in languages
30
+ ]
31
+ buttons = list(zip(tultd[::2], tultd[1::2]))
32
+ if len(tultd) % 2 == 1:
33
+ buttons.append((tultd[-1],))
34
+ buttons.append([Button.inline("« Back", data="mainmenu")])
35
+ await event.edit(get_string("ast_4"), buttons=buttons)
36
+
37
+
38
+ @callback(re.compile(b"set_(.*)"), owner=True)
39
+ async def settt(event):
40
+ lang = event.data_match.group(1).decode("UTF-8")
41
+ languages = get_languages()
42
+ ULTConfig.lang = lang
43
+ udB.del_key("language") if lang == "en" else udB.set_key("language", lang)
44
+ await event.edit(
45
+ f"Your language has been set to {languages[lang]['natively']} [{lang}].",
46
+ buttons=get_back_button("lang"),
47
+ )
assistant/pmbot.py ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2021-2023 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ # https://github.com/xditya/TeleBot/blob/master/telebot/plugins/mybot/pmbot/incoming.py
9
+
10
+ # --------------------------------------- Imports -------------------------------------------- #
11
+
12
+ import os
13
+
14
+ from telethon.errors.rpcerrorlist import UserNotParticipantError
15
+ from telethon.tl.custom import Button
16
+ from telethon.tl.functions.channels import GetFullChannelRequest
17
+ from telethon.tl.functions.messages import GetFullChatRequest
18
+ from telethon.tl.types import Channel, Chat
19
+ from telethon.utils import get_display_name
20
+
21
+ from xteam.dB.base import KeyManager
22
+ from xteam.dB.botchat_db import *
23
+ from xteam.fns.helper import inline_mention
24
+
25
+ from . import *
26
+
27
+ botb = KeyManager("BOTBLS", cast=list)
28
+ FSUB = udB.get_key("PMBOT_FSUB")
29
+ CACHE = {}
30
+ # --------------------------------------- Incoming -------------------------------------------- #
31
+
32
+
33
+ @asst_cmd(
34
+ load=AST_PLUGINS,
35
+ incoming=True,
36
+ func=lambda e: e.is_private and not botb.contains(e.sender_id),
37
+ )
38
+ async def on_new_mssg(event):
39
+ who = event.sender_id
40
+ # doesn't reply to that user anymore
41
+ if event.text.startswith("/") or who == OWNER_ID:
42
+ return
43
+ if FSUB:
44
+ MSG = ""
45
+ BTTS = []
46
+ for chat in FSUB:
47
+ try:
48
+ await event.client.get_permissions(chat, event.sender_id)
49
+ except UserNotParticipantError:
50
+ if not MSG:
51
+ MSG += get_string("pmbot_1")
52
+ try:
53
+ uri = ""
54
+ TAHC_ = await event.client.get_entity(chat)
55
+ if hasattr(TAHC_, "username") and TAHC_.username:
56
+ uri = f"t.me/{TAHC_.username}"
57
+ elif CACHE.get(chat):
58
+ uri = CACHE[chat]
59
+ else:
60
+ if isinstance(TAHC_, Channel):
61
+ FUGB = await event.client(GetFullChannelRequest(chat))
62
+ elif isinstance(TAHC_, Chat):
63
+ FUGB = await event.client(GetFullChatRequest(chat))
64
+ else:
65
+ return
66
+ if FUGB.full_chat.exported_invite:
67
+ CACHE[chat] = FUGB.full_chat.exported_invite.link
68
+ uri = CACHE[chat]
69
+ BTTS.append(Button.url(get_display_name(TAHC_), uri))
70
+ except Exception as er:
71
+ LOGS.exception(f"Error On PmBot Force Sub!\n - {chat} \n{er}")
72
+ if MSG and BTTS:
73
+ return await event.reply(MSG, buttons=BTTS)
74
+ xx = await event.forward_to(OWNER_ID)
75
+ if event.fwd_from:
76
+ await xx.reply(f"From {inline_mention(event.sender)} [`{event.sender_id}`]")
77
+ add_stuff(xx.id, who)
78
+
79
+
80
+ # --------------------------------------- Outgoing -------------------------------------------- #
81
+
82
+
83
+ @asst_cmd(
84
+ load=AST_PLUGINS,
85
+ from_users=[OWNER_ID],
86
+ incoming=True,
87
+ func=lambda e: e.is_private and e.is_reply,
88
+ )
89
+ async def on_out_mssg(event):
90
+ x = event.reply_to_msg_id
91
+ to_user = get_who(x)
92
+ if event.text.startswith("/who"):
93
+ try:
94
+ k = await asst.get_entity(to_user)
95
+ photu = await event.client.download_profile_photo(k.id)
96
+ await event.reply(
97
+ f"• **Name :** {get_display_name(k)}\n• **ID :** `{k.id}`\n• **Link :** {inline_mention(k)}",
98
+ file=photu,
99
+ )
100
+ if photu:
101
+ os.remove(photu)
102
+ return
103
+ except BaseException as er:
104
+ return await event.reply(f"**ERROR : **{str(er)}")
105
+ elif event.text.startswith("/"):
106
+ return
107
+ if to_user:
108
+ await asst.send_message(to_user, event.message)
109
+
110
+
111
+ # --------------------------------------- Ban/Unban -------------------------------------------- #
112
+
113
+
114
+ @asst_cmd(
115
+ pattern="ban",
116
+ load=AST_PLUGINS,
117
+ from_users=[OWNER_ID],
118
+ func=lambda x: x.is_private,
119
+ )
120
+ async def banhammer(event):
121
+ if not event.is_reply:
122
+ return await event.reply(get_string("pmbot_2"))
123
+ target = get_who(event.reply_to_msg_id)
124
+ if botb.contains(target):
125
+ return await event.reply(get_string("pmbot_3"))
126
+
127
+ botb.add(target)
128
+ await event.reply(f"#BAN\nUser : {target}")
129
+ await asst.send_message(target, get_string("pmbot_4"))
130
+
131
+
132
+ @asst_cmd(
133
+ pattern="unban",
134
+ load=AST_PLUGINS,
135
+ from_users=[OWNER_ID],
136
+ func=lambda x: x.is_private,
137
+ )
138
+ async def unbanhammer(event):
139
+ if not event.is_reply:
140
+ return await event.reply(get_string("pmbot_5"))
141
+ target = get_who(event.reply_to_msg_id)
142
+ if not botb.contains(target):
143
+ return await event.reply(get_string("pmbot_6"))
144
+
145
+ botb.remove(target)
146
+ await event.reply(f"#UNBAN\nUser : {target}")
147
+ await asst.send_message(target, get_string("pmbot_7"))
148
+
149
+
150
+ # --------------------------------------- END -------------------------------------------- #
assistant/start.py ADDED
@@ -0,0 +1,320 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2021-2025 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ from datetime import datetime
9
+
10
+ from pytz import timezone as tz
11
+ from telethon import Button, events
12
+ from telethon.errors.rpcerrorlist import MessageDeleteForbiddenError
13
+ from telethon.utils import get_display_name
14
+
15
+ from xteam._misc import SUDO_M, owner_and_sudos
16
+ from xteam.dB.base import KeyManager
17
+ from xteam.fns.helper import inline_mention
18
+ from strings import get_string
19
+
20
+ from . import *
21
+
22
+ Owner_info_msg = udB.get_key("BOT_INFO_START")
23
+ custom_info = True
24
+ if Owner_info_msg is None:
25
+ custom_info = False
26
+ Owner_info_msg = f"""
27
+ **Owner** - {OWNER_NAME}
28
+ **OwnerID** - `{OWNER_ID}`
29
+
30
+ **Message Forwards** - {udB.get_key("PMBOT")}
31
+
32
+ **Xteam [v{ultroid_version}](https://github.com/TeamUltroid/Ultroid), powered by @TeamUltroid**
33
+ """
34
+
35
+
36
+ _settings = [
37
+ [
38
+ Button.inline("API Kᴇʏs", data="cbs_apiset"),
39
+ Button.inline("Pᴍ Bᴏᴛ", data="cbs_chatbot"),
40
+ ],
41
+ [
42
+ Button.inline("Aʟɪᴠᴇ", data="cbs_alvcstm"),
43
+ Button.inline("PᴍPᴇʀᴍɪᴛ", data="cbs_ppmset"),
44
+ ],
45
+ [
46
+ Button.inline("Fᴇᴀᴛᴜʀᴇs", data="cbs_otvars"),
47
+ Button.inline("VC Sᴏɴɢ Bᴏᴛ", data="cbs_vcb"),
48
+ ],
49
+ [Button.inline("« Bᴀᴄᴋ", data="mainmenu")],
50
+ ]
51
+
52
+ _start = [
53
+ [
54
+ Button.url("🥰 OWNER 🥰", url="https://t.me/xteam_clone"),
55
+ #Button.inline("Restart ♻️️", data="restart"),
56
+ ],
57
+ [
58
+ Button.inline("⚙️ Settings ⚙️", data="setter"),
59
+ Button.inline("♻️️ Restart ♻️️", data="restart"),
60
+ ],
61
+ [
62
+ Button.inline("✨ Stats ✨", data="stat"),
63
+ Button.inline("📻 Broadcast 📻", data="bcast"),
64
+ ],
65
+ [
66
+ Button.inline("🌐 Bahasa 🌐", data="lang"),
67
+ ],
68
+ ]
69
+
70
+ @callback("restart", owner=True)
71
+ async def restart_callback(e):
72
+ global restart_counter
73
+ ok = await e.reply("`Processing...`")
74
+ who = "bot" if e.client._bot else "user"
75
+ udB.set_key("_RESTART", f"{who}_{e.chat_id}_{ok.id}")
76
+ if heroku_api and restart_counter < 10:
77
+ restart_counter += 1
78
+ # return await restart_callback(e)
79
+ await bash("git pull && pip3 install -r requirements.txt")
80
+ os.execl(sys.executable, sys.executable, "-m", "xteam")
81
+
82
+
83
+
84
+ @callback("ownerinfo")
85
+ async def own(event):
86
+ msg = Owner_info_msg.format(
87
+ mention=event.sender.mention, me=inline_mention(ultroid_bot.me)
88
+ )
89
+ if custom_info:
90
+ msg += "\n\n• Powered by **@xteam-cloner**"
91
+ await event.edit(
92
+ msg,
93
+ buttons=[Button.inline("Close", data="closeit")],
94
+ link_preview=False,
95
+ )
96
+
97
+
98
+ @callback("closeit")
99
+ async def closet(lol):
100
+ try:
101
+ await lol.delete()
102
+ except MessageDeleteForbiddenError:
103
+ await lol.answer("MESSAGE_TOO_OLD", alert=True)
104
+
105
+
106
+ @asst_cmd(pattern="start( (.*)|$)", forwards=False, func=lambda x: not x.is_group)
107
+ async def ultroid(event):
108
+ args = event.pattern_match.group(1).strip()
109
+ keym = KeyManager("BOT_USERS", cast=list)
110
+ if not keym.contains(event.sender_id) and event.sender_id not in owner_and_sudos():
111
+ keym.add(event.sender_id)
112
+ kak_uiw = udB.get_key("OFF_START_LOG")
113
+ if not kak_uiw or kak_uiw != True:
114
+ msg = f"{inline_mention(event.sender)} `[{event.sender_id}]` started your [Assistant bot](@{asst.me.username})."
115
+ buttons = [[Button.inline("Info", "itkkstyo")]]
116
+ if event.sender.username:
117
+ buttons[0].append(
118
+ Button.mention(
119
+ "User", await event.client.get_input_entity(event.sender_id)
120
+ )
121
+ )
122
+ await event.client.send_message(
123
+ udB.get_key("LOG_CHANNEL"), msg, buttons=buttons
124
+ )
125
+ if event.sender_id not in SUDO_M.fullsudos:
126
+ ok = ""
127
+ me = inline_mention(ultroid_bot.me)
128
+ mention = inline_mention(event.sender)
129
+ if args and args != "set":
130
+ await get_stored_file(event, args)
131
+ if not udB.get_key("STARTMSG"):
132
+ if udB.get_key("PMBOT"):
133
+ ok = "You can contact my master using this bot!!\n\nSend your Message, I will Deliver it To Master."
134
+ await event.reply(
135
+ f"Hey there {mention}, this is Assistant of {me}!\n\n{ok}",
136
+ file=udB.get_key("STARTMEDIA"),
137
+ buttons=[Button.inline("Info.", data="ownerinfo")]
138
+ if Owner_info_msg
139
+ else None,
140
+ )
141
+ else:
142
+ await event.reply(
143
+ udB.get_key("STARTMSG").format(me=me, mention=mention),
144
+ file=udB.get_key("STARTMEDIA"),
145
+ buttons=[Button.inline("Info.", data="ownerinfo")]
146
+ if Owner_info_msg
147
+ else None,
148
+ )
149
+ else:
150
+ name = get_display_name(event.sender)
151
+ if args == "set":
152
+ await event.reply(
153
+ "Choose from the below options -",
154
+ buttons=_settings,
155
+ )
156
+ elif args:
157
+ await get_stored_file(event, args)
158
+ else:
159
+ await event.respond(
160
+ f"<blockquote>Hey {name}. Please browse through the options</blockquote>",
161
+ buttons=_start,
162
+ parse_mode="html",
163
+ )
164
+ await event.react("🔥") # Add a thumbs-up emoji reaction
165
+
166
+
167
+ """@asst_cmd(pattern="start( (.*)|$)", forwards=False, func=lambda x: not x.is_group)
168
+ async def ultroid(event):
169
+ args = event.pattern_match.group(1).strip()
170
+ keym = KeyManager("BOT_USERS", cast=list)
171
+ if not keym.contains(event.sender_id) and event.sender_id not in owner_and_sudos():
172
+ keym.add(event.sender_id)
173
+ kak_uiw = udB.get_key("OFF_START_LOG")
174
+ if not kak_uiw or kak_uiw != True:
175
+ msg = f"{inline_mention(event.sender)} `[{event.sender_id}]` started your [Assistant bot](@{asst.me.username})."
176
+ buttons = [[Button.inline("Info", "itkkstyo")]]
177
+ if event.sender.username:
178
+ buttons[0].append(
179
+ Button.mention(
180
+ "User", await event.client.get_input_entity(event.sender_id)
181
+ )
182
+ )
183
+ await event.client.send_message(
184
+ udB.get_key("LOG_CHANNEL"), msg, buttons=buttons
185
+ )
186
+ if event.sender_id not in SUDO_M.fullsudos:
187
+ ok = ""
188
+ me = inline_mention(ultroid_bot.me)
189
+ mention = inline_mention(event.sender)
190
+ if args and args != "set":
191
+ await get_stored_file(event, args)
192
+ if not udB.get_key("STARTMSG"):
193
+ if udB.get_key("PMBOT"):
194
+ ok = "You can contact my master using this bot!!\n\nSend your Message, I will Deliver it To Master. ✉️"
195
+ await event.reply(
196
+ f"Hey there {mention}, this is Ultroid Assistant of {me}! 👋\n\n{ok}",
197
+ file=udB.get_key("STARTMEDIA"),
198
+ buttons=[Button.inline("Info.", data="ownerinfo")]
199
+ if Owner_info_msg
200
+ else None,
201
+ )
202
+ else:
203
+ await event.reply(
204
+ udB.get_key("STARTMSG").format(me=me, mention=mention),
205
+ file=udB.get_key("STARTMEDIA"),
206
+ buttons=[Button.inline("Info.", data="ownerinfo")]
207
+ if Owner_info_msg
208
+ else None,
209
+ )
210
+ else:
211
+ name = get_display_name(event.sender)
212
+ if args == "set":
213
+ await event.reply(
214
+ "Choose from the below options - ⚙️",
215
+ buttons=_settings,
216
+ )
217
+ elif args:
218
+ await get_stored_file(event, args)
219
+ else:
220
+ await event.reply(
221
+ get_string("ast_3").format(name),
222
+ buttons=_start,
223
+ )
224
+ await event.react("🔥")
225
+ """
226
+ @callback("itkkstyo", owner=True)
227
+ async def ekekdhdb(e):
228
+ text = f"When New Visitor will visit your Assistant Bot. You will get this log message!\n\nTo Disable : {HNDLR}setdb OFF_START_LOG True"
229
+ await e.answer(text, alert=True)
230
+
231
+
232
+ @callback("mainmenu", owner=True, func=lambda x: not x.is_group)
233
+ async def ultroid(event):
234
+ await event.edit(
235
+ get_string("ast_3").format(OWNER_NAME),
236
+ buttons=_start,
237
+ )
238
+
239
+
240
+ @callback("stat", owner=True)
241
+ async def botstat(event):
242
+ ok = len(udB.get_key("BOT_USERS") or [])
243
+ msg = """Xteam Assistant - Stats
244
+ Total Users - {}""".format(
245
+ ok,
246
+ )
247
+ await event.answer(msg, cache_time=0, alert=True)
248
+
249
+
250
+ @callback("bcast", owner=True)
251
+ async def bdcast(event):
252
+ keym = KeyManager("BOT_USERS", cast=list)
253
+ total = keym.count()
254
+ await event.edit(f"• Broadcast to {total} users.")
255
+ async with event.client.conversation(OWNER_ID) as conv:
256
+ await conv.send_message(
257
+ "Enter your broadcast message.\nUse /cancel to stop the broadcast.",
258
+ )
259
+ response = await conv.get_response()
260
+ if response.message == "/cancel":
261
+ return await conv.send_message("Cancelled!!")
262
+ success = 0
263
+ fail = 0
264
+ await conv.send_message(f"Starting a broadcast to {total} users...")
265
+ start = datetime.now()
266
+ for i in keym.get():
267
+ try:
268
+ await asst.send_message(int(i), response)
269
+ success += 1
270
+ except BaseException:
271
+ fail += 1
272
+ end = datetime.now()
273
+ time_taken = (end - start).seconds
274
+ await conv.send_message(
275
+ f"""
276
+ **Broadcast completed in {time_taken} seconds.**
277
+ Total Users in Bot - {total}
278
+ **Sent to** : `{success} users.`
279
+ **Failed for** : `{fail} user(s).`""",
280
+ )
281
+
282
+
283
+ @callback("setter", owner=True)
284
+ async def setting(event):
285
+ await event.edit(
286
+ "Choose from the below options -",
287
+ buttons=_settings,
288
+ )
289
+
290
+
291
+ @callback("tz", owner=True)
292
+ async def timezone_(event):
293
+ await event.delete()
294
+ pru = event.sender_id
295
+ var = "TIMEZONE"
296
+ name = "Timezone"
297
+ async with event.client.conversation(pru) as conv:
298
+ await conv.send_message(
299
+ "Send Your TimeZone From This List [Check From Here](http://www.timezoneconverter.com/cgi-bin/findzone.tzc)"
300
+ )
301
+ response = conv.wait_event(events.NewMessage(chats=pru))
302
+ response = await response
303
+ themssg = response.message.message
304
+ if themssg == "/cancel":
305
+ return await conv.send_message(
306
+ "Cancelled!!",
307
+ buttons=get_back_button("mainmenu"),
308
+ )
309
+ try:
310
+ tz(themssg)
311
+ await setit(event, var, themssg)
312
+ await conv.send_message(
313
+ f"{name} changed to {themssg}\n",
314
+ buttons=get_back_button("mainmenu"),
315
+ )
316
+ except BaseException:
317
+ await conv.send_message(
318
+ "Wrong TimeZone, Try again",
319
+ buttons=get_back_button("mainmenu"),
320
+ )
assistant/ytdl.py ADDED
@@ -0,0 +1,307 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2021-2025 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+
9
+ import os
10
+ import re
11
+
12
+ try:
13
+ from PIL import Image
14
+ except ImportError:
15
+ Image = None
16
+ from telethon import Button
17
+ from telethon.errors.rpcerrorlist import FilePartLengthInvalidError, MediaEmptyError
18
+ from telethon.tl.types import DocumentAttributeAudio, DocumentAttributeVideo
19
+ from telethon.tl.types import InputWebDocument as wb
20
+
21
+ from xteam.fns.helper import (
22
+ bash,
23
+ fast_download,
24
+ humanbytes,
25
+ numerize,
26
+ time_formatter,
27
+ )
28
+ from xteam.fns.ytdl import dler, get_buttons, get_formats
29
+
30
+ from . import LOGS, asst, callback, in_pattern, udB
31
+
32
+ try:
33
+ from youtubesearchpython import VideosSearch
34
+ except ImportError:
35
+ LOGS.info("'youtubesearchpython' not installed!")
36
+ VideosSearch = None
37
+
38
+
39
+ ytt = "https://graph.org/file/afd04510c13914a06dd03.jpg"
40
+ _yt_base_url = "https://www.youtube.com/watch?v="
41
+ BACK_BUTTON = {}
42
+
43
+
44
+ @in_pattern("yt", owner=True)
45
+ async def _(event):
46
+ try:
47
+ string = event.text.split(" ", maxsplit=1)[1]
48
+ except IndexError:
49
+ fuk = event.builder.article(
50
+ title="Search Something",
51
+ thumb=wb(ytt, 0, "image/jpeg", []),
52
+ text="**YᴏᴜTᴜʙᴇ Sᴇᴀʀᴄʜ**\n\nYou didn't search anything",
53
+ buttons=Button.switch_inline(
54
+ "Sᴇᴀʀᴄʜ Aɢᴀɪɴ",
55
+ query="yt ",
56
+ same_peer=True,
57
+ ),
58
+ )
59
+ await event.answer([fuk])
60
+ return
61
+ results = []
62
+ search = VideosSearch(string, limit=50)
63
+ nub = search.result()
64
+ nibba = nub["result"]
65
+ for v in nibba:
66
+ ids = v["id"]
67
+ link = _yt_base_url + ids
68
+ title = v["title"]
69
+ duration = v["duration"]
70
+ views = v["viewCount"]["short"]
71
+ publisher = v["channel"]["name"]
72
+ published_on = v["publishedTime"]
73
+ description = (
74
+ v["descriptionSnippet"][0]["text"]
75
+ if v.get("descriptionSnippet")
76
+ and len(v["descriptionSnippet"][0]["text"]) < 500
77
+ else "None"
78
+ )
79
+ thumb = f"https://i.ytimg.com/vi/{ids}/hqdefault.jpg"
80
+ text = f"**Title: [{title}]({link})**\n\n"
81
+ text += f"`Description: {description}\n\n"
82
+ text += f"「 Duration: {duration} 」\n"
83
+ text += f"「 Views: {views} 」\n"
84
+ text += f"「 Publisher: {publisher} 」\n"
85
+ text += f"「 Published on: {published_on} 」`"
86
+ desc = f"{title}\n{duration}"
87
+ file = wb(thumb, 0, "image/jpeg", [])
88
+ buttons = [
89
+ [
90
+ Button.inline("Audio", data=f"ytdl:audio:{ids}"),
91
+ Button.inline("Video", data=f"ytdl:video:{ids}"),
92
+ ],
93
+ [
94
+ Button.switch_inline(
95
+ "Sᴇᴀʀᴄʜ Aɢᴀɪɴ",
96
+ query="yt ",
97
+ same_peer=True,
98
+ ),
99
+ Button.switch_inline(
100
+ "Sʜᴀʀᴇ",
101
+ query=f"yt {string}",
102
+ same_peer=False,
103
+ ),
104
+ ],
105
+ ]
106
+ BACK_BUTTON.update({ids: {"text": text, "buttons": buttons}})
107
+ results.append(
108
+ await event.builder.article(
109
+ type="photo",
110
+ title=title,
111
+ description=desc,
112
+ thumb=file,
113
+ content=file,
114
+ text=text,
115
+ include_media=True,
116
+ buttons=buttons,
117
+ ),
118
+ )
119
+ await event.answer(results[:50])
120
+
121
+
122
+ @callback(
123
+ re.compile(
124
+ "ytdl:(.*)",
125
+ ),
126
+ owner=True,
127
+ )
128
+ async def _(e):
129
+ _e = e.pattern_match.group(1).strip().decode("UTF-8")
130
+ _lets_split = _e.split(":")
131
+ _ytdl_data = await dler(e, _yt_base_url + _lets_split[1])
132
+ _data = get_formats(_lets_split[0], _lets_split[1], _ytdl_data)
133
+ _buttons = get_buttons(_data)
134
+ _text = (
135
+ "`Select Your Format.`"
136
+ if _buttons
137
+ else "`Error downloading from YouTube.\nTry Restarting your bot.`"
138
+ )
139
+
140
+ await e.edit(_text, buttons=_buttons)
141
+
142
+
143
+ @callback(
144
+ re.compile(
145
+ "ytdownload:(.*)",
146
+ ),
147
+ owner=True,
148
+ )
149
+ async def _(event):
150
+ url = event.pattern_match.group(1).strip().decode("UTF-8")
151
+ lets_split = url.split(":")
152
+ vid_id = lets_split[2]
153
+ link = _yt_base_url + vid_id
154
+ format = lets_split[1]
155
+ try:
156
+ ext = lets_split[3]
157
+ except IndexError:
158
+ ext = "mp3"
159
+ if lets_split[0] == "audio":
160
+ opts = {
161
+ "format": "bestaudio",
162
+ "addmetadata": True,
163
+ "key": "FFmpegMetadata",
164
+ "prefer_ffmpeg": True,
165
+ "geo_bypass": True,
166
+ "outtmpl": f"%(id)s.{ext}",
167
+ "logtostderr": False,
168
+ "postprocessors": [
169
+ {
170
+ "key": "FFmpegExtractAudio",
171
+ "preferredcodec": ext,
172
+ "preferredquality": format,
173
+ },
174
+ {"key": "FFmpegMetadata"},
175
+ ],
176
+ }
177
+
178
+ ytdl_data = await dler(event, link, opts, True)
179
+ title = ytdl_data["title"]
180
+ if ytdl_data.get("artist"):
181
+ artist = ytdl_data["artist"]
182
+ elif ytdl_data.get("creator"):
183
+ artist = ytdl_data["creator"]
184
+ elif ytdl_data.get("channel"):
185
+ artist = ytdl_data["channel"]
186
+ views = numerize(ytdl_data.get("view_count")) or 0
187
+ thumb, _ = await fast_download(ytdl_data["thumbnail"], filename=f"{vid_id}.jpg")
188
+
189
+ likes = numerize(ytdl_data.get("like_count")) or 0
190
+ duration = ytdl_data.get("duration") or 0
191
+ description = (
192
+ ytdl_data["description"]
193
+ if len(ytdl_data["description"]) < 100
194
+ else ytdl_data["description"][:100]
195
+ )
196
+ description = description or "None"
197
+ filepath = f"{vid_id}.{ext}"
198
+ if not os.path.exists(filepath):
199
+ filepath = f"{filepath}.{ext}"
200
+ size = os.path.getsize(filepath)
201
+ file, _ = await event.client.fast_uploader(
202
+ filepath,
203
+ filename=f"{title}.{ext}",
204
+ show_progress=True,
205
+ event=event,
206
+ to_delete=True,
207
+ )
208
+
209
+ attributes = [
210
+ DocumentAttributeAudio(
211
+ duration=int(duration),
212
+ title=title,
213
+ performer=artist,
214
+ ),
215
+ ]
216
+ elif lets_split[0] == "video":
217
+ opts = {
218
+ "format": str(format),
219
+ "addmetadata": True,
220
+ "key": "FFmpegMetadata",
221
+ "prefer_ffmpeg": True,
222
+ "geo_bypass": True,
223
+ "outtmpl": f"%(id)s.{ext}",
224
+ "logtostderr": False,
225
+ "postprocessors": [{"key": "FFmpegMetadata"}],
226
+ }
227
+
228
+ ytdl_data = await dler(event, link, opts, True)
229
+ title = ytdl_data["title"]
230
+ if ytdl_data.get("artist"):
231
+ artist = ytdl_data["artist"]
232
+ elif ytdl_data.get("creator"):
233
+ artist = ytdl_data["creator"]
234
+ elif ytdl_data.get("channel"):
235
+ artist = ytdl_data["channel"]
236
+ views = numerize(ytdl_data.get("view_count")) or 0
237
+ thumb, _ = await fast_download(ytdl_data["thumbnail"], filename=f"{vid_id}.jpg")
238
+
239
+ try:
240
+ Image.open(thumb).save(thumb, "JPEG")
241
+ except Exception as er:
242
+ LOGS.exception(er)
243
+ thumb = None
244
+ description = (
245
+ ytdl_data["description"]
246
+ if len(ytdl_data["description"]) < 100
247
+ else ytdl_data["description"][:100]
248
+ )
249
+ likes = numerize(ytdl_data.get("like_count")) or 0
250
+ hi, wi = ytdl_data.get("height") or 720, ytdl_data.get("width") or 1280
251
+ duration = ytdl_data.get("duration") or 0
252
+ filepath = f"{vid_id}.mkv"
253
+ if not os.path.exists(filepath):
254
+ filepath = f"{filepath}.webm"
255
+ size = os.path.getsize(filepath)
256
+ file, _ = await event.client.fast_uploader(
257
+ filepath,
258
+ filename=f"{title}.mkv",
259
+ show_progress=True,
260
+ event=event,
261
+ to_delete=True,
262
+ )
263
+
264
+ attributes = [
265
+ DocumentAttributeVideo(
266
+ duration=int(duration),
267
+ w=wi,
268
+ h=hi,
269
+ supports_streaming=True,
270
+ ),
271
+ ]
272
+ description = description if description != "" else "None"
273
+ text = f"**Title: [{title}]({_yt_base_url}{vid_id})**\n\n"
274
+ text += f"`📝 Description: {description}\n\n"
275
+ text += f"「 Duration: {time_formatter(int(duration)*1000)} 」\n"
276
+ text += f"「 Artist: {artist} 」\n"
277
+ text += f"「 Views: {views} 」\n"
278
+ text += f"「 Likes: {likes} 」\n"
279
+ text += f"「 Size: {humanbytes(size)} 」`"
280
+ button = Button.switch_inline("Search More", query="yt ", same_peer=True)
281
+ try:
282
+ await event.edit(
283
+ text,
284
+ file=file,
285
+ buttons=button,
286
+ attributes=attributes,
287
+ thumb=thumb,
288
+ )
289
+ except (FilePartLengthInvalidError, MediaEmptyError):
290
+ file = await asst.send_message(
291
+ udB.get_key("LOG_CHANNEL"),
292
+ text,
293
+ file=file,
294
+ buttons=button,
295
+ attributes=attributes,
296
+ thumb=thumb,
297
+ )
298
+ await event.edit(text, file=file.media, buttons=button)
299
+ await bash(f"rm {vid_id}.jpg")
300
+
301
+
302
+ @callback(re.compile("ytdl_back:(.*)"), owner=True)
303
+ async def ytdl_back(event):
304
+ id_ = event.data_match.group(1).decode("utf-8")
305
+ if not BACK_BUTTON.get(id_):
306
+ return await event.answer("Query Expired! Search again 🔍")
307
+ await event.edit(**BACK_BUTTON[id_])