xteamki commited on
Commit
b45d238
·
verified ·
1 Parent(s): afafba7

Upload 100 files

Browse files
plugins/__init__.py CHANGED
@@ -47,6 +47,8 @@ asst: UltroidClient
47
  LOG_CHANNEL = udB.get_key("LOG_CHANNEL")
48
  StartTime = time.time()
49
 
 
 
50
  def inline_pic():
51
  INLINE_PIC = udB.get_key("INLINE_PIC")
52
  if INLINE_PIC is None:
 
47
  LOG_CHANNEL = udB.get_key("LOG_CHANNEL")
48
  StartTime = time.time()
49
 
50
+ xteam = ultroid_cmd
51
+
52
  def inline_pic():
53
  INLINE_PIC = udB.get_key("INLINE_PIC")
54
  if INLINE_PIC is None:
plugins/_bot.py CHANGED
@@ -104,22 +104,36 @@ heroku_api = Var.HEROKU_API
104
 
105
  @ultroid_cmd(
106
  pattern="restart$",
107
- fullsudo=False,
108
  )
109
- async def restart(e):
110
- await e.eor("`Processing...`")
 
 
 
 
111
  await bash("git pull && pip3 install -r requirements.txt")
112
- os.execl(sys.executable, sys.executable, "-m", "xteam")
113
-
 
 
 
114
  @ultroid_cmd(
115
- pattern="Restart$",
116
  fullsudo=False,
117
  )
118
  async def restart(e):
119
- await e.eor("`Processing...`")
120
- await bash("git pull")
121
- await e.eor("Done.")
122
- os.execl(sys.executable, sys.executable, "-m", "xteam")
 
 
 
 
 
 
 
123
 
124
  @ultroid_cmd(
125
  pattern="shutdown$",
 
104
 
105
  @ultroid_cmd(
106
  pattern="restart$",
107
+ fullsudo=True,
108
  )
109
+ async def restark(ult):
110
+ ok = await ult.eor(get_string("bot_5"))
111
+ who = "bot" if ult.client._bot else "user"
112
+ udB.set_key("_RESTART", f"{who}_{ult.chat_id}_{ok.id}")
113
+ if heroku_api:
114
+ return await restart(ok)
115
  await bash("git pull && pip3 install -r requirements.txt")
116
+ if len(sys.argv) > 1:
117
+ os.execl(sys.executable, sys.executable, "main.py")
118
+ else:
119
+ os.execl(sys.executable, sys.executable, "-m", "xteam")
120
+
121
  @ultroid_cmd(
122
+ pattern="gs$",
123
  fullsudo=False,
124
  )
125
  async def restart(e):
126
+ try:
127
+ await e.eor("`Processing...`")
128
+ process = await bash("git pull && pip3 install -r requirements.txt")
129
+ if process == 0: # Check if the bash command was successful (exit code 0)
130
+ await e.eor("`Restarting Success...`")
131
+ os.execl(sys.executable, sys.executable, "-m", "xteam")
132
+ else:
133
+ await e.eor("`Restarting Failed!`\n`Check logs for more info.`")
134
+ except Exception as err:
135
+ await e.eor(f"`An error occurred during restart!`\n`{err}`")
136
+
137
 
138
  @ultroid_cmd(
139
  pattern="shutdown$",
plugins/_help.py CHANGED
@@ -32,94 +32,66 @@ from . import HNDLR, LOGS, OWNER_NAME, asst, get_string, inline_pic, udB, ultroi
32
 
33
  _main_help_menu = [
34
  [
35
- Button.url("18+",url=f"https://t.me/+5WS60Gdkpt84YWM1"),
36
- Button.inline("ᴍᴏᴅᴜʟᴇꜱ", data="uh_Official_"),
37
  ],
38
- [Button.inline("ᴄʟᴏꜱᴇ", data="close")],
39
- ]
 
40
 
41
  @ultroid_cmd(pattern="help( (.*)|$)")
42
- async def _help(ult):
43
- plug = ult.pattern_match.group(1).strip()
44
- chat = await ult.get_chat()
45
  if plug:
46
  try:
47
- if plug in HELP["Official"]:
48
- output = f"**Plugin** - `{plug}`\n"
49
- for i in HELP["Official"][plug]:
50
- output += i
51
- output += "\n© @xteam_cloner"
52
- await ult.eor(output)
53
- elif HELP.get("Addons") and plug in HELP["Addons"]:
54
- output = f"**Plugin** - `{plug}`\n"
55
- for i in HELP["Addons"][plug]:
56
- output += i
57
- output += "\n© @xteam_cloner"
58
- await ult.eor(output)
59
- elif HELP.get("VCBot") and plug in HELP["VCBot"]:
60
- output = f"**Plugin** - `{plug}`\n"
61
- for i in HELP["VCBot"][plug]:
62
- output += i
63
- output += "\n© @xteam_cloner"
64
- await ult.eor(output)
65
  else:
66
- try:
67
- x = get_string("help_11").format(plug)
68
- for d in LIST[plug]:
69
- x += HNDLR + d
70
- x += "\n"
71
- x += "\n© @xteam_cloner"
72
- await ult.eor(x)
73
- except BaseException:
74
- file = None
75
- compare_strings = []
76
- for file_name in LIST:
77
- compare_strings.append(file_name)
78
- value = LIST[file_name]
79
- for j in value:
80
- j = cmd_regex_replace(j)
81
- compare_strings.append(j)
82
- if j.strip() == plug:
83
- file = file_name
84
- break
85
- if not file:
86
- # the entered command/plugin name is not found
87
- text = f"`{plug}` is not a valid plugin!"
88
- best_match = None
89
- for _ in compare_strings:
90
- if plug in _ and not _.startswith("_"):
91
- best_match = _
92
- break
93
- if best_match:
94
- text += f"\nDid you mean `{best_match}`?"
95
- return await ult.eor(text)
96
- output = f"**Command** `{plug}` **found in plugin** - `{file}`\n"
97
- if file in HELP["Official"]:
98
- for i in HELP["Official"][file]:
99
- output += i
100
- elif HELP.get("Addons") and file in HELP["Addons"]:
101
- for i in HELP["Addons"][file]:
102
- output += i
103
- elif HELP.get("VCBot") and file in HELP["VCBot"]:
104
- for i in HELP["VCBot"][file]:
105
- output += i
106
- output += "\n© @xteam_cloner"
107
- await ult.eor(output)
108
- except BaseException as er:
109
- LOGS.exception(er)
110
- await ult.eor("Error 🤔 occurred.")
111
  else:
112
  try:
113
- results = await ult.client.inline_query(asst.me.username, "ultd")
114
- except BotMethodInvalidError:
115
- return await ult.reply(
116
- "Inline mode is disabled. Please enable it in bot settings or contact support.",
117
- )
118
- except BotResponseTimeoutError:
119
- return await ult.eor(
120
- "The bot did not respond in time. Please try again later.",
121
- )
122
  except BotInlineDisabledError:
123
- return await ult.eor("The bot's inline mode is currently disabled.")
124
- await results[0].click(chat.id, reply_to=ult.reply_to_msg_id, hide_via=True)
125
- await ult.delete()
 
32
 
33
  _main_help_menu = [
34
  [
35
+ Button.inline("🏡 Modules 🏡", data="uh_Official_"),
 
36
  ],
37
+
38
+ ]
39
+
40
 
41
  @ultroid_cmd(pattern="help( (.*)|$)")
42
+ async def _help(event):
43
+ plug = event.pattern_match.group(1).strip()
44
+ chat = await event.get_chat()
45
  if plug:
46
  try:
47
+ x = get_string("help_11").format(plug)
48
+ if plug in LIST:
49
+ for d in LIST[plug]:
50
+ x += "" + d
51
+ x += "\n"
52
+ x += "\n© @teamX"
53
+ await event.eor(x)
 
 
 
 
 
 
 
 
 
 
 
54
  else:
55
+ file = None
56
+ compare_strings = []
57
+ for file_name in LIST:
58
+ compare_strings.append(file_name)
59
+ value = LIST[file_name]
60
+ for j in value:
61
+ j = cmd_regex_replace(j)
62
+ compare_strings.append(j)
63
+ if j.strip() == plug:
64
+ file = file_name
65
+ break
66
+ if not file:
67
+ # the enter command/plugin name is not found
68
+ text = f"{plug} is not a valid plugin!"
69
+ best_match = None
70
+ for _ in compare_strings:
71
+ if plug in _ and not _.startswith("_"):
72
+ best_match = _
73
+ break
74
+ if best_match:
75
+ text += f"\nDid you mean {best_match}?"
76
+ return await event.eor(text)
77
+ output = f"Command `{plug}` found in plugin - `{file}`\n"
78
+ if HELP.get("Official") and file in HELP["Official"]:
79
+ for i in HELP["Official"][file]:
80
+ output += i
81
+ elif HELP.get("Addons") and file in HELP["Addons"]:
82
+ for i in HELP["Addons"][file]:
83
+ output += i
84
+ elif HELP.get("VCBot") and file in HELP["VCBot"]:
85
+ for i in HELP["VCBot"][file]:
86
+ output += i
87
+ output += "\n© @teamX"
88
+ await event.eor(output)
89
+ except BaseException as e:
90
+ await event.eor(f"{e}")
 
 
 
 
 
 
 
 
 
91
  else:
92
  try:
93
+ results = await event.client.inline_query(asst.me.username, "help")
 
 
 
 
 
 
 
 
94
  except BotInlineDisabledError:
95
+ return await event.eor(get_string("help_3"))
96
+ await results[0].click(chat.id, reply_to=event.reply_to_msg_id)
97
+ await event.delete()
plugins/_inline.py CHANGED
@@ -85,32 +85,39 @@ async def inline_alive(o):
85
  switch_pm_param="start",
86
  )
87
 
88
-
89
- @in_pattern("ultd", owner=True)
90
- async def inline_handler(event):
91
- z = []
92
- for x in LIST.values():
93
- z.extend(x)
94
- text = get_string("inline_4").format(
95
  OWNER_NAME,
96
  len(HELP.get("Official", [])),
97
  len(HELP.get("Addons", [])),
98
- len(z),
99
  )
100
- if inline_pic():
101
- result = await event.builder.photo(
102
- file=inline_pic(),
103
- link_preview=False,
104
- text=text,
105
- buttons=_main_help_menu,
106
- )
107
- else:
108
- result = await event.builder.article(
109
- title="Ultroid Help Menu", text=text, buttons=_main_help_menu
110
- )
111
- await event.answer([result], private=True, cache_time=300, gallery=True)
112
-
 
 
 
 
 
 
 
 
113
 
 
114
  @in_pattern("pasta", owner=True)
115
  async def _(event):
116
  ok = event.text.split("-")[1]
@@ -159,7 +166,6 @@ async def setting(event):
159
 
160
  _strings = {"Official": helps, "Addons": zhelps, "VCBot": get_string("inline_6")}
161
 
162
-
163
  @callback(re.compile("uh_(.*)"), owner=True)
164
  async def help_func(ult):
165
  key, count = ult.data_match.group(1).decode("utf-8").split("_")
@@ -175,8 +181,8 @@ async def help_func(ult):
175
 
176
 
177
  @callback(re.compile("uplugin_(.*)"), owner=True)
178
- async def uptd_plugin(event):
179
- key, file = event.data_match.group(1).decode("utf-8").split("_")
180
  index = None
181
  if "|" in file:
182
  file, index = file.split("|")
@@ -217,11 +223,11 @@ async def uptd_plugin(event):
217
  ]
218
  )
219
  try:
220
- await event.edit(help_, buttons=buttons)
221
  except Exception as er:
222
  LOGS.exception(er)
223
  help = f"Do `{HNDLR}help {key}` to get list of commands."
224
- await event.edit(help, buttons=buttons)
225
 
226
 
227
  @callback(data="doupdate", owner=True)
@@ -291,7 +297,6 @@ async def _(e):
291
  )
292
  await e.edit(buttons=button, link_preview=False)
293
 
294
-
295
  @callback(data="open", owner=True)
296
  async def opner(event):
297
  z = []
@@ -308,17 +313,63 @@ async def opner(event):
308
  link_preview=False,
309
  )
310
 
311
-
312
- @callback(data="close", owner=True)
313
- async def on_plug_in_callback_query_handler(event):
314
  await event.delete()
 
 
 
 
 
315
 
316
 
317
  def page_num(index, key):
318
  rows = udB.get_key("HELP_ROWS") or 5
319
  cols = udB.get_key("HELP_COLUMNS") or 2
320
  loaded = HELP.get(key, [])
321
- emoji = udB.get_key("EMOJI_IN_HELP") or "🫧"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
322
  List = [
323
  Button.inline(f"{emoji} {x} {emoji}", data=f"uplugin_{key}_{x}|{index}")
324
  for x in sorted(loaded)
@@ -331,7 +382,7 @@ def page_num(index, key):
331
  new_ = fl_[0] if fl_ else []
332
  index = 0
333
  if index == 0 and len(fl_) == 1:
334
- new_.append([Button.inline("×", data="open")])
335
  else:
336
  new_.append(
337
  [
@@ -339,7 +390,7 @@ def page_num(index, key):
339
  "<",
340
  data=f"uh_{key}_{index-1}",
341
  ),
342
- Button.inline("×", data="open"),
343
  Button.inline(
344
  ">",
345
  data=f"uh_{key}_{index+1}",
@@ -347,7 +398,7 @@ def page_num(index, key):
347
  ]
348
  )
349
  return new_
350
-
351
 
352
  # --------------------------------------------------------------------------------- #
353
 
 
85
  switch_pm_param="start",
86
  )
87
 
88
+ @in_pattern("helpme", owner=False)
89
+ async def inline_haandler(event):
90
+ key = "Official"
91
+ count = 0
92
+ text = get_string("inline_4", key).format(
 
 
93
  OWNER_NAME,
94
  len(HELP.get("Official", [])),
95
  len(HELP.get("Addons", [])),
96
+ len(key),
97
  )
98
+ text = f"<blockquote> {text}</blockquote>" # Menambahkan blockquote di awal teks
99
+ result = await event.builder.article(
100
+ title="Menu Help", text=text, buttons=page_num(count, key), parse_mode="html"
101
+ )
102
+ await event.answer([result], cache_time=0, parse_mode="html")
103
+
104
+
105
+ @in_pattern("help", owner=False)
106
+ async def inline_handler(ult):
107
+ key = "Official"
108
+ count = 0
109
+ text = get_string("inline_4", key).format(
110
+ OWNER_NAME,
111
+ len(HELP.get("Official", [])),
112
+ len(HELP.get("Addons", [])),
113
+ len(key),
114
+ )
115
+ result = await ult.builder.article(
116
+ title="Menu Help", text=text, buttons=page_num(count, key)
117
+ )
118
+ await ult.answer([result], cache_time=0)
119
 
120
+
121
  @in_pattern("pasta", owner=True)
122
  async def _(event):
123
  ok = event.text.split("-")[1]
 
166
 
167
  _strings = {"Official": helps, "Addons": zhelps, "VCBot": get_string("inline_6")}
168
 
 
169
  @callback(re.compile("uh_(.*)"), owner=True)
170
  async def help_func(ult):
171
  key, count = ult.data_match.group(1).decode("utf-8").split("_")
 
181
 
182
 
183
  @callback(re.compile("uplugin_(.*)"), owner=True)
184
+ async def uptd_plugin(ult):
185
+ key, file = ult.data_match.group(1).decode("utf-8").split("_")
186
  index = None
187
  if "|" in file:
188
  file, index = file.split("|")
 
223
  ]
224
  )
225
  try:
226
+ await ult.edit(help_, buttons=buttons)
227
  except Exception as er:
228
  LOGS.exception(er)
229
  help = f"Do `{HNDLR}help {key}` to get list of commands."
230
+ await ult.edit(help, buttons=buttons)
231
 
232
 
233
  @callback(data="doupdate", owner=True)
 
297
  )
298
  await e.edit(buttons=button, link_preview=False)
299
 
 
300
  @callback(data="open", owner=True)
301
  async def opner(event):
302
  z = []
 
313
  link_preview=False,
314
  )
315
 
316
+ @callback(data="tutupbotol", owner=False)
317
+ async def tutupbotol(event):
 
318
  await event.delete()
319
+
320
+
321
+ """await event.edit(
322
+ buttons=Button.inline("🏡 Modules 🏡", data="uh_Official_"),
323
+ )"""
324
 
325
 
326
  def page_num(index, key):
327
  rows = udB.get_key("HELP_ROWS") or 5
328
  cols = udB.get_key("HELP_COLUMNS") or 2
329
  loaded = HELP.get(key, [])
330
+ emoji = udB.get_key("EMOJI_IN_HELP") or ""
331
+ List = [
332
+ Button.inline(f"{emoji} {x} {emoji}", data=f"uplugin_{key}_{x}|{index}")
333
+ for x in sorted(loaded)
334
+ ]
335
+ all_ = split_list(List, cols)
336
+ fl_ = split_list(all_, rows)
337
+ try:
338
+ new_ = fl_[index]
339
+ except IndexError:
340
+ new_ = fl_[0] if fl_ else []
341
+ index = 0
342
+
343
+ nav_buttons = []
344
+ if len(fl_) > 1:
345
+ nav_buttons.append(
346
+ Button.inline(
347
+ "<",
348
+ data=f"uh_{key}_{index-1}",
349
+ )
350
+ )
351
+ nav_buttons.append(Button.inline("×", data="tutupbotol"))
352
+ if len(fl_) > 1:
353
+ nav_buttons.append(
354
+ Button.inline(
355
+ ">",
356
+ data=f"uh_{key}_{index+1}",
357
+ )
358
+ )
359
+
360
+ if nav_buttons:
361
+ new_.append(nav_buttons)
362
+ elif not new_: # Tambahkan tombol close jika tidak ada tombol lain dan tidak ada item bantuan
363
+ new_.append([Button.inline("×", data="tutupbotol")])
364
+
365
+ return new_
366
+
367
+
368
+ """def page_num(index, key):
369
+ rows = udB.get_key("HELP_ROWS") or 5
370
+ cols = udB.get_key("HELP_COLUMNS") or 2
371
+ loaded = HELP.get(key, [])
372
+ emoji = udB.get_key("EMOJI_IN_HELP") or ""
373
  List = [
374
  Button.inline(f"{emoji} {x} {emoji}", data=f"uplugin_{key}_{x}|{index}")
375
  for x in sorted(loaded)
 
382
  new_ = fl_[0] if fl_ else []
383
  index = 0
384
  if index == 0 and len(fl_) == 1:
385
+ new_.append([Button.inline("×", data="close")])
386
  else:
387
  new_.append(
388
  [
 
390
  "<",
391
  data=f"uh_{key}_{index-1}",
392
  ),
393
+ Button.inline("×", data="close"),
394
  Button.inline(
395
  ">",
396
  data=f"uh_{key}_{index+1}",
 
398
  ]
399
  )
400
  return new_
401
+ """
402
 
403
  # --------------------------------------------------------------------------------- #
404
 
plugins/alive.py ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import asyncio
3
+ import platform
4
+ import subprocess
5
+ import time
6
+ import random
7
+ from datetime import datetime
8
+ from secrets import choice
9
+ from telethon import Button, events
10
+ from telethon.errors.rpcerrorlist import MessageDeleteForbiddenError
11
+ from telethon.utils import get_display_name
12
+ from telethon.errors.rpcerrorlist import MessageDeleteForbiddenError
13
+ from telethon.utils import get_display_name
14
+ from telethon.tl.types import InputMessagesFilterVideo, InputMessagesFilterVoice, InputMessagesFilterPhotos
15
+
16
+ from xteam._misc import SUDO_M, owner_and_sudos
17
+ from xteam.dB.base import KeyManager
18
+ from xteam.fns.helper import inline_mention
19
+ from strings import get_string
20
+
21
+ from xteam._misc import SUDO_M, owner_and_sudos
22
+ from xteam.dB.base import KeyManager
23
+ from xteam.fns.helper import inline_mention
24
+
25
+ from platform import python_version as pyver
26
+ from pyrogram import __version__ as pver
27
+ from telegram import __version__ as lver
28
+ from telethon import __version__ as tver
29
+ from pytgcalls import __version__ as pytver
30
+ from pyrogram import filters
31
+ from pyrogram.types import Message
32
+ from telethon import TelegramClient, events
33
+ from telethon.tl.custom import Button
34
+ from . import *
35
+ from . import ultroid_bot as client
36
+ import resources
37
+ from xteam.fns.helper import inline_mention
38
+ from . import (
39
+ OWNER_NAME,
40
+ OWNER_ID,
41
+ BOT_NAME,
42
+ OWNER_USERNAME,
43
+ asst,
44
+ start_time,
45
+ time_formatter,
46
+ udB,
47
+ ultroid_cmd as xteam_cmd,
48
+ get_string,
49
+ ultroid_bot as client,
50
+ eor,
51
+ ultroid_bot,
52
+ call_back,
53
+ callback,
54
+ )
55
+
56
+ async def member_permissions(chat_id: int, user_id: int):
57
+ perms = []
58
+ member = (await ultroid_bot.get_chat_member(chat_id, user_id)).privileges
59
+ if not member:
60
+ return []
61
+ if member.can_post_messages:
62
+ perms.append("can_post_messages")
63
+ if member.can_edit_messages:
64
+ perms.append("can_edit_messages")
65
+ if member.can_delete_messages:
66
+ perms.append("can_delete_messages")
67
+ if member.can_restrict_members:
68
+ perms.append("can_restrict_members")
69
+ if member.can_promote_members:
70
+ perms.append("can_promote_members")
71
+ if member.can_change_info:
72
+ perms.append("can_change_info")
73
+ if member.can_invite_users:
74
+ perms.append("can_invite_users")
75
+ if member.can_pin_messages:
76
+ perms.append("can_pin_messages")
77
+ if member.can_manage_video_chats:
78
+ perms.append("can_manage_video_chats")
79
+ return perms
80
+
81
+ PHOTO = [
82
+ "https://files.catbox.moe/fqx4vz.mp4"
83
+ ]
84
+
85
+ Mukesh = [
86
+ [
87
+ Button.url("ɴᴏᴏʙ", url=f"https://t.me/{OWNER_USERNAME}"),
88
+ Button.url("ꜱᴜᴘᴘᴏʀᴛ", url=f"https://t.me/xteam_cloner"),
89
+ ],
90
+ [
91
+ Button.url("➕ᴀᴅᴅ ᴍᴇ ᴇʟsᴇ ʏᴏᴜʀ ɢʀᴏᴜᴘ➕",
92
+ url=f"https://t.me/{BOT_USERNAME}?startgroup=true",
93
+ ),
94
+ ],
95
+ ]
96
+
97
+
98
+ def format_message_text(uptime):
99
+ return f"<blockquote>┏──────────────────┓\n❍─┫ᴜʀʙᴏᴛ ɪꜱ ɴᴏᴡ ᴀʟɪᴠᴇ!┣─❍\n" \
100
+ f"┣──────────────────┫\n\n" \
101
+ f"❍ ᴏᴡɴᴇʀ : {OWNER_NAME}\n\n" \
102
+ f"❍ ʟɪʙʀᴀʀʏ : {lver}\n\n" \
103
+ f"❍ ᴜᴘᴛɪᴍᴇ : {uptime}\n\n" \
104
+ f"❍ ᴛᴇʟᴇᴛʜᴏɴ : {tver}\n\n" \
105
+ f"❍ ᴘʏʀᴏɢʀᴀᴍ : {pver}\n\n" \
106
+ f"❍ ᴘʏᴛʜᴏɴ : {pyver()}\n\n" \
107
+ f"┗──────────────────┛\n</blockquote>"
108
+
109
+ @xteam_cmd(pattern="alive$")
110
+ async def alive(event):
111
+ start = time.time()
112
+ pro = await event.eor("🔥")
113
+ await asyncio.sleep(1)
114
+ end = round((time.time() - start) * 1000)
115
+ uptime = time_formatter((time.time() - start_time) * 1000)
116
+ message_text = format_message_text(uptime)
117
+ await pro.edit(f"<blockquote><b>✰ {asst.full_name} ɪꜱ ᴀʟɪᴠᴇ ✰</b>\n\n" \
118
+ f"✵ Owner : {OWNER_NAME}\n" \
119
+ f"✵ Dc id : {ultroid_bot.dc_id}\n" \
120
+ f"✵ Library : {lver}\n" \
121
+ f"✵ Uptime : {uptime}\n" \
122
+ f"✵ Telethon : {tver}\n" \
123
+ f"✵ Pyrogram : {pver}\n" \
124
+ f"✵ Python : {pyver()}\n</blockquote>",
125
+ parse_mode="html",
126
+ )
127
+
128
+ @xteam_cmd(pattern="Alive$")
129
+ async def alive_video(event):
130
+ try:
131
+ asupannya = [
132
+ asupan
133
+ async for asupan in event.client.iter_messages(
134
+ "@xcryasupan", filter=InputMessagesFilterVideo
135
+ )
136
+ ]
137
+
138
+ if not asupannya:
139
+ await event.respond("No video found in @xcryasupan.")
140
+ return
141
+
142
+ pro = await event.eor("⚡")
143
+ await asyncio.sleep(2)
144
+ await pro.delete()
145
+ uptime = time_formatter((time.time() - start_time) * 1000)
146
+ message_text = format_message_text(uptime)
147
+ await client.send_file(
148
+ event.chat.id,
149
+ file=random.choice(asupannya),
150
+ caption=message_text,
151
+ parse_mode="html",
152
+ )
153
+
154
+ except Exception as e:
155
+ await event.respond(f"An error occurred: {e}")
plugins/chatgpt.py CHANGED
@@ -5,7 +5,7 @@
5
  # PLease read the GNU Affero General Public License in
6
  # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
 
8
- """<blockquote>
9
  ✘ Commands Available -
10
 
11
  • `{i}gemini <prompt>`
@@ -24,7 +24,7 @@ Set custom models using:
24
  • OPENAI_MODEL
25
  • ANTHROPIC_MODEL
26
  • GEMINI_MODEL
27
- • DEEPSEEK_MODEL</blockquote>
28
  """
29
 
30
  import json
@@ -249,8 +249,8 @@ async def gemini_ai(event):
249
  model = get_model("gemini")
250
 
251
  header = (
252
- f"<blockquote>Question :\n{prompt}</blockquote>\n"
253
- "<blockquote>Answer :</blockquote>\n"
254
  )
255
 
256
  if event.client.me.bot:
 
5
  # PLease read the GNU Affero General Public License in
6
  # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
 
8
+ """
9
  ✘ Commands Available -
10
 
11
  • `{i}gemini <prompt>`
 
24
  • OPENAI_MODEL
25
  • ANTHROPIC_MODEL
26
  • GEMINI_MODEL
27
+ • DEEPSEEK_MODEL
28
  """
29
 
30
  import json
 
249
  model = get_model("gemini")
250
 
251
  header = (
252
+ f"<blockquote>🔍 Prompt:\n{prompt}</blockquote>\n"
253
+ "<blockquote>💡 Response:</blockquote>\n"
254
  )
255
 
256
  if event.client.me.bot:
plugins/gikes.py ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # xteam - UserBot
2
+ # Copyright (C) 2021-2022 senpai80
3
+ #
4
+ # This file is a part of < https://github.com/senpai80/xteam/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/senpai80/xteam/blob/main/LICENSE/>.
7
+ """
8
+ ✘ **Bantuan Untuk Broadcast**
9
+
10
+ ๏ **Perintah:** `gcast`
11
+ ◉ **Keterangan:** Kirim pesan ke semua obrolan grup.
12
+
13
+ ๏ **Perintah:** `gucast`
14
+ ◉ **Keterangan:** Kirim pesan ke semua pengguna pribadi.
15
+
16
+ ๏ **Perintah:** `addbl`
17
+ ◉ **Keterangan:** Tambahkan grup ke dalam anti gcast.
18
+
19
+ ๏ **Perintah:** `delbl`
20
+ ◉ **Keterangan:** Hapus grup dari daftar anti gcast.
21
+
22
+ ๏ **Perintah:** `blchat`
23
+ ◉ **Keterangan:** Melihat daftar anti gcast.
24
+ """
25
+ import asyncio
26
+
27
+ from xteam.dB import DEVLIST as DEVS
28
+ from xteam.dB.gcast_blacklist_db import add_gblacklist, rem_gblacklist
29
+ from xteam.dB.blacklist_chat_db import add_black_chat
30
+ from telethon.errors.rpcerrorlist import FloodWaitError
31
+
32
+ from . import *
33
+
34
+
35
+ @ultroid_cmd(pattern="gcast( (.*)|$)", fullsudo=False)
36
+ async def gcast(event):
37
+ if xx := event.pattern_match.group(1):
38
+ msg = xx
39
+ elif event.is_reply:
40
+ msg = await event.get_reply_message()
41
+ else:
42
+ return await eor(
43
+ event, "`Berikan beberapa teks ke Globally Broadcast atau balas pesan..`"
44
+ )
45
+ kk = await event.eor("`Sebentar Kalo Limit Jangan Salahin Kynan Ya...`")
46
+ er = 0
47
+ done = 0
48
+ err = ""
49
+ chat_blacklist = udB.get_key("GBLACKLISTS") or []
50
+ chat_blacklist.append(-1001608847572)
51
+ udB.set_key("GBLACKLISTS", chat_blacklist)
52
+ async for x in event.client.iter_dialogs():
53
+ if x.is_group:
54
+ chat = x.id
55
+
56
+ if chat not in chat_blacklist and chat not in NOSPAM_CHAT:
57
+ try:
58
+ await event.client.send_message(chat, msg)
59
+ done += 1
60
+ except FloodWaitError as fw:
61
+ await asyncio.sleep(fw.seconds + 10)
62
+ try:
63
+ await event.client.send_message(chat, msg)
64
+ done += 1
65
+ except Exception as rr:
66
+ err += f"• {rr}\n"
67
+ er += 1
68
+ except BaseException as h:
69
+ err += f"• {str(h)}" + "\n"
70
+ er += 1
71
+ await kk.edit(
72
+ f"**Pesan Broadcast Berhasil Terkirim Ke : `{done}` Grup.\nDan Gagal Terkirim Ke : `{er}` Grup.**"
73
+ )
74
+
75
+
76
+ @ultroid_cmd(pattern="gucast( (.*)|$)", fullsudo=False)
77
+ async def gucast(event):
78
+ if xx := event.pattern_match.group(1):
79
+ msg = xx
80
+ elif event.is_reply:
81
+ msg = await event.get_reply_message()
82
+ else:
83
+ return await eor(
84
+ event, "`Berikan beberapa teks ke Globally Broadcast atau balas pesan..`"
85
+ )
86
+ kk = await event.eor("`Sebentar Kalo Limit Jangan Salahin Kynan Ya...`")
87
+ er = 0
88
+ done = 0
89
+ chat_blacklist = udB.get_key("GBLACKLISTS") or []
90
+ chat_blacklist.append(482945686)
91
+ udB.set_key("GBLACKLISTS", chat_blacklist)
92
+ async for x in event.client.iter_dialogs():
93
+ if x.is_user and not x.entity.bot:
94
+ chat = x.id
95
+ if chat not in DEVS and chat not in chat_blacklist:
96
+ try:
97
+ await event.client.send_message(chat, msg)
98
+ await asyncio.sleep(0.1)
99
+ done += 1
100
+ except FloodWaitError as anj:
101
+ await asyncio.sleep(int(anj.seconds))
102
+ await event.client.send_message(chat, msg)
103
+ done += 1
104
+ except BaseException:
105
+ er += 1
106
+ await kk.edit(
107
+ f"**Pesan Broadcast Berhasil Terkirim Ke : `{done}` Pengguna.\nDan Gagal Terkirim Ke : `{er}` Pengguna.**"
108
+ )
109
+
110
+
111
+ @ultroid_cmd(pattern="addbl")
112
+ async def blacklist_(event):
113
+ await gblacker(event, "add")
114
+
115
+
116
+ @ultroid_cmd(pattern="dlbl")
117
+ async def ungblacker(event):
118
+ await gblacker(event, "remove")
119
+
120
+
121
+ async def gblacker(event, type_):
122
+ args = event.text.split()
123
+ if len(args) > 2:
124
+ return await event.eor("**Gunakan Format:**\n `delbl` or `addbl`")
125
+ chat_id = None
126
+ chat_id = int(args[1]) if len(args) == 2 else event.chat_id
127
+ if type_ == "add":
128
+ add_gblacklist(chat_id)
129
+ await event.eor(f"**Ditambahkan ke dalam Blacklist Gcast**\n`{chat_id}`")
130
+ elif type_ == "remove":
131
+ rem_gblacklist(chat_id)
132
+ await event.eor(f"**Dihapus dari Blacklist Gcast**\n`{chat_id}`")
133
+
plugins/globaltools.py CHANGED
@@ -429,142 +429,6 @@ async def _(e):
429
  gb_msg += f"\n**Reason** : {reason}"
430
  await xx.edit(gb_msg)
431
 
432
-
433
- @ultroid_cmd(pattern="g(admin|)cast( (.*)|$)", fullsudo=True)
434
- async def gcast(event):
435
- text, btn, reply = "", None, None
436
- if xx := event.pattern_match.group(2):
437
- msg, btn = get_msg_button(event.text.split(maxsplit=1)[1])
438
- elif event.is_reply:
439
- reply = await event.get_reply_message()
440
- msg = reply.text
441
- if reply.buttons:
442
- btn = format_btn(reply.buttons)
443
- else:
444
- msg, btn = get_msg_button(msg)
445
- else:
446
- return await eor(
447
- event, "`Give some text to Globally Broadcast or reply a message..`"
448
- )
449
-
450
- kk = await event.eor("`Globally Broadcasting Msg...`")
451
- er = 0
452
- done = 0
453
- err = ""
454
- if event.client._dialogs:
455
- dialog = event.client._dialogs
456
- else:
457
- dialog = await event.client.get_dialogs()
458
- event.client._dialogs.extend(dialog)
459
- for x in dialog:
460
- if x.is_group:
461
- chat = x.entity.id
462
- if (
463
- not keym.contains(chat)
464
- and int(f"-100{str(chat)}") not in NOSPAM_CHAT
465
- and (
466
- (
467
- event.text[2:7] != "admin"
468
- or (x.entity.admin_rights or x.entity.creator)
469
- )
470
- )
471
- ):
472
- try:
473
- if btn:
474
- bt = create_tl_btn(btn)
475
- await something(
476
- event,
477
- msg,
478
- reply.media if reply else None,
479
- bt,
480
- chat=chat,
481
- reply=False,
482
- )
483
- else:
484
- await event.client.send_message(
485
- chat, msg, file=reply.media if reply else None
486
- )
487
- done += 1
488
- except FloodWaitError as fw:
489
- await asyncio.sleep(fw.seconds + 10)
490
- try:
491
- if btn:
492
- bt = create_tl_btn(btn)
493
- await something(
494
- event,
495
- msg,
496
- reply.media if reply else None,
497
- bt,
498
- chat=chat,
499
- reply=False,
500
- )
501
- else:
502
- await event.client.send_message(
503
- chat, msg, file=reply.media if reply else None
504
- )
505
- done += 1
506
- except Exception as rr:
507
- err += f"• {rr}\n"
508
- er += 1
509
- except BaseException as h:
510
- err += f"• {str(h)}" + "\n"
511
- er += 1
512
- text += f"Done in {done} chats, error in {er} chat(s)"
513
- if err != "":
514
- open("gcast-error.log", "w+").write(err)
515
- text += f"\nYou can do `{HNDLR}ul gcast-error.log` to know error report."
516
- await kk.edit(text)
517
-
518
-
519
- @ultroid_cmd(pattern="gucast( (.*)|$)", fullsudo=True)
520
- async def gucast(event):
521
- msg, btn, reply = "", None, None
522
- if xx := event.pattern_match.group(1).strip():
523
- msg, btn = get_msg_button(event.text.split(maxsplit=1)[1])
524
- elif event.is_reply:
525
- reply = await event.get_reply_message()
526
- msg = reply.text
527
- if reply.buttons:
528
- btn = format_btn(reply.buttons)
529
- else:
530
- msg, btn = get_msg_button(msg)
531
- else:
532
- return await eor(
533
- event, "`Give some text to Globally Broadcast or reply a message..`"
534
- )
535
- kk = await event.eor("`Globally Broadcasting Msg...`")
536
- er = 0
537
- done = 0
538
- if event.client._dialogs:
539
- dialog = event.client._dialogs
540
- else:
541
- dialog = await event.client.get_dialogs()
542
- event.client._dialogs.extend(dialog)
543
- for x in dialog:
544
- if x.is_user and not x.entity.bot:
545
- chat = x.id
546
- if not keym.contains(chat):
547
- try:
548
- if btn:
549
- bt = create_tl_btn(btn)
550
- await something(
551
- event,
552
- msg,
553
- reply.media if reply else None,
554
- bt,
555
- chat=chat,
556
- reply=False,
557
- )
558
- else:
559
- await event.client.send_message(
560
- chat, msg, file=reply.media if reply else None
561
- )
562
- done += 1
563
- except BaseException:
564
- er += 1
565
- await kk.edit(f"Done in {done} chats, error in {er} chat(s)")
566
-
567
-
568
  @ultroid_cmd(pattern="gkick( (.*)|$)", fullsudo=True)
569
  async def gkick(e):
570
  xx = await e.eor("`Gkicking...`")
 
429
  gb_msg += f"\n**Reason** : {reason}"
430
  await xx.edit(gb_msg)
431
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
432
  @ultroid_cmd(pattern="gkick( (.*)|$)", fullsudo=True)
433
  async def gkick(e):
434
  xx = await e.eor("`Gkicking...`")
plugins/ping.py CHANGED
@@ -13,6 +13,7 @@ import asyncio
13
  import os
14
  import sys
15
  import time
 
16
  from telethon import events, TelegramClient
17
  from telethon.tl.functions import PingRequest
18
  from secrets import choice
 
13
  import os
14
  import sys
15
  import time
16
+ import pyrogram
17
  from telethon import events, TelegramClient
18
  from telethon.tl.functions import PingRequest
19
  from secrets import choice
plugins/search.py CHANGED
@@ -68,20 +68,20 @@ async def gitsearch(event):
68
  ufollowing = ult["following"]
69
  except BaseException:
70
  return await event.eor(get_string("srch_2"))
71
- fullusr = f"""
72
- **[GITHUB]({ulink})**
73
- **Name** - {uacc}
74
- **UserName** - {uname}
75
- **ID** - {uid}
76
- **Company** - {ucomp}
77
- **Blog** - {ublog}
78
- **Location** - {ulocation}
79
- **Bio** - {ubio}
80
- **Repos** - {urepos}
81
- **Followers** - {ufollowers}
82
- **Following** - {ufollowing}
83
- """
84
- await event.respond(fullusr, file=upic)
85
  await event.delete()
86
 
87
 
 
68
  ufollowing = ult["following"]
69
  except BaseException:
70
  return await event.eor(get_string("srch_2"))
71
+ fullusr = f"""<blockquote>
72
+ [GITHUB]({ulink})
73
+ Name - {uacc}
74
+ UserName - {uname}
75
+ ID** - {uid}
76
+ Company - {ucomp}
77
+ Blog - {ublog}
78
+ Location - {ulocation}
79
+ Bio** - {ubio}
80
+ Repos - {urepos}
81
+ Followers - {ufollowers}
82
+ Following - {ufollowing}
83
+ </blockquote>"""
84
+ await event.respond(fullusr, file=upic, parse_mode="html")
85
  await event.delete()
86
 
87
 
plugins/sysinfo.py ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ ✘ Commands Available -
3
+
4
+ • `{i}sinfo`
5
+ __Get all information about the server.__
6
+ """
7
+
8
+ import os
9
+ import platform
10
+ import sys
11
+
12
+ import psutil
13
+ from xteam.fns.helper import humanbytes
14
+ from xteam.version import __version__ as UltVer
15
+ from telethon import __version__ as TelethonVer
16
+ from . import *
17
+
18
+ def find_lib_version(lib: str) -> str:
19
+ """Find the version of a Python library installed via pip."""
20
+ try:
21
+ result = os.popen(f"python3 -m pip freeze | grep '^{lib}=='").read().strip()
22
+ return result.split("==")[1] if result else "Not Installed"
23
+ except IndexError:
24
+ return "Not Installed"
25
+
26
+
27
+ def escape_html(text: str) -> str:
28
+ """Escape special characters in HTML."""
29
+ return text.replace("<", "").replace(">", "")
30
+
31
+
32
+ def get_system_info():
33
+ """Get system-related information like CPU, RAM, and OS details."""
34
+ try:
35
+ cpu_cores = psutil.cpu_count(logical=True) or "n/a"
36
+ cpu_percent = psutil.cpu_percent() or "n/a"
37
+ ram_used = humanbytes(psutil.virtual_memory().used)
38
+ ram_total = humanbytes(psutil.virtual_memory().total)
39
+ ram_percent = psutil.virtual_memory().percent or "n/a"
40
+ disk_used = humanbytes(psutil.disk_usage("/").used)
41
+ disk_total = humanbytes(psutil.disk_usage("/").total)
42
+ disk_percent = humanbytes(psutil.disk_usage("/").percent) or "n/a"
43
+ kernel = escape_html(platform.release())
44
+ architecture = escape_html(platform.architecture()[0])
45
+ return (
46
+ cpu_cores,
47
+ cpu_percent,
48
+ ram_used,
49
+ ram_total,
50
+ ram_percent,
51
+ disk_used,
52
+ disk_total,
53
+ disk_percent,
54
+ kernel,
55
+ architecture,
56
+ )
57
+ except Exception:
58
+ return ["n/a"] * 10
59
+
60
+
61
+ def get_os_info():
62
+ """Get operating system distribution information."""
63
+ try:
64
+ system = os.popen("cat /etc/*release").read()
65
+ b = system[system.find("PRETTY_NAME=") + 13 : -1]
66
+ system = b[: b.find('"')]
67
+ return escape_html(system)
68
+ except Exception:
69
+ return "N/A"
70
+
71
+
72
+ def get_python_info():
73
+ """Get Python and pip version information."""
74
+ try:
75
+ python_version = f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
76
+ pip_version = os.popen("python3 -m pip --version").read().split()[1]
77
+ return python_version, pip_version
78
+ except Exception:
79
+ return "n/a", "n/a"
80
+
81
+
82
+ def bandwidth():
83
+ try:
84
+ download = 0
85
+ upload = 0
86
+ for net_io in psutil.net_io_counters(pernic=True).values():
87
+ download += net_io.bytes_recv
88
+ upload += net_io.bytes_sent
89
+ up = humanbytes(upload)
90
+ down = humanbytes(download)
91
+ total = humanbytes(upload + download)
92
+ return up, down, total
93
+ except:
94
+ return ["N/A"] * 3
95
+
96
+
97
+ # Text template for displaying server info
98
+ INFO_TEMPLATE = (
99
+ "<b><u><blockquote>👾 Server Info:</blockquote></u>\n"
100
+ "<u><blockquote>🗄 Used resources:</u>\n"
101
+ " CPU: {} Cores ({}%)\n"
102
+ " RAM: {} / {} ({}%)\n"
103
+ " DISK: {} / {} ({}%)\n\n</blockquote>"
104
+ "<u><blockquote>🌐 Network Stats:</u>\n"
105
+ " Upload: {}\n"
106
+ " Download: {}\n"
107
+ " Total: {}\n\n</blockquote>"
108
+ "<u><blockquote>🧾 Dist info:</u>\n"
109
+ " Kernel: {}\n"
110
+ " Arch: {}\n"
111
+ " OS: {}\n\n</blockquote>"
112
+ "<u><blockquote>📦 Python libs:</u>\n"
113
+ " Telethon: {}\n"
114
+ " Aiohttp: {}\n"
115
+ " GitPython: {}\n"
116
+ " Xteam: {}\n"
117
+ " Python: {}\n"
118
+ " Pip: {}</b></blockquote>"
119
+ )
120
+
121
+
122
+ @ultroid_cmd(pattern="sinfo$")
123
+ async def serverinfo_cmd(message):
124
+ """server information."""
125
+ await message.edit("<b><i><blockquote>🔄 Getting server info...</i></b></blockquote>", parse_mode="html")
126
+
127
+ (
128
+ cpu_cores,
129
+ cpu_percent,
130
+ ram_used,
131
+ ram_total,
132
+ ram_percent,
133
+ disk_used,
134
+ disk_total,
135
+ disk_percent,
136
+ kernel,
137
+ architecture,
138
+ ) = get_system_info()
139
+ os_info = get_os_info()
140
+ python_version, pip_version = get_python_info()
141
+ up, down, total = bandwidth()
142
+
143
+ telethon_version = TelethonVer
144
+ aiohttp_version = find_lib_version("aiohttp")
145
+ gitpython_version = find_lib_version("GitPython")
146
+ xteam_version = UltVer
147
+
148
+ # Format the final text
149
+ info_text = INFO_TEMPLATE.format(
150
+ cpu_cores,
151
+ cpu_percent,
152
+ ram_used,
153
+ ram_total,
154
+ ram_percent,
155
+ disk_used,
156
+ disk_total,
157
+ disk_percent,
158
+ up,
159
+ down,
160
+ total,
161
+ kernel,
162
+ architecture,
163
+ os_info,
164
+ telethon_version,
165
+ aiohttp_version,
166
+ gitpython_version,
167
+ xteam_version,
168
+ python_version,
169
+ pip_version,
170
+ )
171
+
172
+ await message.eor(info_text, parse_mode="html")
plugins/ytdl.py ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ayra - UserBot
2
+ # Copyright (C) 2021-2022 senpai80
3
+ #
4
+ # This file is a part of < https://github.com/senpai80/Ayra/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/senpai80/Ayra/blob/main/LICENSE/>.
7
+ """
8
+ ✘ **Bantuan Untuk Youtube**
9
+
10
+ ๏ **Perintah:** video
11
+ ◉ **Keterangan:** Unduh Video Dari Youtube.
12
+
13
+ ๏ **Perintah:** song
14
+ ◉ **Keterangan:** Unduh Lagu Dari Youtube.
15
+ """
16
+ import os
17
+ from asyncio import get_event_loop
18
+ from functools import partial
19
+
20
+ import wget
21
+ from youtubesearchpython import SearchVideos
22
+ from yt_dlp import YoutubeDL
23
+
24
+ from . import *
25
+
26
+
27
+ def run_sync(func, *args, **kwargs):
28
+ return get_event_loop().run_in_executor(None, partial(func, *args, **kwargs))
29
+
30
+
31
+ @ultroid_cmd(pattern="Video( (.*)|$)")
32
+ async def yt_video(e):
33
+ infomsg = await e.eor("`Processing...`")
34
+ try:
35
+ search = (
36
+ SearchVideos(
37
+ str(e.text.split(None, 1)[1]), offset=1, mode="dict", max_results=1
38
+ )
39
+ .result()
40
+ .get("search_result")
41
+ )
42
+ link = f"https://youtu.be/{search[0]['id']}"
43
+ except Exception as error:
44
+ return await infomsg.edit(f"**Pencarian...\n\n❌ Error: {error}**")
45
+ ydl = YoutubeDL(
46
+ {
47
+ "quiet": True,
48
+ "no_warnings": True,
49
+ "format": "(bestvideo[height<=?720][width<=?1280][ext=mp4])+(bestaudio[ext=m4a])",
50
+ "outtmpl": "downloads/%(id)s.%(ext)s",
51
+ "nocheckcertificate": True,
52
+ "geo_bypass": True,
53
+ "cookiefile": "cookies.txt",
54
+ }
55
+ )
56
+ await infomsg.eor("Mulai Mendownload...")
57
+ try:
58
+ ytdl_data = await run_sync(ydl.extract_info, link, download=True)
59
+ file_path = ydl.prepare_filename(ytdl_data)
60
+ videoid = ytdl_data["id"]
61
+ title = ytdl_data["title"]
62
+ url = f"https://youtu.be/{videoid}"
63
+ duration = ytdl_data["duration"]
64
+ channel = ytdl_data["uploader"]
65
+ views = f"{ytdl_data['view_count']:,}".replace(",", ".")
66
+ thumbs = f"https://img.youtube.com/vi/{videoid}/hqdefault.jpg"
67
+ except Exception as error:
68
+ return await infomsg.eor(f"**Gagal...\n\n❌ Error: {error}**")
69
+ thumbnail = wget.download(thumbs)
70
+ await e.client.send_file(
71
+ e.chat.id,
72
+ file=file_path,
73
+ thumb=thumbnail,
74
+ file_name=title,
75
+ duration=duration,
76
+ supports_streaming=True,
77
+ caption=f'<blockquote>💡 Informasi {"video"}\n\n🏷 Nama: {title}\n🧭 Durasi: {duration}\n👀 Dilihat: {views}\n📢 Channel: {channel}\nUpload By: {ultroid_bot.full_name}</blockquote>',
78
+ reply_to=e.reply_to_msg_id,
79
+ parse_mode="html",
80
+ )
81
+ await infomsg.delete()
82
+ for files in (thumbnail, file_path):
83
+ if files and os.path.exists(files):
84
+ os.remove(files)
85
+
86
+
87
+ @ultroid_cmd(pattern="Song( (.*)|$)")
88
+ async def yt_audio(e):
89
+ infomsg = await e.eor("`Processing...`")
90
+ try:
91
+ search = (
92
+ SearchVideos(
93
+ str(e.text.split(None, 1)[1]), offset=1, mode="dict", max_results=1
94
+ )
95
+ .result()
96
+ .get("search_result")
97
+ )
98
+ link = f"https://youtu.be/{search[0]['id']}"
99
+ except Exception as error:
100
+ return await infomsg.eor(f"**Pencarian...\n\n❌ Error: {error}**")
101
+ ydl = YoutubeDL(
102
+ {
103
+ "quiet": True,
104
+ "no_warnings": True,
105
+ "format": "bestaudio[ext=m4a]",
106
+ "outtmpl": "downloads/%(id)s.%(ext)s",
107
+ "nocheckcertificate": True,
108
+ "geo_bypass": True,
109
+ "cookiefile": "cookies.txt",
110
+ }
111
+ )
112
+ await infomsg.edit("Mulai Mendownload...")
113
+ try:
114
+ ytdl_data = await run_sync(ydl.extract_info, link, download=True)
115
+ file_path = ydl.prepare_filename(ytdl_data)
116
+ videoid = ytdl_data["id"]
117
+ title = ytdl_data["title"]
118
+ url = f"https://youtu.be/{videoid}"
119
+ duration = ytdl_data["duration"]
120
+ channel = ytdl_data["uploader"]
121
+ views = f"{ytdl_data['view_count']:,}".replace(",", ".")
122
+ thumbs = f"https://img.youtube.com/vi/{videoid}/hqdefault.jpg"
123
+ except Exception as error:
124
+ return await infomsg.edit(f"**Downloader...\n\n❌ Error: {error}**")
125
+ thumbnail = wget.download(thumbs)
126
+ await e.client.send_file(
127
+ e.chat.id,
128
+ file=file_path,
129
+ thumb=thumbnail,
130
+ file_name=title,
131
+ duration=duration,
132
+ supports_streaming=False,
133
+ caption=f'<blockquote>💡 Informasi {"Audio"}\n\n🏷 Nama: {title}\n🧭 Durasi: {duration}\n👀 Dilihat: {views}\n**📢 Channel: {channel}\nUpload By: {ultroid_bot.full_name}</blockquote>',
134
+ reply_to=e.reply_to_msg_id,
135
+ parse_mode="html",
136
+ )
137
+ await infomsg.delete()
138
+ for files in (thumbnail, file_path):
139
+ if files and os.path.exists(files):
140
+ os.remove(files)