teamx-cloner commited on
Commit
6c5b283
·
1 Parent(s): 3efbc43

Add files via upload

Browse files
plugins/__init__.py ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 asyncio
9
+ import os
10
+ import time
11
+ import datetime
12
+ from random import choice
13
+ #from ApiNyaEr.teks import ISLAMIC as QUOTES
14
+ import requests
15
+ from telethon import Button, events
16
+ from telethon.tl import functions, types # pylint:ignore
17
+ #from assistant.start import _start, _settings
18
+ from xteam import *
19
+ from xteam._misc._assistant import asst_cmd, callback, in_pattern
20
+ from xteam._misc._decorators import ultroid_cmd
21
+ from xteam._misc._wrappers import eod, eor
22
+ from xteam.dB import DEVLIST, ULTROID_IMAGES, ALIVE_TEXT, ALIVE_NAME, QUOTES
23
+ from xteam.fns.helper import *
24
+ from xteam.fns.misc import *
25
+ from xteam.fns.tools import *
26
+ from xteam.startup._database import _BaseDatabase as Database
27
+ from xteam.version import __version__, ultroid_version
28
+ from strings import get_help, get_string
29
+ from xteam._misc._supporter import CMD_HNDLR
30
+ from xteam.dB import stickers
31
+
32
+
33
+ udB: Database
34
+
35
+ Redis = udB.get_key
36
+ con = TgConverter
37
+ quotly = Quotly()
38
+ OWNER_NAME = ultroid_bot.full_name
39
+ OWNER_ID = ultroid_bot.uid
40
+ OWNER_USERNAME = ultroid_bot.username
41
+ BOT_NAME = asst.full_name
42
+ BOT_USERNAME = asst.username
43
+
44
+ ultroid_bot: UltroidClient
45
+ asst: UltroidClient
46
+
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:
53
+ INLINE_PIC = choice(ULTROID_IMAGES)
54
+ elif INLINE_PIC == False:
55
+ INLINE_PIC = None
56
+ return INLINE_PIC
57
+
58
+ def ping_pic():
59
+ PING_PIC = udB.get_key("PING_PIC")
60
+ if PING_PIC is None:
61
+ PING_PIC = choice(ULTROID_IMAGES)
62
+ elif PING_PIC == False:
63
+ PING_PIC = None
64
+ return PING_PIC
65
+
66
+ def get_readable_time(seconds: int) -> str:
67
+ count = 0
68
+ readable_time = ""
69
+ time_list = []
70
+ time_suffix_list = ["s", "m", "h", "days"]
71
+
72
+ while count < 4:
73
+ count += 1
74
+ remainder, result = divmod(seconds, 60) if count < 3 else divmod(seconds, 24)
75
+ if seconds == 0 and remainder == 0:
76
+ break
77
+ time_list.append(int(result))
78
+ seconds = int(remainder)
79
+
80
+ for x in range(len(time_list)):
81
+ time_list[x] = str(time_list[x]) + time_suffix_list[x]
82
+ if len(time_list) == 4:
83
+ readable_time += f"{time_list.pop()}, "
84
+
85
+ time_list.reverse()
86
+ readable_time += ":".join(time_list)
87
+
88
+ return readable_time
89
+
90
+
91
+ Telegraph = telegraph_client()
92
+
93
+ List = []
94
+ Dict = {}
95
+ InlinePlugin = {}
96
+ N = 0
97
+ cmd = ultroid_cmd
98
+ STUFF = {}
99
+
100
+ # Chats, which needs to be ignore for some cases
101
+ # Considerably, there can be many
102
+ # Feel Free to Add Any other...
103
+
104
+ NOSPAM_CHAT = [
105
+ -1001361294038, # UltroidSupportChat
106
+ -1001387666944, # PyrogramChat
107
+ -1001109500936, # TelethonChat
108
+ -1001050982793, # Python
109
+ -1001256902287, # DurovsChat
110
+ -1001473548283, # SharingUserbot
111
+ -1001599474353,
112
+ -1001692751821,
113
+ -1001473548283,
114
+ -1001459812644,
115
+ -1001433238829,
116
+ -1001476936696,
117
+ -1001327032795,
118
+ -1001294181499,
119
+ -1001419516987,
120
+ -1001209432070,
121
+ -1001296934585,
122
+ -1001481357570,
123
+ -1001459701099,
124
+ -1001109837870,
125
+ -1001485393652,
126
+ -1001354786862,
127
+ -1001109500936,
128
+ -1001387666944,
129
+ -1001390552926,
130
+ -1001752592753,
131
+ -1001777428244,
132
+ -1001771438298,
133
+ -1001287188817,
134
+ -1001812143750,
135
+ -1001883961446,
136
+ -1001753840975,
137
+ -1001896051491,
138
+ -1001578091827,
139
+ -1001284445583,
140
+ -1001927904459,
141
+ -1001675396283,
142
+ -1001825363971,
143
+ -1001537280879,
144
+ -1001302879778,
145
+ -1001797285258,
146
+ -1001864253073,
147
+ -1001876092598,
148
+ -1001608847572,
149
+ -1001451642443,
150
+ -1001538826310,
151
+ -1001608701614,
152
+ -1001861414061,
153
+ -1001406767793,
154
+ -1001306409796,
155
+ -1002136866494,
156
+ -1002234906165,
157
+ -1001557462351,
158
+ -1001185324811,
159
+ -1002341392113,
160
+ -1002385138723,
161
+ ]
162
+
163
+ KANGING_STR = [
164
+ "Using Witchery to kang this sticker...",
165
+ "Plagiarising hehe...",
166
+ "Inviting this sticker over to my pack...",
167
+ "Kanging this sticker...",
168
+ "Hey that's a nice sticker!\nMind if I kang?!..",
169
+ "Hehe me stel ur stiker...",
170
+ "Ay look over there (☉。☉)!→\nWhile I kang this...",
171
+ "Roses are red violets are blue, kanging this sticker so my pack looks cool",
172
+ "Imprisoning this sticker...",
173
+ "Mr.Steal-Your-Sticker is stealing this sticker... ",
174
+ ]
175
+
176
+ ATRA_COL = [
177
+ "DarkCyan",
178
+ "DeepSkyBlue",
179
+ "DarkTurquoise",
180
+ "Cyan",
181
+ "LightSkyBlue",
182
+ "Turquoise",
183
+ "MediumVioletRed",
184
+ "Aquamarine",
185
+ "Lightcyan",
186
+ "Azure",
187
+ "Moccasin",
188
+ "PowderBlue",
189
+ ]
plugins/_chatactions.py ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 asyncio
9
+
10
+ from telethon import events
11
+ from telethon.errors.rpcerrorlist import UserNotParticipantError
12
+ from telethon.tl.functions.channels import GetParticipantRequest
13
+ from telethon.utils import get_display_name
14
+
15
+ from xteam.dB import stickers
16
+ from xteam.dB.echo_db import check_echo
17
+ from xteam.dB.forcesub_db import get_forcesetting
18
+ from xteam.dB.gban_mute_db import is_gbanned
19
+ from xteam.dB.greetings_db import get_goodbye, get_welcome, must_thank
20
+ from xteam.dB.nsfw_db import is_profan
21
+ from xteam.fns.helper import inline_mention
22
+ from xteam.fns.tools import async_searcher, create_tl_btn, get_chatbot_reply
23
+
24
+ try:
25
+ from ProfanityDetector import detector
26
+ except ImportError:
27
+ detector = None
28
+ from . import LOG_CHANNEL, LOGS, asst, get_string, types, udB, ultroid_bot
29
+ from ._inline import something
30
+
31
+
32
+ @ultroid_bot.on(events.ChatAction())
33
+ async def Function(event):
34
+ try:
35
+ await DummyHandler(event)
36
+ except Exception as er:
37
+ LOGS.exception(er)
38
+
39
+
40
+ async def DummyHandler(ult):
41
+ # clean chat actions
42
+ key = udB.get_key("CLEANCHAT") or []
43
+ if ult.chat_id in key:
44
+ try:
45
+ await ult.delete()
46
+ except BaseException:
47
+ pass
48
+
49
+ # thank members
50
+ if must_thank(ult.chat_id):
51
+ chat_count = (await ult.client.get_participants(ult.chat_id, limit=0)).total
52
+ if chat_count % 100 == 0:
53
+ stik_id = chat_count / 100 - 1
54
+ sticker = stickers[stik_id]
55
+ await ult.respond(file=sticker)
56
+ # force subscribe
57
+ if (
58
+ udB.get_key("FORCESUB")
59
+ and ((ult.user_joined or ult.user_added))
60
+ and get_forcesetting(ult.chat_id)
61
+ ):
62
+ user = await ult.get_user()
63
+ if not user.bot:
64
+ joinchat = get_forcesetting(ult.chat_id)
65
+ try:
66
+ await ultroid_bot(GetParticipantRequest(int(joinchat), user.id))
67
+ except UserNotParticipantError:
68
+ await ultroid_bot.edit_permissions(
69
+ ult.chat_id, user.id, send_messages=False
70
+ )
71
+ res = await ultroid_bot.inline_query(
72
+ asst.me.username, f"fsub {user.id}_{joinchat}"
73
+ )
74
+ await res[0].click(ult.chat_id, reply_to=ult.action_message.id)
75
+
76
+ if ult.user_joined or ult.added_by:
77
+ user = await ult.get_user()
78
+ chat = await ult.get_chat()
79
+ # gbans and @UltroidBans checks
80
+ if udB.get_key("ULTROID_BANS"):
81
+ try:
82
+ is_banned = await async_searcher(
83
+ "https://bans.ultroid.tech/api/status",
84
+ json={"userId": user.id},
85
+ post=True,
86
+ re_json=True,
87
+ )
88
+ if is_banned["is_banned"]:
89
+ await ult.client.edit_permissions(
90
+ chat.id,
91
+ user.id,
92
+ view_messages=False,
93
+ )
94
+ await ult.respond(
95
+ f'**@UltroidBans:** Banned user detected and banned!\n`{str(is_banned)}`.\nBan reason: {is_banned["reason"]}',
96
+ )
97
+
98
+ except BaseException:
99
+ pass
100
+ reason = is_gbanned(user.id)
101
+ if reason and chat.admin_rights:
102
+ try:
103
+ await ult.client.edit_permissions(
104
+ chat.id,
105
+ user.id,
106
+ view_messages=False,
107
+ )
108
+ gban_watch = get_string("can_1").format(inline_mention(user), reason)
109
+ await ult.reply(gban_watch)
110
+ except Exception as er:
111
+ LOGS.exception(er)
112
+
113
+ # greetings
114
+ elif get_welcome(ult.chat_id):
115
+ user = await ult.get_user()
116
+ chat = await ult.get_chat()
117
+ title = chat.title or "this chat"
118
+ count = (
119
+ chat.participants_count
120
+ or (await ult.client.get_participants(chat, limit=0)).total
121
+ )
122
+ mention = inline_mention(user)
123
+ name = user.first_name
124
+ fullname = get_display_name(user)
125
+ uu = user.username
126
+ username = f"@{uu}" if uu else mention
127
+ wel = get_welcome(ult.chat_id)
128
+ msgg = wel["welcome"]
129
+ med = wel["media"] or None
130
+ userid = user.id
131
+ msg = None
132
+ if msgg:
133
+ msg = msgg.format(
134
+ mention=mention,
135
+ group=title,
136
+ count=count,
137
+ name=name,
138
+ fullname=fullname,
139
+ username=username,
140
+ userid=userid,
141
+ )
142
+ if wel.get("button"):
143
+ btn = create_tl_btn(wel["button"])
144
+ await something(ult, msg, med, btn)
145
+ elif msg:
146
+ send = await ult.reply(
147
+ msg,
148
+ file=med,
149
+ )
150
+ await asyncio.sleep(150)
151
+ await send.delete()
152
+ else:
153
+ await ult.reply(file=med)
154
+ elif (ult.user_left or ult.user_kicked) and get_goodbye(ult.chat_id):
155
+ user = await ult.get_user()
156
+ chat = await ult.get_chat()
157
+ title = chat.title or "this chat"
158
+ count = (
159
+ chat.participants_count
160
+ or (await ult.client.get_participants(chat, limit=0)).total
161
+ )
162
+ mention = inline_mention(user)
163
+ name = user.first_name
164
+ fullname = get_display_name(user)
165
+ uu = user.username
166
+ username = f"@{uu}" if uu else mention
167
+ wel = get_goodbye(ult.chat_id)
168
+ msgg = wel["goodbye"]
169
+ med = wel["media"]
170
+ userid = user.id
171
+ msg = None
172
+ if msgg:
173
+ msg = msgg.format(
174
+ mention=mention,
175
+ group=title,
176
+ count=count,
177
+ name=name,
178
+ fullname=fullname,
179
+ username=username,
180
+ userid=userid,
181
+ )
182
+ if wel.get("button"):
183
+ btn = create_tl_btn(wel["button"])
184
+ await something(ult, msg, med, btn)
185
+ elif msg:
186
+ send = await ult.reply(
187
+ msg,
188
+ file=med,
189
+ )
190
+ await asyncio.sleep(150)
191
+ await send.delete()
192
+ else:
193
+ await ult.reply(file=med)
194
+
195
+
196
+ @ultroid_bot.on(events.NewMessage(incoming=True))
197
+ async def chatBot_replies(e):
198
+ sender = await e.get_sender()
199
+ if not isinstance(sender, types.User) or sender.bot:
200
+ return
201
+ if check_echo(e.chat_id, e.sender_id):
202
+ try:
203
+ await e.respond(e.message)
204
+ except Exception as er:
205
+ LOGS.exception(er)
206
+ key = udB.get_key("CHATBOT_USERS") or {}
207
+ if e.text and key.get(e.chat_id) and sender.id in key[e.chat_id]:
208
+ msg = await get_chatbot_reply(e.message.message)
209
+ if msg:
210
+ sleep = udB.get_key("CHATBOT_SLEEP") or 1.5
211
+ await asyncio.sleep(sleep)
212
+ await e.reply(msg)
213
+ chat = await e.get_chat()
214
+ if e.is_group and sender.username:
215
+ await uname_stuff(e.sender_id, sender.username, sender.first_name)
216
+ elif e.is_private and chat.username:
217
+ await uname_stuff(e.sender_id, chat.username, chat.first_name)
218
+ if detector and is_profan(e.chat_id) and e.text:
219
+ x, y = detector(e.text)
220
+ if y:
221
+ await e.delete()
222
+
223
+
224
+ @ultroid_bot.on(events.Raw(types.UpdateUserName))
225
+ async def uname_change(e):
226
+ await uname_stuff(e.user_id, e.usernames[0] if e.usernames else None, e.first_name)
227
+
228
+
229
+ async def uname_stuff(id, uname, name):
230
+ if udB.get_key("USERNAME_LOG"):
231
+ old_ = udB.get_key("USERNAME_DB") or {}
232
+ old = old_.get(id)
233
+ # Ignore Name Logs
234
+ if old and old == uname:
235
+ return
236
+ if old and uname:
237
+ await asst.send_message(
238
+ LOG_CHANNEL,
239
+ get_string("can_2").format(old, uname),
240
+ )
241
+ elif old:
242
+ await asst.send_message(
243
+ LOG_CHANNEL,
244
+ get_string("can_3").format(f"[{name}](tg://user?id={id})", old),
245
+ )
246
+ elif uname:
247
+ await asst.send_message(
248
+ LOG_CHANNEL,
249
+ get_string("can_4").format(f"[{name}](tg://user?id={id})", uname),
250
+ )
251
+
252
+ old_[id] = uname
253
+ udB.set_key("USERNAME_DB", old_)
plugins/_help.py ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ from datetime import datetime
11
+ from html import unescape
12
+ from random import choice
13
+ from re import compile as re_compile
14
+
15
+ from bs4 import BeautifulSoup as bs
16
+ from telethon import Button
17
+ from telethon.tl.alltlobjects import LAYER, tlobjects
18
+ from telethon.tl.types import DocumentAttributeAudio as Audio
19
+ from telethon.tl.types import InputWebDocument as wb
20
+
21
+ from telethon.errors.rpcerrorlist import (
22
+ BotInlineDisabledError,
23
+ BotMethodInvalidError,
24
+ BotResponseTimeoutError,
25
+ )
26
+ from telethon.tl.custom import Button
27
+ from assistant import *
28
+ from xteam.dB._core import HELP, LIST
29
+ from xteam.fns.tools import cmd_regex_replace
30
+
31
+ from . import HNDLR, LOGS, OWNER_NAME, asst, get_string, inline_pic, udB, ultroid_cmd, call_back, callback, def_logs, eor, get_string, heroku_logs, in_pattern
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()
plugins/_inline.py ADDED
@@ -0,0 +1,447 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ import time
10
+ from datetime import datetime
11
+ from os import remove
12
+ import resources
13
+ from git import Repo
14
+ from telethon import Button
15
+ from telethon.tl.types import InputWebDocument, Message
16
+ from telethon.utils import resolve_bot_file_id
17
+
18
+ from xteam._misc._assistant import callback, in_pattern
19
+ from xteam.dB._core import HELP, LIST
20
+ from xteam.fns.helper import gen_chlog, time_formatter, updater
21
+ from xteam.fns.misc import split_list
22
+
23
+ from . import (
24
+ HNDLR,
25
+ LOGS,
26
+ OWNER_NAME,
27
+ InlinePlugin,
28
+ asst,
29
+ get_string,
30
+ inline_pic,
31
+ split_list,
32
+ start_time,
33
+ udB,
34
+ )
35
+ from ._help import _main_help_menu
36
+
37
+ # ================================================#
38
+
39
+ helps = get_string("inline_1")
40
+
41
+ add_ons = udB.get_key("ADDONS")
42
+
43
+ zhelps = get_string("inline_3") if add_ons is False else get_string("inline_2")
44
+ PLUGINS = HELP.get("Official", [])
45
+ ADDONS = HELP.get("Addons", [])
46
+ upage = 0
47
+ # ============================================#
48
+
49
+ # --------------------BUTTONS--------------------#
50
+
51
+ SUP_BUTTONS = [
52
+ [
53
+ Button.url("• Repo •", url="https://github.com/xteam-cloner/Userbotx"),
54
+ ],
55
+ ]
56
+
57
+ # --------------------BUTTONS--------------------#
58
+
59
+
60
+ @in_pattern("repo",owner=False)
61
+ async def inline_alive(o):
62
+ TLINK = inline_pic() or "https://telegra.ph/file/cad7038fe82e47f79c609.jpg"
63
+ MSG = "**What are you looking for?**"
64
+ WEB0 = InputWebDocument(
65
+ "https://telegra.ph/file/cad7038fe82e47f79c609.jpg", 0, "image/jpg", []
66
+ )
67
+ RES = [
68
+ await o.builder.article(
69
+ type="photo",
70
+ text=MSG,
71
+ include_media=True,
72
+ buttons=SUP_BUTTONS,
73
+ title="Userbot",
74
+ description="Userbot",
75
+ url=TLINK,
76
+ thumb=WEB0,
77
+ content=InputWebDocument(TLINK, 0, "image/jpg", []),
78
+ )
79
+ ]
80
+ await o.answer(
81
+ RES,
82
+ private=True,
83
+ cache_time=300,
84
+ switch_pm="xteam-userbot",
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=page_num,
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]
117
+ link = f"https://spaceb.in/{ok}"
118
+ raw = f"https://spaceb.in/api/v1/documents/{ok}/raw"
119
+ result = await event.builder.article(
120
+ title="Paste",
121
+ text="Pasted to Spacebin 🌌",
122
+ buttons=[
123
+ [
124
+ Button.url("SpaceBin", url=link),
125
+ Button.url("Raw", url=raw),
126
+ ],
127
+ ],
128
+ )
129
+ await event.answer([result])
130
+
131
+
132
+ @callback("ownr", owner=True)
133
+ async def setting(event):
134
+ z = []
135
+ for x in LIST.values():
136
+ z.extend(x)
137
+ await event.edit(
138
+ get_string("inline_4").format(
139
+ OWNER_NAME,
140
+ len(HELP.get("Official", [])),
141
+ len(HELP.get("Addons", [])),
142
+ len(z),
143
+ ),
144
+ file=inline_pic(),
145
+ link_preview=False,
146
+ buttons=[
147
+ [
148
+ Button.inline("•Pɪɴɢ•", data="pkng"),
149
+ Button.inline("•Uᴘᴛɪᴍᴇ•", data="upp"),
150
+ ],
151
+ [
152
+ Button.inline("•Stats•", data="alive"),
153
+ Button.inline("•Uᴘᴅᴀᴛᴇ•", data="doupdate"),
154
+ ],
155
+ [Button.inline("« Bᴀᴄᴋ", data="open")],
156
+ ],
157
+ )
158
+
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("_")
166
+ if key == "VCBot" and HELP.get("VCBot") is None:
167
+ return await ult.answer(get_string("help_12"), alert=True)
168
+ elif key == "Addons" and HELP.get("Addons") is None:
169
+ return await ult.answer(get_string("help_13").format(HNDLR), alert=True)
170
+ if "|" in count:
171
+ _, count = count.split("|")
172
+ count = int(count) if count else 0
173
+ text = _strings.get(key, "").format(OWNER_NAME, len(HELP.get(key)))
174
+ await ult.edit(text, buttons=page_num(count, key), link_preview=False)
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("|")
183
+ key_ = HELP.get(key, [])
184
+ hel_p = f"Plugin Name - `{file}`\n"
185
+ help_ = ""
186
+ try:
187
+ for i in key_[file]:
188
+ help_ += i
189
+ except BaseException:
190
+ if file in LIST:
191
+ help_ = get_string("help_11").format(file)
192
+ for d in LIST[file]:
193
+ help_ += HNDLR + d
194
+ help_ += "\n"
195
+ if not help_:
196
+ help_ = f"{file} has no Detailed Help!"
197
+ help_ += "\n© @xteam_cloner"
198
+ buttons = []
199
+ if inline_pic():
200
+ data = f"sndplug_{key}_{file}"
201
+ if index is not None:
202
+ data += f"|{index}"
203
+ buttons.append(
204
+ [
205
+ Button.inline(
206
+ "« Sᴇɴᴅ Pʟᴜɢɪɴ »",
207
+ data=data,
208
+ )
209
+ ]
210
+ )
211
+ data = f"uh_{key}_"
212
+ if index is not None:
213
+ data += f"|{index}"
214
+ buttons.append(
215
+ [
216
+ Button.inline("<<", data=data),
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)
228
+ async def _(event):
229
+ if not await updater():
230
+ return await event.answer(get_string("inline_9"), cache_time=0, alert=True)
231
+ if not inline_pic():
232
+ return await event.answer(f"Do '{HNDLR}update' to update..")
233
+ repo = Repo.init()
234
+ changelog, tl_chnglog = await gen_chlog(
235
+ repo, f"HEAD..upstream/{repo.active_branch}"
236
+ )
237
+ changelog_str = changelog + "\n\n" + get_string("inline_8")
238
+ if len(changelog_str) > 1024:
239
+ await event.edit(get_string("upd_4"))
240
+ with open("ultroid_updates.txt", "w+") as file:
241
+ file.write(tl_chnglog)
242
+ await event.edit(
243
+ get_string("upd_5"),
244
+ file="ultroid_updates.txt",
245
+ buttons=[
246
+ [Button.inline("• Uᴘᴅᴀᴛᴇ Nᴏᴡ •", data="updatenow")],
247
+ [Button.inline("<<", data="ownr")],
248
+ ],
249
+ )
250
+ remove("ultroid_updates.txt")
251
+ else:
252
+ await event.edit(
253
+ changelog_str,
254
+ buttons=[
255
+ [Button.inline("Update Now", data="updatenow")],
256
+ [Button.inline("<<", data="ownr")],
257
+ ],
258
+ parse_mode="html",
259
+ )
260
+
261
+
262
+ @callback(data="pkng", owner=True)
263
+ async def _(event):
264
+ start = datetime.now()
265
+ end = datetime.now()
266
+ ms = (end - start).microseconds
267
+ pin = f"🌋Pɪɴɢ = {ms} microseconds"
268
+ await event.answer(pin, cache_time=0, alert=True)
269
+
270
+
271
+ @callback(data="upp", owner=True)
272
+ async def _(event):
273
+ uptime = time_formatter((time.time() - start_time) * 1000)
274
+ pin = f"🙋Uᴘᴛɪᴍᴇ = {uptime}"
275
+ await event.answer(pin, cache_time=0, alert=True)
276
+
277
+
278
+ @callback(data="inlone", owner=True)
279
+ async def _(e):
280
+ _InButtons = [
281
+ Button.switch_inline(_, query=InlinePlugin[_], same_peer=True)
282
+ for _ in list(InlinePlugin.keys())
283
+ ]
284
+ InButtons = split_list(_InButtons, 2)
285
+
286
+ button = InButtons.copy()
287
+ button.append(
288
+ [
289
+ Button.inline("<<", data="open"),
290
+ ],
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 = []
298
+ for x in LIST.values():
299
+ z.extend(x)
300
+ await event.edit(
301
+ get_string("inline_4").format(
302
+ OWNER_NAME,
303
+ len(HELP.get("Official", [])),
304
+ len(HELP.get("Addons", [])),
305
+ len(z),
306
+ ),
307
+ buttons=_main_help_menu,
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)
325
+ ]
326
+ all_ = split_list(List, cols)
327
+ fl_ = split_list(all_, rows)
328
+ try:
329
+ new_ = fl_[index]
330
+ except IndexError:
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
+ [
338
+ Button.inline(
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}",
346
+ ),
347
+ ]
348
+ )
349
+ return new_
350
+
351
+
352
+ # --------------------------------------------------------------------------------- #
353
+
354
+
355
+ STUFF = {}
356
+
357
+
358
+ @in_pattern("stf(.*)", owner=True)
359
+ async def ibuild(e):
360
+ n = e.pattern_match.group(1).strip()
361
+ builder = e.builder
362
+ if not (n and n.isdigit()):
363
+ return
364
+ ok = STUFF.get(int(n))
365
+ txt = ok.get("msg")
366
+ pic = ok.get("media")
367
+ btn = ok.get("button")
368
+ if not (pic or txt):
369
+ txt = "Hey!"
370
+ if pic:
371
+ try:
372
+ include_media = True
373
+ mime_type, _pic = None, None
374
+ cont, results = None, None
375
+ try:
376
+ ext = str(pic).split(".")[-1].lower()
377
+ except BaseException:
378
+ ext = None
379
+ if ext in ["img", "jpg", "png"]:
380
+ _type = "photo"
381
+ mime_type = "image/jpg"
382
+ elif ext in ["mp4", "mkv", "gif"]:
383
+ mime_type = "video/mp4"
384
+ _type = "gif"
385
+ else:
386
+ try:
387
+ if "telethon.tl.types" in str(type(pic)):
388
+ _pic = pic
389
+ else:
390
+ _pic = resolve_bot_file_id(pic)
391
+ except BaseException:
392
+ pass
393
+ if _pic:
394
+ results = [
395
+ await builder.document(
396
+ _pic,
397
+ title="Ultroid Op",
398
+ text=txt,
399
+ description="@TeamUltroid",
400
+ buttons=btn,
401
+ link_preview=False,
402
+ )
403
+ ]
404
+ else:
405
+ _type = "article"
406
+ include_media = False
407
+ if not results:
408
+ if include_media:
409
+ cont = InputWebDocument(pic, 0, mime_type, [])
410
+ results = [
411
+ await builder.article(
412
+ title="Ultroid Op",
413
+ type=_type,
414
+ text=txt,
415
+ description="@TeamUltroid",
416
+ include_media=include_media,
417
+ buttons=btn,
418
+ thumb=cont,
419
+ content=cont,
420
+ link_preview=False,
421
+ )
422
+ ]
423
+ return await e.answer(results)
424
+ except Exception as er:
425
+ LOGS.exception(er)
426
+ result = [
427
+ await builder.article("Ultroid Op", text=txt, link_preview=False, buttons=btn)
428
+ ]
429
+ await e.answer(result)
430
+
431
+
432
+ async def something(e, msg, media, button, reply=True, chat=None):
433
+ if e.client._bot:
434
+ return await e.reply(msg, file=media, buttons=button)
435
+ num = len(STUFF) + 1
436
+ STUFF.update({num: {"msg": msg, "media": media, "button": button}})
437
+ try:
438
+ res = await e.client.inline_query(asst.me.username, f"stf{num}")
439
+ return await res[0].click(
440
+ chat or e.chat_id,
441
+ reply_to=bool(isinstance(e, Message) and reply),
442
+ hide_via=True,
443
+ silent=True,
444
+ )
445
+
446
+ except Exception as er:
447
+ LOGS.exception(er)
plugins/_sendplugin.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # < Source - t.me/testingpluginnn >
2
+ # < https://github.com/TeamUltroid/Ultroid >
3
+
4
+ """
5
+ ✘ **Send any Installed Plugin to the Chat!**
6
+
7
+ >> Use : `{i}cd <plugin_name>`
8
+ """
9
+
10
+ import os
11
+
12
+ from . import *
13
+ async def get_paste(data: str, extension: str = "txt"):
14
+ ssl_context = ssl.create_default_context(cafile=certifi.where())
15
+ json = {"content": data, "extension": extension}
16
+ key = await async_searcher(
17
+ url="https://spaceb.in/api/",
18
+ json=json,
19
+ ssl=ssl_context,
20
+ post=True,
21
+ re_json=True,
22
+ )
23
+ try:
24
+ return True, key["payload"]["id"]
25
+ except KeyError:
26
+ if "the length must be between 2 and 400000." in key["error"]:
27
+ return await get_paste(data[-400000:], extension=extension)
28
+ return False, key["error"]
29
+ except Exception as e:
30
+ LOGS.info(e)
31
+ return None, str(e)
32
+
33
+
34
+ def send(fn):
35
+ lst = ["plugins", "addons"]
36
+ if not fn.endswith(".py"):
37
+ fn += ".py"
38
+ for i in lst:
39
+ path = os.path.join(i, fn)
40
+ if os.path.exists(path):
41
+ return path
42
+ else:
43
+ return
44
+
45
+
46
+ def alt_send(fn):
47
+ import re
48
+ for k, v in LIST.items():
49
+ for fx in v:
50
+ if re.findall(fn, fx):
51
+ return send(k)
52
+ else:
53
+ return
54
+
55
+
56
+ async def pastee(path):
57
+ with open(path, "r") as f:
58
+ data = f.read()
59
+ err, linky = await get_paste(data)
60
+ if err:
61
+ return f"<b>>> <a href='https://spaceb.in/{linky}'>Pasted Here!</a></b> \n"
62
+ else:
63
+ LOGS.error(linky)
64
+ return ""
65
+
66
+
67
+ @ultroid_cmd(pattern="cd ?(.*)")
68
+ async def semd_plugin(ult):
69
+ repo = "https://github.com/xteam-clone r/Userbotx"
70
+ args = ult.pattern_match.group(1)
71
+ if not args:
72
+ return await ult.eod("`Give a modules name too`")
73
+
74
+ eris = await ult.eor("`...`")
75
+ path = send(args)
76
+ if not path:
77
+ path = alt_send(args)
78
+ if not path:
79
+ return await eris.edit(f"No modules were found for: `{args}`")
80
+
81
+ paste = await pastee(path)
82
+ caption = f"<b>>> </b><code>{path}</code> \n{paste} \n" \
83
+ f"© <a href='{repo}'>Userbot</a>"
84
+ try:
85
+ await ult.client.send_file(
86
+ ult.chat_id, path,
87
+ caption=caption, parse_mode="html",
88
+ silent=True, reply_to=ult.reply_to_msg_id,
89
+ )
90
+ await eris.delete()
91
+ except Exception as fx:
92
+ return await eris.edit(str(fx))
plugins/_ultroid.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.errors import (
9
+ BotMethodInvalidError,
10
+ ChatSendInlineForbiddenError,
11
+ ChatSendMediaForbiddenError,
12
+ )
13
+
14
+ from . import LOG_CHANNEL, LOGS, Button, asst, eor, get_string, ultroid_cmd
15
+
16
+ REPOMSG = """
17
+ • **USERBOT** •\n
18
+ • Repo - [Click Here](https://github.com/xteam-cloner/Userbot)
19
+ • Addons - [Click Here](https://github.com/xteam-cloner/Userbot)
20
+ • Support - @xteam_cloner
21
+ """
22
+
23
+ RP_BUTTONS = [
24
+ [
25
+ Button.url(get_string("bot_3"), "https://github.com/xteam-cloner/Userbot"),
26
+ Button.url("Addons", "https://github.com/xteam-cloner/Userbot"),
27
+ ],
28
+ [Button.url("Support Group", "t.me/xteam_cloner")],
29
+ ]
30
+
31
+ ULTSTRING = """🎇 **Thanks for Deploying Userbot!**
32
+
33
+ • Here, are the Some Basic stuff from, where you can Know, about its Usage."""
34
+
35
+
36
+ @ultroid_cmd(
37
+ pattern="repo$",
38
+ manager=True,
39
+ )
40
+ async def repify(e):
41
+ try:
42
+ q = await e.client.inline_query(asst.me.username, "")
43
+ await q[0].click(e.chat_id)
44
+ return await e.delete()
45
+ except (
46
+ ChatSendInlineForbiddenError,
47
+ ChatSendMediaForbiddenError,
48
+ BotMethodInvalidError,
49
+ ):
50
+ pass
51
+ except Exception as er:
52
+ LOGS.info(f"Error while repo command : {str(er)}")
53
+ await e.eor(REPOMSG)
54
+
55
+
56
+ @ultroid_cmd(pattern="userbot$")
57
+ async def useUltroid(rs):
58
+ button = Button.inline("Start >>", "initft_2")
59
+ msg = await asst.send_message(
60
+ LOG_CHANNEL,
61
+ ULTSTRING,
62
+ file="https://telegra.ph/file/8d7b534e34e13316a7dd2.jpg",
63
+ buttons=button,
64
+ )
65
+ if not (rs.chat_id == LOG_CHANNEL and rs.client._bot):
66
+ await eor(rs, f"**[Click Here]({msg.message_link})**")
plugins/_userlogs.py ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 os
9
+ import re
10
+
11
+ from telethon.errors.rpcerrorlist import (
12
+ ChannelPrivateError,
13
+ ChatWriteForbiddenError,
14
+ MediaCaptionTooLongError,
15
+ MediaEmptyError,
16
+ MessageTooLongError,
17
+ PeerIdInvalidError,
18
+ UserNotParticipantError,
19
+ )
20
+ from telethon.tl.types import MessageEntityMention, MessageEntityMentionName, User
21
+ from telethon.utils import get_display_name
22
+
23
+ from xteam.dB.botchat_db import tag_add, who_tag
24
+
25
+ from . import (
26
+ LOG_CHANNEL,
27
+ LOGS,
28
+ Button,
29
+ asst,
30
+ callback,
31
+ events,
32
+ get_string,
33
+ inline_mention,
34
+ udB,
35
+ ultroid_bot,
36
+ )
37
+
38
+ CACHE_SPAM = {}
39
+ TAG_EDITS = {}
40
+
41
+
42
+ @ultroid_bot.on(
43
+ events.NewMessage(
44
+ incoming=True,
45
+ func=lambda e: (e.mentioned),
46
+ ),
47
+ )
48
+ async def all_messages_catcher(e):
49
+ x = await e.get_sender()
50
+ if isinstance(x, User) and (x.bot or x.verified):
51
+ return
52
+ if not udB.get_key("TAG_LOG"):
53
+ return
54
+ NEEDTOLOG = udB.get_key("TAG_LOG")
55
+ buttons = await parse_buttons(e)
56
+ try:
57
+ sent = await asst.send_message(NEEDTOLOG, e.message, buttons=buttons)
58
+ if TAG_EDITS.get(e.chat_id):
59
+ TAG_EDITS[e.chat_id].update({e.id: {"id": sent.id, "msg": e}})
60
+ else:
61
+ TAG_EDITS.update({e.chat_id: {e.id: {"id": sent.id, "msg": e}}})
62
+ tag_add(sent.id, e.chat_id, e.id)
63
+ except MediaEmptyError as er:
64
+ LOGS.debug(f"handling {er}.")
65
+ try:
66
+ msg = await asst.get_messages(e.chat_id, ids=e.id)
67
+ sent = await asst.send_message(NEEDTOLOG, msg, buttons=buttons)
68
+ if TAG_EDITS.get(e.chat_id):
69
+ TAG_EDITS[e.chat_id].update({e.id: {"id": sent.id, "msg": e}})
70
+ else:
71
+ TAG_EDITS.update({e.chat_id: {e.id: {"id": sent.id, "msg": e}}})
72
+ tag_add(sent.id, e.chat_id, e.id)
73
+ except Exception as me:
74
+ if not isinstance(me, (PeerIdInvalidError, ValueError)):
75
+ LOGS.exception(me)
76
+ if e.photo or e.sticker or e.gif:
77
+ try:
78
+ media = await e.download_media()
79
+ sent = await asst.send_message(
80
+ NEEDTOLOG, e.message.text, file=media, buttons=buttons
81
+ )
82
+ if TAG_EDITS.get(e.chat_id):
83
+ TAG_EDITS[e.chat_id].update({e.id: {"id": sent.id, "msg": e}})
84
+ else:
85
+ TAG_EDITS.update({e.chat_id: {e.id: {"id": sent.id, "msg": e}}})
86
+ return os.remove(media)
87
+ except Exception as er:
88
+ LOGS.exception(er)
89
+ await asst.send_message(NEEDTOLOG, get_string("com_4"), buttons=buttons)
90
+ except (PeerIdInvalidError, ValueError) as er:
91
+ LOGS.exception(er)
92
+ try:
93
+ CACHE_SPAM[NEEDTOLOG]
94
+ except KeyError:
95
+ await asst.send_message(
96
+ udB.get_key("LOG_CHANNEL"), get_string("userlogs_1")
97
+ )
98
+ CACHE_SPAM.update({NEEDTOLOG: True})
99
+ except ChatWriteForbiddenError:
100
+ try:
101
+ await asst.get_permissions(NEEDTOLOG, "me")
102
+ MSG = get_string("userlogs_4")
103
+ except UserNotParticipantError:
104
+ MSG = get_string("userlogs_2")
105
+ try:
106
+ CACHE_SPAM[NEEDTOLOG]
107
+ except KeyError:
108
+ await asst.send_message(LOG_CHANNEL, MSG)
109
+ CACHE_SPAM.update({NEEDTOLOG: True})
110
+ except Exception as er:
111
+ LOGS.exception(er)
112
+
113
+
114
+ if udB.get_key("TAG_LOG"):
115
+
116
+ @ultroid_bot.on(events.MessageEdited(func=lambda x: not x.out))
117
+ async def upd_edits(event):
118
+ x = event.sender
119
+ if isinstance(x, User) and (x.bot or x.verified):
120
+ return
121
+ if event.chat_id not in TAG_EDITS:
122
+ if event.sender_id == udB.get_key("TAG_LOG"):
123
+ return
124
+ if event.is_private:
125
+ return
126
+ if entities := event.get_entities_text():
127
+ is_self = False
128
+ username = event.client.me.username
129
+ if username:
130
+ username = username.lower()
131
+ for ent, text in entities:
132
+ if isinstance(ent, MessageEntityMention):
133
+ is_self = text[1:].lower() == username
134
+ elif isinstance(ent, MessageEntityMentionName):
135
+ is_self = ent.user_id == event.client.me.id
136
+ if is_self:
137
+ text = f"**#Edited & #Mentioned**\n\n{event.text}"
138
+ try:
139
+ sent = await asst.send_message(
140
+ udB.get_key("TAG_LOG"),
141
+ text,
142
+ buttons=await parse_buttons(event),
143
+ )
144
+ except Exception as er:
145
+ return LOGS.exception(er)
146
+ if TAG_EDITS.get(event.chat_id):
147
+ TAG_EDITS[event.chat_id].update({event.id: {"id": sent.id}})
148
+ else:
149
+ TAG_EDITS.update({event.chat_id: {event.id: {"id": sent.id}}})
150
+ return
151
+ d_ = TAG_EDITS[event.chat_id]
152
+ if not d_.get(event.id):
153
+ return
154
+ d_ = d_[event.id]
155
+ if d_["msg"].text == event.text:
156
+ return
157
+ msg = None
158
+ if d_.get("count"):
159
+ d_["count"] += 1
160
+ else:
161
+ msg = True
162
+ d_.update({"count": 1})
163
+ if d_["count"] > 10:
164
+ return # some limit to take edits
165
+ try:
166
+ MSG = await asst.get_messages(udB.get_key("TAG_LOG"), ids=d_["id"])
167
+ except Exception as er:
168
+ return LOGS.exception(er)
169
+ TEXT = MSG.text
170
+ if msg:
171
+ TEXT += "\n\n🖋 **Later Edited to !**"
172
+ strf = event.edit_date.strftime("%H:%M:%S")
173
+ if "\n" not in event.text:
174
+ TEXT += f"\n• `{strf}` : {event.text}"
175
+ else:
176
+ TEXT += f"\n• `{strf}` :\n-> {event.text}"
177
+ if d_["count"] == 10:
178
+ TEXT += "\n\n• __Only the first 10 Edits are shown.__"
179
+ try:
180
+ msg = await MSG.edit(TEXT, buttons=await parse_buttons(event))
181
+ d_["msg"] = msg
182
+ except (MessageTooLongError, MediaCaptionTooLongError):
183
+ del TAG_EDITS[event.chat_id][event.id]
184
+ except Exception as er:
185
+ LOGS.exception(er)
186
+
187
+ @ultroid_bot.on(
188
+ events.NewMessage(
189
+ outgoing=True,
190
+ chats=[udB.get_key("TAG_LOG")],
191
+ func=lambda e: e.reply_to,
192
+ )
193
+ )
194
+ async def idk(e):
195
+ id = e.reply_to_msg_id
196
+ chat, msg = who_tag(id)
197
+ if chat and msg:
198
+ try:
199
+ await ultroid_bot.send_message(chat, e.message, reply_to=msg)
200
+ except BaseException as er:
201
+ LOGS.exception(er)
202
+
203
+
204
+ # log for assistant/user joins/add
205
+
206
+
207
+ async def when_added_or_joined(event):
208
+ user = await event.get_user()
209
+ chat = await event.get_chat()
210
+ if not (user and user.is_self):
211
+ return
212
+ if getattr(chat, "username", None):
213
+ chat = f"[{chat.title}](https://t.me/{chat.username}/{event.action_message.id})"
214
+ else:
215
+ chat = f"[{chat.title}](https://t.me/c/{chat.id}/{event.action_message.id})"
216
+ key = "bot" if event.client._bot else "user"
217
+ buttons = Button.inline(
218
+ get_string("userlogs_3"), data=f"leave_ch_{event.chat_id}|{key}"
219
+ )
220
+ if event.user_added:
221
+ tmp = event.added_by
222
+ text = f"#ADD_LOG\n\n{inline_mention(tmp)} just added {inline_mention(user)} to {chat}."
223
+ elif event.from_request:
224
+ text = f"#APPROVAL_LOG\n\n{inline_mention(user)} just got Chat Join Approval to {chat}."
225
+ else:
226
+ text = f"#JOIN_LOG\n\n{inline_mention(user)} just joined {chat}."
227
+ await asst.send_message(udB.get_key("LOG_CHANNEL"), text, buttons=buttons)
228
+
229
+
230
+ asst.add_event_handler(
231
+ when_added_or_joined, events.ChatAction(func=lambda x: x.user_added)
232
+ )
233
+ ultroid_bot.add_event_handler(
234
+ when_added_or_joined,
235
+ events.ChatAction(func=lambda x: x.user_added or x.user_joined),
236
+ )
237
+ _client = {"bot": asst, "user": ultroid_bot}
238
+
239
+
240
+ @callback(
241
+ re.compile(
242
+ "leave_ch_(.*)",
243
+ ),
244
+ from_users=[ultroid_bot.uid],
245
+ )
246
+ async def leave_ch_at(event):
247
+ cht = event.data_match.group(1).decode("UTF-8")
248
+ ch_id, client = cht.split("|")
249
+ try:
250
+ client = _client[client]
251
+ except KeyError:
252
+ return
253
+ try:
254
+ name = (await client.get_entity(int(ch_id))).title
255
+ await client.delete_dialog(int(ch_id))
256
+ except UserNotParticipantError:
257
+ pass
258
+ except ChannelPrivateError:
259
+ return await event.edit(
260
+ "`[CANT_ACCESS_CHAT]` `Maybe already left or got banned.`"
261
+ )
262
+ except Exception as er:
263
+ LOGS.exception(er)
264
+ return await event.answer(str(er))
265
+ await event.edit(get_string("userlogs_5").format(name))
266
+
267
+
268
+ @callback("do_nothing")
269
+ async def _(event):
270
+ await event.answer()
271
+
272
+
273
+ async def parse_buttons(event):
274
+ y, x = event.chat, event.sender
275
+ where_n, who_n = get_display_name(y), get_display_name(x)
276
+ where_l = event.message_link
277
+ buttons = [[Button.url(where_n, where_l)]]
278
+ if isinstance(x, User) and x.username:
279
+ try:
280
+ buttons.append(
281
+ [Button.mention(who_n, await asst.get_input_entity(x.username))]
282
+ )
283
+ except Exception as er:
284
+ LOGS.exception(er)
285
+ buttons.append([Button.url(who_n, f"t.me/{x.username}")])
286
+ elif getattr(x, "username"):
287
+ buttons.append([Button.url(who_n, f"t.me/{x.username}")])
288
+ else:
289
+ buttons.append([Button.url(who_n, where_l)])
290
+ replied = await event.get_reply_message()
291
+ if replied and replied.out:
292
+ button = Button.url("Replied to", replied.message_link)
293
+ if len(who_n) > 7:
294
+ buttons.append([button])
295
+ else:
296
+ buttons[-1].append(button)
297
+ return buttons
plugins/_wspr.py ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 telethon import Button
11
+ from telethon.errors.rpcerrorlist import (
12
+ BotInlineDisabledError,
13
+ BotResponseTimeoutError,
14
+ MessageNotModifiedError,
15
+ )
16
+ from telethon.tl import types
17
+ from telethon.tl.functions.users import GetFullUserRequest as gu
18
+
19
+ from . import (
20
+ HNDLR,
21
+ LOGS,
22
+ asst,
23
+ callback,
24
+ get_string,
25
+ in_pattern,
26
+ inline_mention,
27
+ ultroid_bot,
28
+ ultroid_cmd,
29
+ )
30
+
31
+ buddhhu = {}
32
+
33
+
34
+ @ultroid_cmd(
35
+ pattern="wspr( (.*)|$)",
36
+ )
37
+ async def _(e):
38
+ if e.reply_to_msg_id:
39
+ okk = await e.get_reply_message()
40
+ put = f"@{okk.sender.username}" if okk.sender.username else okk.sender_id
41
+ else:
42
+ put = e.pattern_match.group(1).strip()
43
+ if put:
44
+ try:
45
+ results = await e.client.inline_query(asst.me.username, f"msg {put}")
46
+ except BotResponseTimeoutError:
47
+ return await e.eor(
48
+ get_string("help_2").format(HNDLR),
49
+ )
50
+ except BotInlineDisabledError:
51
+ return await e.eor(get_string("help_3"))
52
+ await results[0].click(e.chat_id, reply_to=e.reply_to_msg_id, hide_via=True)
53
+ return await e.delete()
54
+ await e.eor(get_string("wspr_3"))
55
+
56
+
57
+ @in_pattern("wspr", owner=True)
58
+ async def _(e):
59
+ iuser = e.query.user_id
60
+ zzz = e.text.split(maxsplit=2)
61
+ try:
62
+ query = zzz[1]
63
+ if query.isdigit():
64
+ query = int(query)
65
+ logi = await ultroid_bot.get_entity(query)
66
+ if not isinstance(logi, types.User):
67
+ raise ValueError("Invalid Username.")
68
+ except IndexError:
69
+ sur = await e.builder.article(
70
+ title="Give Username",
71
+ description="You Didn't Type Username or id.",
72
+ text="You Didn't Type Username or id.",
73
+ )
74
+ return await e.answer([sur])
75
+ except ValueError as er:
76
+ LOGS.exception(er)
77
+ sur = await e.builder.article(
78
+ title="User Not Found",
79
+ description="Make sure username or id is correct.",
80
+ text="Make sure username or id is correct.",
81
+ )
82
+ return await e.answer([sur])
83
+ try:
84
+ desc = zzz[2]
85
+ except IndexError:
86
+ sur = await e.builder.article(
87
+ title="Type ur msg", text="You Didn't Type Your Msg"
88
+ )
89
+ return await e.answer([sur])
90
+ button = [
91
+ [
92
+ Button.inline("Secret Msg", data=f"dd_{e.id}"),
93
+ Button.inline("Delete Msg", data=f"del_{e.id}"),
94
+ ],
95
+ [
96
+ Button.switch_inline(
97
+ "New", query=f"wspr {logi.username or logi.id}", same_peer=True
98
+ )
99
+ ],
100
+ ]
101
+ us = logi.username or logi.first_name
102
+ sur = await e.builder.article(
103
+ title=logi.first_name,
104
+ description=desc,
105
+ text=get_string("wspr_1").format(us),
106
+ buttons=button,
107
+ )
108
+ buddhhu.update({e.id: [logi.id, iuser, desc]})
109
+ await e.answer([sur])
110
+
111
+
112
+ @in_pattern("msg", owner=True)
113
+ async def _(e):
114
+ zzz = e.text.split(maxsplit=1)
115
+ desc = "Touch me"
116
+ try:
117
+ query = zzz[1]
118
+ if query.isdigit():
119
+ query = int(query)
120
+ logi = await ultroid_bot(gu(id=query))
121
+ user = logi.users[0]
122
+ mention = inline_mention(user)
123
+ x = user.status
124
+ if isinstance(x, types.UserStatusOnline):
125
+ status = "Online"
126
+ elif isinstance(x, types.UserStatusOffline):
127
+ status = "Offline"
128
+ elif isinstance(x, types.UserStatusRecently):
129
+ status = "Last Seen Recently"
130
+ elif isinstance(x, types.UserStatusLastMonth):
131
+ status = "Last seen months ago"
132
+ elif isinstance(x, types.UserStatusLastWeek):
133
+ status = "Last seen weeks ago"
134
+ else:
135
+ status = "Can't Tell"
136
+ text = f"**Name:** `{user.first_name}`\n"
137
+ text += f"**Id:** `{user.id}`\n"
138
+ if user.username:
139
+ text += f"**Username:** `{user.username}`\n"
140
+ url = f"https://t.me/{user.username}"
141
+ else:
142
+ text += f"**Mention:** `{mention}`\n"
143
+ url = f"tg://user?id={user.id}"
144
+ text += f"**Status:** `{status}`\n"
145
+ text += f"**About:** `{logi.full_user.about}`"
146
+ button = [
147
+ Button.url("Private", url=url),
148
+ Button.switch_inline(
149
+ "Secret msg",
150
+ query=f"wspr {query} Hello 👋",
151
+ same_peer=True,
152
+ ),
153
+ ]
154
+ sur = e.builder.article(
155
+ title=user.first_name,
156
+ description=desc,
157
+ text=text,
158
+ buttons=button,
159
+ )
160
+ except IndexError:
161
+ sur = e.builder.article(
162
+ title="Give Username",
163
+ description="You Didn't Type Username or id.",
164
+ text="You Didn't Type Username or id.",
165
+ )
166
+ except BaseException as er:
167
+ LOGS.exception(er)
168
+ name = get_string("wspr_4").format(query)
169
+ sur = e.builder.article(
170
+ title=name,
171
+ text=name,
172
+ )
173
+
174
+ await e.answer([sur])
175
+
176
+
177
+ @callback(
178
+ re.compile(
179
+ "dd_(.*)",
180
+ ),
181
+ )
182
+ async def _(e):
183
+ ids = int(e.pattern_match.group(1).strip().decode("UTF-8"))
184
+ if buddhhu.get(ids):
185
+ if e.sender_id in buddhhu[ids]:
186
+ await e.answer(buddhhu[ids][-1], alert=True)
187
+ else:
188
+ await e.answer("Not For You", alert=True)
189
+ else:
190
+ await e.answer(get_string("wspr_2"), alert=True)
191
+
192
+
193
+ @callback(re.compile("del_(.*)"))
194
+ async def _(e):
195
+ ids = int(e.pattern_match.group(1).strip().decode("UTF-8"))
196
+ if buddhhu.get(ids):
197
+ if e.sender_id in buddhhu[ids]:
198
+ buddhhu.pop(ids)
199
+ try:
200
+ await e.edit(get_string("wspr_2"))
201
+ except MessageNotModifiedError:
202
+ pass
203
+ else:
204
+ await e.answer(get_string("wspr_5"), alert=True)
plugins/absen.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ayiin - Userbot
2
+ # Copyright (C) 2022-2023 @AyiinXd
3
+ #
4
+ # This file is a part of < https://github.com/AyiinXd/Ayiin-Userbot >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/AyiinXd/Ayiin-Userbot/blob/main/LICENSE/>.
7
+ #
8
+ # FROM Ayiin-Userbot <https://github.com/AyiinXd/Ayiin-Userbot>
9
+ # t.me/AyiinXdSupport & t.me/AyiinSupport
10
+
11
+ # ========================×========================
12
+ # Jangan Hapus Credit Ngentod
13
+ # ========================×========================
14
+
15
+ import time
16
+ from datetime import datetime
17
+ from secrets import choice
18
+ from xteam.dB import devs
19
+ from telethon.tl.types import User
20
+ from xteam._misc import sudoers
21
+ from . import ultroid_cmd as ayiinCmd
22
+ from . import (
23
+ ATRA_COL,
24
+ LOGS,
25
+ OWNER_NAME,
26
+ ULTROID_IMAGES,
27
+ Button,
28
+ Carbon,
29
+ Telegraph,
30
+ Var,
31
+ allcmds,
32
+ asst,
33
+ bash,
34
+ call_back,
35
+ callback,
36
+ def_logs,
37
+ eor,
38
+ get_string,
39
+ heroku_logs,
40
+ in_pattern,
41
+ inline_pic,
42
+ restart,
43
+ shutdown,
44
+ start_time,
45
+ time_formatter,
46
+ udB,
47
+ ultroid_version,
48
+ updater,
49
+ )
50
+
51
+ absen = [
52
+ "**𝙃𝙖𝙙𝙞𝙧 𝙙𝙤𝙣𝙜 𝙏𝙤𝙙** 😁",
53
+ "**𝙃𝙖𝙙𝙞𝙧 𝙆𝙖𝙠𝙖 𝙂𝙖𝙣𝙩𝙚𝙣𝙜** 😉",
54
+ "**𝙂𝙪𝙖 𝙃𝙖𝙙𝙞𝙧 𝘾𝙤𝙣𝙩𝙤𝙡** 😁",
55
+ "**𝙂𝙪𝙖 𝙃𝙖𝙙𝙞𝙧 𝙂𝙖𝙣𝙩𝙚𝙣𝙜** 🥵",
56
+ "**𝙃𝙖𝙙𝙞𝙧 𝙉𝙜𝙖𝙗** 😎",
57
+ "**𝙂𝙪𝙖 𝙃𝙖𝙙𝙞𝙧 𝘼𝙗𝙖𝙣𝙜** 🥺",
58
+ "**𝙎𝙞 𝘾𝙖𝙠𝙚𝙥 𝙃𝙖𝙙𝙞𝙧 𝘽𝙖𝙣𝙜** 😎",
59
+ ]
60
+
61
+ ayiincakep = [
62
+ "**𝙄𝙮𝙖 𝙂𝙖𝙣𝙩𝙚𝙣𝙜 𝘽𝙖𝙣𝙜𝙚𝙩** 😍",
63
+ "**𝙂𝙖𝙣𝙩𝙚𝙣𝙜𝙣𝙮𝙖 𝙂𝙖𝙠 𝘼𝙙𝙖 𝙇𝙖𝙬𝙖𝙣** 😚",
64
+ "**𝙠𝙖𝙢𝙪 𝙂𝙖𝙣𝙩𝙚𝙣𝙜𝙣𝙮𝙖 𝘼𝙠𝙪 𝙆𝙖𝙣** 😍",
65
+ "**𝙞𝙮𝙖𝙖 𝙜𝙖𝙙𝙖 𝙖𝙙𝙖 𝙨𝙖𝙞𝙣𝙜** 😎",
66
+ "**𝙠𝙖𝙢𝙪 𝙟𝙖𝙢𝙚𝙩 𝙏𝙖𝙥𝙞 𝘽𝙤𝙤𝙣𝙜** 😚",
67
+ ]
68
+
69
+
70
+ @ayiinCmd("cping$", devs=True)
71
+ async def _(ping):
72
+ start = time.time()
73
+ x = await ping.eor("Pong !")
74
+ end = round((time.time() - start) * 1000)
75
+ uptime = time_formatter((time.time() - start_time) * 1000)
76
+ user = await ping.client.get_me()
77
+ message = "**✧ ᴀʏɪɪɴ-ᴜsᴇʀʙᴏᴛ ✧**\n\n✧ **ᴘɪɴɢᴇʀ :** `{} ms`\n✧ **ᴜᴘᴛɪᴍᴇ :** `{}`\n✧ **ᴏᴡɴᴇʀ :** `{}`\n✧ **ɪᴅ :** `{}`"
78
+ await ping.reply(
79
+ message.format(
80
+ end,
81
+ uptime,
82
+ user.first_name,
83
+ user.id
84
+ )
85
+ )
86
+
87
+
88
+ # KALO NGEFORK absen ini GA USAH DI HAPUS YA GOBLOK 😡
89
+ # JANGAN DI HAPUS GOBLOK 😡 LU COPY AJA TINGGAL TAMBAHIN
90
+ # DI HAPUS GUA GBAN YA 🥴 GUA TANDAIN LU AKUN TELENYA 😡
91
+
92
+ # Absen by : mrismanaziz <https://github.com/mrismanaziz/man-userbot>
93
+
94
+ @ayiinCmd("absen$", devs=True)
95
+ async def ayiinabsen(ganteng):
96
+ await ganteng.reply(choice(absen))
97
+
98
+
99
+ @ayiinCmd("Aku ganteng kan$", devs=True)
100
+ async def ayiin(ganteng):
101
+ await ganteng.reply(choice(ayiincakep))
102
+
103
+
104
+ # ========================×========================
105
+ # Jangan Hapus Credit Ngentod
106
+ # ========================×========================
107
+
plugins/admintools.py ADDED
@@ -0,0 +1,472 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 . import get_help
9
+
10
+ __doc__ = get_help("help_admintools")
11
+
12
+ import asyncio
13
+
14
+ from telethon.errors import BadRequestError
15
+ from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidError
16
+ from telethon.tl.functions.channels import EditAdminRequest, GetFullChannelRequest
17
+ from telethon.tl.functions.messages import GetFullChatRequest, SetHistoryTTLRequest
18
+ from telethon.tl.types import InputMessagesFilterPinned
19
+ from telethon.utils import get_display_name
20
+
21
+ from xteam.dB import DEVLIST
22
+ from xteam.fns.admins import ban_time
23
+ from xteam.fns.info import get_uinfo
24
+
25
+ from . import HNDLR, LOGS, eod, eor, get_string, inline_mention, types, ultroid_cmd
26
+
27
+
28
+ @ultroid_cmd(
29
+ pattern="promote( (.*)|$)",
30
+ admins_only=True,
31
+ manager=True,
32
+ require="add_admins",
33
+ fullsudo=True,
34
+ )
35
+ async def prmte(ult):
36
+ xx = await ult.eor(get_string("com_1"))
37
+ user, rank = await get_uinfo(ult)
38
+ rank = rank or "Admin"
39
+ FullRight = False
40
+ if not user:
41
+ return await xx.edit(get_string("pro_1"))
42
+ if rank.split()[0] == "-f":
43
+ try:
44
+ rank = rank.split(maxsplit=1)[1]
45
+ except IndexError:
46
+ rank = "Admin"
47
+ FullRight = True
48
+ try:
49
+ if FullRight:
50
+ await ult.client(
51
+ EditAdminRequest(ult.chat_id, user.id, ult.chat.admin_rights, rank)
52
+ )
53
+ else:
54
+ await ult.client.edit_admin(
55
+ ult.chat_id,
56
+ user.id,
57
+ invite_users=True,
58
+ ban_users=True,
59
+ delete_messages=True,
60
+ pin_messages=True,
61
+ manage_call=True,
62
+ title=rank,
63
+ )
64
+ await eod(
65
+ xx, get_string("pro_2").format(inline_mention(user), ult.chat.title, rank)
66
+ )
67
+ except Exception as ex:
68
+ return await xx.edit(f"`{ex}`")
69
+
70
+
71
+ @ultroid_cmd(
72
+ pattern="demote( (.*)|$)",
73
+ admins_only=True,
74
+ manager=True,
75
+ require="add_admins",
76
+ fullsudo=True,
77
+ )
78
+ async def dmote(ult):
79
+ xx = await ult.eor(get_string("com_1"))
80
+ user, rank = await get_uinfo(ult)
81
+ if not rank:
82
+ rank = "Not Admin"
83
+ if not user:
84
+ return await xx.edit(get_string("de_1"))
85
+ try:
86
+ await ult.client.edit_admin(
87
+ ult.chat_id,
88
+ user.id,
89
+ invite_users=None,
90
+ ban_users=None,
91
+ delete_messages=None,
92
+ pin_messages=None,
93
+ manage_call=None,
94
+ title=rank,
95
+ )
96
+ await eod(xx, get_string("de_2").format(inline_mention(user), ult.chat.title))
97
+ except Exception as ex:
98
+ return await xx.edit(f"`{ex}`")
99
+
100
+
101
+ @ultroid_cmd(
102
+ pattern="ban( (.*)|$)",
103
+ admins_only=True,
104
+ manager=True,
105
+ require="ban_users",
106
+ fullsudo=True,
107
+ )
108
+ async def bban(ult):
109
+ something = await get_uinfo(ult)
110
+ if not something:
111
+ return
112
+ user, reason = something
113
+ if not user:
114
+ return await eod(ult, get_string("ban_1"))
115
+ if user.id in DEVLIST:
116
+ return await eod(ult, get_string("ban_2"))
117
+ try:
118
+ await ult.client.edit_permissions(ult.chat_id, user.id, view_messages=False)
119
+ except UserIdInvalidError:
120
+ return await eod(ult, get_string("adm_1"))
121
+ except BadRequestError:
122
+ return await eod(ult, get_string("ban_3"))
123
+ senderme = inline_mention(await ult.get_sender())
124
+ userme = inline_mention(user)
125
+ text = get_string("ban_4").format(userme, senderme, ult.chat.title)
126
+ if reason:
127
+ text += get_string("ban_5").format(reason)
128
+ await eod(ult, text)
129
+
130
+
131
+ @ultroid_cmd(
132
+ pattern="unban( (.*)|$)",
133
+ admins_only=True,
134
+ manager=True,
135
+ require="ban_users",
136
+ fullsudo=True,
137
+ )
138
+ async def uunban(ult):
139
+ xx = await ult.eor(get_string("com_1"))
140
+ if ult.text[1:].startswith("unbanall"):
141
+ return
142
+ something = await get_uinfo(ult)
143
+ if not something:
144
+ return
145
+ user, reason = something
146
+ if not user:
147
+ return await xx.edit(get_string("unban_1"))
148
+ try:
149
+ await ult.client.edit_permissions(ult.chat_id, user.id, view_messages=True)
150
+ except UserIdInvalidError:
151
+ return await eod(ult, get_string("adm_1"))
152
+ except BadRequestError:
153
+ return await xx.edit(get_string("adm_2"))
154
+ sender = inline_mention(await ult.get_sender())
155
+ text = get_string("unban_3").format(inline_mention(user), sender, ult.chat.title)
156
+ if reason:
157
+ text += get_string("ban_5").format(reason)
158
+ await xx.edit(text)
159
+
160
+
161
+ @ultroid_cmd(
162
+ pattern="kick( (.*)|$)",
163
+ manager=True,
164
+ require="ban_users",
165
+ fullsudo=True,
166
+ )
167
+ async def kck(ult):
168
+ if "kickme" in ult.text:
169
+ return
170
+ if ult.is_private:
171
+ return await ult.eor("`Use this in Group/Channel.`", time=5)
172
+ ml = ult.text.split(" ", maxsplit=1)[0]
173
+ xx = await ult.eor(get_string("com_1"))
174
+ something = await get_uinfo(ult)
175
+ if not something:
176
+ return
177
+ user, reason = something
178
+ if not user:
179
+ return await xx.edit(get_string("adm_1"))
180
+ if user.id in DEVLIST:
181
+ return await xx.edit(get_string("kick_2"))
182
+ if getattr(user, "is_self", False):
183
+ return await xx.edit(get_string("kick_3"))
184
+ try:
185
+ await ult.client.kick_participant(ult.chat_id, user.id)
186
+ except BadRequestError as er:
187
+ LOGS.info(er)
188
+ return await xx.edit(get_string("kick_1"))
189
+ except Exception as e:
190
+ LOGS.exception(e)
191
+ return
192
+ text = get_string("kick_4").format(
193
+ inline_mention(user), inline_mention(await ult.get_sender()), ult.chat.title
194
+ )
195
+ if reason:
196
+ text += get_string("ban_5").format(reason)
197
+ await xx.edit(text)
198
+
199
+
200
+ @ultroid_cmd(
201
+ pattern="tban( (.*)|$)",
202
+ admins_only=True,
203
+ manager=True,
204
+ require="ban_users",
205
+ fullsudo=True,
206
+ )
207
+ async def tkicki(e):
208
+ huh = e.text.split()
209
+ inputt = None
210
+ try:
211
+ tme = huh[1]
212
+ except IndexError:
213
+ return await e.eor(get_string("adm_3"), time=15)
214
+ try:
215
+ inputt = huh[2]
216
+ except IndexError:
217
+ if e.reply_to_msg_id:
218
+ inputt = (await e.get_reply_message()).sender_id
219
+ if not inputt:
220
+ return await e.eor(get_string("tban_1"))
221
+ userid = await e.client.parse_id(inputt)
222
+ try:
223
+ user = await e.client.get_entity(userid)
224
+ except Exception as ex:
225
+ return await eor(e, f"`{ex}`")
226
+ try:
227
+ bun = ban_time(tme)
228
+ await e.client.edit_permissions(
229
+ e.chat_id, user.id, until_date=bun, view_messages=False
230
+ )
231
+ await eod(
232
+ e,
233
+ get_string("tban_2").format(inline_mention(user), e.chat.title, tme),
234
+ time=15,
235
+ )
236
+ except Exception as m:
237
+ return await e.eor(str(m))
238
+
239
+
240
+ @ultroid_cmd(pattern="pin$", manager=True, require="pin_messages", fullsudo=True)
241
+ async def pin(msg):
242
+ if not msg.is_reply:
243
+ return await eor(msg, get_string("pin_1"))
244
+ me = await msg.get_reply_message()
245
+ if me.is_private:
246
+ text = "`Pinned.`"
247
+ else:
248
+ text = f"Pinned [This Message]({me.message_link}) !"
249
+ try:
250
+ await msg.client.pin_message(msg.chat_id, me.id, notify=False)
251
+ except BadRequestError:
252
+ return await eor(msg, get_string("adm_2"))
253
+ except Exception as e:
254
+ return await eor(msg, f"**ERROR:**`{e}`")
255
+ await eor(msg, text)
256
+
257
+
258
+ @ultroid_cmd(
259
+ pattern="unpin($| (.*))",
260
+ manager=True,
261
+ require="pin_messages",
262
+ fullsudo=True,
263
+ )
264
+ async def unp(ult):
265
+ xx = await ult.eor(get_string("com_1"))
266
+ ch = (ult.pattern_match.group(1).strip()).strip()
267
+ msg = None
268
+ if ult.is_reply:
269
+ msg = ult.reply_to_msg_id
270
+ elif ch != "all":
271
+ return await xx.edit(get_string("unpin_1").format(HNDLR))
272
+ try:
273
+ await ult.client.unpin_message(ult.chat_id, msg)
274
+ except BadRequestError:
275
+ return await xx.edit(get_string("adm_2"))
276
+ except Exception as e:
277
+ return await xx.edit(f"**ERROR:**`{e}`")
278
+ await xx.edit("`Unpinned!`")
279
+
280
+
281
+ @ultroid_cmd(
282
+ pattern="tpin( (.*)|$)",
283
+ admins_only=True,
284
+ manager=True,
285
+ require="pin_messages",
286
+ fullsudo=True,
287
+ )
288
+ async def pin_message(ult):
289
+ match = ult.pattern_match.group(1).strip()
290
+ if not ult.is_reply:
291
+ return await ult.eor("`Reply to message..`", time=6)
292
+ if not match:
293
+ return await ult.eor("`Please provide time..`", time=8)
294
+ msg = await ult.eor(get_string("com_1"))
295
+ msg_id = ult.reply_to_msg_id
296
+ try:
297
+ time = ban_time(match)
298
+ await ult.client.pin_message(ult.chat_id, msg_id)
299
+ await msg.eor(f"`pinned for time` `{time}`", time=8)
300
+ except Exception as er:
301
+ return await msg.edit(str(er))
302
+ await asyncio.sleep(time)
303
+ try:
304
+ await ult.client.unpin_message(ult.chat_id, msg_id)
305
+ except Exception as er:
306
+ LOGS.exception(er)
307
+
308
+
309
+ @ultroid_cmd(pattern="purge( (.*)|$)", manager=True, require="delete_messages")
310
+ async def fastpurger(purg):
311
+ match = purg.pattern_match.group(1).strip()
312
+ try:
313
+ ABC = purg.text[6]
314
+ except IndexError:
315
+ ABC = None
316
+ if ABC and purg.text[6] in ["m", "a"]:
317
+ return
318
+ if not purg._client._bot and (
319
+ (match)
320
+ or (purg.is_reply and (purg.is_private or isinstance(purg.chat, types.Chat)))
321
+ ):
322
+ p = 0
323
+ async for msg in purg.client.iter_messages(
324
+ purg.chat_id,
325
+ limit=int(match) if match else None,
326
+ min_id=purg.reply_to_msg_id if purg.is_reply else None,
327
+ ):
328
+ await msg.delete()
329
+ p += 0
330
+ return await eor(purg, f"Purged {p} Messages! ", time=5)
331
+ if not purg.reply_to_msg_id:
332
+ return await eor(purg, get_string("purge_1"), time=10)
333
+ try:
334
+ await purg.client.delete_messages(
335
+ purg.chat_id, list(range(purg.reply_to_msg_id, purg.id))
336
+ )
337
+
338
+ except Exception as er:
339
+ LOGS.info(er)
340
+ await purg.eor("__Fast purge complete!__", time=5)
341
+
342
+
343
+ @ultroid_cmd(
344
+ pattern="purgeme( (.*)|$)",
345
+ )
346
+ async def fastpurgerme(purg):
347
+ if num := purg.pattern_match.group(1).strip():
348
+ try:
349
+ nnt = int(num)
350
+ except BaseException:
351
+ await eor(purg, get_string("com_3"), time=5)
352
+ return
353
+ mp = 0
354
+ async for mm in purg.client.iter_messages(
355
+ purg.chat_id, limit=nnt, from_user="me"
356
+ ):
357
+ await mm.delete()
358
+ mp += 1
359
+ await eor(purg, f"Purged {mp} Messages!", time=5)
360
+ return
361
+ elif not purg.reply_to_msg_id:
362
+ return await eod(
363
+ purg,
364
+ "`Reply to a message to purge from or use it like ``purgeme <num>`",
365
+ time=10,
366
+ )
367
+ chat = await purg.get_input_chat()
368
+ msgs = []
369
+ async for msg in purg.client.iter_messages(
370
+ chat,
371
+ from_user="me",
372
+ min_id=purg.reply_to_msg_id,
373
+ ):
374
+ msgs.append(msg)
375
+ if msgs:
376
+ await purg.client.delete_messages(chat, msgs)
377
+ await purg.eor(
378
+ "__Fast purge complete!__\n**Purged** `" + str(len(msgs)) + "` **messages.**",
379
+ time=5,
380
+ )
381
+
382
+
383
+ @ultroid_cmd(
384
+ pattern="purgeall$",
385
+ )
386
+ async def _(e):
387
+ if not e.is_reply:
388
+ return await eod(
389
+ e,
390
+ get_string("purgeall_1"),
391
+ )
392
+
393
+ msg = await e.get_reply_message()
394
+ name = msg.sender
395
+ try:
396
+ await e.client.delete_messages(e.chat_id, from_user=msg.sender_id)
397
+ await e.eor(get_string("purgeall_2").format(name.first_name), time=5)
398
+ except Exception as er:
399
+ return await e.eor(str(er), time=5)
400
+
401
+
402
+ @ultroid_cmd(pattern="pinned", manager=True, groups_only=True)
403
+ async def djshsh(event):
404
+ chat = await event.get_chat()
405
+ if isinstance(chat, types.Chat):
406
+ FChat = await event.client(GetFullChatRequest(chat.id))
407
+ elif isinstance(chat, types.Channel):
408
+ FChat = await event.client(GetFullChannelRequest(chat.id))
409
+ else:
410
+ return
411
+ msg_id = FChat.full_chat.pinned_msg_id
412
+ if not msg_id:
413
+ return await event.eor(get_string("pinned_1"))
414
+ msg = await event.client.get_messages(chat.id, ids=msg_id)
415
+ if msg:
416
+ await event.eor(get_string("pinned_2").format(msg.message_link))
417
+
418
+
419
+ @ultroid_cmd(
420
+ pattern="listpinned$",
421
+ )
422
+ async def get_all_pinned(event):
423
+ x = await event.eor(get_string("com_1"))
424
+ chat_id = (str(event.chat_id)).replace("-100", "")
425
+ chat_name = get_display_name(event.chat)
426
+ a = ""
427
+ c = 1
428
+ async for i in event.client.iter_messages(
429
+ event.chat_id, filter=InputMessagesFilterPinned
430
+ ):
431
+ if i.message:
432
+ t = " ".join(i.message.split()[:4])
433
+ txt = f"{t}...."
434
+ else:
435
+ txt = "Go to message."
436
+ a += f"{c}. <a href=https://t.me/c/{chat_id}/{i.id}>{txt}</a>\n"
437
+ c += 1
438
+
439
+ if c == 1:
440
+ m = f"<b>The pinned message in {chat_name}:</b>\n\n"
441
+ else:
442
+ m = f"<b>List of pinned message(s) in {chat_name}:</b>\n\n"
443
+
444
+ if not a:
445
+ return await eor(x, get_string("listpin_1"), time=5)
446
+
447
+ await x.edit(m + a, parse_mode="html")
448
+
449
+
450
+ @ultroid_cmd(
451
+ pattern="autodelete( (.*)|$)",
452
+ admins_only=True,
453
+ )
454
+ async def autodelte(ult):
455
+ match = ult.pattern_match.group(1).strip()
456
+ if not match or match not in ["24h", "7d", "1m", "off"]:
457
+ return await ult.eor("`Please Use in Proper Format..`", time=5)
458
+ if match == "24h":
459
+ tt = 3600 * 24
460
+ elif match == "7d":
461
+ tt = 3600 * 24 * 7
462
+ elif match == "1m":
463
+ tt = 3600 * 24 * 31
464
+ else:
465
+ tt = 0
466
+ try:
467
+ await ult.client(SetHistoryTTLRequest(ult.chat_id, period=tt))
468
+ except ChatNotModifiedError:
469
+ return await ult.eor(
470
+ f"Auto Delete Setting is Already same to `{match}`", time=5
471
+ )
472
+ await ult.eor(f"Auto Delete Status Changed to `{match}` !")
plugins/afk.py ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 . import get_help
9
+
10
+ __doc__ = get_help("help_afk")
11
+
12
+
13
+ import asyncio
14
+
15
+ from telegraph import upload_file as uf
16
+ from telethon import events
17
+
18
+ from xteam.dB.afk_db import add_afk, del_afk, is_afk
19
+ from xteam.dB.base import KeyManager
20
+
21
+ from . import (
22
+ LOG_CHANNEL,
23
+ NOSPAM_CHAT,
24
+ Redis,
25
+ asst,
26
+ get_string,
27
+ mediainfo,
28
+ udB,
29
+ ultroid_bot,
30
+ ultroid_cmd,
31
+ )
32
+
33
+ old_afk_msg = []
34
+
35
+ is_approved = KeyManager("PMPERMIT", cast=list).contains
36
+
37
+
38
+ @ultroid_cmd(pattern="afk( (.*)|$)", owner_only=True)
39
+ async def set_afk(event):
40
+ if event.client._bot or is_afk():
41
+ return
42
+ text, media, media_type = None, None, None
43
+ if event.pattern_match.group(1).strip():
44
+ text = event.text.split(maxsplit=1)[1]
45
+ reply = await event.get_reply_message()
46
+ if reply:
47
+ if reply.text and not text:
48
+ text = reply.text
49
+ if reply.media:
50
+ media_type = mediainfo(reply.media)
51
+ if media_type.startswith(("pic", "gif")):
52
+ file = await event.client.download_media(reply.media)
53
+ iurl = uf(file)
54
+ media = f"https://graph.org{iurl[0]}"
55
+ else:
56
+ media = reply.file.id
57
+ await event.eor("`Done`", time=2)
58
+ add_afk(text, media_type, media)
59
+ ultroid_bot.add_handler(remove_afk, events.NewMessage(outgoing=True))
60
+ ultroid_bot.add_handler(
61
+ on_afk,
62
+ events.NewMessage(
63
+ incoming=True, func=lambda e: bool(e.mentioned or e.is_private)
64
+ ),
65
+ )
66
+ msg1, msg2 = None, None
67
+ if text and media:
68
+ if "sticker" in media_type:
69
+ msg1 = await ultroid_bot.send_file(event.chat_id, file=media)
70
+ msg2 = await ultroid_bot.send_message(
71
+ event.chat_id, get_string("afk_5").format(text)
72
+ )
73
+ else:
74
+ msg1 = await ultroid_bot.send_message(
75
+ event.chat_id, get_string("afk_5").format(text), file=media
76
+ )
77
+ elif media:
78
+ if "sticker" in media_type:
79
+ msg1 = await ultroid_bot.send_file(event.chat_id, file=media)
80
+ msg2 = await ultroid_bot.send_message(event.chat_id, get_string("afk_6"))
81
+ else:
82
+ msg1 = await ultroid_bot.send_message(
83
+ event.chat_id, get_string("afk_6"), file=media
84
+ )
85
+ elif text:
86
+ msg1 = await event.respond(get_string("afk_5").format(text))
87
+ else:
88
+ msg1 = await event.respond(get_string("afk_6"))
89
+ old_afk_msg.append(msg1)
90
+ if msg2:
91
+ old_afk_msg.append(msg2)
92
+ return await asst.send_message(LOG_CHANNEL, msg2.text)
93
+ await asst.send_message(LOG_CHANNEL, msg1.text)
94
+
95
+
96
+ async def remove_afk(event):
97
+ if event.is_private and udB.get_key("PMSETTING") and not is_approved(event.chat_id):
98
+ return
99
+ elif "afk" in event.text.lower():
100
+ return
101
+ elif event.chat_id in NOSPAM_CHAT:
102
+ return
103
+ if is_afk():
104
+ _, _, _, afk_time = is_afk()
105
+ del_afk()
106
+ off = await event.reply(get_string("afk_1").format(afk_time))
107
+ await asst.send_message(LOG_CHANNEL, get_string("afk_2").format(afk_time))
108
+ for x in old_afk_msg:
109
+ try:
110
+ await x.delete()
111
+ except BaseException:
112
+ pass
113
+ await asyncio.sleep(10)
114
+ await off.delete()
115
+
116
+
117
+ async def on_afk(event):
118
+ if event.is_private and Redis("PMSETTING") and not is_approved(event.chat_id):
119
+ return
120
+ elif "afk" in event.text.lower():
121
+ return
122
+ elif not is_afk():
123
+ return
124
+ if event.chat_id in NOSPAM_CHAT:
125
+ return
126
+ sender = await event.get_sender()
127
+ if sender.bot or sender.verified:
128
+ return
129
+ text, media_type, media, afk_time = is_afk()
130
+ msg1, msg2 = None, None
131
+ if text and media:
132
+ if "sticker" in media_type:
133
+ msg1 = await event.reply(file=media)
134
+ msg2 = await event.reply(get_string("afk_3").format(afk_time, text))
135
+ else:
136
+ msg1 = await event.reply(
137
+ get_string("afk_3").format(afk_time, text), file=media
138
+ )
139
+ elif media:
140
+ if "sticker" in media_type:
141
+ msg1 = await event.reply(file=media)
142
+ msg2 = await event.reply(get_string("afk_4").format(afk_time))
143
+ else:
144
+ msg1 = await event.reply(get_string("afk_4").format(afk_time), file=media)
145
+ elif text:
146
+ msg1 = await event.reply(get_string("afk_3").format(afk_time, text))
147
+ else:
148
+ msg1 = await event.reply(get_string("afk_4").format(afk_time))
149
+ for x in old_afk_msg:
150
+ try:
151
+ await x.delete()
152
+ except BaseException:
153
+ pass
154
+ old_afk_msg.append(msg1)
155
+ if msg2:
156
+ old_afk_msg.append(msg2)
157
+
158
+
159
+ if udB.get_key("AFK_DB"):
160
+ ultroid_bot.add_handler(remove_afk, events.NewMessage(outgoing=True))
161
+ ultroid_bot.add_handler(
162
+ on_afk,
163
+ events.NewMessage(
164
+ incoming=True, func=lambda e: bool(e.mentioned or e.is_private)
165
+ ),
166
+ )
plugins/allive.py ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ def format_message_text(uptime):
98
+ return f"<blockquote>ʜᴇʏ, ɪ ᴀᴍ {BOT_NAME} 🥀</blockquote>\n" \
99
+ f"<blockquote>❍ ᴍʏ ᴏᴡɴᴇʀ : {OWNER_NAME}\n" \
100
+ f"❍ ʟɪʙʀᴀʀʏ : {lver}\n" \
101
+ f"❍ ᴜᴘᴛɪᴍᴇ : {uptime}\n" \
102
+ f"❍ ᴛᴇʟᴇᴛʜᴏɴ : {tver}\n" \
103
+ f"❍ ᴘʏʀᴏɢʀᴀᴍ : {pver}\n" \
104
+ f"❍ ᴘʏ-ᴛɢᴄᴀʟʟꜱ : {pytver}\n" \
105
+ f"❍ ᴘʏᴛʜᴏɴ : {pyver()}\n</blockquote>"
106
+
107
+ @xteam_cmd(pattern="alive$")
108
+ async def alive(event):
109
+ start = time.time()
110
+ pro = await event.eor("⚡")
111
+ await asyncio.sleep(2)
112
+ await pro.delete()
113
+ end = round((time.time() - start) * 1000)
114
+ uptime = time_formatter((time.time() - start_time) * 1000)
115
+ message_text = format_message_text(uptime)
116
+ await event.client.send_file(
117
+ event.chat.id,
118
+ file=random.choice(PHOTO),
119
+ caption=message_text,
120
+ parse_mode="html")
121
+
122
+ @xteam_cmd(pattern="Alive$")
123
+ async def alive_video(event):
124
+ try:
125
+ asupannya = [
126
+ asupan
127
+ async for asupan in event.client.iter_messages(
128
+ "@xcryasupan", filter=InputMessagesFilterVideo
129
+ )
130
+ ]
131
+
132
+ if not asupannya:
133
+ await event.respond("No video found in @xcryasupan.")
134
+ return
135
+
136
+ pro = await event.eor("⚡")
137
+ await asyncio.sleep(2)
138
+ await pro.delete()
139
+
140
+ uptime = time_formatter((time.time() - start_time) * 1000)
141
+ message_text = format_message_text(uptime)
142
+
143
+ await event.client.send_file(
144
+ event.chat.id,
145
+ file=random.choice(asupannya),
146
+ caption=message_text,
147
+ parse_mode="html",
148
+ )
149
+
150
+ except Exception as e:
151
+ await event.respond(f"An error occurred: {e}")
152
+
plugins/antiflood.py ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 . import get_help
9
+
10
+ __doc__ = get_help("help_antiflood")
11
+
12
+
13
+ import re
14
+
15
+ from telethon.events import NewMessage as NewMsg
16
+
17
+ from xteam.dB import DEVLIST
18
+ from xteam.dB.antiflood_db import get_flood, get_flood_limit, rem_flood, set_flood
19
+ from xteam.fns.admins import admin_check
20
+
21
+ from . import Button, Redis, asst, callback, eod, get_string, ultroid_bot, ultroid_cmd
22
+
23
+ _check_flood = {}
24
+
25
+ if Redis("ANTIFLOOD"):
26
+
27
+ @ultroid_bot.on(
28
+ NewMsg(
29
+ chats=list(get_flood().keys()),
30
+ ),
31
+ )
32
+ async def flood_checm(event):
33
+ count = 1
34
+ chat = (await event.get_chat()).title
35
+ if event.chat_id in _check_flood.keys():
36
+ if event.sender_id == list(_check_flood[event.chat_id].keys())[0]:
37
+ count = _check_flood[event.chat_id][event.sender_id]
38
+ _check_flood[event.chat_id] = {event.sender_id: count + 1}
39
+ else:
40
+ _check_flood[event.chat_id] = {event.sender_id: count}
41
+ else:
42
+ _check_flood[event.chat_id] = {event.sender_id: count}
43
+ if await admin_check(event, silent=True) or getattr(event.sender, "bot", None):
44
+ return
45
+ if event.sender_id in DEVLIST:
46
+ return
47
+ if _check_flood[event.chat_id][event.sender_id] >= int(
48
+ get_flood_limit(event.chat_id)
49
+ ):
50
+ try:
51
+ name = event.sender.first_name
52
+ await event.client.edit_permissions(
53
+ event.chat_id, event.sender_id, send_messages=False
54
+ )
55
+ del _check_flood[event.chat_id]
56
+ await event.reply(f"#AntiFlood\n\n{get_string('antiflood_3')}")
57
+ await asst.send_message(
58
+ int(Redis("LOG_CHANNEL")),
59
+ f"#Antiflood\n\n`Muted `[{name}](tg://user?id={event.sender_id})` in {chat}`",
60
+ buttons=Button.inline(
61
+ "Unmute", data=f"anti_{event.sender_id}_{event.chat_id}"
62
+ ),
63
+ )
64
+ except BaseException:
65
+ pass
66
+
67
+
68
+ @callback(
69
+ re.compile(
70
+ "anti_(.*)",
71
+ ),
72
+ )
73
+ async def unmuting(e):
74
+ ino = (e.data_match.group(1)).decode("UTF-8").split("_")
75
+ user = int(ino[0])
76
+ chat = int(ino[1])
77
+ user_name = (await ultroid_bot.get_entity(user)).first_name
78
+ chat_title = (await ultroid_bot.get_entity(chat)).title
79
+ await ultroid_bot.edit_permissions(chat, user, send_messages=True)
80
+ await e.edit(
81
+ f"#Antiflood\n\n`Unmuted `[{user_name}](tg://user?id={user})` in {chat_title}`"
82
+ )
83
+
84
+
85
+ @ultroid_cmd(
86
+ pattern="setflood ?(\\d+)",
87
+ admins_only=True,
88
+ )
89
+ async def setflood(e):
90
+ input_ = e.pattern_match.group(1).strip()
91
+ if not input_:
92
+ return await e.eor("`What?`", time=5)
93
+ if not input_.isdigit():
94
+ return await e.eor(get_string("com_3"), time=5)
95
+ if m := set_flood(e.chat_id, input_):
96
+ return await eod(e, get_string("antiflood_4").format(input_))
97
+
98
+
99
+ @ultroid_cmd(
100
+ pattern="remflood$",
101
+ admins_only=True,
102
+ )
103
+ async def remove_flood(e):
104
+ hmm = rem_flood(e.chat_id)
105
+ try:
106
+ del _check_flood[e.chat_id]
107
+ except BaseException:
108
+ pass
109
+ if hmm:
110
+ return await e.eor(get_string("antiflood_1"), time=5)
111
+ await e.eor(get_string("antiflood_2"), time=5)
112
+
113
+
114
+ @ultroid_cmd(
115
+ pattern="getflood$",
116
+ admins_only=True,
117
+ )
118
+ async def getflood(e):
119
+ if ok := get_flood_limit(e.chat_id):
120
+ return await e.eor(get_string("antiflood_5").format(ok), time=5)
121
+ await e.eor(get_string("antiflood_2"), time=5)
plugins/bot.py ADDED
@@ -0,0 +1,363 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 . import get_help
9
+
10
+ __doc__ = get_help("help_bot")
11
+
12
+ import os
13
+ import sys
14
+ import time
15
+ from platform import python_version as pyver
16
+ from random import choice
17
+
18
+ from telethon import __version__
19
+ from telethon.errors.rpcerrorlist import (
20
+ BotMethodInvalidError,
21
+ ChatSendMediaForbiddenError,
22
+ )
23
+
24
+ from xteam.version import __version__ as UltVer
25
+
26
+ from . import HOSTED_ON, LOGS
27
+
28
+ try:
29
+ from git import Repo
30
+ except ImportError:
31
+ LOGS.error("bot: 'gitpython' module not found!")
32
+ Repo = None
33
+
34
+ from telethon.utils import resolve_bot_file_id
35
+ from config import Var
36
+ from . import (
37
+ ATRA_COL,
38
+ LOGS,
39
+ OWNER_NAME,
40
+ ULTROID_IMAGES,
41
+ Button,
42
+ Carbon,
43
+ Telegraph,
44
+ allcmds,
45
+ asst,
46
+ bash,
47
+ call_back,
48
+ callback,
49
+ def_logs,
50
+ eor,
51
+ get_string,
52
+ heroku_logs,
53
+ in_pattern,
54
+ inline_pic,
55
+ restart,
56
+ shutdown,
57
+ start_time,
58
+ time_formatter,
59
+ udB,
60
+ ultroid_cmd,
61
+ ultroid_version,
62
+ updater,
63
+ )
64
+
65
+
66
+ def ULTPIC():
67
+ return inline_pic() or choice(ULTROID_IMAGES)
68
+
69
+
70
+ buttons = [
71
+ [
72
+ Button.url(get_string("bot_3"), "https://github.com/TeamUltroid/Ultroid"),
73
+ Button.url(get_string("bot_4"), "t.me/UltroidSupportChat"),
74
+ ]
75
+ ]
76
+
77
+ # Will move to strings
78
+ alive_txt = """
79
+ ᴜꜱᴇʀʙᴏᴛ ɪꜱ ᴀʟɪᴠᴇ
80
+
81
+ ◍ ᴜꜱᴇʀʙᴏᴛ - {}
82
+ ◍ ᴅᴀᴛᴀʙᴀꜱᴇ - {}
83
+ ◍ ᴛᴇʟᴇᴛʜᴏɴ - {}
84
+ """
85
+
86
+ in_alive = "{}\n\n🌀 <b>Ultroid Version -><b> <code>{}</code>\n🌀 <b>xteam -></b> <code>{}</code>\n🌀 <b>Python -></b> <code>{}</code>\n🌀 <b>Uptime -></b> <code>{}</code>\n🌀 <b>Branch -></b>[ {} ]\n\n• <b>Join @TeamUltroid</b>"
87
+
88
+
89
+ @callback("alive")
90
+ async def alive(event):
91
+ text = alive_txt.format(ultroid_version, UltVer, __version__)
92
+ await event.answer(text, alert=True)
93
+
94
+
95
+ """@ultroid_cmd(
96
+ pattern="alive( (.*)|$)",
97
+ )
98
+ async def lol(ult):
99
+ match = ult.pattern_match.group(1).strip()
100
+ inline = None
101
+ if match in ["inline", "i"]:
102
+ try:
103
+ res = await ult.client.inline_query(asst.me.username, "alive")
104
+ return await res[0].click(ult.chat_id)
105
+ except BotMethodInvalidError:
106
+ pass
107
+ except BaseException as er:
108
+ LOGS.exception(er)
109
+ inline = True
110
+ pic = udB.get_key("ALIVE_PIC")
111
+ if isinstance(pic, list):
112
+ pic = choice(pic)
113
+ uptime = time_formatter((time.time() - start_time) * 1000)
114
+ header = udB.get_key("ALIVE_TEXT") or get_string("bot_1")
115
+ y = Repo().active_branch
116
+ xx = Repo().remotes[0].config_reader.get("url")
117
+ rep = xx.replace(".git", f"/tree/{y}")
118
+ kk = f" `[{y}]({rep})` "
119
+ if inline:
120
+ kk = f"<a href={rep}>{y}</a>"
121
+ parse = "html"
122
+ als = in_alive.format(
123
+ header,
124
+ f"{ultroid_version} [{HOSTED_ON}]",
125
+ UltVer,
126
+ pyver(),
127
+ uptime,
128
+ kk,
129
+ )
130
+
131
+ if _e := udB.get_key("ALIVE_EMOJI"):
132
+ als = als.replace("🌀", _e)
133
+ else:
134
+ parse = "md"
135
+ als = (get_string("alive_1")).format(
136
+ header,
137
+ OWNER_NAME,
138
+ f"{ultroid_version} [{HOSTED_ON}]",
139
+ UltVer,
140
+ uptime,
141
+ pyver(),
142
+ __version__,
143
+ kk,
144
+ )
145
+
146
+ if a := udB.get_key("ALIVE_EMOJI"):
147
+ als = als.replace("✵", a)
148
+ if pic:
149
+ try:
150
+ await ult.reply(
151
+ als,
152
+ file=pic,
153
+ parse_mode=parse,
154
+ link_preview=False,
155
+ buttons=buttons if inline else None,
156
+ )
157
+ return await ult.try_delete()
158
+ except ChatSendMediaForbiddenError:
159
+ pass
160
+ except BaseException as er:
161
+ LOGS.exception(er)
162
+ try:
163
+ await ult.reply(file=pic)
164
+ await ult.reply(
165
+ als,
166
+ parse_mode=parse,
167
+ buttons=buttons if inline else None,
168
+ link_preview=False,
169
+ )
170
+ return await ult.try_delete()
171
+ except BaseException as er:
172
+ LOGS.exception(er)
173
+ await eor(
174
+ ult,
175
+ als,
176
+ parse_mode=parse,
177
+ link_preview=False,
178
+ buttons=buttons if inline else None,
179
+ )
180
+
181
+
182
+ @ultroid_cmd(pattern="ping$", chats=[], type=["official", "assistant"])
183
+ async def _(event):
184
+ start = time.time()
185
+ x = await event.eor("Pong !")
186
+ end = round((time.time() - start) * 1000)
187
+ uptime = time_formatter((time.time() - start_time) * 1000)
188
+ await x.edit(get_string("ping").format(end, uptime))
189
+ """
190
+
191
+ @ultroid_cmd(
192
+ pattern="cmds$",
193
+ )
194
+ async def cmds(event):
195
+ await allcmds(event, Telegraph)
196
+
197
+
198
+ heroku_api = Var.HEROKU_API
199
+
200
+
201
+ @ultroid_cmd(
202
+ pattern="restart$",
203
+ fullsudo=True,
204
+ )
205
+ async def restartbt(ult):
206
+ ok = await ult.eor(get_string("bot_5"))
207
+ call_back()
208
+ who = "bot" if ult.client._bot else "user"
209
+ udB.set_key("_RESTART", f"{who}_{ult.chat_id}_{ok.id}")
210
+ if heroku_api:
211
+ return await restart(ok)
212
+ await bash("git pull && pip3 install -r requirements.txt")
213
+ if len(sys.argv) > 1:
214
+ os.execl(sys.executable, sys.executable, "main.py")
215
+ else:
216
+ os.execl(sys.executable, sys.executable, "-m", "xteam")
217
+
218
+
219
+ @ultroid_cmd(
220
+ pattern="shutdown$",
221
+ fullsudo=True,
222
+ )
223
+ async def shutdownbot(ult):
224
+ await shutdown(ult)
225
+
226
+
227
+ @ultroid_cmd(
228
+ pattern="logs( (.*)|$)",
229
+ chats=[],
230
+ )
231
+ async def _(event):
232
+ opt = event.pattern_match.group(1).strip()
233
+ file = f"userbot{sys.argv[-1]}.log" if len(sys.argv) > 1 else "userbot.log"
234
+ if opt == "heroku":
235
+ await heroku_logs(event)
236
+ elif opt == "carbon" and Carbon:
237
+ event = await event.eor(get_string("com_1"))
238
+ with open(file, "r") as f:
239
+ code = f.read()[-2500:]
240
+ file = await Carbon(
241
+ file_name="userbot-logs",
242
+ code=code,
243
+ backgroundColor=choice(ATRA_COL),
244
+ )
245
+ if isinstance(file, dict):
246
+ await event.eor(f"`{file}`")
247
+ return
248
+ await event.reply("**Userbot Logs.**", file=file)
249
+ elif opt == "open":
250
+ with open("userbot.log", "r") as f:
251
+ file = f.read()[-4000:]
252
+ return await event.eor(f"`{file}`")
253
+ elif (
254
+ opt.isdigit() and 5 <= int(opt) <= 100
255
+ ): # Check if input is a number between 10 and 100
256
+ num_lines = int(opt)
257
+ with open("userbot.log", "r") as f:
258
+ lines = f.readlines()[-num_lines:]
259
+ file = "".join(lines)
260
+ return await event.eor(f"`{file}`")
261
+ else:
262
+ await def_logs(event, file)
263
+ await event.try_delete()
264
+
265
+
266
+ @in_pattern("alive", owner=True)
267
+ async def inline_alive(ult):
268
+ pic = udB.get_key("ALIVE_PIC")
269
+ if isinstance(pic, list):
270
+ pic = choice(pic)
271
+ uptime = time_formatter((time.time() - start_time) * 1000)
272
+ header = udB.get_key("ALIVE_TEXT") or get_string("bot_1")
273
+ y = Repo().active_branch
274
+ xx = Repo().remotes[0].config_reader.get("url")
275
+ rep = xx.replace(".git", f"/tree/{y}")
276
+ kk = f"<a href={rep}>{y}</a>"
277
+ als = in_alive.format(
278
+ header, f"{ultroid_version} [{HOSTED_ON}]", UltVer, pyver(), uptime, kk
279
+ )
280
+
281
+ if _e := udB.get_key("ALIVE_EMOJI"):
282
+ als = als.replace("🌀", _e)
283
+ builder = ult.builder
284
+ if pic:
285
+ try:
286
+ if ".jpg" in pic:
287
+ results = [
288
+ await builder.photo(
289
+ pic, text=als, parse_mode="html", buttons=buttons
290
+ )
291
+ ]
292
+ else:
293
+ if _pic := resolve_bot_file_id(pic):
294
+ pic = _pic
295
+ buttons.insert(
296
+ 0, [Button.inline(get_string("bot_2"), data="alive")]
297
+ )
298
+ results = [
299
+ await builder.document(
300
+ pic,
301
+ title="Inline Alive",
302
+ description="@TeamUltroid",
303
+ parse_mode="html",
304
+ buttons=buttons,
305
+ )
306
+ ]
307
+ return await ult.answer(results)
308
+ except BaseException as er:
309
+ LOGS.exception(er)
310
+ result = [
311
+ await builder.article(
312
+ "Alive", text=als, parse_mode="html", link_preview=False, buttons=buttons
313
+ )
314
+ ]
315
+ await ult.answer(result)
316
+
317
+
318
+ @ultroid_cmd(pattern="update( (.*)|$)")
319
+ async def _(e):
320
+ xx = await e.eor(get_string("upd_1"))
321
+ if e.pattern_match.group(1).strip() and (
322
+ "fast" in e.pattern_match.group(1).strip()
323
+ or "soft" in e.pattern_match.group(1).strip()
324
+ ):
325
+ await bash("git pull -f && pip3 install -r requirements.txt")
326
+ call_back()
327
+ await xx.edit(get_string("upd_7"))
328
+ os.execl(sys.executable, "python3", "-m", "xteam")
329
+ # return
330
+ m = await updater()
331
+ branch = (Repo.init()).active_branch
332
+ if m:
333
+ x = await asst.send_file(
334
+ udB.get_key("LOG_CHANNEL"),
335
+ ULTPIC(),
336
+ caption="• **Update Available** •",
337
+ force_document=False,
338
+ buttons=Button.inline("Changelogs", data="changes"),
339
+ )
340
+ Link = x.message_link
341
+ await xx.edit(
342
+ f'<strong><a href="{Link}">[ChangeLogs]</a></strong>',
343
+ parse_mode="html",
344
+ link_preview=False,
345
+ )
346
+ else:
347
+ await xx.edit(
348
+ f'<code>Your BOT is </code><strong>up-to-date</strong><code> with </code><strong><a href="https://github.com/TeamUltroid/Ultroid/tree/{branch}">[{branch}]</a></strong>',
349
+ parse_mode="html",
350
+ link_preview=False,
351
+ )
352
+
353
+
354
+ @callback("updtavail", owner=True)
355
+ async def updava(event):
356
+ await event.delete()
357
+ await asst.send_file(
358
+ udB.get_key("LOG_CHANNEL"),
359
+ ULTPIC(),
360
+ caption="• **Update Available** •",
361
+ force_document=False,
362
+ buttons=Button.inline("Changelogs", data="changes"),
363
+ )
plugins/chatgpt.py ADDED
@@ -0,0 +1,394 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ✘ Commands Available -
10
+
11
+ • `{i}gemini <prompt>`
12
+ Get response from Google Gemini.
13
+
14
+ • `{i}antr <prompt>`
15
+ Get response from Anthropic Claude.
16
+
17
+ • `{i}gpt <prompt>`
18
+ Get response from OpenAI GPT.
19
+
20
+ • `{i}deepseek <prompt>`
21
+ Get response from DeepSeek AI.
22
+
23
+ Set custom models using:
24
+ • OPENAI_MODEL
25
+ • ANTHROPIC_MODEL
26
+ • GEMINI_MODEL
27
+ • DEEPSEEK_MODEL
28
+ """
29
+
30
+ import json
31
+ from . import LOGS, eor, get_string, udB, ultroid_cmd, async_searcher
32
+ import aiohttp
33
+ import asyncio
34
+
35
+
36
+ ENDPOINTS = {
37
+ "gpt": "https://api.openai.com/v1/chat/completions",
38
+ "antr": "https://api.anthropic.com/v1/messages",
39
+ "gemini": "https://generativelanguage.googleapis.com/v1/models/gemini-1.5-flash:generateContent",
40
+ "deepseek": "https://api.deepseek.com/v3/chat/completions"
41
+ }
42
+
43
+ DEFAULT_MODELS = {
44
+ "gpt": "gpt-3.5-turbo",
45
+ "antr": "claude-3-haiku",
46
+ "gemini": "gemini-1.5-flash",
47
+ "deepseek": "DeepSeek-V3"
48
+ }
49
+
50
+
51
+
52
+ def get_model(provider):
53
+ """Get model name from database or use default"""
54
+ model_keys = {
55
+ "gpt": "OPENAI_MODEL",
56
+ "antr": "ANTHROPIC_MODEL",
57
+ "gemini": "GEMINI_MODEL",
58
+ "deepseek": "DEEPSEEK_MODEL"
59
+ }
60
+ return udB.get_key(model_keys[provider]) or DEFAULT_MODELS[provider]
61
+
62
+
63
+ async def stream_response(msg, text):
64
+ """Stream response by editing message"""
65
+ current = ""
66
+ # Split into chunks of ~100 characters at word boundaries
67
+ words = text.split()
68
+ chunks = []
69
+ current_chunk = []
70
+
71
+ for word in words:
72
+ current_chunk.append(word)
73
+ if len(" ".join(current_chunk)) > 100:
74
+ chunks.append(" ".join(current_chunk[:-1]))
75
+ current_chunk = [word]
76
+ if current_chunk:
77
+ chunks.append(" ".join(current_chunk))
78
+
79
+ for chunk in chunks:
80
+ current += chunk + " "
81
+ try:
82
+ await msg.edit(current)
83
+ except Exception:
84
+ pass
85
+ await asyncio.sleep(0.5)
86
+ return current
87
+
88
+
89
+ async def get_ai_response(provider, prompt, api_key, stream=False):
90
+ """Get response from AI provider"""
91
+ try:
92
+ headers = {"Content-Type": "application/json"}
93
+ model = get_model(provider)
94
+
95
+ if provider == "gpt":
96
+ headers["Authorization"] = f"Bearer {api_key}"
97
+ data = {
98
+ "model": model,
99
+ "messages": [{"role": "user", "content": prompt}],
100
+ "stream": stream
101
+ }
102
+ if not stream:
103
+ response = await async_searcher(
104
+ ENDPOINTS[provider],
105
+ headers=headers,
106
+ post=True,
107
+ json=data,
108
+ re_json=True
109
+ )
110
+ yield response["choices"][0]["message"]["content"]
111
+ return
112
+
113
+ async with aiohttp.ClientSession() as session:
114
+ async with session.post(
115
+ ENDPOINTS[provider],
116
+ headers=headers,
117
+ json=data
118
+ ) as resp:
119
+ async for line in resp.content:
120
+ if line:
121
+ try:
122
+ json_line = json.loads(line.decode('utf-8').strip().strip('data:').strip())
123
+ if 'choices' in json_line and json_line['choices']:
124
+ content = json_line['choices'][0].get('delta', {}).get('content', '')
125
+ if content:
126
+ yield content
127
+ except Exception:
128
+ continue
129
+
130
+ elif provider == "antr":
131
+ headers["x-api-key"] = api_key
132
+ headers["anthropic-version"] = "2023-06-01"
133
+ data = {
134
+ "model": model,
135
+ "messages": [{"role": "user", "content": prompt}],
136
+ "stream": stream
137
+ }
138
+ if not stream:
139
+ response = await async_searcher(
140
+ ENDPOINTS[provider],
141
+ headers=headers,
142
+ post=True,
143
+ json=data,
144
+ re_json=True
145
+ )
146
+ yield response["content"][0]["text"]
147
+ return
148
+
149
+ async with aiohttp.ClientSession() as session:
150
+ async with session.post(
151
+ ENDPOINTS[provider],
152
+ headers=headers,
153
+ json=data
154
+ ) as resp:
155
+ async for line in resp.content:
156
+ if line:
157
+ try:
158
+ json_line = json.loads(line.decode('utf-8').strip())
159
+ if 'content' in json_line:
160
+ content = json_line['content'][0]['text']
161
+ if content:
162
+ yield content
163
+ except Exception:
164
+ continue
165
+
166
+ elif provider == "gemini":
167
+ params = {"key": api_key}
168
+ data = {
169
+ "contents": [{
170
+ "parts": [{"text": prompt}]
171
+ }]
172
+ }
173
+ response = await async_searcher(
174
+ ENDPOINTS[provider],
175
+ params=params,
176
+ headers=headers,
177
+ post=True,
178
+ json=data,
179
+ re_json=True
180
+ )
181
+ text = response["candidates"][0]["content"]["parts"][0]["text"]
182
+ if not stream:
183
+ yield text
184
+ return
185
+
186
+ # Simulate streaming by yielding chunks
187
+ words = text.split()
188
+ buffer = []
189
+ for word in words:
190
+ buffer.append(word)
191
+ if len(' '.join(buffer)) > 20: # Adjust chunk size as needed
192
+ yield ' '.join(buffer) + ' '
193
+ buffer = []
194
+ if buffer:
195
+ yield ' '.join(buffer)
196
+
197
+ elif provider == "deepseek":
198
+ headers["Authorization"] = f"Bearer {api_key}"
199
+ data = {
200
+ "model": model,
201
+ "messages": [{"role": "user", "content": prompt}],
202
+ "stream": stream
203
+ }
204
+ if not stream:
205
+ response = await async_searcher(
206
+ ENDPOINTS[provider],
207
+ headers=headers,
208
+ post=True,
209
+ json=data,
210
+ re_json=True
211
+ )
212
+ yield response["choices"][0]["message"]["content"]
213
+ return
214
+
215
+ async with aiohttp.ClientSession() as session:
216
+ async with session.post(
217
+ ENDPOINTS[provider],
218
+ headers=headers,
219
+ json=data
220
+ ) as resp:
221
+ async for line in resp.content:
222
+ if line:
223
+ try:
224
+ json_line = json.loads(line.decode('utf-8').strip())
225
+ if 'choices' in json_line and json_line['choices']:
226
+ content = json_line['choices'][0].get('delta', {}).get('content', '')
227
+ if content:
228
+ yield content
229
+ except Exception:
230
+ continue
231
+
232
+ except Exception as e:
233
+ LOGS.exception(e)
234
+ yield f"Error: {str(e)}"
235
+
236
+
237
+ @ultroid_cmd(pattern="gemini( (.*)|$)")
238
+ async def gemini_ai(event):
239
+ """Use Google Gemini"""
240
+ prompt = event.pattern_match.group(1).strip()
241
+ if not prompt:
242
+ return await event.eor("❌ Please provide a prompt!")
243
+
244
+ api_key = udB.get_key("GEMINI_API_KEY")
245
+ if not api_key:
246
+ return await event.eor("⚠️ Please set Gemini API key using `setdb GEMINI_API_KEY your_api_key`")
247
+
248
+ msg = await event.eor(f"<blockquote>🤔 Thinking...</blockquote>", parse_mode="html")
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:
257
+ await msg.edit(header)
258
+ response = ""
259
+ async for chunk in get_ai_response("gemini", prompt, api_key, stream=False):
260
+ response += chunk
261
+ try:
262
+ await msg.edit(header + f"<blockquote>{response}</blockquote>", parse_mode="html")
263
+ except Exception:
264
+ pass
265
+ else:
266
+ response = ""
267
+ async for chunk in get_ai_response("gemini", prompt, api_key, stream=False):
268
+ response += chunk
269
+ try:
270
+ await msg.edit(header + f"<blockquote>{response}</blockquote>", parse_mode="html")
271
+ except Exception:
272
+ pass
273
+
274
+ @ultroid_cmd(pattern="antr( (.*)|$)")
275
+ async def anthropic_ai(event):
276
+ """Use Anthropic Claude"""
277
+ prompt = event.pattern_match.group(1).strip()
278
+ if not prompt:
279
+ return await event.eor("❌ Please provide a prompt!")
280
+
281
+ api_key = udB.get_key("ANTHROPIC_KEY")
282
+ if not api_key:
283
+ return await event.eor("⚠️ Please set Anthropic API key using `setdb ANTHROPIC_KEY your_api_key`")
284
+
285
+ msg = await event.eor("🤔 Thinking...")
286
+ model = get_model("antr")
287
+
288
+ formatted_response = (
289
+ "🧠 **Anthropic Claude**\n"
290
+ f"**Model:** `{model}`\n"
291
+ "➖➖➖➖➖➖➖➖➖➖\n\n"
292
+ f"**🔍 Prompt:**\n{prompt}\n\n"
293
+ f"**💡 Response:**\n"
294
+ )
295
+
296
+ if event.client.me.bot:
297
+ await msg.edit(formatted_response)
298
+ response = ""
299
+ async for chunk in get_ai_response("antr", prompt, api_key, stream=True):
300
+ response += chunk
301
+ try:
302
+ await msg.edit(formatted_response + response)
303
+ except Exception:
304
+ pass
305
+ else:
306
+ response = ""
307
+ async for chunk in get_ai_response("antr", prompt, api_key, stream=True):
308
+ response += chunk
309
+ try:
310
+ await msg.edit(formatted_response + response)
311
+ except Exception:
312
+ pass
313
+
314
+ @ultroid_cmd(pattern="gpt( (.*)|$)")
315
+ async def openai_ai(event):
316
+ """Use OpenAI GPT"""
317
+ prompt = event.pattern_match.group(1).strip()
318
+ if not prompt:
319
+ return await event.eor("❌ Please provide a prompt!")
320
+
321
+ api_key = udB.get_key("OPENAI_API_KEY")
322
+ if not api_key:
323
+ return await event.eor("⚠️ Please set GPT API key using `setdb OPENAI_API_KEY your_api_key`")
324
+
325
+ msg = await event.eor("🤔 Thinking...")
326
+ model = get_model("gpt")
327
+
328
+ header = (
329
+ "🌟 **OpenAI GPT**\n"
330
+ f"**Model:** `{model}`\n"
331
+ "➖➖➖➖➖➖➖➖➖➖\n\n"
332
+ f"**🔍 Prompt:**\n{prompt}\n\n"
333
+ "**💡 Response:**\n"
334
+ )
335
+
336
+ if event.client.me.bot:
337
+ await msg.edit(header)
338
+ response = ""
339
+ async for chunk in get_ai_response("gpt", prompt, api_key, stream=True):
340
+ response += chunk
341
+ try:
342
+ await msg.edit(header + response)
343
+ except Exception:
344
+ pass
345
+ else:
346
+ response =""
347
+ async for chunk in get_ai_response("gpt", prompt, api_key, stream=True):
348
+ response += chunk
349
+ try:
350
+ await msg.edit(header + response)
351
+ except Exception:
352
+ pass
353
+
354
+ @ultroid_cmd(pattern="deepseek( (.*)|$)")
355
+ async def deepseek_ai(event):
356
+ """Use DeepSeek AI"""
357
+ prompt = event.pattern_match.group(1).strip()
358
+ if not prompt:
359
+ return await event.eor("❌ Please provide a prompt!")
360
+
361
+ api_key = udB.get_key("DEEPSEEK_API_KEY")
362
+ if not api_key:
363
+ return await event.eor("⚠️ Please set DeepSeek API key using `setdb DEEPSEEK_API_KEY your_api_key`")
364
+
365
+ msg = await event.eor("🤔 Thinking...")
366
+ model = get_model("deepseek")
367
+
368
+ formatted_response = (
369
+ "🤖 **DeepSeek AI**\n"
370
+ f"**Model:** `{model}`\n"
371
+ "➖➖➖➖➖➖➖➖➖➖\n\n"
372
+ f"**🔍 Prompt:**\n{prompt}\n\n"
373
+ f"**💡 Response:**\n"
374
+ )
375
+
376
+ if event.client.me.bot:
377
+ await msg.edit(formatted_response)
378
+ response = ""
379
+ async for chunk in get_ai_response("deepseek", prompt, api_key, stream=True):
380
+ response += chunk
381
+ try:
382
+ await msg.edit(formatted_response + response)
383
+ except Exception:
384
+ pass
385
+ else:
386
+ response = ""
387
+ async for chunk in get_ai_response("deepseek", prompt, api_key, stream=True):
388
+ response += chunk
389
+
390
+ try:
391
+ await msg.edit(formatted_response + response)
392
+ except Exception:
393
+ pass
394
+
plugins/devtools.py ADDED
@@ -0,0 +1,387 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 . import get_help
9
+
10
+ __doc__ = get_help("help_devtools")
11
+
12
+ import inspect
13
+ import sys
14
+ import traceback
15
+ from io import BytesIO, StringIO
16
+ from os import remove
17
+ from pprint import pprint
18
+
19
+ from telethon.utils import get_display_name
20
+
21
+ from xteam import _ignore_eval
22
+
23
+ from . import *
24
+
25
+ # Used for Formatting Eval Code, if installed
26
+ try:
27
+ import black
28
+ except ImportError:
29
+ black = None
30
+ from random import choice
31
+
32
+ try:
33
+ from yaml import safe_load
34
+ except ImportError:
35
+ from xteam.fns.tools import safe_load
36
+ try:
37
+ from telegraph import upload_file as uf
38
+ except ImportError:
39
+ uf = None
40
+ from telethon.tl import functions
41
+
42
+ fn = functions
43
+
44
+
45
+ @ultroid_cmd(
46
+ pattern="sysinfo$",
47
+ )
48
+ async def _(e):
49
+ xx = await e.eor(get_string("com_1"))
50
+ x, y = await bash("neofetch|sed 's/\x1B\\[[0-9;\\?]*[a-zA-Z]//g' >> neo.txt")
51
+ if y and y.endswith("NOT_FOUND"):
52
+ return await xx.edit(f"Error: `{y}`")
53
+ with open("neo.txt", "r", encoding="utf-8") as neo:
54
+ p = (neo.read()).replace("\n\n", "")
55
+ haa = await Carbon(code=p, file_name="neofetch", backgroundColor=choice(ATRA_COL))
56
+ if isinstance(haa, dict):
57
+ await xx.edit(f"`{haa}`")
58
+ else:
59
+ await e.reply(file=haa)
60
+ await xx.delete()
61
+ remove("neo.txt")
62
+
63
+
64
+ @ultroid_cmd(pattern="sh", fullsudo=True, only_devs=True)
65
+ async def _(event):
66
+ carb, rayso, yamlf = None, None, False
67
+ try:
68
+ cmd = event.text.split(" ", maxsplit=1)[1]
69
+ if cmd.split()[0] in ["-c", "--carbon"]:
70
+ cmd = cmd.split(maxsplit=1)[1]
71
+ carb = True
72
+ if cmd.split()[0] in ["-r", "--rayso"]:
73
+ cmd = cmd.split(maxsplit=1)[1]
74
+ rayso = True
75
+ except IndexError:
76
+ return await event.eor(get_string("devs_1"), time=10)
77
+ xx = await event.eor(get_string("com_1"))
78
+ reply_to_id = event.reply_to_msg_id or event.id
79
+ stdout, stderr = await bash(cmd, run_code=1)
80
+ OUT = f"**```• Input:**\n{cmd}\n\n```"
81
+ err, out = "", ""
82
+ if stderr:
83
+ err = f"**```• Input:**```\n```{stderr}`\n\n```"
84
+ if stdout:
85
+ if (carb or udB.get_key("CARBON_ON_BASH")) and (
86
+ event.is_private
87
+ or event.chat.admin_rights
88
+ or event.chat.creator
89
+ or event.chat.default_banned_rights.embed_links
90
+ ):
91
+ li = await Carbon(
92
+ code=stdout,
93
+ file_name="bash",
94
+ download=True,
95
+ backgroundColor=choice(ATRA_COL),
96
+ )
97
+ if isinstance(li, dict):
98
+ await xx.edit(
99
+ f"Unknown Response from Carbon: `{li}`\n\nstdout`:{stdout}`\nstderr: `{stderr}`"
100
+ )
101
+ return
102
+ url = f"https://graph.org{uf(li)[-1]}"
103
+ OUT = f"[\xad]({url}){OUT}"
104
+ out = "**```• Output:```**"
105
+ remove(li)
106
+ elif (rayso or udB.get_key("RAYSO_ON_BASH")) and (
107
+ event.is_private
108
+ or event.chat.admin_rights
109
+ or event.chat.creator
110
+ or event.chat.default_banned_rights.embed_links
111
+ ):
112
+ li = await Carbon(
113
+ code=stdout,
114
+ file_name="bash",
115
+ download=True,
116
+ backgroundColor=choice(ATRA_COL),
117
+ rayso=True,
118
+ )
119
+ if isinstance(li, dict):
120
+ await xx.edit(
121
+ f"Unknown Response from Carbon: `{li}`\n\nstdout`:{stdout}`\nstderr: `{stderr}`"
122
+ )
123
+ return
124
+ url = f"https://graph.org{uf(li)[-1]}"
125
+ OUT = f"[\xad]({url}){OUT}"
126
+ out = "**```• OUTPUT:```**"
127
+ remove(li)
128
+ else:
129
+ if "pip" in cmd and all(":" in line for line in stdout.split("\n")):
130
+ try:
131
+ load = safe_load(stdout)
132
+ stdout = ""
133
+ for data in list(load.keys()):
134
+ res = load[data] or ""
135
+ if res and "http" not in str(res):
136
+ res = f"```{res}```"
137
+ stdout += f"```**{data}** : {res}\n```"
138
+ yamlf = True
139
+ except Exception as er:
140
+ stdout = f"```{stdout}```"
141
+ LOGS.exception(er)
142
+ else:
143
+ stdout = f"`{stdout}`"
144
+ out = f"**```• OUTPUT:```**\n```{stdout}```"
145
+ if not stderr and not stdout:
146
+ out = "**```• OUTPUT:```**\n`Success`"
147
+ OUT += err + out
148
+ if len(OUT) > 4096:
149
+ ultd = err + out
150
+ with BytesIO(str.encode(ultd)) as out_file:
151
+ out_file.name = "bash.txt"
152
+ await event.client.send_file(
153
+ event.chat_id,
154
+ out_file,
155
+ force_document=True,
156
+ thumb=ULTConfig.thumb,
157
+ allow_cache=False,
158
+ caption=f"```{cmd}```" if len(cmd) < 998 else None,
159
+ reply_to=reply_to_id,
160
+ )
161
+
162
+ await xx.delete()
163
+ else:
164
+ await xx.edit(OUT, link_preview=not yamlf)
165
+
166
+
167
+ pp = pprint # ignore: pylint
168
+ bot = ultroid = ultroid_bot
169
+
170
+
171
+ class u:
172
+ _ = ""
173
+
174
+
175
+ def _parse_eval(value=None):
176
+ if not value:
177
+ return value
178
+ if hasattr(value, "stringify"):
179
+ try:
180
+ return value.stringify()
181
+ except TypeError:
182
+ pass
183
+ elif isinstance(value, dict):
184
+ try:
185
+ return json_parser(value, indent=1)
186
+ except BaseException:
187
+ pass
188
+ elif isinstance(value, list):
189
+ newlist = "["
190
+ for index, child in enumerate(value):
191
+ newlist += "\n " + str(_parse_eval(child))
192
+ if index < len(value) - 1:
193
+ newlist += ","
194
+ newlist += "\n]"
195
+ return newlist
196
+ return str(value)
197
+
198
+
199
+ @ultroid_cmd(pattern="eval", fullsudo=True, only_devs=True)
200
+ async def _(event):
201
+ try:
202
+ cmd = event.text.split(maxsplit=1)[1]
203
+ except IndexError:
204
+ return await event.eor(get_string("devs_2"), time=5)
205
+ xx = None
206
+ mode = ""
207
+ spli = cmd.split()
208
+
209
+ async def get_():
210
+ try:
211
+ cm = cmd.split(maxsplit=1)[1]
212
+ except IndexError:
213
+ await event.eor("->> Wrong Format <<-")
214
+ cm = None
215
+ return cm
216
+
217
+ if spli[0] in ["-s", "--silent"]:
218
+ await event.delete()
219
+ mode = "silent"
220
+ elif spli[0] in ["-n", "-noedit"]:
221
+ mode = "no-edit"
222
+ xx = await event.reply(get_string("com_1"))
223
+ elif spli[0] in ["-gs", "--source"]:
224
+ mode = "gsource"
225
+ elif spli[0] in ["-ga", "--args"]:
226
+ mode = "g-args"
227
+ if mode:
228
+ cmd = await get_()
229
+ if not cmd:
230
+ return
231
+ if not mode == "silent" and not xx:
232
+ xx = await event.eor(get_string("com_1"))
233
+ if black:
234
+ try:
235
+ cmd = black.format_str(cmd, mode=black.Mode())
236
+ except BaseException:
237
+ # Consider it as Code Error, and move on to be shown ahead.
238
+ pass
239
+ reply_to_id = event.reply_to_msg_id or event
240
+ if any(item in cmd for item in KEEP_SAFE().All) and (
241
+ not (event.out or event.sender_id == ultroid_bot.uid)
242
+ ):
243
+ warning = await event.forward_to(udB.get_key("LOG_CHANNEL"))
244
+ await warning.reply(
245
+ f"Malicious Activities suspected by {inline_mention(await event.get_sender())}"
246
+ )
247
+ _ignore_eval.append(event.sender_id)
248
+ return await xx.edit(
249
+ "`Malicious Activities suspected⚠️!\nReported to owner. Aborted this request!`"
250
+ )
251
+ old_stderr = sys.stderr
252
+ old_stdout = sys.stdout
253
+ redirected_output = sys.stdout = StringIO()
254
+ redirected_error = sys.stderr = StringIO()
255
+ stdout, stderr, exc, timeg = None, None, None, None
256
+ tima = time.time()
257
+ try:
258
+ value = await aexec(cmd, event)
259
+ except Exception:
260
+ value = None
261
+ exc = traceback.format_exc()
262
+ tima = time.time() - tima
263
+ stdout = redirected_output.getvalue()
264
+ stderr = redirected_error.getvalue()
265
+ sys.stdout = old_stdout
266
+ sys.stderr = old_stderr
267
+ if value:
268
+ try:
269
+ if mode == "gsource":
270
+ exc = inspect.getsource(value)
271
+ elif mode == "g-args":
272
+ args = inspect.signature(value).parameters.values()
273
+ name = ""
274
+ if hasattr(value, "__name__"):
275
+ name = value.__name__
276
+ exc = f"**{name}**\n\n" + "\n ".join([str(arg) for arg in args])
277
+ except Exception:
278
+ exc = traceback.format_exc()
279
+ evaluation = exc or stderr or stdout or _parse_eval(value) or get_string("instu_4")
280
+ if mode == "silent":
281
+ if exc:
282
+ msg = f"• <b>EVAL ERROR\n\n• CHAT:</b> <code>{get_display_name(event.chat)}</code> [<code>{event.chat_id}</code>]"
283
+ msg += f"\n\n∆ <b>CODE:</b>\n<code>{cmd}</code>\n\n∆ <b>ERROR:</b>\n<code>{exc}</code>"
284
+ log_chat = udB.get_key("LOG_CHANNEL")
285
+ if len(msg) > 4000:
286
+ with BytesIO(msg.encode()) as out_file:
287
+ out_file.name = "Eval-Error.txt"
288
+ return await event.client.send_message(
289
+ log_chat, f"`{cmd}`", file=out_file
290
+ )
291
+ await event.client.send_message(log_chat, msg, parse_mode="html")
292
+ return
293
+ tmt = tima * 1000
294
+ timef = time_formatter(tmt)
295
+ timeform = timef if not timef == "0s" else f"{tmt:.3f}µs"
296
+ final_output = "<blockquote>Input:\n{}</blockquote>\n<blockquote>Output:\n{}</blockquote>\n<blockquote>Timsec:{}\n</blockquote>".format(
297
+ cmd,
298
+ evaluation,
299
+ timeform,
300
+ )
301
+ if len(final_output) > 4096:
302
+ final_output = evaluation
303
+ with BytesIO(str.encode(final_output)) as out_file:
304
+ out_file.name = "eval.txt"
305
+ await event.client.send_file(
306
+ event.chat_id,
307
+ out_file,
308
+ force_document=True,
309
+ thumb=ULTConfig.thumb,
310
+ allow_cache=False,
311
+ caption=f"```{cmd}```" if len(cmd) < 998 else None,
312
+ reply_to=reply_to_id,
313
+ parse_mode="html",
314
+ )
315
+ return await xx.delete()
316
+ await xx.edit(final_output, parse_mode="html")
317
+
318
+
319
+ def _stringify(text=None, *args, **kwargs):
320
+ if text:
321
+ u._ = text
322
+ text = _parse_eval(text)
323
+ return print(text, *args, **kwargs)
324
+
325
+
326
+ async def aexec(code, event):
327
+ exec(
328
+ (
329
+ "async def __aexec(e, client): "
330
+ + "\n print = p = _stringify"
331
+ + "\n message = event = e"
332
+ + "\n u.r = reply = await event.get_reply_message()"
333
+ + "\n chat = event.chat_id"
334
+ + "\n u.lr = locals()"
335
+ )
336
+ + "".join(f"\n {l}" for l in code.split("\n"))
337
+ )
338
+
339
+ return await locals()["__aexec"](event, event.client)
340
+
341
+
342
+ DUMMY_CPP = """#include <iostream>
343
+ using namespace std;
344
+
345
+ int main(){
346
+ !code
347
+ }
348
+ """
349
+
350
+
351
+ @ultroid_cmd(pattern="cpp", only_devs=True)
352
+ async def doie(e):
353
+ match = e.text.split(" ", maxsplit=1)
354
+ try:
355
+ match = match[1]
356
+ except IndexError:
357
+ return await e.eor(get_string("devs_3"))
358
+ msg = await e.eor(get_string("com_1"))
359
+ if "main(" not in match:
360
+ new_m = "".join(" " * 4 + i + "\n" for i in match.split("\n"))
361
+ match = DUMMY_CPP.replace("!code", new_m)
362
+ open("cpp-ultroid.cpp", "w").write(match)
363
+ m = await bash("g++ -o CppUltroid cpp-ultroid.cpp")
364
+ o_cpp = f"• **Eval-Cpp**\n`{match}`"
365
+ if m[1]:
366
+ o_cpp += f"\n\n**• Error :**\n`{m[1]}`"
367
+ if len(o_cpp) > 3000:
368
+ os.remove("cpp-ultroid.cpp")
369
+ if os.path.exists("CppUltroid"):
370
+ os.remove("CppUltroid")
371
+ with BytesIO(str.encode(o_cpp)) as out_file:
372
+ out_file.name = "error.txt"
373
+ return await msg.reply(f"`{match}`", file=out_file)
374
+ return await eor(msg, o_cpp)
375
+ m = await bash("./CppUltroid")
376
+ if m[0] != "":
377
+ o_cpp += f"\n\n**• Output :**\n`{m[0]}`"
378
+ if m[1]:
379
+ o_cpp += f"\n\n**• Error :**\n`{m[1]}`"
380
+ if len(o_cpp) > 3000:
381
+ with BytesIO(str.encode(o_cpp)) as out_file:
382
+ out_file.name = "eval.txt"
383
+ await msg.reply(f"`{match}`", file=out_file)
384
+ else:
385
+ await eor(msg, o_cpp)
386
+ os.remove("CppUltroid")
387
+ os.remove("cpp-ultroid.cpp")
plugins/ping.py ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # UserBot
2
+ # Copyright (C) 2021-2023 Teamx-cloner
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 . import get_help
9
+
10
+ __doc__ = get_help("help_bot")
11
+
12
+ 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
19
+ from telethon import Button
20
+ from xteam._misc import sudoers
21
+ from telethon.tl.types import InputMessagesFilterVideo, InputMessagesFilterVoice
22
+ from telethon.tl.types import InputMessagesFilterPhotos
23
+ from xteam.fns.custom_markdown import CustomMarkdown
24
+ from xteam.fns.helper import download_file, inline_mention
25
+ from ._inline import *
26
+ from xteam.fns.helper import inline_mention
27
+ from . import (
28
+ OWNER_NAME,
29
+ OWNER_ID,
30
+ BOT_NAME,
31
+ OWNER_USERNAME,
32
+ asst,
33
+ start_time,
34
+ time_formatter,
35
+ udB,
36
+ ultroid_cmd as xteam_cmd,
37
+ get_string,
38
+ ultroid_bot as client,
39
+ eor,
40
+ ultroid_bot,
41
+ call_back,
42
+ callback,
43
+ )
44
+
45
+ PING = [
46
+ [ # First row of buttons (you can have multiple rows)
47
+ #InlineKeyboardButton("Button 1 Text", url="https://example.com/1"), # Example URL button
48
+ Button.inline("CLOSE", data="close"),
49
+ #InlineKeyboardButton("ᴘɪɴɢ", callback_data="close") # Example callback button
50
+ ]
51
+ ]
52
+
53
+ #markup = ReplyInlineMarkup(PING)
54
+
55
+
56
+
57
+ async def mention_user(user_id):
58
+ try:
59
+ user_entity = await ultroid_bot.get_entity(user_id)
60
+ first_name = user_entity.first_name
61
+ mention_text = f"[{first_name}](tg://user?id={user_id})"
62
+ return mention_text
63
+ except Exception as e:
64
+ print(f"Failed to mention user: {e}")
65
+
66
+
67
+ @xteam_cmd(pattern="xping$", chats=[], type=["official", "assistant"])
68
+ async def _(event):
69
+ start = time.time()
70
+ x = await event.edit("ping")
71
+ end = round((time.time() - start) * 1000)
72
+ uptime = time_formatter((time.time() - start_time) * 1000)
73
+ await x.edit(f"**Pong!\n{end}ms**")
74
+
75
+
76
+ """
77
+ papnya = [
78
+ pap
79
+ async for pap in e.client.iter_messages(
80
+ "@CeweLogoPack", filter=InputMessagesFilterPhotos
81
+ )
82
+ ]
83
+
84
+ ppcpnya = [
85
+ ppcp
86
+ async for ppcp in event.client.iter_messages(
87
+ "@ppcpcilik", filter=InputMessagesFilterPhotos
88
+ )
89
+ ]
90
+
91
+ desahcewe = [
92
+ desah
93
+ async for desah in event.client.iter_messages(
94
+ "@desahancewesangesange", filter=InputMessagesFilterVoice
95
+ )
96
+ ]
97
+ """
98
+ """@xteam_cmd(pattern="Cping")
99
+ async def wping(e):
100
+ asupannya = [
101
+ asupan
102
+ async for asupan in e.client.iter_messages(
103
+ "@xcryasupan", filter=InputMessagesFilterVideo
104
+ )
105
+ ]
106
+ start = time.time()
107
+ x = await e.eor("Pong!")
108
+ end = round((time.time() - start) * 1000)
109
+ uptime = time_formatter((time.time() - start_time) * 1000)
110
+ #await asyncio.sleep(1)
111
+ try:
112
+ await asst.send_message(
113
+ e.chat.id,
114
+ f"<blockquote> Ping : {end}ms\nUptime : {uptime}\nOwner : `{inline_mention(ultroid_bot.me)}`</blockquote>",
115
+ file=choice(asupannya),
116
+ buttons=[
117
+ [
118
+ Button.inline("• x🥰x •", data="close")
119
+ ]
120
+ ],
121
+ parse_mode="html",
122
+ )
123
+
124
+ except Exception as e:
125
+ await x.edit(f"**Ping Error:** {e}")
126
+ """
127
+ @xteam_cmd(pattern="ping$", chats=[], type=["official", "assistant"])
128
+ async def _(event):
129
+ start = time.time()
130
+ x = await event.reply("Ping")
131
+ end = round((time.time() - start) * 1000)
132
+ uptime = time_formatter((time.time() - start_time) * 1000)
133
+ await x.edit(f"<blockquote>Pong !! {end}ms\nUptime - {uptime}</blockquote>", parse_mode="html")
134
+
135
+ import time
136
+ import asyncio
137
+ from telethon import Button
138
+ from telethon.tl.types import InputMessagesFilterVideo
139
+ import random
140
+
141
+ # Assuming you have these defined elsewhere in your code:
142
+ # @xteam_cmd, e, client, start_time, time_formatter, OWNER_NAME
143
+
144
+ @xteam_cmd(pattern="kping")
145
+ async def wping(e):
146
+ try:
147
+ asupannya = [
148
+ asupan
149
+ async for asupan in e.client.iter_messages(
150
+ "@xcryasupan", filter=InputMessagesFilterVideo
151
+ )
152
+ ]
153
+
154
+ if not asupannya:
155
+ await e.respond("No video found in @xcryasupan.")
156
+ return
157
+
158
+ start = time.time()
159
+ x = await e.respond("Pong!") # Use respond instead of eor for initial message
160
+ end = round((time.time() - start) * 1000)
161
+ uptime = time_formatter((time.time() - start_time) * 1000)
162
+
163
+ await e.client.send_file( # send_file is used for sending files with caption and buttons.
164
+ e.chat.id,
165
+ file=random.choice(asupannya),
166
+ caption=f"<blockquote> Ping : {end}ms\nUptime : {uptime}\nOwner :{OWNER_NAME}</blockquote>",
167
+ parse_mode="html",
168
+ buttons=Button.inline("• x •", "close"),
169
+ )
170
+
171
+ await x.delete() # delete the "pong" message after sending the video with caption.
172
+
173
+ except Exception as ex:
174
+ try:
175
+ await x.edit(f"**Ping Error:** {ex}")
176
+ except:
177
+ await e.respond(f"**Ping Error:** {ex}") #in case x was not defined.
178
+
179
+ @callback(data="close", owner=True)
180
+ async def on_plug_in_callback_query_handler(event):
181
+ await event.edit(
182
+ get_string("inline_5"),
183
+ buttons=Button.inline("OPEN", data="open"),
184
+ )