Spaces:
Paused
Paused
Danish
New-dev0
Danish
Amit Sharma
Programming Error
Aakash
xditya
sppidy
Arnab Paryali
divkix
hellboi_atul
commited on

Commit
·
8efedad
1
Parent(s):
433f66d
Ultroid v0.0.7 2021/05/22
Browse filesCo-authored-by: New-dev0 <[email protected]>
Co-authored-by: Danish <[email protected]>
Co-authored-by: Amit Sharma <[email protected]>
Co-authored-by: Programming Error <[email protected]>
Co-authored-by: Aakash <[email protected]>
Co-authored-by: Aditya <[email protected]>
Co-authored-by: sppidy <[email protected]>
Co-authored-by: Arnab Paryali <[email protected]>
Co-authored-by: divkix <[email protected]>
Co-authored-by: hellboi_atul <[email protected]>
This view is limited to 50 files because it contains too many changes.
See raw diff
- .env.sample +0 -2
- .gitignore +3 -5
- Dockerfile +6 -3
- README.md +1 -4
- app.json +0 -8
- assistant/inlinestuff.py +45 -64
- assistant/othervars.py +62 -40
- assistant/pmbot/__init__.py +1 -1
- assistant/pmbot/banuser.py +9 -3
- assistant/pmbot/incoming.py +1 -1
- assistant/pmbot/outgoing.py +1 -1
- plugins/__init__.py +2 -1
- plugins/_inline.py +440 -403
- plugins/_ultroid.py +1 -1
- plugins/_userlogs.py +59 -38
- plugins/_wspr.py +1 -1
- plugins/admintools.py +40 -61
- plugins/afk.py +1 -1
- plugins/autocorrect.py +2 -2
- plugins/autopic.py +2 -2
- plugins/bot.py +6 -7
- plugins/broadcast.py +28 -18
- plugins/calculator.py +146 -0
- plugins/channelhacks.py +3 -4
- plugins/chats.py +6 -4
- plugins/compressor.py +157 -0
- plugins/converter.py +20 -19
- plugins/core.py +1 -67
- plugins/devtools.py +177 -0
- plugins/download_upload.py +115 -18
- plugins/echo.py +98 -0
- plugins/extra.py +118 -0
- plugins/fedutils.py +40 -56
- plugins/filter.py +3 -0
- plugins/forcesubscribe.py +143 -0
- plugins/giftools.py +137 -0
- plugins/globaltools.py +403 -8
- plugins/imagetools.py +29 -0
- plugins/locks.py +51 -0
- plugins/logo.py +114 -0
- plugins/megadl.py +77 -0
- plugins/mute.py +4 -3
- plugins/pdftools.py +14 -12
- plugins/pinterest.py +60 -0
- plugins/pmpermit.py +132 -95
- plugins/polls.py +74 -0
- plugins/profile.py +2 -0
- plugins/qrcode.py +110 -0
- plugins/resize.py +65 -0
- plugins/saavn.py +4 -2
.env.sample
CHANGED
@@ -3,7 +3,5 @@
|
|
3 |
API_ID=
|
4 |
API_HASH=
|
5 |
SESSION=
|
6 |
-
BOT_TOKEN=
|
7 |
REDIS_URI=
|
8 |
REDIS_PASSWORD=
|
9 |
-
LOG_CHANNEL=
|
|
|
3 |
API_ID=
|
4 |
API_HASH=
|
5 |
SESSION=
|
|
|
6 |
REDIS_URI=
|
7 |
REDIS_PASSWORD=
|
|
.gitignore
CHANGED
@@ -1,23 +1,21 @@
|
|
1 |
.env
|
2 |
venv/
|
3 |
__pycache__
|
4 |
-
|
5 |
-
|
6 |
*.mp3
|
7 |
*.webm
|
8 |
*.webp
|
9 |
*.mp4
|
10 |
*.tgs
|
11 |
-
logs-ultroid.txt
|
12 |
.vscode/*
|
13 |
-
ultroid-log.txt
|
14 |
/*.jpg
|
15 |
/*.png
|
16 |
/*.mp4
|
17 |
addons/
|
18 |
ultroid.log
|
19 |
target/npmlist.json
|
20 |
-
node_modules
|
21 |
glitch_me/
|
22 |
.idea
|
23 |
venv/
|
|
|
1 |
.env
|
2 |
venv/
|
3 |
__pycache__
|
4 |
+
ultroid.session-journal
|
5 |
+
ultroid.session
|
6 |
*.mp3
|
7 |
*.webm
|
8 |
*.webp
|
9 |
*.mp4
|
10 |
*.tgs
|
|
|
11 |
.vscode/*
|
|
|
12 |
/*.jpg
|
13 |
/*.png
|
14 |
/*.mp4
|
15 |
addons/
|
16 |
ultroid.log
|
17 |
target/npmlist.json
|
18 |
+
node_modules/
|
19 |
glitch_me/
|
20 |
.idea
|
21 |
venv/
|
Dockerfile
CHANGED
@@ -3,14 +3,17 @@
|
|
3 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
4 |
# PLease read the GNU Affero General Public License in <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
5 |
|
6 |
-
FROM programmingerror/ultroid:v0.0.
|
|
|
|
|
|
|
|
|
7 |
|
8 |
RUN git clone https://github.com/TeamUltroid/Ultroid.git /root/TeamUltroid/
|
9 |
|
10 |
-
RUN git clone https://github.com/1Danish-00/glitch_me.git && pip install -e ./glitch_me
|
11 |
WORKDIR /root/TeamUltroid/
|
12 |
|
13 |
RUN pip3 install -r requirements.txt
|
14 |
-
RUN npm install -g npm@7.
|
15 |
RUN npm install
|
16 |
RUN npm run build
|
|
|
3 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
4 |
# PLease read the GNU Affero General Public License in <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
5 |
|
6 |
+
FROM programmingerror/ultroid:v0.0.2
|
7 |
+
|
8 |
+
ENV TZ=Asia/Kolkata
|
9 |
+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
10 |
+
RUN apt-get autoremove --purge
|
11 |
|
12 |
RUN git clone https://github.com/TeamUltroid/Ultroid.git /root/TeamUltroid/
|
13 |
|
|
|
14 |
WORKDIR /root/TeamUltroid/
|
15 |
|
16 |
RUN pip3 install -r requirements.txt
|
17 |
+
RUN npm install -g npm@7.12.1 -g
|
18 |
RUN npm install
|
19 |
RUN npm run build
|
README.md
CHANGED
@@ -79,9 +79,6 @@ Get the [Necessary Variables](#Necessary-Variables) and then click the button be
|
|
79 |
- `API_ID` - Your API_ID from [my.telegram.org](https://my.telegram.org/)
|
80 |
- `API_HASH` - Your API_HASH from [my.telegram.org](https://my.telegram.org/)
|
81 |
- `SESSION` - SessionString for your accounts login session. Get it from [here](#Session-String)
|
82 |
-
- `BOT_TOKEN` - The token of your bot from [@BotFather](https://t.me/BotFather)
|
83 |
-
- `BOT_USERNAME` - The username of your bot from [@BotFather](https://t.me/BotFather)
|
84 |
-
- `LOG_CHANNEL` - A private group/channel id.
|
85 |
- `REDIS_URI` - Redis endpoint URL, from [redislabs](http://redislabs.com/), tutorial [here.](./resources/extras/redistut.md)
|
86 |
- `REDIS_PASSWORD ` - Redis endpoint Password, from [redislabs](http://redislabs.com/), tutorial [here.](./resources/extras/redistut.md)
|
87 |
|
@@ -102,5 +99,5 @@ Ultroid is licensed under [GNU Affero General Public License](https://www.gnu.or
|
|
102 |
# Credits
|
103 |
* [](https://t.me/UltroidDevs)
|
104 |
* [Lonami](https://github.com/LonamiWebs/) for [Telethon.](https://github.com/LonamiWebs/Telethon)
|
105 |
-
* [AndrewLaneX](https://github.com/AndrewLaneX) for [tgcalls.](http://github.com/tgcallsjs/tgcalls)
|
106 |
|
|
|
79 |
- `API_ID` - Your API_ID from [my.telegram.org](https://my.telegram.org/)
|
80 |
- `API_HASH` - Your API_HASH from [my.telegram.org](https://my.telegram.org/)
|
81 |
- `SESSION` - SessionString for your accounts login session. Get it from [here](#Session-String)
|
|
|
|
|
|
|
82 |
- `REDIS_URI` - Redis endpoint URL, from [redislabs](http://redislabs.com/), tutorial [here.](./resources/extras/redistut.md)
|
83 |
- `REDIS_PASSWORD ` - Redis endpoint Password, from [redislabs](http://redislabs.com/), tutorial [here.](./resources/extras/redistut.md)
|
84 |
|
|
|
99 |
# Credits
|
100 |
* [](https://t.me/UltroidDevs)
|
101 |
* [Lonami](https://github.com/LonamiWebs/) for [Telethon.](https://github.com/LonamiWebs/Telethon)
|
102 |
+
* [AndrewLaneX](https://github.com/AndrewLaneX) for [tgcalls-base.](http://github.com/tgcallsjs/tgcalls)
|
103 |
|
app.json
CHANGED
@@ -22,10 +22,6 @@
|
|
22 |
"description": "You api hash, from my.telegram.org or @ScrapperRoBot.",
|
23 |
"value": ""
|
24 |
},
|
25 |
-
"BOT_TOKEN": {
|
26 |
-
"description": "Make a bot from @BotFather, and enter it's api token here.",
|
27 |
-
"value": ""
|
28 |
-
},
|
29 |
"SESSION": {
|
30 |
"description": "Your session string. Can be added now, or after deploy. (The bot will NOT work without a session string!!)",
|
31 |
"value": ""
|
@@ -47,10 +43,6 @@
|
|
47 |
"description": "Name of your heroku app, given in the first blank on this page. To be added if deploying to heroku ONLY.",
|
48 |
"value": "",
|
49 |
"required": false
|
50 |
-
},
|
51 |
-
"LOG_CHANNEL": {
|
52 |
-
"description": "Create a private group. Add @missrose_bot and your BOT_USERNAME bot. Do /id. Paste that here",
|
53 |
-
"value": ""
|
54 |
}
|
55 |
},
|
56 |
"formation": {
|
|
|
22 |
"description": "You api hash, from my.telegram.org or @ScrapperRoBot.",
|
23 |
"value": ""
|
24 |
},
|
|
|
|
|
|
|
|
|
25 |
"SESSION": {
|
26 |
"description": "Your session string. Can be added now, or after deploy. (The bot will NOT work without a session string!!)",
|
27 |
"value": ""
|
|
|
43 |
"description": "Name of your heroku app, given in the first blank on this page. To be added if deploying to heroku ONLY.",
|
44 |
"value": "",
|
45 |
"required": false
|
|
|
|
|
|
|
|
|
46 |
}
|
47 |
},
|
48 |
"formation": {
|
assistant/inlinestuff.py
CHANGED
@@ -5,7 +5,8 @@
|
|
5 |
# PLease read the GNU Affero General Public License in
|
6 |
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
7 |
|
8 |
-
|
|
|
9 |
from re import compile as re_compile
|
10 |
from re import findall
|
11 |
from urllib.request import urlopen
|
@@ -29,6 +30,16 @@ ultpic = "https://telegra.ph/file/4136aa1650bc9d4109cc5.jpg"
|
|
29 |
|
30 |
ofox_api = OrangeFoxAPI()
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
@in_pattern("ofox")
|
34 |
@in_owner
|
@@ -75,15 +86,13 @@ async def _(e):
|
|
75 |
],
|
76 |
)
|
77 |
)
|
78 |
-
await e.answer(
|
|
|
|
|
79 |
else:
|
80 |
-
|
81 |
-
|
82 |
-
description="Wrong Codename",
|
83 |
-
text="OʀᴀɴɢFᴏx Rᴇᴄᴏᴠᴇʀʏ Fᴏʀ Yᴏᴜʀ Pʜᴏɴᴇ Is Eɪᴛʜᴇʀ Nᴏᴛ Oғғɪᴄɪᴀʟʟʏ Bᴜɪʟᴛ Oʀ Yᴏᴜ Hᴀᴠᴇ Eɴᴛᴇʀᴇᴅ Wʀᴏɴɢ Cᴏᴅᴇɴᴀᴍᴇ",
|
84 |
-
buttons=Button.switch_inline("Sᴇᴀʀᴄʜ Aɢᴀɪɴ", query="ofox ", same_peer=True),
|
85 |
)
|
86 |
-
await e.answer([sed])
|
87 |
|
88 |
|
89 |
@in_pattern("fl2lnk ?(.*)")
|
@@ -116,7 +125,7 @@ async def _(e):
|
|
116 |
title="fl2lnk",
|
117 |
text="File not found",
|
118 |
)
|
119 |
-
await e.answer([lnk])
|
120 |
|
121 |
|
122 |
@callback(
|
@@ -145,17 +154,17 @@ async def repo(e):
|
|
145 |
thumb=wb(ultpic, 0, "image/jpeg", []),
|
146 |
text="• **ULTROID USERBOT** •",
|
147 |
buttons=[
|
148 |
-
[Button.url("Repo", url="https://github.com/TeamUltroid/Ultroid")],
|
149 |
[
|
|
|
150 |
Button.url(
|
151 |
"Addons", url="https://github.com/TeamUltroid/UltroidAddons"
|
152 |
-
)
|
153 |
],
|
154 |
[Button.url("Support", url="t.me/UltroidSupport")],
|
155 |
],
|
156 |
),
|
157 |
]
|
158 |
-
await e.answer(res)
|
159 |
|
160 |
|
161 |
@in_pattern("go")
|
@@ -164,13 +173,9 @@ async def gsearch(q_event):
|
|
164 |
try:
|
165 |
match = q_event.text.split(" ", maxsplit=1)[1]
|
166 |
except IndexError:
|
167 |
-
|
168 |
-
|
169 |
-
thumb=wb(gugirl, 0, "image/jpeg", []),
|
170 |
-
text="**Gᴏᴏɢʟᴇ Sᴇᴀʀᴄʜ**\n\nYou didn't search anything",
|
171 |
-
buttons=Button.switch_inline("Sᴇᴀʀᴄʜ Aɢᴀɪɴ", query="go ", same_peer=True),
|
172 |
)
|
173 |
-
await q_event.answer([kkkk])
|
174 |
searcher = []
|
175 |
page = findall(r"page=\d+", match)
|
176 |
cache = False
|
@@ -216,7 +221,7 @@ async def gsearch(q_event):
|
|
216 |
)
|
217 |
except IndexError:
|
218 |
break
|
219 |
-
await q_event.answer(searcher)
|
220 |
|
221 |
|
222 |
@in_pattern("rex")
|
@@ -251,33 +256,29 @@ async def rextester(event):
|
|
251 |
description=f"Language-`{lang}` & Code-`{code}`",
|
252 |
text=f"Language:\n`{lang}`\n\nCode:\n`{code}`\n\nResult:\n`{outputt}`\n\nStats:\n`{stats}`",
|
253 |
)
|
254 |
-
await event.answer(
|
|
|
|
|
255 |
except UnknownLanguage:
|
256 |
resultm = builder.article(
|
257 |
title="Error", # By @ProgrammingError
|
258 |
description="Invalid language choosen",
|
259 |
text=f"The list of valid languages are\n\n{rex_langs}\n\n\nFormat to use Rextester is `@Yourassistantusername rex langcode|code`",
|
260 |
)
|
261 |
-
await event.answer(
|
|
|
|
|
262 |
|
263 |
|
264 |
@in_pattern("yahoo")
|
265 |
@in_owner
|
266 |
-
async def
|
267 |
try:
|
268 |
match = q_event.text.split(" ", maxsplit=1)[1]
|
269 |
except IndexError:
|
270 |
-
|
271 |
-
|
272 |
-
thumb=wb(yeah, 0, "image/jpeg", []),
|
273 |
-
text="**Yᴀʜᴏᴏ Sᴇᴀʀᴄʜ**\n\nYou didn't search anything",
|
274 |
-
buttons=Button.switch_inline(
|
275 |
-
"Sᴇᴀʀᴄʜ Aɢᴀɪɴ",
|
276 |
-
query="yahoo ",
|
277 |
-
same_peer=True,
|
278 |
-
),
|
279 |
)
|
280 |
-
await q_event.answer([kkkk])
|
281 |
searcher = []
|
282 |
page = findall(r"page=\d+", match)
|
283 |
cache = False
|
@@ -323,7 +324,7 @@ async def gsearch(q_event):
|
|
323 |
)
|
324 |
except IndexError:
|
325 |
break
|
326 |
-
await q_event.answer(searcher)
|
327 |
|
328 |
|
329 |
@in_pattern("app")
|
@@ -332,13 +333,9 @@ async def _(e):
|
|
332 |
try:
|
333 |
f = e.text.split(" ", maxsplit=1)[1]
|
334 |
except IndexError:
|
335 |
-
|
336 |
-
|
337 |
-
thumb=wb(ps, 0, "image/jpeg", []),
|
338 |
-
text="**Pʟᴀʏ Sᴛᴏʀᴇ**\n\nYou didn't search anything",
|
339 |
-
buttons=Button.switch_inline("Sᴇᴀʀᴄʜ Aɢᴀɪɴ", query="app ", same_peer=True),
|
340 |
)
|
341 |
-
await e.answer([kkkk])
|
342 |
foles = []
|
343 |
aap = search(f)
|
344 |
for z in aap:
|
@@ -377,7 +374,7 @@ async def _(e):
|
|
377 |
],
|
378 |
),
|
379 |
)
|
380 |
-
await e.answer(foles)
|
381 |
|
382 |
|
383 |
@in_pattern("mods")
|
@@ -386,21 +383,12 @@ async def _(e):
|
|
386 |
try:
|
387 |
quer = e.text.split(" ", maxsplit=1)[1]
|
388 |
except IndexError:
|
389 |
-
|
390 |
-
|
391 |
-
text="**Mᴏᴅᴅᴇᴅ Aᴘᴘs**\n\nYou didn't search anything",
|
392 |
-
buttons=Button.switch_inline("Sᴇᴀʀᴄʜ Aɢᴀɪɴ", query="mods ", same_peer=True),
|
393 |
)
|
394 |
-
await e.answer([kkkk])
|
395 |
page = 1
|
396 |
start = (page - 1) * 3 + 1
|
397 |
-
|
398 |
-
if urd == 1:
|
399 |
-
da = "AIzaSyAyDBsY3WRtB5YPC6aB_w8JAy6ZdXNc6FU"
|
400 |
-
if urd == 2:
|
401 |
-
da = "AIzaSyBF0zxLlYlPMp9xwMQqVKCQRq8DgdrLXsg"
|
402 |
-
if urd == 3:
|
403 |
-
da = "AIzaSyDdOKnwnPwVIQ_lbH5sYE4FoXjAKIQV0DQ"
|
404 |
url = f"https://www.googleapis.com/customsearch/v1?key={da}&cx=25b3b50edb928435b&q={quer}&start={start}"
|
405 |
data = requests.get(url).json()
|
406 |
search_items = data.get("items")
|
@@ -435,7 +423,7 @@ async def _(e):
|
|
435 |
],
|
436 |
),
|
437 |
)
|
438 |
-
await e.answer(modss)
|
439 |
|
440 |
|
441 |
@in_pattern("clipart")
|
@@ -444,16 +432,7 @@ async def clip(e):
|
|
444 |
try:
|
445 |
quer = e.text.split(" ", maxsplit=1)[1]
|
446 |
except IndexError:
|
447 |
-
|
448 |
-
title="Search Something",
|
449 |
-
text="**Cʟɪᴘᴀʀᴛ Sᴇᴀʀᴄʜ**\n\nYou didn't search anything",
|
450 |
-
buttons=Button.switch_inline(
|
451 |
-
"Sᴇᴀʀᴄʜ Aɢᴀɪɴ",
|
452 |
-
query="clipart ",
|
453 |
-
same_peer=True,
|
454 |
-
),
|
455 |
-
)
|
456 |
-
await e.answer([kkkk])
|
457 |
quer = quer.replace(" ", "+")
|
458 |
sear = f"https://clipartix.com/search/{quer}"
|
459 |
html = urlopen(sear)
|
@@ -463,4 +442,6 @@ async def clip(e):
|
|
463 |
hm = []
|
464 |
for res in resul:
|
465 |
hm += [buil.photo(include_media=True, file=res["src"])]
|
466 |
-
await e.answer(
|
|
|
|
|
|
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 |
+
from random import choice
|
10 |
from re import compile as re_compile
|
11 |
from re import findall
|
12 |
from urllib.request import urlopen
|
|
|
30 |
|
31 |
ofox_api = OrangeFoxAPI()
|
32 |
|
33 |
+
api1 = base64.b64decode("QUl6YVN5QXlEQnNZM1dSdEI1WVBDNmFCX3c4SkF5NlpkWE5jNkZV").decode(
|
34 |
+
"ascii"
|
35 |
+
)
|
36 |
+
api2 = base64.b64decode("QUl6YVN5QkYwenhMbFlsUE1wOXh3TVFxVktDUVJxOERnZHJMWHNn").decode(
|
37 |
+
"ascii"
|
38 |
+
)
|
39 |
+
api3 = base64.b64decode("QUl6YVN5RGRPS253blB3VklRX2xiSDVzWUU0Rm9YakFLSVFWMERR").decode(
|
40 |
+
"ascii"
|
41 |
+
)
|
42 |
+
|
43 |
|
44 |
@in_pattern("ofox")
|
45 |
@in_owner
|
|
|
86 |
],
|
87 |
)
|
88 |
)
|
89 |
+
await e.answer(
|
90 |
+
fox, switch_pm="OrangeFox Recovery Search.", switch_pm_param="start"
|
91 |
+
)
|
92 |
else:
|
93 |
+
await e.answer(
|
94 |
+
[], switch_pm="OrangeFox Recovery Search.", switch_pm_param="start"
|
|
|
|
|
|
|
95 |
)
|
|
|
96 |
|
97 |
|
98 |
@in_pattern("fl2lnk ?(.*)")
|
|
|
125 |
title="fl2lnk",
|
126 |
text="File not found",
|
127 |
)
|
128 |
+
await e.answer([lnk], switch_pm="File to Link.", switch_pm_param="start")
|
129 |
|
130 |
|
131 |
@callback(
|
|
|
154 |
thumb=wb(ultpic, 0, "image/jpeg", []),
|
155 |
text="• **ULTROID USERBOT** •",
|
156 |
buttons=[
|
|
|
157 |
[
|
158 |
+
Button.url("Repo", url="https://github.com/TeamUltroid/Ultroid"),
|
159 |
Button.url(
|
160 |
"Addons", url="https://github.com/TeamUltroid/UltroidAddons"
|
161 |
+
),
|
162 |
],
|
163 |
[Button.url("Support", url="t.me/UltroidSupport")],
|
164 |
],
|
165 |
),
|
166 |
]
|
167 |
+
await e.answer(res, switch_pm="Ultroid Repo.", switch_pm_param="start")
|
168 |
|
169 |
|
170 |
@in_pattern("go")
|
|
|
173 |
try:
|
174 |
match = q_event.text.split(" ", maxsplit=1)[1]
|
175 |
except IndexError:
|
176 |
+
await q_event.answer(
|
177 |
+
[], switch_pm="Google Search. Enter a query!", switch_pm_param="start"
|
|
|
|
|
|
|
178 |
)
|
|
|
179 |
searcher = []
|
180 |
page = findall(r"page=\d+", match)
|
181 |
cache = False
|
|
|
221 |
)
|
222 |
except IndexError:
|
223 |
break
|
224 |
+
await q_event.answer(searcher, switch_pm="Google Search.", switch_pm_param="start")
|
225 |
|
226 |
|
227 |
@in_pattern("rex")
|
|
|
256 |
description=f"Language-`{lang}` & Code-`{code}`",
|
257 |
text=f"Language:\n`{lang}`\n\nCode:\n`{code}`\n\nResult:\n`{outputt}`\n\nStats:\n`{stats}`",
|
258 |
)
|
259 |
+
await event.answer(
|
260 |
+
[resultm], switch_pm="RexTester.", switch_pm_param="start"
|
261 |
+
)
|
262 |
except UnknownLanguage:
|
263 |
resultm = builder.article(
|
264 |
title="Error", # By @ProgrammingError
|
265 |
description="Invalid language choosen",
|
266 |
text=f"The list of valid languages are\n\n{rex_langs}\n\n\nFormat to use Rextester is `@Yourassistantusername rex langcode|code`",
|
267 |
)
|
268 |
+
await event.answer(
|
269 |
+
[resultm], switch_pm="RexTester. Invalid Language!", switch_pm_param="start"
|
270 |
+
)
|
271 |
|
272 |
|
273 |
@in_pattern("yahoo")
|
274 |
@in_owner
|
275 |
+
async def yahoosearch(q_event):
|
276 |
try:
|
277 |
match = q_event.text.split(" ", maxsplit=1)[1]
|
278 |
except IndexError:
|
279 |
+
await q_event.answer(
|
280 |
+
[], switch_pm="Yahoo Search. Enter a query!", switch_pm_param="start"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
)
|
|
|
282 |
searcher = []
|
283 |
page = findall(r"page=\d+", match)
|
284 |
cache = False
|
|
|
324 |
)
|
325 |
except IndexError:
|
326 |
break
|
327 |
+
await q_event.answer(searcher, switch_pm="Yahoo Search.", switch_pm_param="start")
|
328 |
|
329 |
|
330 |
@in_pattern("app")
|
|
|
333 |
try:
|
334 |
f = e.text.split(" ", maxsplit=1)[1]
|
335 |
except IndexError:
|
336 |
+
await e.answer(
|
337 |
+
[], switch_pm="App search. Enter app name!", switch_pm_param="start"
|
|
|
|
|
|
|
338 |
)
|
|
|
339 |
foles = []
|
340 |
aap = search(f)
|
341 |
for z in aap:
|
|
|
374 |
],
|
375 |
),
|
376 |
)
|
377 |
+
await e.answer(foles, switch_pm="Application Searcher.", switch_pm_param="start")
|
378 |
|
379 |
|
380 |
@in_pattern("mods")
|
|
|
383 |
try:
|
384 |
quer = e.text.split(" ", maxsplit=1)[1]
|
385 |
except IndexError:
|
386 |
+
await e.answer(
|
387 |
+
[], switch_pm="Mod Apps Search. Enter app name!", switch_pm_param="start"
|
|
|
|
|
388 |
)
|
|
|
389 |
page = 1
|
390 |
start = (page - 1) * 3 + 1
|
391 |
+
da = choice([api1, api2, api3])
|
|
|
|
|
|
|
|
|
|
|
|
|
392 |
url = f"https://www.googleapis.com/customsearch/v1?key={da}&cx=25b3b50edb928435b&q={quer}&start={start}"
|
393 |
data = requests.get(url).json()
|
394 |
search_items = data.get("items")
|
|
|
423 |
],
|
424 |
),
|
425 |
)
|
426 |
+
await e.answer(modss, switch_pm="Search Mod Applications.", switch_pm_param="start")
|
427 |
|
428 |
|
429 |
@in_pattern("clipart")
|
|
|
432 |
try:
|
433 |
quer = e.text.split(" ", maxsplit=1)[1]
|
434 |
except IndexError:
|
435 |
+
await e.answer([], switch_pm="ClipArt Search.", switch_pm_param="start")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
436 |
quer = quer.replace(" ", "+")
|
437 |
sear = f"https://clipartix.com/search/{quer}"
|
438 |
html = urlopen(sear)
|
|
|
442 |
hm = []
|
443 |
for res in resul:
|
444 |
hm += [buil.photo(include_media=True, file=res["src"])]
|
445 |
+
await e.answer(
|
446 |
+
hm, gallery=True, switch_pm="Clipart Searcher.", switch_pm_param="start"
|
447 |
+
)
|
assistant/othervars.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
7 |
|
8 |
import re
|
9 |
-
from os import
|
10 |
|
11 |
import requests
|
12 |
from telegraph import Telegraph
|
@@ -24,6 +24,42 @@ auth_url = r["auth_url"]
|
|
24 |
TOKEN_FILE = "resources/auths/auth_token.txt"
|
25 |
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
@callback("updatenow")
|
28 |
@owner
|
29 |
async def update(eve):
|
@@ -63,6 +99,18 @@ async def update(eve):
|
|
63 |
repo.__del__()
|
64 |
return
|
65 |
await eve.edit("`Successfully Updated!\nRestarting, please wait...`")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
else:
|
67 |
try:
|
68 |
ups_rem.pull(ac_br)
|
@@ -82,11 +130,10 @@ async def changes(okk):
|
|
82 |
ac_br = repo.active_branch
|
83 |
changelog, tl_chnglog = await gen_chlog(repo, f"HEAD..upstream/{ac_br}")
|
84 |
changelog_str = changelog + f"\n\nClick the below button to update!"
|
85 |
-
tldr_str = tl_chnglog + f"\n\nClick the below button to update!"
|
86 |
if len(changelog_str) > 1024:
|
87 |
await okk.edit(get_string("upd_4"))
|
88 |
file = open(f"ultroid_updates.txt", "w+")
|
89 |
-
file.write(
|
90 |
file.close()
|
91 |
await okk.edit(
|
92 |
get_string("upd_5"),
|
@@ -106,7 +153,7 @@ async def changes(okk):
|
|
106 |
@callback(re.compile("pasta-(.*)"))
|
107 |
@owner
|
108 |
async def _(e):
|
109 |
-
ok = e.data_match.group(1)
|
110 |
hmm = open(ok)
|
111 |
hmmm = hmm.read()
|
112 |
hmm.close()
|
@@ -116,13 +163,19 @@ async def _(e):
|
|
116 |
.get("result")
|
117 |
.get("key")
|
118 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
await e.edit(
|
120 |
f"Pasted to Nekobin\n 👉[Link](https://nekobin.com/{key})\n 👉[Raw Link](https://nekobin.com/raw/{key})",
|
121 |
-
buttons=
|
122 |
-
"Search Again..?",
|
123 |
-
query="send ",
|
124 |
-
same_peer=True,
|
125 |
-
),
|
126 |
link_preview=False,
|
127 |
)
|
128 |
|
@@ -959,7 +1012,6 @@ async def vcb(event):
|
|
959 |
f"From This Feature U can play songs in group voice chat\n\n[moreinfo](https://t.me/UltroidUpdates/4)",
|
960 |
buttons=[
|
961 |
[Button.inline("VC Sᴇssɪᴏɴ", data="vcs")],
|
962 |
-
[Button.inline("WEBSOCKET", data="vcw")],
|
963 |
[Button.inline("« Bᴀᴄᴋ", data="setter")],
|
964 |
],
|
965 |
link_preview=False,
|
@@ -994,33 +1046,3 @@ async def name(event):
|
|
994 |
),
|
995 |
buttons=get_back_button("vcb"),
|
996 |
)
|
997 |
-
|
998 |
-
|
999 |
-
@callback("vcw")
|
1000 |
-
@owner
|
1001 |
-
async def name(event):
|
1002 |
-
await event.delete()
|
1003 |
-
pru = event.sender_id
|
1004 |
-
var = "WEBSOCKET_URL"
|
1005 |
-
name = "WEBSOCKET URL"
|
1006 |
-
async with event.client.conversation(pru) as conv:
|
1007 |
-
await conv.send_message(
|
1008 |
-
"**WEBSOCKET URL**\nEnter your websocket url means\n`https://{HEROKU_APP_NAME}.herokuapp.com`\nIn place of HEROKU_APP_NAME put ur heroku app name\n\nUse /cancel to terminate the operation.",
|
1009 |
-
)
|
1010 |
-
response = conv.wait_event(events.NewMessage(chats=pru))
|
1011 |
-
response = await response
|
1012 |
-
themssg = response.message.message
|
1013 |
-
if themssg == "/cancel":
|
1014 |
-
return await conv.send_message(
|
1015 |
-
"Cancelled!!",
|
1016 |
-
buttons=get_back_button("vcb"),
|
1017 |
-
)
|
1018 |
-
else:
|
1019 |
-
await setit(event, var, themssg)
|
1020 |
-
await conv.send_message(
|
1021 |
-
"{} changed to {}\n\nAfter Setting All Things Do restart".format(
|
1022 |
-
name,
|
1023 |
-
themssg,
|
1024 |
-
),
|
1025 |
-
buttons=get_back_button("vcb"),
|
1026 |
-
)
|
|
|
6 |
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
7 |
|
8 |
import re
|
9 |
+
from os import remove
|
10 |
|
11 |
import requests
|
12 |
from telegraph import Telegraph
|
|
|
24 |
TOKEN_FILE = "resources/auths/auth_token.txt"
|
25 |
|
26 |
|
27 |
+
@callback(re.compile("sndplug_(.*)"))
|
28 |
+
async def send(eve):
|
29 |
+
name = (eve.data_match.group(1)).decode("UTF-8")
|
30 |
+
if name.startswith("def"):
|
31 |
+
plug_name = name.replace(f"def_plugin_", "")
|
32 |
+
plugin = f"plugins/{plug_name}.py"
|
33 |
+
buttons = [
|
34 |
+
[
|
35 |
+
Button.inline(
|
36 |
+
"« Pᴀsᴛᴇ »",
|
37 |
+
data=f"pasta-{plugin}",
|
38 |
+
)
|
39 |
+
],
|
40 |
+
[
|
41 |
+
Button.inline("« Bᴀᴄᴋ", data="back"),
|
42 |
+
Button.inline("••Cʟᴏꜱᴇ••", data="close"),
|
43 |
+
],
|
44 |
+
]
|
45 |
+
else:
|
46 |
+
plug_name = name.replace(f"add_plugin_", "")
|
47 |
+
plugin = f"addons/{plug_name}.py"
|
48 |
+
buttons = [
|
49 |
+
[
|
50 |
+
Button.inline(
|
51 |
+
"« Pᴀsᴛᴇ »",
|
52 |
+
data=f"pasta-{plugin}",
|
53 |
+
)
|
54 |
+
],
|
55 |
+
[
|
56 |
+
Button.inline("« Bᴀᴄᴋ", data="buck"),
|
57 |
+
Button.inline("••Cʟᴏꜱᴇ••", data="close"),
|
58 |
+
],
|
59 |
+
]
|
60 |
+
await eve.edit(file=plugin, buttons=buttons)
|
61 |
+
|
62 |
+
|
63 |
@callback("updatenow")
|
64 |
@owner
|
65 |
async def update(eve):
|
|
|
99 |
repo.__del__()
|
100 |
return
|
101 |
await eve.edit("`Successfully Updated!\nRestarting, please wait...`")
|
102 |
+
elif Var.HEROKU_API is None:
|
103 |
+
try:
|
104 |
+
ups_rem.pull(ac_br)
|
105 |
+
except GitCommandError:
|
106 |
+
repo.git.reset("--hard", "FETCH_HEAD")
|
107 |
+
await updateme_requirements()
|
108 |
+
await eve.edit(
|
109 |
+
"`Successfully Updated!\nBot is restarting... Wait for a second!`"
|
110 |
+
)
|
111 |
+
os.system("git pull"), os.system(
|
112 |
+
"pip3.9 install -U -r requirements.txt"
|
113 |
+
), os.execl(sys.executable, sys.executable, "-m", "pyUltroid")
|
114 |
else:
|
115 |
try:
|
116 |
ups_rem.pull(ac_br)
|
|
|
130 |
ac_br = repo.active_branch
|
131 |
changelog, tl_chnglog = await gen_chlog(repo, f"HEAD..upstream/{ac_br}")
|
132 |
changelog_str = changelog + f"\n\nClick the below button to update!"
|
|
|
133 |
if len(changelog_str) > 1024:
|
134 |
await okk.edit(get_string("upd_4"))
|
135 |
file = open(f"ultroid_updates.txt", "w+")
|
136 |
+
file.write(tl_chnglog)
|
137 |
file.close()
|
138 |
await okk.edit(
|
139 |
get_string("upd_5"),
|
|
|
153 |
@callback(re.compile("pasta-(.*)"))
|
154 |
@owner
|
155 |
async def _(e):
|
156 |
+
ok = (e.data_match.group(1)).decode("UTF-8")
|
157 |
hmm = open(ok)
|
158 |
hmmm = hmm.read()
|
159 |
hmm.close()
|
|
|
163 |
.get("result")
|
164 |
.get("key")
|
165 |
)
|
166 |
+
if ok.startswith("plugins"):
|
167 |
+
buttons = [
|
168 |
+
Button.inline("« Bᴀᴄᴋ", data="back"),
|
169 |
+
Button.inline("••Cʟᴏꜱᴇ••", data="close"),
|
170 |
+
]
|
171 |
+
else:
|
172 |
+
buttons = [
|
173 |
+
Button.inline("« Bᴀᴄᴋ", data="buck"),
|
174 |
+
Button.inline("••Cʟᴏꜱᴇ••", data="close"),
|
175 |
+
]
|
176 |
await e.edit(
|
177 |
f"Pasted to Nekobin\n 👉[Link](https://nekobin.com/{key})\n 👉[Raw Link](https://nekobin.com/raw/{key})",
|
178 |
+
buttons=buttons,
|
|
|
|
|
|
|
|
|
179 |
link_preview=False,
|
180 |
)
|
181 |
|
|
|
1012 |
f"From This Feature U can play songs in group voice chat\n\n[moreinfo](https://t.me/UltroidUpdates/4)",
|
1013 |
buttons=[
|
1014 |
[Button.inline("VC Sᴇssɪᴏɴ", data="vcs")],
|
|
|
1015 |
[Button.inline("« Bᴀᴄᴋ", data="setter")],
|
1016 |
],
|
1017 |
link_preview=False,
|
|
|
1046 |
),
|
1047 |
buttons=get_back_button("vcb"),
|
1048 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assistant/pmbot/__init__.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
from pyUltroid.functions.asst_fns import *
|
2 |
-
|
3 |
from .. import *
|
4 |
|
5 |
OWNER_NAME = ultroid_bot.me.first_name
|
|
|
1 |
from pyUltroid.functions.asst_fns import *
|
2 |
+
from pyUltroid.functions.botchat_db import *
|
3 |
from .. import *
|
4 |
|
5 |
OWNER_NAME = ultroid_bot.me.first_name
|
assistant/pmbot/banuser.py
CHANGED
@@ -1,12 +1,18 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
2 |
|
|
|
3 |
|
4 |
@asst_cmd("ban")
|
5 |
async def banhammer(event):
|
6 |
x = await event.get_reply_message()
|
7 |
if x is None:
|
8 |
return await event.edit("Please reply to someone to ban him.")
|
9 |
-
target =
|
10 |
if not is_blacklisted(target):
|
11 |
blacklist_user(target)
|
12 |
await asst.send_message(event.chat_id, f"#BAN\nUser - {target}")
|
@@ -23,7 +29,7 @@ async def banhammer(event):
|
|
23 |
x = await event.get_reply_message()
|
24 |
if x is None:
|
25 |
return await event.edit("Please reply to someone to ban him.")
|
26 |
-
target =
|
27 |
if is_blacklisted(target):
|
28 |
rem_blacklist(target)
|
29 |
await asst.send_message(event.chat_id, f"#UNBAN\nUser - {target}")
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2020 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 *
|
9 |
|
10 |
@asst_cmd("ban")
|
11 |
async def banhammer(event):
|
12 |
x = await event.get_reply_message()
|
13 |
if x is None:
|
14 |
return await event.edit("Please reply to someone to ban him.")
|
15 |
+
target = get_who(x.id)
|
16 |
if not is_blacklisted(target):
|
17 |
blacklist_user(target)
|
18 |
await asst.send_message(event.chat_id, f"#BAN\nUser - {target}")
|
|
|
29 |
x = await event.get_reply_message()
|
30 |
if x is None:
|
31 |
return await event.edit("Please reply to someone to ban him.")
|
32 |
+
target = get_who(x.id)
|
33 |
if is_blacklisted(target):
|
34 |
rem_blacklist(target)
|
35 |
await asst.send_message(event.chat_id, f"#UNBAN\nUser - {target}")
|
assistant/pmbot/incoming.py
CHANGED
@@ -30,4 +30,4 @@ async def on_new_mssg(event):
|
|
30 |
return
|
31 |
else:
|
32 |
xx = await event.forward_to(OWNER_ID)
|
33 |
-
|
|
|
30 |
return
|
31 |
else:
|
32 |
xx = await event.forward_to(OWNER_ID)
|
33 |
+
add_stuff(xx.id, who)
|
assistant/pmbot/outgoing.py
CHANGED
@@ -23,7 +23,7 @@ async def on_out_mssg(event):
|
|
23 |
if who == OWNER_ID:
|
24 |
if event.text.startswith("/"):
|
25 |
return
|
26 |
-
to_user =
|
27 |
if event.media:
|
28 |
if event.text:
|
29 |
await asst.send_file(int(to_user), event.media, caption=event.text)
|
|
|
23 |
if who == OWNER_ID:
|
24 |
if event.text.startswith("/"):
|
25 |
return
|
26 |
+
to_user = get_who(x.id)
|
27 |
if event.media:
|
28 |
if event.text:
|
29 |
await asst.send_file(int(to_user), event.media, caption=event.text)
|
plugins/__init__.py
CHANGED
@@ -16,6 +16,7 @@ from pyUltroid.functions.goodbye_db import *
|
|
16 |
from pyUltroid.functions.google_image import googleimagesdownload
|
17 |
from pyUltroid.functions.sudos import *
|
18 |
from pyUltroid.functions.welcome_db import *
|
|
|
19 |
from pyUltroid.utils import *
|
20 |
|
21 |
from strings import get_string
|
@@ -29,7 +30,7 @@ except ModuleNotFoundError:
|
|
29 |
|
30 |
|
31 |
start_time = time.time()
|
32 |
-
ultroid_version = "v0.0.
|
33 |
OWNER_NAME = ultroid_bot.me.first_name
|
34 |
OWNER_ID = ultroid_bot.me.id
|
35 |
|
|
|
16 |
from pyUltroid.functions.google_image import googleimagesdownload
|
17 |
from pyUltroid.functions.sudos import *
|
18 |
from pyUltroid.functions.welcome_db import *
|
19 |
+
from pyUltroid.functions.ytdl import *
|
20 |
from pyUltroid.utils import *
|
21 |
|
22 |
from strings import get_string
|
|
|
30 |
|
31 |
|
32 |
start_time = time.time()
|
33 |
+
ultroid_version = "v0.0.7"
|
34 |
OWNER_NAME = ultroid_bot.me.first_name
|
35 |
OWNER_ID = ultroid_bot.me.id
|
36 |
|
plugins/_inline.py
CHANGED
@@ -5,11 +5,11 @@
|
|
5 |
# PLease read the GNU Affero General Public License in
|
6 |
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
7 |
|
8 |
-
import random
|
9 |
import re
|
10 |
import time
|
11 |
from datetime import datetime
|
12 |
from math import ceil
|
|
|
13 |
from platform import python_version as PyVer
|
14 |
|
15 |
from git import Repo
|
@@ -22,7 +22,7 @@ from . import *
|
|
22 |
|
23 |
# ================================================#
|
24 |
notmine = f"This bot is for {OWNER_NAME}"
|
25 |
-
ULTROID_PIC = "https://telegra.ph/file/
|
26 |
helps = get_string("inline_1")
|
27 |
|
28 |
add_ons = udB.get("ADDONS")
|
@@ -30,6 +30,10 @@ if add_ons == "True" or add_ons is None:
|
|
30 |
zhelps = get_string("inline_2")
|
31 |
else:
|
32 |
zhelps = get_string("inline_3")
|
|
|
|
|
|
|
|
|
33 |
# ============================================#
|
34 |
|
35 |
|
@@ -71,453 +75,486 @@ async def e(o):
|
|
71 |
await o.answer(res, switch_pm=f"👥 ULTROID PORTAL", switch_pm_param="start")
|
72 |
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
thumb=InputWebDocument(ULTROID_PIC, 0, "image/jpeg", []),
|
94 |
-
text=get_string("inline_4").format(
|
95 |
-
OWNER_NAME,
|
96 |
-
len(PLUGINS) - 5,
|
97 |
-
len(ADDONS),
|
98 |
-
cmd,
|
99 |
-
),
|
100 |
-
buttons=[
|
101 |
-
[
|
102 |
-
Button.inline("• Pʟᴜɢɪɴs", data="hrrrr"),
|
103 |
-
Button.inline("• Aᴅᴅᴏɴs", data="frrr"),
|
104 |
-
],
|
105 |
-
[
|
106 |
-
Button.inline("Oᴡɴᴇʀ•ᴛᴏᴏʟꜱ", data="ownr"),
|
107 |
-
Button.inline("Iɴʟɪɴᴇ•Pʟᴜɢɪɴs", data="inlone"),
|
108 |
-
],
|
109 |
-
[
|
110 |
-
Button.url(
|
111 |
-
"⚙️Sᴇᴛᴛɪɴɢs⚙️",
|
112 |
-
url=f"https://t.me/{bnn}?start=set",
|
113 |
-
),
|
114 |
-
],
|
115 |
-
[Button.inline("••Cʟᴏꜱᴇ••", data="close")],
|
116 |
-
],
|
117 |
-
)
|
118 |
-
await event.answer([result] if result else None)
|
119 |
-
elif event.query.user_id in sed and query.startswith("paste"):
|
120 |
-
ok = query.split("-")[1]
|
121 |
-
link = f"https://nekobin.com/{ok}"
|
122 |
-
link_raw = f"https://nekobin.com/raw/{ok}"
|
123 |
-
result = builder.article(
|
124 |
-
title="Paste",
|
125 |
-
text="Pᴀsᴛᴇᴅ Tᴏ Nᴇᴋᴏʙɪɴ!",
|
126 |
-
buttons=[
|
127 |
-
[
|
128 |
-
Button.url("NekoBin", url=f"{link}"),
|
129 |
-
Button.url("Raw", url=f"{link_raw}"),
|
130 |
-
],
|
131 |
-
],
|
132 |
-
)
|
133 |
-
await event.answer([result] if result else None)
|
134 |
-
|
135 |
-
@callback("ownr")
|
136 |
-
@owner
|
137 |
-
async def setting(event):
|
138 |
-
await event.edit(
|
139 |
-
buttons=[
|
140 |
-
[
|
141 |
-
Button.inline("•Pɪɴɢ•", data="pkng"),
|
142 |
-
Button.inline("•Uᴘᴛɪᴍᴇ•", data="upp"),
|
143 |
-
],
|
144 |
-
[Button.inline("•Rᴇsᴛᴀʀᴛ•", data="rstrt")],
|
145 |
-
[Button.inline("<- Bᴀᴄᴋ", data="open")],
|
146 |
-
],
|
147 |
-
)
|
148 |
-
|
149 |
-
@callback("pkng")
|
150 |
-
async def _(event):
|
151 |
-
start = datetime.now()
|
152 |
-
end = datetime.now()
|
153 |
-
ms = (end - start).microseconds / 1000
|
154 |
-
pin = f"🌋Pɪɴɢ = {ms}ms"
|
155 |
-
await event.answer(pin, cache_time=0, alert=True)
|
156 |
-
|
157 |
-
@callback("upp")
|
158 |
-
async def _(event):
|
159 |
-
uptime = grt(time.time() - start_time)
|
160 |
-
pin = f"🙋Uᴘᴛɪᴍᴇ = {uptime}"
|
161 |
-
await event.answer(pin, cache_time=0, alert=True)
|
162 |
-
|
163 |
-
@callback("inlone")
|
164 |
-
@owner
|
165 |
-
async def _(e):
|
166 |
-
button = [
|
167 |
-
[
|
168 |
-
Button.switch_inline(
|
169 |
-
"Sᴇɴᴅ Oғғɪᴄɪᴀʟ Pʟᴜɢɪɴs",
|
170 |
-
query="send",
|
171 |
-
same_peer=True,
|
172 |
-
),
|
173 |
-
],
|
174 |
-
[
|
175 |
-
Button.switch_inline(
|
176 |
-
"Pʟᴀʏ Sᴛᴏʀᴇ Aᴘᴘs",
|
177 |
-
query="app telegram",
|
178 |
-
same_peer=True,
|
179 |
-
),
|
180 |
-
Button.switch_inline(
|
181 |
-
"Mᴏᴅᴅᴇᴅ Aᴘᴘs",
|
182 |
-
query="mods minecraft",
|
183 |
-
same_peer=True,
|
184 |
-
),
|
185 |
-
],
|
186 |
[
|
187 |
-
Button.
|
188 |
-
|
189 |
-
query="go TeamUltroid",
|
190 |
-
same_peer=True,
|
191 |
-
),
|
192 |
-
Button.switch_inline(
|
193 |
-
"Sᴇᴀʀᴄʜ Oɴ Yᴀʜᴏᴏ",
|
194 |
-
query="yahoo TeamUltroid",
|
195 |
-
same_peer=True,
|
196 |
-
),
|
197 |
],
|
198 |
[
|
199 |
-
Button.
|
200 |
-
|
201 |
-
query="yt Ed Sheeran Perfect",
|
202 |
-
same_peer=True,
|
203 |
-
),
|
204 |
],
|
205 |
[
|
206 |
-
Button.
|
207 |
-
"CʟɪᴘAʀᴛ Sᴇᴀʀᴄʜ",
|
208 |
-
query="clipart frog",
|
209 |
-
same_peer=True,
|
210 |
-
),
|
211 |
-
Button.switch_inline(
|
212 |
-
"OʀᴀɴɢᴇFᴏx🦊",
|
213 |
-
query="ofox beryllium",
|
214 |
-
same_peer=True,
|
215 |
-
),
|
216 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
[
|
218 |
-
Button.
|
219 |
-
|
220 |
-
data="open",
|
221 |
-
),
|
222 |
],
|
223 |
-
]
|
224 |
-
|
225 |
-
|
226 |
-
@callback("hrrrr")
|
227 |
-
@owner
|
228 |
-
async def on_plug_in_callback_query_handler(event):
|
229 |
-
xhelps = helps.format(OWNER_NAME, len(PLUGINS) - 5)
|
230 |
-
buttons = paginate_help(0, PLUGINS, "helpme")
|
231 |
-
await event.edit(f"{xhelps}", buttons=buttons, link_preview=False)
|
232 |
-
|
233 |
-
@callback("frrr")
|
234 |
-
@owner
|
235 |
-
async def addon(event):
|
236 |
-
halp = zhelps.format(OWNER_NAME, len(ADDONS))
|
237 |
-
if len(ADDONS) > 0:
|
238 |
-
buttons = paginate_addon(0, ADDONS, "addon")
|
239 |
-
await event.edit(f"{halp}", buttons=buttons, link_preview=False)
|
240 |
-
else:
|
241 |
-
await event.answer(
|
242 |
-
f"• Tʏᴘᴇ `{HNDLR}setredis ADDONS True`\n Tᴏ ɢᴇᴛ ᴀᴅᴅᴏɴs ᴘʟᴜɢɪɴs",
|
243 |
-
cache_time=0,
|
244 |
-
alert=True,
|
245 |
-
)
|
246 |
|
247 |
-
@callback("rstrt")
|
248 |
-
@owner
|
249 |
-
async def rrst(ult):
|
250 |
-
await restart(ult)
|
251 |
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
)
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
),
|
267 |
-
)
|
268 |
-
@owner
|
269 |
-
async def on_plug_in_callback_query_handler(event):
|
270 |
-
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
|
271 |
-
buttons = paginate_help(current_page_number - 1, PLUGINS, "helpme")
|
272 |
-
await event.edit(buttons=buttons, link_preview=False)
|
273 |
-
|
274 |
-
@callback(
|
275 |
-
re.compile(
|
276 |
-
rb"addon_next\((.+?)\)",
|
277 |
-
),
|
278 |
-
)
|
279 |
-
@owner
|
280 |
-
async def on_plug_in_callback_query_handler(event):
|
281 |
-
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
|
282 |
-
buttons = paginate_addon(current_page_number + 1, ADDONS, "addon")
|
283 |
-
await event.edit(buttons=buttons, link_preview=False)
|
284 |
-
|
285 |
-
@callback(
|
286 |
-
re.compile(
|
287 |
-
rb"addon_prev\((.+?)\)",
|
288 |
),
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
|
293 |
-
buttons = paginate_addon(current_page_number - 1, ADDONS, "addon")
|
294 |
-
await event.edit(buttons=buttons, link_preview=False)
|
295 |
-
|
296 |
-
@callback("back")
|
297 |
-
@owner
|
298 |
-
async def backr(event):
|
299 |
-
xhelps = helps.format(OWNER_NAME, len(PLUGINS) - 5)
|
300 |
-
current_page_number = int(upage)
|
301 |
-
buttons = paginate_help(current_page_number, PLUGINS, "helpme")
|
302 |
-
await event.edit(f"{xhelps}", buttons=buttons, link_preview=False)
|
303 |
-
|
304 |
-
@callback("buck")
|
305 |
-
@owner
|
306 |
-
async def backr(event):
|
307 |
-
xhelps = zhelps.format(OWNER_NAME, len(ADDONS))
|
308 |
-
current_page_number = int(addpage)
|
309 |
-
buttons = paginate_addon(current_page_number, ADDONS, "addon")
|
310 |
-
await event.edit(f"{xhelps}", buttons=buttons, link_preview=False)
|
311 |
-
|
312 |
-
@callback("open")
|
313 |
-
@owner
|
314 |
-
async def opner(event):
|
315 |
-
bnn = asst.me.username
|
316 |
-
buttons = [
|
317 |
[
|
318 |
-
Button.inline("•
|
319 |
-
Button.inline("•
|
320 |
],
|
321 |
[
|
322 |
-
Button.inline("
|
323 |
-
Button.inline("
|
324 |
],
|
325 |
-
[
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
],
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
for y in x:
|
336 |
-
z.append(y)
|
337 |
-
cmd = len(z) + 10
|
338 |
await event.edit(
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
buttons=buttons,
|
346 |
-
link_preview=False,
|
347 |
)
|
348 |
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
)
|
356 |
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
361 |
)
|
362 |
-
@owner
|
363 |
-
async def on_plug_in_callback_query_handler(event):
|
364 |
-
plugin_name = event.data_match.group(1).decode("UTF-8")
|
365 |
-
help_string = f"Plugin Name - `{plugin_name}`\n"
|
366 |
-
try:
|
367 |
-
for i in HELP[plugin_name]:
|
368 |
-
help_string += i
|
369 |
-
except BaseException:
|
370 |
-
pass
|
371 |
-
if help_string == "":
|
372 |
-
reply_pop_up_alert = f"{plugin_name} has no detailed help..."
|
373 |
-
else:
|
374 |
-
reply_pop_up_alert = help_string
|
375 |
-
reply_pop_up_alert += "\n© @TeamUltroid"
|
376 |
-
try:
|
377 |
-
if event.query.user_id in sed:
|
378 |
-
await event.edit(
|
379 |
-
reply_pop_up_alert,
|
380 |
-
buttons=[
|
381 |
-
Button.inline("<- Bᴀᴄᴋ", data="back"),
|
382 |
-
Button.inline("••Cʟᴏꜱᴇ••", data="close"),
|
383 |
-
],
|
384 |
-
)
|
385 |
-
else:
|
386 |
-
reply_pop_up_alert = notmine
|
387 |
-
await event.answer(reply_pop_up_alert, cache_time=0)
|
388 |
-
except BaseException:
|
389 |
-
halps = f"Do .help {plugin_name} to get the list of commands."
|
390 |
-
await event.edit(halps)
|
391 |
|
392 |
-
|
393 |
-
|
394 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
395 |
),
|
|
|
|
|
396 |
)
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
401 |
try:
|
402 |
-
for
|
403 |
-
help_string
|
|
|
404 |
except BaseException:
|
405 |
try:
|
406 |
-
|
407 |
help_string = (
|
408 |
f"Plugin Name-{plugin_name}\n\n✘ Commands Available-\n\n"
|
409 |
)
|
410 |
-
|
|
|
|
|
411 |
except BaseException:
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
424 |
else:
|
425 |
-
reply_pop_up_alert =
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
reply_pop_up_alert,
|
431 |
-
buttons=[
|
432 |
-
Button.inline("<- Bᴀᴄᴋ", data="buck"),
|
433 |
-
Button.inline("••Cʟᴏꜱᴇ••", data="close"),
|
434 |
-
],
|
435 |
-
)
|
436 |
-
else:
|
437 |
-
reply_pop_up_alert = notmine
|
438 |
-
await event.answer(reply_pop_up_alert, cache_time=0)
|
439 |
-
except BaseException:
|
440 |
-
halps = f"Do .help {plugin_name} to get the list of commands."
|
441 |
-
await event.edit(halps)
|
442 |
|
443 |
|
444 |
-
def
|
445 |
number_of_rows = 5
|
446 |
number_of_cols = 2
|
447 |
emoji = Redis("EMOJI_IN_HELP")
|
448 |
if emoji:
|
449 |
-
multi
|
450 |
else:
|
451 |
-
multi
|
452 |
helpable_plugins = []
|
453 |
global upage
|
454 |
upage = page_number
|
455 |
for p in loaded_plugins:
|
456 |
-
|
457 |
-
helpable_plugins.append(p)
|
458 |
-
helpable_plugins = sorted(helpable_plugins)
|
459 |
-
modules = [
|
460 |
-
Button.inline(
|
461 |
-
"{} {} {}".format(
|
462 |
-
random.choice(list(multi)),
|
463 |
-
x,
|
464 |
-
random.choice(list(mult2i)),
|
465 |
-
),
|
466 |
-
data=f"us_plugin_{x}",
|
467 |
-
)
|
468 |
-
for x in helpable_plugins
|
469 |
-
]
|
470 |
-
pairs = list(zip(modules[::number_of_cols], modules[1::number_of_cols]))
|
471 |
-
if len(modules) % number_of_cols == 1:
|
472 |
-
pairs.append((modules[-1],))
|
473 |
-
max_num_pages = ceil(len(pairs) / number_of_rows)
|
474 |
-
modulo_page = page_number % max_num_pages
|
475 |
-
if len(pairs) > number_of_rows:
|
476 |
-
pairs = pairs[
|
477 |
-
modulo_page * number_of_rows : number_of_rows * (modulo_page + 1)
|
478 |
-
] + [
|
479 |
-
(
|
480 |
-
Button.inline(
|
481 |
-
"<- Pʀᴇᴠɪᴏᴜs",
|
482 |
-
data=f"{prefix}_prev({modulo_page})",
|
483 |
-
),
|
484 |
-
Button.inline("-Bᴀᴄᴋ-", data="open"),
|
485 |
-
Button.inline(
|
486 |
-
"Nᴇxᴛ ->",
|
487 |
-
data=f"{prefix}_next({modulo_page})",
|
488 |
-
),
|
489 |
-
),
|
490 |
-
]
|
491 |
-
else:
|
492 |
-
pairs = pairs[
|
493 |
-
modulo_page * number_of_rows : number_of_rows * (modulo_page + 1)
|
494 |
-
] + [(Button.inline("-Bᴀᴄᴋ-", data="open"),)]
|
495 |
-
return pairs
|
496 |
-
|
497 |
-
|
498 |
-
def paginate_addon(page_number, loaded_plugins, prefix):
|
499 |
-
number_of_rows = 5
|
500 |
-
number_of_cols = 2
|
501 |
-
emoji = Redis("EMOJI_IN_HELP")
|
502 |
-
if emoji:
|
503 |
-
multi, mult2i = emoji, emoji
|
504 |
-
else:
|
505 |
-
multi, mult2i = "✘", "✘"
|
506 |
-
helpable_plugins = []
|
507 |
-
global addpage
|
508 |
-
addpage = page_number
|
509 |
-
for p in loaded_plugins:
|
510 |
-
if not p.startswith("_"):
|
511 |
-
helpable_plugins.append(p)
|
512 |
helpable_plugins = sorted(helpable_plugins)
|
513 |
modules = [
|
514 |
Button.inline(
|
515 |
"{} {} {}".format(
|
516 |
-
|
517 |
x,
|
518 |
-
|
519 |
),
|
520 |
-
data=f"
|
521 |
)
|
522 |
for x in helpable_plugins
|
523 |
]
|
@@ -532,12 +569,12 @@ def paginate_addon(page_number, loaded_plugins, prefix):
|
|
532 |
] + [
|
533 |
(
|
534 |
Button.inline(
|
535 |
-
"
|
536 |
data=f"{prefix}_prev({modulo_page})",
|
537 |
),
|
538 |
-
Button.inline("
|
539 |
Button.inline(
|
540 |
-
"Nᴇxᴛ
|
541 |
data=f"{prefix}_next({modulo_page})",
|
542 |
),
|
543 |
),
|
@@ -545,5 +582,5 @@ def paginate_addon(page_number, loaded_plugins, prefix):
|
|
545 |
else:
|
546 |
pairs = pairs[
|
547 |
modulo_page * number_of_rows : number_of_rows * (modulo_page + 1)
|
548 |
-
] + [(Button.inline("
|
549 |
return pairs
|
|
|
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 math import ceil
|
12 |
+
from os import remove
|
13 |
from platform import python_version as PyVer
|
14 |
|
15 |
from git import Repo
|
|
|
22 |
|
23 |
# ================================================#
|
24 |
notmine = f"This bot is for {OWNER_NAME}"
|
25 |
+
ULTROID_PIC = "https://telegra.ph/file/115f149ed8e154641708b.jpg"
|
26 |
helps = get_string("inline_1")
|
27 |
|
28 |
add_ons = udB.get("ADDONS")
|
|
|
30 |
zhelps = get_string("inline_2")
|
31 |
else:
|
32 |
zhelps = get_string("inline_3")
|
33 |
+
if udB.get("INLINE_PIC"):
|
34 |
+
_file_to_replace = udB.get("INLINE_PIC")
|
35 |
+
else:
|
36 |
+
_file_to_replace = "resources/extras/inline.jpg"
|
37 |
# ============================================#
|
38 |
|
39 |
|
|
|
75 |
await o.answer(res, switch_pm=f"👥 ULTROID PORTAL", switch_pm_param="start")
|
76 |
|
77 |
|
78 |
+
@in_pattern("ultd")
|
79 |
+
@in_owner
|
80 |
+
async def inline_handler(event):
|
81 |
+
z = []
|
82 |
+
for x in LIST.values():
|
83 |
+
for y in x:
|
84 |
+
z.append(y)
|
85 |
+
cmd = len(z)
|
86 |
+
bnn = asst.me.username
|
87 |
+
result = event.builder.photo(
|
88 |
+
file=_file_to_replace,
|
89 |
+
link_preview=False,
|
90 |
+
text=get_string("inline_4").format(
|
91 |
+
OWNER_NAME,
|
92 |
+
len(PLUGINS),
|
93 |
+
len(ADDONS),
|
94 |
+
cmd,
|
95 |
+
),
|
96 |
+
buttons=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
[
|
98 |
+
Button.inline("• Pʟᴜɢɪɴs", data="hrrrr"),
|
99 |
+
Button.inline("• Aᴅᴅᴏɴs", data="frrr"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
],
|
101 |
[
|
102 |
+
Button.inline("Oᴡɴᴇʀ•ᴛᴏᴏʟꜱ", data="ownr"),
|
103 |
+
Button.inline("Iɴʟɪɴᴇ•Pʟᴜɢɪɴs", data="inlone"),
|
|
|
|
|
|
|
104 |
],
|
105 |
[
|
106 |
+
Button.url("⚙️Sᴇᴛᴛɪɴɢs⚙️", url=f"https://t.me/{bnn}?start=set"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
],
|
108 |
+
[Button.inline("••Cʟᴏꜱᴇ••", data="close")],
|
109 |
+
],
|
110 |
+
)
|
111 |
+
await event.answer([result])
|
112 |
+
|
113 |
+
|
114 |
+
@in_pattern("paste")
|
115 |
+
@in_owner
|
116 |
+
async def _(event):
|
117 |
+
ok = event.text.split(" ")[1]
|
118 |
+
link = "https://nekobin.com/"
|
119 |
+
result = event.builder.article(
|
120 |
+
title="Paste",
|
121 |
+
text="Pᴀsᴛᴇᴅ Tᴏ Nᴇᴋᴏʙɪɴ!",
|
122 |
+
buttons=[
|
123 |
[
|
124 |
+
Button.url("NekoBin", url=f"{link}{ok}"),
|
125 |
+
Button.url("Raw", url=f"{link}raw/{ok}"),
|
|
|
|
|
126 |
],
|
127 |
+
],
|
128 |
+
)
|
129 |
+
await event.answer([result])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
|
|
|
|
|
|
|
|
131 |
|
132 |
+
@callback("ownr")
|
133 |
+
@owner
|
134 |
+
async def setting(event):
|
135 |
+
z = []
|
136 |
+
for x in LIST.values():
|
137 |
+
for y in x:
|
138 |
+
z.append(y)
|
139 |
+
cmd = len(z)
|
140 |
+
await event.edit(
|
141 |
+
get_string("inline_4").format(
|
142 |
+
OWNER_NAME,
|
143 |
+
len(PLUGINS),
|
144 |
+
len(ADDONS),
|
145 |
+
cmd,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
),
|
147 |
+
file=_file_to_replace,
|
148 |
+
link_preview=False,
|
149 |
+
buttons=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
[
|
151 |
+
Button.inline("•Pɪɴɢ•", data="pkng"),
|
152 |
+
Button.inline("•Uᴘᴛɪᴍᴇ•", data="upp"),
|
153 |
],
|
154 |
[
|
155 |
+
Button.inline("•Rᴇsᴛᴀʀᴛ•", data="rstrt"),
|
156 |
+
Button.inline("•Uᴘᴅᴀᴛᴇ•", data="doupdate"),
|
157 |
],
|
158 |
+
[Button.inline("« Bᴀᴄᴋ", data="open")],
|
159 |
+
],
|
160 |
+
)
|
161 |
+
|
162 |
+
|
163 |
+
@callback("doupdate")
|
164 |
+
@owner
|
165 |
+
async def _(event):
|
166 |
+
check = await updater()
|
167 |
+
if not check:
|
168 |
+
return await event.answer(
|
169 |
+
"You Are Already On Latest Version", cache_time=0, alert=True
|
170 |
+
)
|
171 |
+
repo = Repo.init()
|
172 |
+
ac_br = repo.active_branch
|
173 |
+
changelog, tl_chnglog = await gen_chlog(repo, f"HEAD..upstream/{ac_br}")
|
174 |
+
changelog_str = changelog + f"\n\nClick the below button to update!"
|
175 |
+
if len(changelog_str) > 1024:
|
176 |
+
await event.edit(get_string("upd_4"))
|
177 |
+
file = open(f"ultroid_updates.txt", "w+")
|
178 |
+
file.write(tl_chnglog)
|
179 |
+
file.close()
|
180 |
+
await event.edit(
|
181 |
+
get_string("upd_5"),
|
182 |
+
file="ultroid_updates.txt",
|
183 |
+
buttons=[
|
184 |
+
[Button.inline("• Uᴘᴅᴀᴛᴇ Nᴏᴡ •", data="updatenow")],
|
185 |
+
[Button.inline("« Bᴀᴄᴋ", data="ownr")],
|
186 |
],
|
187 |
+
)
|
188 |
+
remove(f"ultroid_updates.txt")
|
189 |
+
return
|
190 |
+
else:
|
|
|
|
|
|
|
191 |
await event.edit(
|
192 |
+
changelog_str,
|
193 |
+
buttons=[
|
194 |
+
[Button.inline("Update Now", data="updatenow")],
|
195 |
+
[Button.inline("« Bᴀᴄᴋ", data="ownr")],
|
196 |
+
],
|
197 |
+
parse_mode="html",
|
|
|
|
|
198 |
)
|
199 |
|
200 |
+
|
201 |
+
@callback("pkng")
|
202 |
+
async def _(event):
|
203 |
+
start = datetime.now()
|
204 |
+
end = datetime.now()
|
205 |
+
ms = (end - start).microseconds / 1000
|
206 |
+
pin = f"🌋Pɪɴɢ = {ms}ms"
|
207 |
+
await event.answer(pin, cache_time=0, alert=True)
|
208 |
+
|
209 |
+
|
210 |
+
@callback("upp")
|
211 |
+
async def _(event):
|
212 |
+
uptime = grt(time.time() - start_time)
|
213 |
+
pin = f"🙋Uᴘᴛɪᴍᴇ = {uptime}"
|
214 |
+
await event.answer(pin, cache_time=0, alert=True)
|
215 |
+
|
216 |
+
|
217 |
+
@callback("inlone")
|
218 |
+
@owner
|
219 |
+
async def _(e):
|
220 |
+
button = [
|
221 |
+
[
|
222 |
+
Button.switch_inline(
|
223 |
+
"Pʟᴀʏ Sᴛᴏʀᴇ Aᴘᴘs",
|
224 |
+
query="app telegram",
|
225 |
+
same_peer=True,
|
226 |
+
),
|
227 |
+
Button.switch_inline(
|
228 |
+
"Mᴏᴅᴅᴇᴅ Aᴘᴘs",
|
229 |
+
query="mods minecraft",
|
230 |
+
same_peer=True,
|
231 |
+
),
|
232 |
+
],
|
233 |
+
[
|
234 |
+
Button.switch_inline(
|
235 |
+
"Sᴇᴀʀᴄʜ Oɴ Gᴏᴏɢʟᴇ",
|
236 |
+
query="go TeamUltroid",
|
237 |
+
same_peer=True,
|
238 |
+
),
|
239 |
+
Button.switch_inline(
|
240 |
+
"Sᴇᴀʀᴄʜ Oɴ Yᴀʜᴏᴏ",
|
241 |
+
query="yahoo TeamUltroid",
|
242 |
+
same_peer=True,
|
243 |
+
),
|
244 |
+
],
|
245 |
+
[
|
246 |
+
Button.switch_inline(
|
247 |
+
"WʜɪSᴘᴇʀ",
|
248 |
+
query="msg username wspr Hello",
|
249 |
+
same_peer=True,
|
250 |
+
),
|
251 |
+
Button.switch_inline(
|
252 |
+
"YᴏᴜTᴜʙᴇ Dᴏᴡɴʟᴏᴀᴅᴇʀ",
|
253 |
+
query="yt Ed Sheeran Perfect",
|
254 |
+
same_peer=True,
|
255 |
+
),
|
256 |
+
],
|
257 |
+
[
|
258 |
+
Button.switch_inline(
|
259 |
+
"CʟɪᴘAʀᴛ Sᴇᴀʀᴄʜ",
|
260 |
+
query="clipart frog",
|
261 |
+
same_peer=True,
|
262 |
+
),
|
263 |
+
Button.switch_inline(
|
264 |
+
"OʀᴀɴɢᴇFᴏx🦊",
|
265 |
+
query="ofox beryllium",
|
266 |
+
same_peer=True,
|
267 |
+
),
|
268 |
+
],
|
269 |
+
[
|
270 |
+
Button.inline(
|
271 |
+
"« Bᴀᴄᴋ",
|
272 |
+
data="open",
|
273 |
+
),
|
274 |
+
],
|
275 |
+
]
|
276 |
+
await e.edit(buttons=button, link_preview=False)
|
277 |
+
|
278 |
+
|
279 |
+
@callback("hrrrr")
|
280 |
+
@owner
|
281 |
+
async def on_plug_in_callback_query_handler(event):
|
282 |
+
xhelps = helps.format(OWNER_NAME, len(PLUGINS))
|
283 |
+
buttons = page_num(0, PLUGINS, "helpme", "def")
|
284 |
+
await event.edit(f"{xhelps}", buttons=buttons, link_preview=False)
|
285 |
+
|
286 |
+
|
287 |
+
@callback("frrr")
|
288 |
+
@owner
|
289 |
+
async def addon(event):
|
290 |
+
halp = zhelps.format(OWNER_NAME, len(ADDONS))
|
291 |
+
if len(ADDONS) > 0:
|
292 |
+
buttons = page_num(0, ADDONS, "addon", "add")
|
293 |
+
await event.edit(f"{halp}", buttons=buttons, link_preview=False)
|
294 |
+
else:
|
295 |
+
await event.answer(
|
296 |
+
f"• Tʏᴘᴇ `{HNDLR}setredis ADDONS True`\n Tᴏ ɢᴇᴛ ᴀᴅᴅᴏɴs ᴘʟᴜɢɪɴs",
|
297 |
+
cache_time=0,
|
298 |
+
alert=True,
|
299 |
)
|
300 |
|
301 |
+
|
302 |
+
@callback("rstrt")
|
303 |
+
@owner
|
304 |
+
async def rrst(ult):
|
305 |
+
await restart(ult)
|
306 |
+
|
307 |
+
|
308 |
+
@callback(
|
309 |
+
re.compile(
|
310 |
+
rb"helpme_next\((.+?)\)",
|
311 |
+
),
|
312 |
+
)
|
313 |
+
@owner
|
314 |
+
async def on_plug_in_callback_query_handler(event):
|
315 |
+
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
|
316 |
+
buttons = page_num(current_page_number + 1, PLUGINS, "helpme", "def")
|
317 |
+
await event.edit(buttons=buttons, link_preview=False)
|
318 |
+
|
319 |
+
|
320 |
+
@callback(
|
321 |
+
re.compile(
|
322 |
+
rb"helpme_prev\((.+?)\)",
|
323 |
+
),
|
324 |
+
)
|
325 |
+
@owner
|
326 |
+
async def on_plug_in_callback_query_handler(event):
|
327 |
+
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
|
328 |
+
buttons = page_num(current_page_number - 1, PLUGINS, "helpme", "def")
|
329 |
+
await event.edit(buttons=buttons, link_preview=False)
|
330 |
+
|
331 |
+
|
332 |
+
@callback(
|
333 |
+
re.compile(
|
334 |
+
rb"addon_next\((.+?)\)",
|
335 |
+
),
|
336 |
+
)
|
337 |
+
@owner
|
338 |
+
async def on_plug_in_callback_query_handler(event):
|
339 |
+
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
|
340 |
+
buttons = page_num(current_page_number + 1, ADDONS, "addon", "add")
|
341 |
+
await event.edit(buttons=buttons, link_preview=False)
|
342 |
+
|
343 |
+
|
344 |
+
@callback(
|
345 |
+
re.compile(
|
346 |
+
rb"addon_prev\((.+?)\)",
|
347 |
+
),
|
348 |
+
)
|
349 |
+
@owner
|
350 |
+
async def on_plug_in_callback_query_handler(event):
|
351 |
+
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
|
352 |
+
buttons = page_num(current_page_number - 1, ADDONS, "addon", "add")
|
353 |
+
await event.edit(buttons=buttons, link_preview=False)
|
354 |
+
|
355 |
+
|
356 |
+
@callback("back")
|
357 |
+
@owner
|
358 |
+
async def backr(event):
|
359 |
+
xhelps = helps.format(OWNER_NAME, len(PLUGINS))
|
360 |
+
current_page_number = int(upage)
|
361 |
+
buttons = page_num(current_page_number, PLUGINS, "helpme", "def")
|
362 |
+
await event.edit(
|
363 |
+
f"{xhelps}",
|
364 |
+
file=_file_to_replace,
|
365 |
+
buttons=buttons,
|
366 |
+
link_preview=False,
|
367 |
+
)
|
368 |
+
|
369 |
+
|
370 |
+
@callback("buck")
|
371 |
+
@owner
|
372 |
+
async def backr(event):
|
373 |
+
xhelps = zhelps.format(OWNER_NAME, len(ADDONS))
|
374 |
+
current_page_number = int(upage)
|
375 |
+
buttons = page_num(current_page_number, ADDONS, "addon", "add")
|
376 |
+
await event.edit(
|
377 |
+
f"{xhelps}",
|
378 |
+
file=_file_to_replace,
|
379 |
+
buttons=buttons,
|
380 |
+
link_preview=False,
|
381 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
382 |
|
383 |
+
|
384 |
+
@callback("open")
|
385 |
+
@owner
|
386 |
+
async def opner(event):
|
387 |
+
bnn = asst.me.username
|
388 |
+
buttons = [
|
389 |
+
[
|
390 |
+
Button.inline("• Pʟᴜɢɪɴs ", data="hrrrr"),
|
391 |
+
Button.inline("• Aᴅᴅᴏɴs", data="frrr"),
|
392 |
+
],
|
393 |
+
[
|
394 |
+
Button.inline("Oᴡɴᴇʀ•Tᴏᴏʟꜱ", data="ownr"),
|
395 |
+
Button.inline("Iɴʟɪɴᴇ•Pʟᴜɢɪɴs", data="inlone"),
|
396 |
+
],
|
397 |
+
[
|
398 |
+
Button.url(
|
399 |
+
"⚙️Sᴇᴛᴛɪɴɢs⚙️",
|
400 |
+
url=f"https://t.me/{bnn}?start={ultroid_bot.me.id}",
|
401 |
+
),
|
402 |
+
],
|
403 |
+
[Button.inline("••Cʟᴏꜱᴇ••", data="close")],
|
404 |
+
]
|
405 |
+
z = []
|
406 |
+
for x in LIST.values():
|
407 |
+
for y in x:
|
408 |
+
z.append(y)
|
409 |
+
cmd = len(z) + 10
|
410 |
+
await event.edit(
|
411 |
+
get_string("inline_4").format(
|
412 |
+
OWNER_NAME,
|
413 |
+
len(PLUGINS),
|
414 |
+
len(ADDONS),
|
415 |
+
cmd,
|
416 |
),
|
417 |
+
buttons=buttons,
|
418 |
+
link_preview=False,
|
419 |
)
|
420 |
+
|
421 |
+
|
422 |
+
@callback("close")
|
423 |
+
@owner
|
424 |
+
async def on_plug_in_callback_query_handler(event):
|
425 |
+
await event.edit(
|
426 |
+
get_string("inline_5"),
|
427 |
+
file=_file_to_replace,
|
428 |
+
buttons=Button.inline("Oᴘᴇɴ Mᴀɪɴ Mᴇɴᴜ Aɢᴀɪɴ", data="open"),
|
429 |
+
)
|
430 |
+
|
431 |
+
|
432 |
+
@callback(
|
433 |
+
re.compile(
|
434 |
+
b"def_plugin_(.*)",
|
435 |
+
),
|
436 |
+
)
|
437 |
+
@owner
|
438 |
+
async def on_plug_in_callback_query_handler(event):
|
439 |
+
plugin_name = event.data_match.group(1).decode("UTF-8")
|
440 |
+
help_string = f"Plugin Name - `{plugin_name}`\n"
|
441 |
+
try:
|
442 |
+
for i in HELP[plugin_name]:
|
443 |
+
help_string += i
|
444 |
+
except BaseException:
|
445 |
+
pass
|
446 |
+
if help_string == "":
|
447 |
+
reply_pop_up_alert = f"{plugin_name} has no detailed help..."
|
448 |
+
else:
|
449 |
+
reply_pop_up_alert = help_string
|
450 |
+
reply_pop_up_alert += "\n© @TeamUltroid"
|
451 |
+
buttons = [
|
452 |
+
[
|
453 |
+
Button.inline(
|
454 |
+
"« Sᴇɴᴅ Pʟᴜɢɪɴ »",
|
455 |
+
data=f"sndplug_{(event.data).decode('UTF-8')}",
|
456 |
+
)
|
457 |
+
],
|
458 |
+
[
|
459 |
+
Button.inline("« Bᴀᴄᴋ", data="back"),
|
460 |
+
Button.inline("••Cʟᴏꜱᴇ••", data="close"),
|
461 |
+
],
|
462 |
+
]
|
463 |
+
try:
|
464 |
+
if event.query.user_id in sed:
|
465 |
+
await event.edit(
|
466 |
+
reply_pop_up_alert,
|
467 |
+
buttons=buttons,
|
468 |
+
)
|
469 |
+
else:
|
470 |
+
reply_pop_up_alert = notmine
|
471 |
+
await event.answer(reply_pop_up_alert, cache_time=0)
|
472 |
+
except BaseException:
|
473 |
+
halps = f"Do .help {plugin_name} to get the list of commands."
|
474 |
+
await event.edit(halps, buttons=buttons)
|
475 |
+
|
476 |
+
|
477 |
+
@callback(
|
478 |
+
re.compile(
|
479 |
+
b"add_plugin_(.*)",
|
480 |
+
),
|
481 |
+
)
|
482 |
+
@owner
|
483 |
+
async def on_plug_in_callback_query_handler(event):
|
484 |
+
plugin_name = event.data_match.group(1).decode("UTF-8")
|
485 |
+
help_string = ""
|
486 |
+
try:
|
487 |
+
for i in HELP[plugin_name]:
|
488 |
+
help_string += i
|
489 |
+
except BaseException:
|
490 |
try:
|
491 |
+
for u in CMD_HELP[plugin_name]:
|
492 |
+
help_string = f"Plugin Name-{plugin_name}\n\n✘ Commands Available-\n\n"
|
493 |
+
help_string += str(CMD_HELP[plugin_name])
|
494 |
except BaseException:
|
495 |
try:
|
496 |
+
if plugin_name in LIST:
|
497 |
help_string = (
|
498 |
f"Plugin Name-{plugin_name}\n\n✘ Commands Available-\n\n"
|
499 |
)
|
500 |
+
for d in LIST[plugin_name]:
|
501 |
+
help_string += HNDLR + d
|
502 |
+
help_string += "\n"
|
503 |
except BaseException:
|
504 |
+
pass
|
505 |
+
if help_string == "":
|
506 |
+
reply_pop_up_alert = f"{plugin_name} has no detailed help..."
|
507 |
+
else:
|
508 |
+
reply_pop_up_alert = help_string
|
509 |
+
reply_pop_up_alert += "\n© @TeamUltroid"
|
510 |
+
buttons = [
|
511 |
+
[
|
512 |
+
Button.inline(
|
513 |
+
"« Sᴇɴᴅ Pʟᴜɢɪɴ »",
|
514 |
+
data=f"sndplug_{(event.data).decode('UTF-8')}",
|
515 |
+
)
|
516 |
+
],
|
517 |
+
[
|
518 |
+
Button.inline("« Bᴀᴄᴋ", data="buck"),
|
519 |
+
Button.inline("••Cʟᴏꜱᴇ••", data="close"),
|
520 |
+
],
|
521 |
+
]
|
522 |
+
try:
|
523 |
+
if event.query.user_id in sed:
|
524 |
+
await event.edit(
|
525 |
+
reply_pop_up_alert,
|
526 |
+
buttons=buttons,
|
527 |
+
)
|
528 |
else:
|
529 |
+
reply_pop_up_alert = notmine
|
530 |
+
await event.answer(reply_pop_up_alert, cache_time=0)
|
531 |
+
except BaseException:
|
532 |
+
halps = f"Do .help {plugin_name} to get the list of commands."
|
533 |
+
await event.edit(halps, buttons=buttons)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
534 |
|
535 |
|
536 |
+
def page_num(page_number, loaded_plugins, prefix, type):
|
537 |
number_of_rows = 5
|
538 |
number_of_cols = 2
|
539 |
emoji = Redis("EMOJI_IN_HELP")
|
540 |
if emoji:
|
541 |
+
multi = emoji
|
542 |
else:
|
543 |
+
multi = "✘"
|
544 |
helpable_plugins = []
|
545 |
global upage
|
546 |
upage = page_number
|
547 |
for p in loaded_plugins:
|
548 |
+
helpable_plugins.append(p)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
549 |
helpable_plugins = sorted(helpable_plugins)
|
550 |
modules = [
|
551 |
Button.inline(
|
552 |
"{} {} {}".format(
|
553 |
+
multi,
|
554 |
x,
|
555 |
+
multi,
|
556 |
),
|
557 |
+
data=f"{type}_plugin_{x}",
|
558 |
)
|
559 |
for x in helpable_plugins
|
560 |
]
|
|
|
569 |
] + [
|
570 |
(
|
571 |
Button.inline(
|
572 |
+
"« Pʀᴇᴠɪᴏᴜs",
|
573 |
data=f"{prefix}_prev({modulo_page})",
|
574 |
),
|
575 |
+
Button.inline("« Bᴀᴄᴋ »", data="open"),
|
576 |
Button.inline(
|
577 |
+
"Nᴇxᴛ »",
|
578 |
data=f"{prefix}_next({modulo_page})",
|
579 |
),
|
580 |
),
|
|
|
582 |
else:
|
583 |
pairs = pairs[
|
584 |
modulo_page * number_of_rows : number_of_rows * (modulo_page + 1)
|
585 |
+
] + [(Button.inline("« Bᴀᴄᴋ »", data="open"),)]
|
586 |
return pairs
|
plugins/_ultroid.py
CHANGED
@@ -26,5 +26,5 @@ async def repify(e):
|
|
26 |
await q[0].click(e.chat_id)
|
27 |
if e.sender_id == ultroid_bot.uid:
|
28 |
await e.delete()
|
29 |
-
except ChatSendInlineForbiddenError
|
30 |
await eor(e, REPOMSG)
|
|
|
26 |
await q[0].click(e.chat_id)
|
27 |
if e.sender_id == ultroid_bot.uid:
|
28 |
await e.delete()
|
29 |
+
except (ChatSendInlineForbiddenError, bmi):
|
30 |
await eor(e, REPOMSG)
|
plugins/_userlogs.py
CHANGED
@@ -5,14 +5,20 @@
|
|
5 |
# PLease read the GNU Affero General Public License in
|
6 |
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
from telethon.utils import get_display_name
|
9 |
-
from telethon.errors.rpcerrorlist import MediaEmptyError as mee
|
10 |
-
from . import *
|
11 |
|
12 |
-
import
|
13 |
|
14 |
# taglogger
|
15 |
|
|
|
16 |
@ultroid_bot.on(
|
17 |
events.NewMessage(
|
18 |
incoming=True,
|
@@ -24,11 +30,11 @@ async def all_messages_catcher(e):
|
|
24 |
try:
|
25 |
NEEDTOLOG = int(udB.get("TAG_LOG"))
|
26 |
except Exception:
|
27 |
-
return LOGS.
|
28 |
-
x =
|
29 |
if x.bot or x.verified:
|
30 |
return
|
31 |
-
y =
|
32 |
where_n = get_display_name(y)
|
33 |
who_n = get_display_name(x)
|
34 |
where_l = f"https://t.me/c/{y.id}/{e.id}"
|
@@ -39,36 +45,54 @@ async def all_messages_catcher(e):
|
|
39 |
await asst.send_message(
|
40 |
NEEDTOLOG,
|
41 |
send,
|
42 |
-
buttons=[
|
|
|
|
|
|
|
43 |
)
|
44 |
else:
|
45 |
await asst.send_message(
|
46 |
NEEDTOLOG,
|
47 |
send,
|
48 |
-
buttons=[
|
|
|
|
|
|
|
49 |
)
|
50 |
-
except
|
51 |
if x.username:
|
52 |
who_l = f"https://t.me/{x.username}"
|
53 |
await asst.send_message(
|
54 |
NEEDTOLOG,
|
55 |
"`Unsupported Media`",
|
56 |
-
buttons=[
|
|
|
|
|
|
|
57 |
)
|
58 |
else:
|
59 |
await asst.send_message(
|
60 |
NEEDTOLOG,
|
61 |
"`Unsupported Media`",
|
62 |
-
buttons=[
|
|
|
|
|
|
|
63 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
except Exception as er:
|
65 |
LOGS.info(str(er))
|
66 |
-
await ultroid_bot.send_message(NEEDTOLOG, f"Please Add Your Assistant Bot - @{asst.me.username} as admin here.")
|
67 |
else:
|
68 |
return
|
69 |
|
70 |
|
71 |
-
@callback(re.compile(
|
72 |
async def _(e):
|
73 |
wah = e.pattern_match.group(1).decode("UTF-8")
|
74 |
y = await ultroid_bot.get_entity(int(wah))
|
@@ -85,18 +109,13 @@ async def when_asst_added_to_chat(event):
|
|
85 |
user = await event.get_user()
|
86 |
chat = (await event.get_chat()).title
|
87 |
tmp = event.added_by
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
else:
|
96 |
-
# , buttons=Button.inline("Leave Chat", data=f"leave_ch_{event.chat_id}|bot"))
|
97 |
-
return await asst.send_message(
|
98 |
-
Var.LOG_CHANNEL, f"#ADD_LOG\n\n`{add}` added me to {chat}."
|
99 |
-
)
|
100 |
|
101 |
|
102 |
# log for user's new joins
|
@@ -108,35 +127,37 @@ async def when_ultd_added_to_chat(event):
|
|
108 |
user = await event.get_user()
|
109 |
chat = (await event.get_chat()).title
|
110 |
tmp = event.added_by
|
111 |
-
|
112 |
-
|
113 |
-
# , buttons=Button.inline("Leave Chat", data=f"leave_ch_{event.chat_id}|user"))
|
114 |
return await asst.send_message(
|
115 |
-
|
|
|
|
|
116 |
)
|
117 |
elif event.user_joined:
|
118 |
user = await event.get_user()
|
119 |
chat = (await event.get_chat()).title
|
120 |
-
if user.
|
121 |
-
|
122 |
return await asst.send_message(
|
123 |
-
|
|
|
|
|
124 |
)
|
125 |
|
126 |
|
127 |
-
"""
|
128 |
@callback(
|
129 |
re.compile(
|
130 |
-
|
131 |
),
|
132 |
)
|
133 |
@owner
|
134 |
async def leave_ch_at(event):
|
135 |
cht = event.data_match.group(1).decode("UTF-8")
|
136 |
ch_id, client = cht.split("|")
|
|
|
137 |
if client == "bot":
|
138 |
-
await asst.delete_dialog(ch_id)
|
139 |
elif client == "user":
|
140 |
-
await
|
141 |
-
await event.edit(f"Left `{
|
142 |
-
"""
|
|
|
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.errors.rpcerrorlist import (
|
11 |
+
ChatWriteForbiddenError,
|
12 |
+
MediaEmptyError,
|
13 |
+
PeerIdInvalidError,
|
14 |
+
)
|
15 |
from telethon.utils import get_display_name
|
|
|
|
|
16 |
|
17 |
+
from . import *
|
18 |
|
19 |
# taglogger
|
20 |
|
21 |
+
|
22 |
@ultroid_bot.on(
|
23 |
events.NewMessage(
|
24 |
incoming=True,
|
|
|
30 |
try:
|
31 |
NEEDTOLOG = int(udB.get("TAG_LOG"))
|
32 |
except Exception:
|
33 |
+
return LOGS.info("you given Wrong Grp/Channel ID in TAG_LOG.")
|
34 |
+
x = e.sender
|
35 |
if x.bot or x.verified:
|
36 |
return
|
37 |
+
y = e.chat
|
38 |
where_n = get_display_name(y)
|
39 |
who_n = get_display_name(x)
|
40 |
where_l = f"https://t.me/c/{y.id}/{e.id}"
|
|
|
45 |
await asst.send_message(
|
46 |
NEEDTOLOG,
|
47 |
send,
|
48 |
+
buttons=[
|
49 |
+
[Button.url(who_n, who_l)],
|
50 |
+
[Button.url(where_n, where_l)],
|
51 |
+
],
|
52 |
)
|
53 |
else:
|
54 |
await asst.send_message(
|
55 |
NEEDTOLOG,
|
56 |
send,
|
57 |
+
buttons=[
|
58 |
+
[Button.inline(who_n, data=f"who{x.id}")],
|
59 |
+
[Button.url(where_n, where_l)],
|
60 |
+
],
|
61 |
)
|
62 |
+
except MediaEmptyError:
|
63 |
if x.username:
|
64 |
who_l = f"https://t.me/{x.username}"
|
65 |
await asst.send_message(
|
66 |
NEEDTOLOG,
|
67 |
"`Unsupported Media`",
|
68 |
+
buttons=[
|
69 |
+
[Button.url(who_n, who_l)],
|
70 |
+
[Button.url(where_n, where_l)],
|
71 |
+
],
|
72 |
)
|
73 |
else:
|
74 |
await asst.send_message(
|
75 |
NEEDTOLOG,
|
76 |
"`Unsupported Media`",
|
77 |
+
buttons=[
|
78 |
+
[Button.inline(who_n, data=f"who{x.id}")],
|
79 |
+
[Button.url(where_n, where_l)],
|
80 |
+
],
|
81 |
)
|
82 |
+
except PeerIdInvalidError:
|
83 |
+
await ultroid_bot.send_message(
|
84 |
+
int(udB.get("LOG_CHANNEL")),
|
85 |
+
"The Chat Id You Set In Tag Logger Is Wrong , Please Correct It",
|
86 |
+
)
|
87 |
+
except ChatWriteForbiddenError:
|
88 |
+
await ultroid_bot.send_message(NEEDTOLOG, "Please Give Your Assistant Bot")
|
89 |
except Exception as er:
|
90 |
LOGS.info(str(er))
|
|
|
91 |
else:
|
92 |
return
|
93 |
|
94 |
|
95 |
+
@callback(re.compile("who(.*)"))
|
96 |
async def _(e):
|
97 |
wah = e.pattern_match.group(1).decode("UTF-8")
|
98 |
y = await ultroid_bot.get_entity(int(wah))
|
|
|
109 |
user = await event.get_user()
|
110 |
chat = (await event.get_chat()).title
|
111 |
tmp = event.added_by
|
112 |
+
if user.is_self:
|
113 |
+
buttons = Button.inline("Leave Chat", data=f"leave_ch_{event.chat_id}|bot")
|
114 |
+
return await asst.send_message(
|
115 |
+
int(udB.get("LOG_CHANNEL")),
|
116 |
+
f"#ADD_LOG\n\n[{tmp.first_name}](tg://user?id={tmp.id}) added [{user.first_name}](tg://user?id={user.id}) to {chat}.",
|
117 |
+
buttons=buttons,
|
118 |
+
)
|
|
|
|
|
|
|
|
|
|
|
119 |
|
120 |
|
121 |
# log for user's new joins
|
|
|
127 |
user = await event.get_user()
|
128 |
chat = (await event.get_chat()).title
|
129 |
tmp = event.added_by
|
130 |
+
if user.is_self:
|
131 |
+
buttons = Button.inline("Leave Chat", data=f"leave_ch_{event.chat_id}|user")
|
|
|
132 |
return await asst.send_message(
|
133 |
+
int(udB.get("LOG_CHANNEL")),
|
134 |
+
f"#ADD_LOG\n\n[{tmp.first_name}](tg://user?id={tmp.id}) just added [{user.first_name}](tg://user?id={user.id}) to {chat}.",
|
135 |
+
buttons=buttons,
|
136 |
)
|
137 |
elif event.user_joined:
|
138 |
user = await event.get_user()
|
139 |
chat = (await event.get_chat()).title
|
140 |
+
if user.is_self:
|
141 |
+
buttons = Button.inline("Leave Chat", data=f"leave_ch_{event.chat_id}|user")
|
142 |
return await asst.send_message(
|
143 |
+
int(udB.get("LOG_CHANNEL")),
|
144 |
+
f"#JOIN_LOG\n\n[{user.first_name}](tg://user?id={user.id}) just joined {chat}.",
|
145 |
+
buttons=buttons,
|
146 |
)
|
147 |
|
148 |
|
|
|
149 |
@callback(
|
150 |
re.compile(
|
151 |
+
"leave_ch_(.*)",
|
152 |
),
|
153 |
)
|
154 |
@owner
|
155 |
async def leave_ch_at(event):
|
156 |
cht = event.data_match.group(1).decode("UTF-8")
|
157 |
ch_id, client = cht.split("|")
|
158 |
+
name = (await event.get_chat()).title
|
159 |
if client == "bot":
|
160 |
+
await asst.delete_dialog(int(ch_id))
|
161 |
elif client == "user":
|
162 |
+
await ultroid_bot.delete_dialog(int(ch_id))
|
163 |
+
await event.edit(f"Left `{name}`")
|
|
plugins/_wspr.py
CHANGED
@@ -100,7 +100,7 @@ async def _(e):
|
|
100 |
Button.url("Private", url=f"t.me/{username}"),
|
101 |
Button.switch_inline(
|
102 |
"Secret msg",
|
103 |
-
query=f"msg {query} wspr ",
|
104 |
same_peer=True,
|
105 |
),
|
106 |
]
|
|
|
100 |
Button.url("Private", url=f"t.me/{username}"),
|
101 |
Button.switch_inline(
|
102 |
"Secret msg",
|
103 |
+
query=f"msg {query} wspr Hello 👋",
|
104 |
same_peer=True,
|
105 |
),
|
106 |
]
|
plugins/admintools.py
CHANGED
@@ -9,16 +9,12 @@
|
|
9 |
✘ Commands Available -
|
10 |
|
11 |
• `{i}promote <reply to user/userid/username>`
|
12 |
-
|
13 |
-
|
14 |
-
• `{i}demote <reply to user/userid/username>`
|
15 |
-
Demote the user in the chat.
|
16 |
|
17 |
• `{i}ban <reply to user/userid/username> <reason>`
|
18 |
-
|
19 |
-
|
20 |
-
• `{i}unban <reply to user/userid/username> <reason>`
|
21 |
-
Unban the user from the chat.
|
22 |
|
23 |
• `{i}kick <reply to user/userid/username> <reason>`
|
24 |
Kick the user from the chat.
|
@@ -28,11 +24,14 @@
|
|
28 |
for silent pin use ({i}pin silent).
|
29 |
|
30 |
• `{i}unpin (all) <reply to message>`
|
31 |
-
Unpin the
|
32 |
|
33 |
• `{i}pinned`
|
34 |
Get pinned message in the current chat.
|
35 |
|
|
|
|
|
|
|
36 |
• `{i}listpinned`
|
37 |
Get all pinned messages in current chat.
|
38 |
|
@@ -42,21 +41,16 @@
|
|
42 |
• `{i}purgeme <reply to message>`
|
43 |
Purge Only your messages from the replied message.
|
44 |
|
45 |
-
• `{i}purgeall
|
46 |
Delete all msgs of replied user.
|
47 |
-
|
48 |
-
• `{i}del <reply to message>`
|
49 |
-
Delete the replied message.
|
50 |
-
|
51 |
-
• `{i}edit <new message>`
|
52 |
-
Edit your last message.
|
53 |
"""
|
54 |
|
55 |
import asyncio
|
56 |
|
57 |
from telethon.errors import BadRequestError
|
58 |
-
from telethon.errors.rpcerrorlist import UserIdInvalidError
|
59 |
-
from telethon.tl.functions.channels import EditAdminRequest
|
|
|
60 |
from telethon.tl.types import ChatAdminRights, InputMessagesFilterPinned
|
61 |
|
62 |
from . import *
|
@@ -317,7 +311,13 @@ async def unp(ult):
|
|
317 |
async def fastpurger(purg):
|
318 |
chat = await purg.get_input_chat()
|
319 |
match = purg.pattern_match.group(1)
|
320 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
p = 0
|
322 |
async for msg in ultroid_bot.iter_messages(purg.chat_id, limit=int(match)):
|
323 |
await msg.delete()
|
@@ -408,14 +408,9 @@ async def _(e):
|
|
408 |
input = (await e.get_reply_message()).sender_id
|
409 |
name = (await e.client.get_entity(input)).first_name
|
410 |
try:
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
nos += 1
|
415 |
-
await xx.edit(
|
416 |
-
f"**Purged **`{nos}`** msgs of **[{name}](tg://user?id={input})",
|
417 |
-
)
|
418 |
-
except ValueError:
|
419 |
return await eod(xx, str(er), time=5)
|
420 |
else:
|
421 |
return await eod(
|
@@ -425,40 +420,6 @@ async def _(e):
|
|
425 |
)
|
426 |
|
427 |
|
428 |
-
@ultroid_cmd(
|
429 |
-
pattern="del$",
|
430 |
-
)
|
431 |
-
async def delete_it(delme):
|
432 |
-
msg_src = await delme.get_reply_message()
|
433 |
-
if delme.reply_to_msg_id:
|
434 |
-
try:
|
435 |
-
await msg_src.delete()
|
436 |
-
await delme.delete()
|
437 |
-
except BaseException:
|
438 |
-
await eod(
|
439 |
-
delme,
|
440 |
-
f"Couldn't delete the message.\n\n**ERROR:**\n`{str(e)}`",
|
441 |
-
time=5,
|
442 |
-
)
|
443 |
-
|
444 |
-
|
445 |
-
@ultroid_cmd(
|
446 |
-
pattern="edit",
|
447 |
-
)
|
448 |
-
async def editer(edit):
|
449 |
-
message = edit.text
|
450 |
-
chat = await edit.get_input_chat()
|
451 |
-
self_id = await ultroid_bot.get_peer_id("me")
|
452 |
-
string = str(message[6:])
|
453 |
-
i = 1
|
454 |
-
async for message in ultroid_bot.iter_messages(chat, self_id):
|
455 |
-
if i == 2:
|
456 |
-
await message.edit(string)
|
457 |
-
await edit.delete()
|
458 |
-
break
|
459 |
-
i = i + 1
|
460 |
-
|
461 |
-
|
462 |
@ultroid_cmd(pattern="pinned")
|
463 |
async def get_pinned(event):
|
464 |
x = await eor(event, get_string("com_1"))
|
@@ -503,4 +464,22 @@ async def get_all_pinned(event):
|
|
503 |
await x.edit(m + a, parse_mode="html")
|
504 |
|
505 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
506 |
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
|
|
|
9 |
✘ Commands Available -
|
10 |
|
11 |
• `{i}promote <reply to user/userid/username>`
|
12 |
+
• `{i}demote`
|
13 |
+
Promote/Demote the user in the chat.
|
|
|
|
|
14 |
|
15 |
• `{i}ban <reply to user/userid/username> <reason>`
|
16 |
+
• `{i}unban`
|
17 |
+
Ban/Unban the user from the chat.
|
|
|
|
|
18 |
|
19 |
• `{i}kick <reply to user/userid/username> <reason>`
|
20 |
Kick the user from the chat.
|
|
|
24 |
for silent pin use ({i}pin silent).
|
25 |
|
26 |
• `{i}unpin (all) <reply to message>`
|
27 |
+
Unpin the messages in the chat.
|
28 |
|
29 |
• `{i}pinned`
|
30 |
Get pinned message in the current chat.
|
31 |
|
32 |
+
• `{i}autodelete <24h/7d/off>`
|
33 |
+
Enable Auto Delete Messages in Chat.
|
34 |
+
|
35 |
• `{i}listpinned`
|
36 |
Get all pinned messages in current chat.
|
37 |
|
|
|
41 |
• `{i}purgeme <reply to message>`
|
42 |
Purge Only your messages from the replied message.
|
43 |
|
44 |
+
• `{i}purgeall`
|
45 |
Delete all msgs of replied user.
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
"""
|
47 |
|
48 |
import asyncio
|
49 |
|
50 |
from telethon.errors import BadRequestError
|
51 |
+
from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidError
|
52 |
+
from telethon.tl.functions.channels import DeleteUserHistoryRequest, EditAdminRequest
|
53 |
+
from telethon.tl.functions.messages import SetHistoryTTLRequest
|
54 |
from telethon.tl.types import ChatAdminRights, InputMessagesFilterPinned
|
55 |
|
56 |
from . import *
|
|
|
311 |
async def fastpurger(purg):
|
312 |
chat = await purg.get_input_chat()
|
313 |
match = purg.pattern_match.group(1)
|
314 |
+
try:
|
315 |
+
ABC = purg.text[6]
|
316 |
+
except IndexError:
|
317 |
+
ABC = None
|
318 |
+
if ABC and purg.text[6] in ["m", "a"]:
|
319 |
+
return
|
320 |
+
if match and not purg.is_reply:
|
321 |
p = 0
|
322 |
async for msg in ultroid_bot.iter_messages(purg.chat_id, limit=int(match)):
|
323 |
await msg.delete()
|
|
|
408 |
input = (await e.get_reply_message()).sender_id
|
409 |
name = (await e.client.get_entity(input)).first_name
|
410 |
try:
|
411 |
+
await ultroid_bot(DeleteUserHistoryRequest(e.chat_id, input))
|
412 |
+
await eod(e, f"Successfully Purged All Messages from {name}")
|
413 |
+
except Exception as er:
|
|
|
|
|
|
|
|
|
|
|
414 |
return await eod(xx, str(er), time=5)
|
415 |
else:
|
416 |
return await eod(
|
|
|
420 |
)
|
421 |
|
422 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
423 |
@ultroid_cmd(pattern="pinned")
|
424 |
async def get_pinned(event):
|
425 |
x = await eor(event, get_string("com_1"))
|
|
|
464 |
await x.edit(m + a, parse_mode="html")
|
465 |
|
466 |
|
467 |
+
@ultroid_cmd(pattern="autodelete ?(.*)", groups_only=True, admins_only=True)
|
468 |
+
async def autodelte(ult): # Tg Feature
|
469 |
+
match = ult.pattern_match.group(1)
|
470 |
+
if not match or match not in ["24h", "7d", "off"]:
|
471 |
+
return await eod(ult, "`Please Use Proper Format..`")
|
472 |
+
if match == "24h":
|
473 |
+
tt = 3600 * 24
|
474 |
+
elif match == "7d":
|
475 |
+
tt = 3600 * 24 * 7
|
476 |
+
else:
|
477 |
+
tt = 0
|
478 |
+
try:
|
479 |
+
await ultroid_bot(SetHistoryTTLRequest(ult.chat_id, period=tt))
|
480 |
+
except ChatNotModifiedError:
|
481 |
+
return await eod(ult, f"Auto Delete Setting is Already same to `{match}`")
|
482 |
+
await eor(ult, f"Auto Delete Status Changed to {match} !")
|
483 |
+
|
484 |
+
|
485 |
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
|
plugins/afk.py
CHANGED
@@ -37,7 +37,7 @@ last_afk_message = {}
|
|
37 |
last_afk_msg = {}
|
38 |
afk_start = {}
|
39 |
|
40 |
-
LOG =
|
41 |
|
42 |
|
43 |
@ultroid_bot.on(events.NewMessage(outgoing=True))
|
|
|
37 |
last_afk_msg = {}
|
38 |
afk_start = {}
|
39 |
|
40 |
+
LOG = int(udB.get("LOG_CHANNEL"))
|
41 |
|
42 |
|
43 |
@ultroid_bot.on(events.NewMessage(outgoing=True))
|
plugins/autocorrect.py
CHANGED
@@ -24,14 +24,14 @@ tr = Translator()
|
|
24 |
|
25 |
@ultroid_cmd(pattern="autocorrect")
|
26 |
async def acc(e):
|
27 |
-
if not is_fullsudo(
|
28 |
return await eod(ult, "`This Command Is Sudo Restricted.`")
|
29 |
if Redis("AUTOCORRECT") != "True":
|
30 |
udB.set("AUTOCORRECT", "True")
|
31 |
await eod(e, "AUTOCORRECT Feature On")
|
32 |
else:
|
33 |
udB.delete("AUTOCORRECT")
|
34 |
-
await
|
35 |
|
36 |
|
37 |
@ultroid_bot.on(events.NewMessage(outgoing=True))
|
|
|
24 |
|
25 |
@ultroid_cmd(pattern="autocorrect")
|
26 |
async def acc(e):
|
27 |
+
if not is_fullsudo(e.sender_id):
|
28 |
return await eod(ult, "`This Command Is Sudo Restricted.`")
|
29 |
if Redis("AUTOCORRECT") != "True":
|
30 |
udB.set("AUTOCORRECT", "True")
|
31 |
await eod(e, "AUTOCORRECT Feature On")
|
32 |
else:
|
33 |
udB.delete("AUTOCORRECT")
|
34 |
+
await eod(e, "AUTOCORRECT Feature Off")
|
35 |
|
36 |
|
37 |
@ultroid_bot.on(events.NewMessage(outgoing=True))
|
plugins/autopic.py
CHANGED
@@ -8,10 +8,10 @@
|
|
8 |
"""
|
9 |
✘ Commands Available -
|
10 |
|
11 |
-
• {i}autopic <search query
|
12 |
Will change your profile pic at defined intervals with pics related to the given topic.
|
13 |
|
14 |
-
• {i}stoppic
|
15 |
Stop the AutoPic command.
|
16 |
|
17 |
"""
|
|
|
8 |
"""
|
9 |
✘ Commands Available -
|
10 |
|
11 |
+
• `{i}autopic <search query>`
|
12 |
Will change your profile pic at defined intervals with pics related to the given topic.
|
13 |
|
14 |
+
• `{i}stoppic`
|
15 |
Stop the AutoPic command.
|
16 |
|
17 |
"""
|
plugins/bot.py
CHANGED
@@ -122,17 +122,16 @@ async def cmds(event):
|
|
122 |
)
|
123 |
async def restartbt(ult):
|
124 |
if Var.HEROKU_API:
|
125 |
-
await
|
126 |
-
try:
|
127 |
-
await restart(ult)
|
128 |
-
except BaseException:
|
129 |
-
await bash("pkill python3 && python3 -m pyUltroid")
|
130 |
else:
|
131 |
await bash("pkill python3 && python3 -m pyUltroid")
|
132 |
|
133 |
|
134 |
@ultroid_cmd(pattern="shutdown")
|
135 |
async def shutdownbot(ult):
|
|
|
|
|
|
|
136 |
try:
|
137 |
dyno = ult.text.split(" ", maxsplit=1)[1]
|
138 |
except IndexError:
|
@@ -181,7 +180,7 @@ async def heroku_logs(event):
|
|
181 |
await ultroid.send_file(
|
182 |
event.chat_id,
|
183 |
file="ultroid-heroku.log",
|
184 |
-
thumb="resources/extras/
|
185 |
caption=f"**Ultroid Heroku Logs.**\nPasted [here]({url}) too!",
|
186 |
)
|
187 |
os.remove("ultroid-heroku.log")
|
@@ -201,7 +200,7 @@ async def def_logs(ult):
|
|
201 |
await ultroid.send_file(
|
202 |
ult.chat_id,
|
203 |
file="ultroid.log",
|
204 |
-
thumb="resources/extras/
|
205 |
caption=f"**Ultroid Logs.**\nPasted [here]({url}) too!",
|
206 |
)
|
207 |
await xx.edit("Done")
|
|
|
122 |
)
|
123 |
async def restartbt(ult):
|
124 |
if Var.HEROKU_API:
|
125 |
+
await restart(ult)
|
|
|
|
|
|
|
|
|
126 |
else:
|
127 |
await bash("pkill python3 && python3 -m pyUltroid")
|
128 |
|
129 |
|
130 |
@ultroid_cmd(pattern="shutdown")
|
131 |
async def shutdownbot(ult):
|
132 |
+
if not ult.out:
|
133 |
+
if not is_fullsudo(ult.sender_id):
|
134 |
+
return await eod(ult, "`This Command Is Sudo Restricted.`")
|
135 |
try:
|
136 |
dyno = ult.text.split(" ", maxsplit=1)[1]
|
137 |
except IndexError:
|
|
|
180 |
await ultroid.send_file(
|
181 |
event.chat_id,
|
182 |
file="ultroid-heroku.log",
|
183 |
+
thumb="resources/extras/ultroid.jpg",
|
184 |
caption=f"**Ultroid Heroku Logs.**\nPasted [here]({url}) too!",
|
185 |
)
|
186 |
os.remove("ultroid-heroku.log")
|
|
|
200 |
await ultroid.send_file(
|
201 |
ult.chat_id,
|
202 |
file="ultroid.log",
|
203 |
+
thumb="resources/extras/ultroid.jpg",
|
204 |
caption=f"**Ultroid Logs.**\nPasted [here]({url}) too!",
|
205 |
)
|
206 |
await xx.edit("Done")
|
plugins/broadcast.py
CHANGED
@@ -8,10 +8,10 @@
|
|
8 |
"""
|
9 |
✘ Commands Available
|
10 |
|
11 |
-
• `{i}
|
12 |
Add chat to database. Adds current chat if no id specified.
|
13 |
|
14 |
-
• `{i}
|
15 |
Removes the specified chat (current chat if none specified), or all chats.
|
16 |
|
17 |
• `{i}broadcast <reply to msg>`
|
@@ -30,11 +30,11 @@ import io
|
|
30 |
from . import *
|
31 |
|
32 |
|
33 |
-
@ultroid_cmd(
|
|
|
|
|
|
|
34 |
async def broadcast_adder(event):
|
35 |
-
if len(event.text) > 4:
|
36 |
-
if not event.text[4] == " ": # weird fix
|
37 |
-
return
|
38 |
msgg = event.pattern_match.group(1)
|
39 |
x = await eor(event, get_string("bd_1"))
|
40 |
aldone = new = crsh = 0
|
@@ -74,7 +74,7 @@ async def broadcast_adder(event):
|
|
74 |
return
|
75 |
chat_id = event.chat_id
|
76 |
try:
|
77 |
-
if int(chat_id) ==
|
78 |
return
|
79 |
except BaseException:
|
80 |
pass
|
@@ -92,11 +92,11 @@ async def broadcast_adder(event):
|
|
92 |
await event.delete()
|
93 |
|
94 |
|
95 |
-
@ultroid_cmd(
|
|
|
|
|
|
|
96 |
async def broadcast_remover(event):
|
97 |
-
if len(event.text) > 4:
|
98 |
-
if not event.text[4] == " ": # weird fix
|
99 |
-
return
|
100 |
chat_id = event.pattern_match.group(1)
|
101 |
x = await eor(event, get_string("com_1"))
|
102 |
if chat_id == "all":
|
@@ -120,7 +120,9 @@ async def broadcast_remover(event):
|
|
120 |
await x.delete()
|
121 |
|
122 |
|
123 |
-
@ultroid_cmd(
|
|
|
|
|
124 |
async def list_all(event):
|
125 |
x = await eor(event, "`Calculating...`")
|
126 |
channels = get_channels()
|
@@ -153,7 +155,10 @@ async def list_all(event):
|
|
153 |
await x.edit(msg)
|
154 |
|
155 |
|
156 |
-
@ultroid_cmd(
|
|
|
|
|
|
|
157 |
async def forw(event):
|
158 |
if not event.is_reply:
|
159 |
await eor(event, "Reply to a message to broadcast.")
|
@@ -177,7 +182,7 @@ async def forw(event):
|
|
177 |
except Exception:
|
178 |
try:
|
179 |
await ultroid_bot.send_message(
|
180 |
-
|
181 |
f"Error in sending at {channel}.",
|
182 |
)
|
183 |
except BaseException:
|
@@ -189,12 +194,17 @@ async def forw(event):
|
|
189 |
await x.edit(f"{sent_count} messages sent with {error_count} errors.")
|
190 |
if error_count > 0:
|
191 |
try:
|
192 |
-
await ultroid_bot.send_message(
|
|
|
|
|
193 |
except BaseException:
|
194 |
await x.edit("Set up log channel for checking errors.")
|
195 |
|
196 |
|
197 |
-
@ultroid_cmd(
|
|
|
|
|
|
|
198 |
async def sending(event):
|
199 |
x = await eor(event, "`Processing...`")
|
200 |
if not event.is_reply:
|
@@ -220,7 +230,7 @@ async def sending(event):
|
|
220 |
except Exception as error:
|
221 |
try:
|
222 |
await ultroid_bot.send_message(
|
223 |
-
|
224 |
f"Error in sending at {channel}.\n\n{error}",
|
225 |
)
|
226 |
except BaseException:
|
@@ -233,7 +243,7 @@ async def sending(event):
|
|
233 |
if error_count > 0:
|
234 |
try:
|
235 |
await ultroid_bot.send_message(
|
236 |
-
|
237 |
f"{error_count} Errors",
|
238 |
)
|
239 |
except BaseException:
|
|
|
8 |
"""
|
9 |
✘ Commands Available
|
10 |
|
11 |
+
• `{i}addch <id/reply to list/none>`
|
12 |
Add chat to database. Adds current chat if no id specified.
|
13 |
|
14 |
+
• `{i}remch <all/id/none>`
|
15 |
Removes the specified chat (current chat if none specified), or all chats.
|
16 |
|
17 |
• `{i}broadcast <reply to msg>`
|
|
|
30 |
from . import *
|
31 |
|
32 |
|
33 |
+
@ultroid_cmd(
|
34 |
+
pattern="addch ?(.*)",
|
35 |
+
allow_sudo=False,
|
36 |
+
)
|
37 |
async def broadcast_adder(event):
|
|
|
|
|
|
|
38 |
msgg = event.pattern_match.group(1)
|
39 |
x = await eor(event, get_string("bd_1"))
|
40 |
aldone = new = crsh = 0
|
|
|
74 |
return
|
75 |
chat_id = event.chat_id
|
76 |
try:
|
77 |
+
if int(chat_id) == int(udB.get("LOG_CHANNEL")):
|
78 |
return
|
79 |
except BaseException:
|
80 |
pass
|
|
|
92 |
await event.delete()
|
93 |
|
94 |
|
95 |
+
@ultroid_cmd(
|
96 |
+
pattern="remch ?(.*)",
|
97 |
+
allow_sudo=False,
|
98 |
+
)
|
99 |
async def broadcast_remover(event):
|
|
|
|
|
|
|
100 |
chat_id = event.pattern_match.group(1)
|
101 |
x = await eor(event, get_string("com_1"))
|
102 |
if chat_id == "all":
|
|
|
120 |
await x.delete()
|
121 |
|
122 |
|
123 |
+
@ultroid_cmd(
|
124 |
+
pattern="listchannels$",
|
125 |
+
)
|
126 |
async def list_all(event):
|
127 |
x = await eor(event, "`Calculating...`")
|
128 |
channels = get_channels()
|
|
|
155 |
await x.edit(msg)
|
156 |
|
157 |
|
158 |
+
@ultroid_cmd(
|
159 |
+
pattern="forward$",
|
160 |
+
allow_sudo=False,
|
161 |
+
)
|
162 |
async def forw(event):
|
163 |
if not event.is_reply:
|
164 |
await eor(event, "Reply to a message to broadcast.")
|
|
|
182 |
except Exception:
|
183 |
try:
|
184 |
await ultroid_bot.send_message(
|
185 |
+
int(udB.get("LOG_CHANNEL")),
|
186 |
f"Error in sending at {channel}.",
|
187 |
)
|
188 |
except BaseException:
|
|
|
194 |
await x.edit(f"{sent_count} messages sent with {error_count} errors.")
|
195 |
if error_count > 0:
|
196 |
try:
|
197 |
+
await ultroid_bot.send_message(
|
198 |
+
int(udB.get("LOG_CHANNEL")), f"{error_count} Errors"
|
199 |
+
)
|
200 |
except BaseException:
|
201 |
await x.edit("Set up log channel for checking errors.")
|
202 |
|
203 |
|
204 |
+
@ultroid_cmd(
|
205 |
+
pattern="broadcast ?(.*)",
|
206 |
+
allow_sudo=False,
|
207 |
+
)
|
208 |
async def sending(event):
|
209 |
x = await eor(event, "`Processing...`")
|
210 |
if not event.is_reply:
|
|
|
230 |
except Exception as error:
|
231 |
try:
|
232 |
await ultroid_bot.send_message(
|
233 |
+
int(udB.get("LOG_CHANNEL")),
|
234 |
f"Error in sending at {channel}.\n\n{error}",
|
235 |
)
|
236 |
except BaseException:
|
|
|
243 |
if error_count > 0:
|
244 |
try:
|
245 |
await ultroid_bot.send_message(
|
246 |
+
int(udB.get("LOG_CHANNEL")),
|
247 |
f"{error_count} Errors",
|
248 |
)
|
249 |
except BaseException:
|
plugins/calculator.py
ADDED
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2020 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}calc` - Inline Calculator
|
12 |
+
|
13 |
+
"""
|
14 |
+
|
15 |
+
import re
|
16 |
+
|
17 |
+
from . import *
|
18 |
+
|
19 |
+
|
20 |
+
@ultroid_cmd(pattern="calc")
|
21 |
+
async def icalc(e):
|
22 |
+
udB.delete("calc")
|
23 |
+
results = await ultroid_bot.inline_query(asst.me.username, "calc")
|
24 |
+
await results[0].click(e.chat_id, silent=True, hide_via=True)
|
25 |
+
await e.delete()
|
26 |
+
|
27 |
+
|
28 |
+
@in_pattern("calc")
|
29 |
+
@in_owner
|
30 |
+
async def _(e):
|
31 |
+
m = [
|
32 |
+
"AC",
|
33 |
+
"C",
|
34 |
+
"⌫",
|
35 |
+
"%",
|
36 |
+
"7",
|
37 |
+
"8",
|
38 |
+
"9",
|
39 |
+
"+",
|
40 |
+
"4",
|
41 |
+
"5",
|
42 |
+
"6",
|
43 |
+
"-",
|
44 |
+
"1",
|
45 |
+
"2",
|
46 |
+
"3",
|
47 |
+
"x",
|
48 |
+
"00",
|
49 |
+
"0",
|
50 |
+
".",
|
51 |
+
"÷",
|
52 |
+
]
|
53 |
+
tultd = [Button.inline(f"{x}", data=f"calc{x}") for x in m]
|
54 |
+
lst = list(zip(tultd[::4], tultd[1::4], tultd[2::4], tultd[3::4]))
|
55 |
+
lst.append([Button.inline("=", data="calc=")])
|
56 |
+
calc = e.builder.article("Calc", text="• Ultroid Inline Calculator •", buttons=lst)
|
57 |
+
await e.answer([calc])
|
58 |
+
|
59 |
+
|
60 |
+
@callback(re.compile("calc(.*)"))
|
61 |
+
@owner
|
62 |
+
async def _(e):
|
63 |
+
x = (e.data_match.group(1)).decode()
|
64 |
+
if x == "AC":
|
65 |
+
udB.delete("calc")
|
66 |
+
return await e.edit(
|
67 |
+
"• Ultroid Inline Calculator •",
|
68 |
+
buttons=[Button.inline("Open Calculator Again", data="recalc")],
|
69 |
+
)
|
70 |
+
elif x == "C":
|
71 |
+
udB.delete("calc")
|
72 |
+
return await e.answer("cleared")
|
73 |
+
elif x == "⌫":
|
74 |
+
get = udB.get("calc")
|
75 |
+
if get:
|
76 |
+
udB.set("calc", get[:-1])
|
77 |
+
return await e.answer(str(get[:-1]))
|
78 |
+
elif x == "%":
|
79 |
+
get = udB.get("calc")
|
80 |
+
if get:
|
81 |
+
udB.set("calc", get + "/100")
|
82 |
+
return await e.answer(str(get + "/100"))
|
83 |
+
elif x == "÷":
|
84 |
+
get = udB.get("calc")
|
85 |
+
if get:
|
86 |
+
udB.set("calc", get + "/")
|
87 |
+
return await e.answer(str(get + "/"))
|
88 |
+
elif x == "x":
|
89 |
+
get = udB.get("calc")
|
90 |
+
if get:
|
91 |
+
udB.set("calc", get + "*")
|
92 |
+
return await e.answer(str(get + "*"))
|
93 |
+
elif x == "=":
|
94 |
+
get = udB.get("calc")
|
95 |
+
if get:
|
96 |
+
if get.endswith(("*", ".", "/", "-", "+")):
|
97 |
+
get = get[:-1]
|
98 |
+
out = await calcc(get, e)
|
99 |
+
try:
|
100 |
+
num = float(out)
|
101 |
+
return await e.answer(f"Answer : {num}", cache_time=0, alert=True)
|
102 |
+
except BaseException:
|
103 |
+
udB.delete("calc")
|
104 |
+
return await e.answer("Error", cache_time=0, alert=True)
|
105 |
+
return await e.answer("None")
|
106 |
+
else:
|
107 |
+
get = udB.get("calc")
|
108 |
+
if get:
|
109 |
+
udB.set("calc", get + x)
|
110 |
+
return await e.answer(str(get + x))
|
111 |
+
udB.set("calc", x)
|
112 |
+
return await e.answer(str(x))
|
113 |
+
|
114 |
+
|
115 |
+
@callback("recalc")
|
116 |
+
@owner
|
117 |
+
async def _(e):
|
118 |
+
m = [
|
119 |
+
"AC",
|
120 |
+
"C",
|
121 |
+
"⌫",
|
122 |
+
"%",
|
123 |
+
"7",
|
124 |
+
"8",
|
125 |
+
"9",
|
126 |
+
"+",
|
127 |
+
"4",
|
128 |
+
"5",
|
129 |
+
"6",
|
130 |
+
"-",
|
131 |
+
"1",
|
132 |
+
"2",
|
133 |
+
"3",
|
134 |
+
"x",
|
135 |
+
"00",
|
136 |
+
"0",
|
137 |
+
".",
|
138 |
+
"÷",
|
139 |
+
]
|
140 |
+
tultd = [Button.inline(f"{x}", data=f"calc{x}") for x in m]
|
141 |
+
lst = list(zip(tultd[::4], tultd[1::4], tultd[2::4], tultd[3::4]))
|
142 |
+
lst.append([Button.inline("=", data="calc=")])
|
143 |
+
await e.edit("Noice Inline Calculator", buttons=lst)
|
144 |
+
|
145 |
+
|
146 |
+
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
|
plugins/channelhacks.py
CHANGED
@@ -49,9 +49,8 @@ async def _(e):
|
|
49 |
return
|
50 |
x = get_source_channels()
|
51 |
th = await e.get_chat()
|
52 |
-
|
53 |
-
|
54 |
-
return
|
55 |
y = get_destinations()
|
56 |
for ys in y:
|
57 |
try:
|
@@ -88,7 +87,7 @@ async def _(e):
|
|
88 |
return
|
89 |
async for msg in ultroid_bot.iter_messages(int(c), reverse=True):
|
90 |
try:
|
91 |
-
await asyncio.sleep(1)
|
92 |
await ultroid_bot.send_message(int(d), msg)
|
93 |
except BaseException:
|
94 |
pass
|
|
|
49 |
return
|
50 |
x = get_source_channels()
|
51 |
th = await e.get_chat()
|
52 |
+
if str(th.id) not in x:
|
53 |
+
return
|
|
|
54 |
y = get_destinations()
|
55 |
for ys in y:
|
56 |
try:
|
|
|
87 |
return
|
88 |
async for msg in ultroid_bot.iter_messages(int(c), reverse=True):
|
89 |
try:
|
90 |
+
await asyncio.sleep(1.3)
|
91 |
await ultroid_bot.send_message(int(d), msg)
|
92 |
except BaseException:
|
93 |
pass
|
plugins/chats.py
CHANGED
@@ -14,10 +14,10 @@
|
|
14 |
• `{i}getlink`
|
15 |
Get link of group this cmd is used in.
|
16 |
|
17 |
-
• `{i}create (b|
|
18 |
Create group woth a specific name.
|
19 |
-
|
20 |
-
|
21 |
c - channel
|
22 |
"""
|
23 |
|
@@ -47,7 +47,9 @@ async def _(e):
|
|
47 |
return await eod(xx, "`Cant delete this chat`", time=10)
|
48 |
except no_admin:
|
49 |
return await eod(xx, "`I m not an admin`", time=10)
|
50 |
-
await e.client.send_message(
|
|
|
|
|
51 |
|
52 |
|
53 |
@ultroid_cmd(
|
|
|
14 |
• `{i}getlink`
|
15 |
Get link of group this cmd is used in.
|
16 |
|
17 |
+
• `{i}create (g|b|c) <group_name>`
|
18 |
Create group woth a specific name.
|
19 |
+
g - megagroup/supergroup
|
20 |
+
b - small group
|
21 |
c - channel
|
22 |
"""
|
23 |
|
|
|
47 |
return await eod(xx, "`Cant delete this chat`", time=10)
|
48 |
except no_admin:
|
49 |
return await eod(xx, "`I m not an admin`", time=10)
|
50 |
+
await e.client.send_message(
|
51 |
+
int(udB.get("LOG_CHANNEL")), f"#Deleted\nDeleted {e.chat_id}"
|
52 |
+
)
|
53 |
|
54 |
|
55 |
@ultroid_cmd(
|
plugins/compressor.py
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2020 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}compress <reply to video>`
|
12 |
+
optional `crf` and `stream`
|
13 |
+
Example : `{i}compress 27 | stream` or `{i}compress 28`
|
14 |
+
Encode the replied video according to CRF value.
|
15 |
+
Less CRF == High Quality, More Size
|
16 |
+
More CRF == Low Quality, Less Size
|
17 |
+
CRF Range = 20-51
|
18 |
+
Default = 27
|
19 |
+
|
20 |
+
"""
|
21 |
+
|
22 |
+
import asyncio
|
23 |
+
import os
|
24 |
+
import re
|
25 |
+
import time
|
26 |
+
from datetime import datetime as dt
|
27 |
+
|
28 |
+
from hachoir.metadata import extractMetadata
|
29 |
+
from hachoir.parser import createParser
|
30 |
+
from telethon.tl.types import DocumentAttributeVideo
|
31 |
+
|
32 |
+
from . import *
|
33 |
+
|
34 |
+
|
35 |
+
@ultroid_cmd(pattern="compress ?((\\d+)(.*)|$)")
|
36 |
+
async def _(e):
|
37 |
+
crf = e.pattern_match.group(1)
|
38 |
+
if not crf:
|
39 |
+
crf = 27
|
40 |
+
to_stream = e.pattern_match.group(2)
|
41 |
+
vido = await e.get_reply_message()
|
42 |
+
if vido and vido.media:
|
43 |
+
if "video" in mediainfo(vido.media):
|
44 |
+
if hasattr(vido.media, "document"):
|
45 |
+
vfile = vido.media.document
|
46 |
+
name = vido.file.name
|
47 |
+
else:
|
48 |
+
vfile = vido.media
|
49 |
+
name = ""
|
50 |
+
if not name:
|
51 |
+
name = "video_" + dt.now().isoformat("_", "seconds") + ".mp4"
|
52 |
+
xxx = await eor(e, "`Trying To Download...`")
|
53 |
+
c_time = time.time()
|
54 |
+
file = await downloader(
|
55 |
+
"resources/downloads/" + name,
|
56 |
+
vfile,
|
57 |
+
xxx,
|
58 |
+
c_time,
|
59 |
+
"Downloading " + name + "...",
|
60 |
+
)
|
61 |
+
o_size = os.path.getsize(file.name)
|
62 |
+
d_time = time.time()
|
63 |
+
diff = time_formatter((d_time - c_time) * 1000)
|
64 |
+
file_name = (file.name).split("/")[-1]
|
65 |
+
out = file_name.replace(file_name.split(".")[-1], " compressed.mkv")
|
66 |
+
await xxx.edit(
|
67 |
+
f"`Downloaded {file.name} of {humanbytes(o_size)} in {diff}.\nNow Compressing...`"
|
68 |
+
)
|
69 |
+
x, y = await bash(
|
70 |
+
f'mediainfo --fullscan """{file.name}""" | grep "Frame count"'
|
71 |
+
)
|
72 |
+
total_frames = x.split(":")[1].split("\n")[0]
|
73 |
+
progress = "progress.txt"
|
74 |
+
with open(progress, "w") as fk:
|
75 |
+
pass
|
76 |
+
proce = await asyncio.create_subprocess_shell(
|
77 |
+
f'ffmpeg -hide_banner -loglevel quiet -progress {progress} -i """{file.name}""" -preset ultrafast -c:v libx265 -crf {crf} -map 0:v -c:a aac -map 0:a -c:s copy -map 0:s? """{out}""" -y',
|
78 |
+
stdout=asyncio.subprocess.PIPE,
|
79 |
+
stderr=asyncio.subprocess.PIPE,
|
80 |
+
)
|
81 |
+
while proce.returncode != 0:
|
82 |
+
await asyncio.sleep(3)
|
83 |
+
with open(progress, "r+") as fil:
|
84 |
+
text = fil.read()
|
85 |
+
frames = re.findall("frame=(\\d+)", text)
|
86 |
+
size = re.findall("total_size=(\\d+)", text)
|
87 |
+
|
88 |
+
if len(frames):
|
89 |
+
elapse = int(frames[-1])
|
90 |
+
if len(size):
|
91 |
+
size = int(size[-1])
|
92 |
+
per = elapse * 100 / int(total_frames)
|
93 |
+
progress_str = "`[{0}{1}] {2}%\n`".format(
|
94 |
+
"".join(["●" for i in range(math.floor(per / 5))]),
|
95 |
+
"".join(["" for i in range(20 - math.floor(per / 5))]),
|
96 |
+
round(per, 2),
|
97 |
+
)
|
98 |
+
e_size = humanbytes(size)
|
99 |
+
await xxx.edit(progress_str + "\n" + "`" + e_size + "`")
|
100 |
+
os.remove(file.name)
|
101 |
+
c_size = os.path.getsize(out)
|
102 |
+
f_time = time.time()
|
103 |
+
difff = time_formatter((f_time - d_time) * 1000)
|
104 |
+
await xxx.edit(
|
105 |
+
f"`Compressed {humanbytes(o_size)} to {humanbytes(c_size)} in {difff}\nTrying to Upload...`"
|
106 |
+
)
|
107 |
+
differ = 100 - ((c_size / o_size) * 100)
|
108 |
+
caption = f"**Original Size: **`{humanbytes(o_size)}`\n"
|
109 |
+
caption += f"**Compressed Size: **`{humanbytes(c_size)}`\n"
|
110 |
+
caption += f"**Compression Ratio: **`{differ:.2f}%`\n"
|
111 |
+
caption += f"\n**Time Taken To Compress: **`{difff}`"
|
112 |
+
mmmm = await uploader(
|
113 |
+
out,
|
114 |
+
out,
|
115 |
+
f_time,
|
116 |
+
xxx,
|
117 |
+
"Uploading " + out + "...",
|
118 |
+
)
|
119 |
+
if to_stream and "| stream" in to_stream:
|
120 |
+
metadata = extractMetadata(createParser(out))
|
121 |
+
duration = metadata.get("duration").seconds
|
122 |
+
hi, _ = await bash(f'mediainfo "{out}" | grep "Height"')
|
123 |
+
wi, _ = await bash(f'mediainfo "{out}" | grep "Width"')
|
124 |
+
height = int(hi.split(":")[1].split()[0])
|
125 |
+
width = int(wi.split(":")[1].split()[0])
|
126 |
+
attributes = [
|
127 |
+
DocumentAttributeVideo(
|
128 |
+
duration=duration, w=width, h=height, supports_streaming=True
|
129 |
+
)
|
130 |
+
]
|
131 |
+
await e.client.send_file(
|
132 |
+
e.chat_id,
|
133 |
+
mmmm,
|
134 |
+
thumb="resources/extras/ultroid.jpg",
|
135 |
+
caption=caption,
|
136 |
+
attributes=attributes,
|
137 |
+
force_document=False,
|
138 |
+
reply_to=e.reply_to_msg_id,
|
139 |
+
)
|
140 |
+
else:
|
141 |
+
await e.client.send_file(
|
142 |
+
e.chat_id,
|
143 |
+
mmmm,
|
144 |
+
thumb="resources/extras/ultroid.jpg",
|
145 |
+
caption=caption,
|
146 |
+
force_document=True,
|
147 |
+
reply_to=e.reply_to_msg_id,
|
148 |
+
)
|
149 |
+
await xxx.delete()
|
150 |
+
os.remove(out)
|
151 |
+
else:
|
152 |
+
await eod(e, "`Reply To Video File Only`")
|
153 |
+
else:
|
154 |
+
await eod(e, "`Reply To Video File Only`")
|
155 |
+
|
156 |
+
|
157 |
+
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
|
plugins/converter.py
CHANGED
@@ -10,10 +10,10 @@
|
|
10 |
|
11 |
|
12 |
• `{i}mtoi <reply to media>`
|
13 |
-
|
14 |
|
15 |
• `{i}mtos <reply to media>`
|
16 |
-
|
17 |
|
18 |
• `{i}doc <filename.ext>`
|
19 |
Reply to a text msg to save it in a file.
|
@@ -22,14 +22,12 @@
|
|
22 |
Reply to a file to reveal it's text.
|
23 |
|
24 |
• `{i}rename <file name with extension>`
|
25 |
-
|
26 |
|
27 |
-
• `{i}thumbnail <reply to image
|
28 |
-
|
29 |
-
In Commands `{i}rename` and `{i}ul`
|
30 |
"""
|
31 |
|
32 |
-
import asyncio
|
33 |
import os
|
34 |
import time
|
35 |
|
@@ -37,6 +35,8 @@ import cv2
|
|
37 |
import requests
|
38 |
from PIL import Image
|
39 |
from telegraph import upload_file as uf
|
|
|
|
|
40 |
|
41 |
from . import *
|
42 |
|
@@ -46,13 +46,21 @@ opn = []
|
|
46 |
@ultroid_cmd(pattern="thumbnail$")
|
47 |
async def _(e):
|
48 |
r = await e.get_reply_message()
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
variable = uf(dl)
|
53 |
os.remove(dl)
|
54 |
nn = "https://telegra.ph" + variable[0]
|
55 |
udB.set("CUSTOM_THUMBNAIL", str(nn))
|
|
|
56 |
await eor(e, f"Added [This]({nn}) As Your Custom Thumbnail", link_preview=False)
|
57 |
|
58 |
|
@@ -78,17 +86,13 @@ async def imak(event):
|
|
78 |
else:
|
79 |
file = await event.download_media(reply)
|
80 |
os.rename(file, inp)
|
81 |
-
if Redis("CUSTOM_THUMBNAIL"):
|
82 |
-
await bash(
|
83 |
-
f"wget {Redis('CUSTOM_THUMBNAIL')} -O resources/extras/new_thumb.jpg"
|
84 |
-
)
|
85 |
k = time.time()
|
86 |
xxx = await uploader(inp, inp, k, xx, "Uploading...")
|
87 |
await ultroid_bot.send_file(
|
88 |
event.chat_id,
|
89 |
xxx,
|
90 |
force_document=True,
|
91 |
-
thumb="resources/extras/
|
92 |
caption=f"`{xxx.name}`",
|
93 |
reply_to=reply,
|
94 |
)
|
@@ -155,11 +159,8 @@ async def _(event):
|
|
155 |
b.write(str(a.message))
|
156 |
b.close()
|
157 |
await xx.edit(f"**Packing into** `{input_str}`")
|
158 |
-
await asyncio.sleep(2)
|
159 |
-
await xx.edit(f"**Uploading** `{input_str}`")
|
160 |
-
await asyncio.sleep(2)
|
161 |
await event.client.send_file(
|
162 |
-
event.chat_id, input_str, thumb="resources/extras/
|
163 |
)
|
164 |
await xx.delete()
|
165 |
os.remove(input_str)
|
|
|
10 |
|
11 |
|
12 |
• `{i}mtoi <reply to media>`
|
13 |
+
Media to image conversion
|
14 |
|
15 |
• `{i}mtos <reply to media>`
|
16 |
+
Convert media to sticker.
|
17 |
|
18 |
• `{i}doc <filename.ext>`
|
19 |
Reply to a text msg to save it in a file.
|
|
|
22 |
Reply to a file to reveal it's text.
|
23 |
|
24 |
• `{i}rename <file name with extension>`
|
25 |
+
Rename the file
|
26 |
|
27 |
+
• `{i}thumbnail <reply to image/thumbnail file>`
|
28 |
+
Upload Your file with your custom thumbnail.
|
|
|
29 |
"""
|
30 |
|
|
|
31 |
import os
|
32 |
import time
|
33 |
|
|
|
35 |
import requests
|
36 |
from PIL import Image
|
37 |
from telegraph import upload_file as uf
|
38 |
+
from telethon.tl.types import MessageMediaDocument as doc
|
39 |
+
from telethon.tl.types import MessageMediaPhoto as photu
|
40 |
|
41 |
from . import *
|
42 |
|
|
|
46 |
@ultroid_cmd(pattern="thumbnail$")
|
47 |
async def _(e):
|
48 |
r = await e.get_reply_message()
|
49 |
+
pop = "`Reply to img or file with thumbnail.`"
|
50 |
+
if not r:
|
51 |
+
return await eor(e, pop)
|
52 |
+
if isinstance(r.media, photu):
|
53 |
+
dl = await ultroid_bot.download_media(r.media)
|
54 |
+
elif isinstance(r.media, doc):
|
55 |
+
if r.media.document.thumbs:
|
56 |
+
dl = await ultroid_bot.download_media(r, thumb=-1)
|
57 |
+
else:
|
58 |
+
return await eor(e, pop)
|
59 |
variable = uf(dl)
|
60 |
os.remove(dl)
|
61 |
nn = "https://telegra.ph" + variable[0]
|
62 |
udB.set("CUSTOM_THUMBNAIL", str(nn))
|
63 |
+
await bash(f"wget {nn} -O resources/extras/ultroid.jpg")
|
64 |
await eor(e, f"Added [This]({nn}) As Your Custom Thumbnail", link_preview=False)
|
65 |
|
66 |
|
|
|
86 |
else:
|
87 |
file = await event.download_media(reply)
|
88 |
os.rename(file, inp)
|
|
|
|
|
|
|
|
|
89 |
k = time.time()
|
90 |
xxx = await uploader(inp, inp, k, xx, "Uploading...")
|
91 |
await ultroid_bot.send_file(
|
92 |
event.chat_id,
|
93 |
xxx,
|
94 |
force_document=True,
|
95 |
+
thumb="resources/extras/ultroid.jpg",
|
96 |
caption=f"`{xxx.name}`",
|
97 |
reply_to=reply,
|
98 |
)
|
|
|
159 |
b.write(str(a.message))
|
160 |
b.close()
|
161 |
await xx.edit(f"**Packing into** `{input_str}`")
|
|
|
|
|
|
|
162 |
await event.client.send_file(
|
163 |
+
event.chat_id, input_str, thumb="resources/extras/ultroid.jpg"
|
164 |
)
|
165 |
await xx.delete()
|
166 |
os.remove(input_str)
|
plugins/core.py
CHANGED
@@ -28,80 +28,14 @@
|
|
28 |
|
29 |
import os
|
30 |
|
31 |
-
from telethon import Button
|
32 |
-
|
33 |
from . import *
|
34 |
|
35 |
|
36 |
-
@in_pattern(
|
37 |
-
"send ?(.*)",
|
38 |
-
)
|
39 |
-
@in_owner
|
40 |
-
async def inline_handler(event):
|
41 |
-
builder = event.builder
|
42 |
-
input_str = event.pattern_match.group(1)
|
43 |
-
if input_str is None or input_str == "":
|
44 |
-
plugs = await event.builder.article(
|
45 |
-
title=f"Which plugin?",
|
46 |
-
text="No Module",
|
47 |
-
buttons=[
|
48 |
-
Button.switch_inline(
|
49 |
-
"Search Again..?",
|
50 |
-
query="send ",
|
51 |
-
same_peer=True,
|
52 |
-
),
|
53 |
-
],
|
54 |
-
)
|
55 |
-
await event.answer(plugs)
|
56 |
-
else:
|
57 |
-
try:
|
58 |
-
ultroid = builder.document(
|
59 |
-
f"plugins/{input_str}.py",
|
60 |
-
title=f"{input_str}.py",
|
61 |
-
description=f"Module {input_str} Found",
|
62 |
-
text=f"{input_str}.py use below button to paste in neko and raw..",
|
63 |
-
buttons=[
|
64 |
-
[
|
65 |
-
Button.switch_inline(
|
66 |
-
"Search Again..?",
|
67 |
-
query="send ",
|
68 |
-
same_peer=True,
|
69 |
-
),
|
70 |
-
],
|
71 |
-
[
|
72 |
-
Button.inline(
|
73 |
-
"Paste?",
|
74 |
-
data=f"pasta-plugins/{input_str}.py",
|
75 |
-
),
|
76 |
-
],
|
77 |
-
],
|
78 |
-
)
|
79 |
-
await event.answer([ultroid])
|
80 |
-
return
|
81 |
-
except BaseException:
|
82 |
-
ultroidcode = builder.article(
|
83 |
-
title=f"Module {input_str}.py Not Found",
|
84 |
-
description=f"No Such Module",
|
85 |
-
text=f"No Module Named {input_str}.py",
|
86 |
-
buttons=[
|
87 |
-
[
|
88 |
-
Button.switch_inline(
|
89 |
-
"Search Again",
|
90 |
-
query="send ",
|
91 |
-
same_peer=True,
|
92 |
-
),
|
93 |
-
],
|
94 |
-
],
|
95 |
-
)
|
96 |
-
await event.answer([ultroidcode])
|
97 |
-
return
|
98 |
-
|
99 |
-
|
100 |
@ultroid_cmd(
|
101 |
pattern="install",
|
102 |
)
|
103 |
async def install(event):
|
104 |
-
if not is_fullsudo(event.sender_id):
|
105 |
return await eod(event, "`This Command Is Sudo Restricted.`")
|
106 |
await safeinstall(event)
|
107 |
|
|
|
28 |
|
29 |
import os
|
30 |
|
|
|
|
|
31 |
from . import *
|
32 |
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
@ultroid_cmd(
|
35 |
pattern="install",
|
36 |
)
|
37 |
async def install(event):
|
38 |
+
if not event.out and not is_fullsudo(event.sender_id):
|
39 |
return await eod(event, "`This Command Is Sudo Restricted.`")
|
40 |
await safeinstall(event)
|
41 |
|
plugins/devtools.py
ADDED
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2020 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}bash <cmds>`
|
12 |
+
Run linux commands on telegram.
|
13 |
+
|
14 |
+
• `{i}eval <cmds>`
|
15 |
+
Evaluate python commands on telegram.
|
16 |
+
|
17 |
+
• `{i}sysinfo`
|
18 |
+
Shows System Info.
|
19 |
+
"""
|
20 |
+
import io
|
21 |
+
import sys
|
22 |
+
import traceback
|
23 |
+
from os import remove
|
24 |
+
|
25 |
+
from carbonnow import Carbon
|
26 |
+
|
27 |
+
from . import *
|
28 |
+
|
29 |
+
|
30 |
+
@ultroid_cmd(
|
31 |
+
pattern="sysinfo$",
|
32 |
+
)
|
33 |
+
async def _(e):
|
34 |
+
await eor(e, "`Sending...`")
|
35 |
+
x, y = await bash("neofetch|sed 's/\x1B\\[[0-9;\\?]*[a-zA-Z]//g' >> neo.txt")
|
36 |
+
with open("neo.txt", "r") as neo:
|
37 |
+
p = (neo.read()).replace("\n\n", "")
|
38 |
+
ok = Carbon(code=p)
|
39 |
+
haa = await ok.save("neofetch")
|
40 |
+
await e.client.send_file(e.chat_id, haa)
|
41 |
+
remove("neofetch.jpg")
|
42 |
+
remove("neo.txt")
|
43 |
+
|
44 |
+
|
45 |
+
@ultroid_cmd(
|
46 |
+
pattern="bash",
|
47 |
+
)
|
48 |
+
async def _(event):
|
49 |
+
if not event.out and not is_fullsudo(event.sender_id):
|
50 |
+
return await eor(event, "`This Command Is Sudo Restricted.`")
|
51 |
+
if Redis("I_DEV") != "True":
|
52 |
+
await eor(
|
53 |
+
event,
|
54 |
+
f"Developer Restricted!\nIf you know what this does, and want to proceed\n\n `{HNDLR}setredis I_DEV True`\n\nThis Might Be Dangerous.",
|
55 |
+
)
|
56 |
+
return
|
57 |
+
xx = await eor(event, "`Processing...`")
|
58 |
+
try:
|
59 |
+
cmd = event.text.split(" ", maxsplit=1)[1]
|
60 |
+
except IndexError:
|
61 |
+
return await eod(xx, "`No cmd given`", time=10)
|
62 |
+
reply_to_id = event.message.id
|
63 |
+
if event.reply_to_msg_id:
|
64 |
+
reply_to_id = event.reply_to_msg_id
|
65 |
+
stdout, stderr = await bash(cmd)
|
66 |
+
OUT = f"**☞ BASH\n\n• COMMAND:**\n`{cmd}` \n\n"
|
67 |
+
if stderr:
|
68 |
+
OUT += f"**• ERROR:** \n`{stderr}`\n\n"
|
69 |
+
if stdout:
|
70 |
+
_o = stdout.split("\n")
|
71 |
+
o = "\n".join(_o)
|
72 |
+
OUT += f"**• OUTPUT:**\n`{o}`"
|
73 |
+
if not stderr and not stdout:
|
74 |
+
OUT += f"**• OUTPUT:**\n`Success`"
|
75 |
+
if len(OUT) > 4096:
|
76 |
+
ultd = OUT.replace("`", "").replace("*", "").replace("_", "")
|
77 |
+
with io.BytesIO(str.encode(ultd)) as out_file:
|
78 |
+
out_file.name = "bash.txt"
|
79 |
+
await event.client.send_file(
|
80 |
+
event.chat_id,
|
81 |
+
out_file,
|
82 |
+
force_document=True,
|
83 |
+
thumb="resources/extras/ultroid.jpg",
|
84 |
+
allow_cache=False,
|
85 |
+
caption=f"`{cmd}`",
|
86 |
+
reply_to=reply_to_id,
|
87 |
+
)
|
88 |
+
await xx.delete()
|
89 |
+
else:
|
90 |
+
await eor(xx, OUT)
|
91 |
+
|
92 |
+
|
93 |
+
p = print # ignore: pylint
|
94 |
+
|
95 |
+
|
96 |
+
@ultroid_cmd(
|
97 |
+
pattern="eval",
|
98 |
+
)
|
99 |
+
async def _(event):
|
100 |
+
if len(event.text) > 5:
|
101 |
+
if not event.text[5] == " ":
|
102 |
+
return
|
103 |
+
if not event.out and not is_fullsudo(event.sender_id):
|
104 |
+
return await eor(event, "`This Command Is Sudo Restricted.`")
|
105 |
+
if Redis("I_DEV") != "True":
|
106 |
+
await eor(
|
107 |
+
event,
|
108 |
+
f"Developer Restricted!\nIf you know what this does, and want to proceed\n\n {HNDLR}setredis I_DEV True\n\nThis Might Be Dangerous.",
|
109 |
+
)
|
110 |
+
return
|
111 |
+
xx = await eor(event, "`Processing ...`")
|
112 |
+
try:
|
113 |
+
cmd = event.text.split(" ", maxsplit=1)[1]
|
114 |
+
except IndexError:
|
115 |
+
return await eod(xx, "`Give some python cmd`", time=5)
|
116 |
+
if event.reply_to_msg_id:
|
117 |
+
reply_to_id = event.reply_to_msg_id
|
118 |
+
old_stderr = sys.stderr
|
119 |
+
old_stdout = sys.stdout
|
120 |
+
redirected_output = sys.stdout = io.StringIO()
|
121 |
+
redirected_error = sys.stderr = io.StringIO()
|
122 |
+
stdout, stderr, exc = None, None, None
|
123 |
+
reply_to_id = event.message.id
|
124 |
+
try:
|
125 |
+
await aexec(cmd, event)
|
126 |
+
except Exception:
|
127 |
+
exc = traceback.format_exc()
|
128 |
+
stdout = redirected_output.getvalue()
|
129 |
+
stderr = redirected_error.getvalue()
|
130 |
+
sys.stdout = old_stdout
|
131 |
+
sys.stderr = old_stderr
|
132 |
+
evaluation = ""
|
133 |
+
if exc:
|
134 |
+
evaluation = exc
|
135 |
+
elif stderr:
|
136 |
+
evaluation = stderr
|
137 |
+
elif stdout:
|
138 |
+
evaluation = stdout
|
139 |
+
else:
|
140 |
+
evaluation = "Success"
|
141 |
+
final_output = (
|
142 |
+
"__►__ **EVALPy**\n```{}``` \n\n __►__ **OUTPUT**: \n```{}``` \n".format(
|
143 |
+
cmd,
|
144 |
+
evaluation,
|
145 |
+
)
|
146 |
+
)
|
147 |
+
if len(final_output) > 4096:
|
148 |
+
ultd = final_output.replace("`", "").replace("*", "").replace("_", "")
|
149 |
+
with io.BytesIO(str.encode(ultd)) as out_file:
|
150 |
+
out_file.name = "eval.txt"
|
151 |
+
await ultroid_bot.send_file(
|
152 |
+
event.chat_id,
|
153 |
+
out_file,
|
154 |
+
force_document=True,
|
155 |
+
thumb="resources/extras/ultroid.jpg",
|
156 |
+
allow_cache=False,
|
157 |
+
caption=f"```{cmd}```",
|
158 |
+
reply_to=reply_to_id,
|
159 |
+
)
|
160 |
+
await xx.delete()
|
161 |
+
else:
|
162 |
+
await eor(xx, final_output)
|
163 |
+
|
164 |
+
|
165 |
+
async def aexec(code, event):
|
166 |
+
e = message = event
|
167 |
+
client = event.client
|
168 |
+
exec(
|
169 |
+
f"async def __aexec(e, client): "
|
170 |
+
+ "\n message = event = e"
|
171 |
+
+ "".join(f"\n {l}" for l in code.split("\n")),
|
172 |
+
)
|
173 |
+
|
174 |
+
return await locals()["__aexec"](e, e.client)
|
175 |
+
|
176 |
+
|
177 |
+
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
|
plugins/download_upload.py
CHANGED
@@ -10,6 +10,7 @@
|
|
10 |
|
11 |
• `{i}ul <path/to/file>`
|
12 |
Upload file to telegram chat.
|
|
|
13 |
|
14 |
• `{i}ul <path/to/file> | stream`
|
15 |
Upload files as stream.
|
@@ -19,6 +20,8 @@
|
|
19 |
|
20 |
"""
|
21 |
|
|
|
|
|
22 |
import time
|
23 |
from datetime import datetime as dt
|
24 |
|
@@ -107,19 +110,89 @@ async def download(event):
|
|
107 |
tt = time.time()
|
108 |
if not kk:
|
109 |
return await eod(xx, get_string("udl_3"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
else:
|
111 |
try:
|
112 |
-
if Redis("CUSTOM_THUMBNAIL"):
|
113 |
-
await bash(
|
114 |
-
f"wget {Redis('CUSTOM_THUMBNAIL')} -O resources/extras/new_thumb.jpg"
|
115 |
-
)
|
116 |
try:
|
117 |
res = await uploader(kk, kk, tt, xx, "Uploading...")
|
118 |
except MessageNotModifiedError as err:
|
119 |
return await xx.edit(str(err))
|
120 |
-
if "
|
121 |
-
|
122 |
-
|
123 |
metadata = extractMetadata(createParser(res.name))
|
124 |
wi = 512
|
125 |
hi = 512
|
@@ -131,48 +204,72 @@ async def download(event):
|
|
131 |
if metadata.has("duration"):
|
132 |
duration = metadata.get("duration").seconds
|
133 |
if metadata.has("artist"):
|
134 |
-
metadata.get("artist")
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
136 |
attributes = [
|
137 |
DocumentAttributeVideo(
|
138 |
w=wi, h=hi, duration=duration, supports_streaming=True
|
139 |
)
|
140 |
]
|
141 |
-
|
142 |
attributes = [
|
143 |
-
DocumentAttributeAudio(
|
|
|
|
|
|
|
|
|
144 |
]
|
|
|
|
|
145 |
try:
|
146 |
x = await event.client.send_file(
|
147 |
event.chat_id,
|
148 |
res,
|
149 |
-
caption=title,
|
150 |
attributes=attributes,
|
151 |
supports_streaming=True,
|
152 |
-
thumb="resources/extras/
|
153 |
)
|
154 |
except BaseException:
|
155 |
x = await event.client.send_file(
|
156 |
event.chat_id,
|
157 |
res,
|
158 |
-
caption=title,
|
159 |
force_document=True,
|
160 |
-
thumb="resources/extras/
|
161 |
)
|
162 |
else:
|
163 |
x = await event.client.send_file(
|
164 |
event.chat_id,
|
165 |
res,
|
166 |
-
caption=title,
|
167 |
force_document=True,
|
168 |
-
thumb="resources/extras/
|
169 |
)
|
170 |
except Exception as ve:
|
171 |
return await eor(xx, str(ve))
|
172 |
e = datetime.now()
|
173 |
t = time_formatter(((e - s).seconds) * 1000)
|
174 |
if t != "":
|
175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
else:
|
177 |
await eor(xx, f"Uploaded `{kk}` in `0 second(s)`")
|
178 |
|
|
|
10 |
|
11 |
• `{i}ul <path/to/file>`
|
12 |
Upload file to telegram chat.
|
13 |
+
You Can Upload Folders too.
|
14 |
|
15 |
• `{i}ul <path/to/file> | stream`
|
16 |
Upload files as stream.
|
|
|
20 |
|
21 |
"""
|
22 |
|
23 |
+
import glob
|
24 |
+
import os
|
25 |
import time
|
26 |
from datetime import datetime as dt
|
27 |
|
|
|
110 |
tt = time.time()
|
111 |
if not kk:
|
112 |
return await eod(xx, get_string("udl_3"))
|
113 |
+
elif os.path.isdir(kk):
|
114 |
+
if not os.listdir(kk):
|
115 |
+
return await eod(xx, "`This Directory is Empty.`")
|
116 |
+
ok = glob.glob(f"{kk}/*")
|
117 |
+
kk = [*sorted(ok)]
|
118 |
+
for kk in kk:
|
119 |
+
try:
|
120 |
+
try:
|
121 |
+
res = await uploader(kk, kk, tt, xx, "Uploading...")
|
122 |
+
except MessageNotModifiedError as err:
|
123 |
+
return await xx.edit(str(err))
|
124 |
+
title = kk.split("/")[-1]
|
125 |
+
if title.endswith((".mp3", ".m4a", ".opus", ".ogg")):
|
126 |
+
hmm = " | stream"
|
127 |
+
if " | stream" in hmm:
|
128 |
+
metadata = extractMetadata(createParser(res.name))
|
129 |
+
wi = 512
|
130 |
+
hi = 512
|
131 |
+
duration = 0
|
132 |
+
if metadata.has("width"):
|
133 |
+
wi = metadata.get("width")
|
134 |
+
if metadata.has("height"):
|
135 |
+
hi = metadata.get("height")
|
136 |
+
if metadata.has("duration"):
|
137 |
+
duration = metadata.get("duration").seconds
|
138 |
+
if metadata.has("artist"):
|
139 |
+
artist = metadata.get("artist")
|
140 |
+
else:
|
141 |
+
if udB.get("artist"):
|
142 |
+
artist = udB.get("artist")
|
143 |
+
else:
|
144 |
+
artist = ultroid_bot.first_name
|
145 |
+
if res.name.endswith(tuple([".mkv", ".mp4", ".avi"])):
|
146 |
+
attributes = [
|
147 |
+
DocumentAttributeVideo(
|
148 |
+
w=wi, h=hi, duration=duration, supports_streaming=True
|
149 |
+
)
|
150 |
+
]
|
151 |
+
elif res.name.endswith(tuple([".mp3", ".m4a", ".opus", ".ogg"])):
|
152 |
+
attributes = [
|
153 |
+
DocumentAttributeAudio(
|
154 |
+
duration=duration,
|
155 |
+
title=title.split(".")[0],
|
156 |
+
performer=artist,
|
157 |
+
)
|
158 |
+
]
|
159 |
+
else:
|
160 |
+
attributes = None
|
161 |
+
try:
|
162 |
+
x = await event.client.send_file(
|
163 |
+
event.chat_id,
|
164 |
+
res,
|
165 |
+
caption=f"`{title}`",
|
166 |
+
attributes=attributes,
|
167 |
+
supports_streaming=True,
|
168 |
+
thumb="resources/extras/ultroid.jpg",
|
169 |
+
)
|
170 |
+
except BaseException:
|
171 |
+
x = await event.client.send_file(
|
172 |
+
event.chat_id,
|
173 |
+
res,
|
174 |
+
caption=f"`{title}`",
|
175 |
+
thumb="resources/extras/ultroid.jpg",
|
176 |
+
)
|
177 |
+
else:
|
178 |
+
x = await event.client.send_file(
|
179 |
+
event.chat_id,
|
180 |
+
res,
|
181 |
+
caption=f"`{title}`",
|
182 |
+
force_document=True,
|
183 |
+
thumb="resources/extras/ultroid.jpg",
|
184 |
+
)
|
185 |
+
except Exception as ve:
|
186 |
+
return await eor(xx, str(ve))
|
187 |
else:
|
188 |
try:
|
|
|
|
|
|
|
|
|
189 |
try:
|
190 |
res = await uploader(kk, kk, tt, xx, "Uploading...")
|
191 |
except MessageNotModifiedError as err:
|
192 |
return await xx.edit(str(err))
|
193 |
+
if title.endswith((".mp3", ".m4a", ".opus", ".ogg")):
|
194 |
+
hmm = " | stream"
|
195 |
+
if " | stream" in hmm:
|
196 |
metadata = extractMetadata(createParser(res.name))
|
197 |
wi = 512
|
198 |
hi = 512
|
|
|
204 |
if metadata.has("duration"):
|
205 |
duration = metadata.get("duration").seconds
|
206 |
if metadata.has("artist"):
|
207 |
+
artist = metadata.get("artist")
|
208 |
+
else:
|
209 |
+
if udB.get("artist"):
|
210 |
+
artist = udB.get("artist")
|
211 |
+
else:
|
212 |
+
artist = ultroid_bot.first_name
|
213 |
+
if res.name.endswith(tuple([".mkv", ".mp4", ".avi"])):
|
214 |
attributes = [
|
215 |
DocumentAttributeVideo(
|
216 |
w=wi, h=hi, duration=duration, supports_streaming=True
|
217 |
)
|
218 |
]
|
219 |
+
elif res.name.endswith(tuple([".mp3", ".m4a", ".opus", ".ogg"])):
|
220 |
attributes = [
|
221 |
+
DocumentAttributeAudio(
|
222 |
+
duration=duration,
|
223 |
+
title=title.split(".")[0],
|
224 |
+
performer=artist,
|
225 |
+
)
|
226 |
]
|
227 |
+
else:
|
228 |
+
attributes = None
|
229 |
try:
|
230 |
x = await event.client.send_file(
|
231 |
event.chat_id,
|
232 |
res,
|
233 |
+
caption=f"`{title}`",
|
234 |
attributes=attributes,
|
235 |
supports_streaming=True,
|
236 |
+
thumb="resources/extras/ultroid.jpg",
|
237 |
)
|
238 |
except BaseException:
|
239 |
x = await event.client.send_file(
|
240 |
event.chat_id,
|
241 |
res,
|
242 |
+
caption=f"`{title}`",
|
243 |
force_document=True,
|
244 |
+
thumb="resources/extras/ultroid.jpg",
|
245 |
)
|
246 |
else:
|
247 |
x = await event.client.send_file(
|
248 |
event.chat_id,
|
249 |
res,
|
250 |
+
caption=f"`{title}`",
|
251 |
force_document=True,
|
252 |
+
thumb="resources/extras/ultroid.jpg",
|
253 |
)
|
254 |
except Exception as ve:
|
255 |
return await eor(xx, str(ve))
|
256 |
e = datetime.now()
|
257 |
t = time_formatter(((e - s).seconds) * 1000)
|
258 |
if t != "":
|
259 |
+
if os.path.isdir(kk):
|
260 |
+
size = 0
|
261 |
+
for path, dirs, files in os.walk(kk):
|
262 |
+
for f in files:
|
263 |
+
fp = os.path.join(path, f)
|
264 |
+
size += os.path.getsize(fp)
|
265 |
+
c = len(os.listdir(kk))
|
266 |
+
await xx.delete()
|
267 |
+
await ultroid_bot.send_message(
|
268 |
+
event.chat_id,
|
269 |
+
f"Uploaded Total - `{c}` files of `{humanbytes(size)}` in `{t}`",
|
270 |
+
)
|
271 |
+
else:
|
272 |
+
await eor(xx, f"Uploaded `{kk}` in `{t}`")
|
273 |
else:
|
274 |
await eor(xx, f"Uploaded `{kk}` in `0 second(s)`")
|
275 |
|
plugins/echo.py
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2020 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}addecho <reply to anyone>`
|
12 |
+
Start Auto Echo message of Replied user.
|
13 |
+
|
14 |
+
•`{i}remecho <reply to anyone>`
|
15 |
+
Turn It off
|
16 |
+
|
17 |
+
•`{i}listecho <reply to anyone>`
|
18 |
+
To Get list.
|
19 |
+
|
20 |
+
"""
|
21 |
+
|
22 |
+
from pyUltroid.functions.echo_db import *
|
23 |
+
from telethon.utils import get_display_name
|
24 |
+
|
25 |
+
from . import *
|
26 |
+
|
27 |
+
|
28 |
+
@ultroid_cmd(pattern="addecho ?(.*)")
|
29 |
+
async def echo(e):
|
30 |
+
r = await e.get_reply_message()
|
31 |
+
if r:
|
32 |
+
user = r.sender_id
|
33 |
+
else:
|
34 |
+
try:
|
35 |
+
user = e.text.split()[1]
|
36 |
+
if user.startswith("@"):
|
37 |
+
ok = await ultroid_bot.get_entity(user)
|
38 |
+
user = ok.id
|
39 |
+
else:
|
40 |
+
user = int(user)
|
41 |
+
except BaseException:
|
42 |
+
return await eod(e, "Reply To A user.")
|
43 |
+
if check_echo(e.chat_id, user):
|
44 |
+
return await eod(e, "Echo already activated for this user.")
|
45 |
+
add_echo(e.chat_id, user)
|
46 |
+
ok = await ultroid_bot.get_entity(user)
|
47 |
+
user = f"[{get_display_name(ok)}](tg://user?id={ok.id})"
|
48 |
+
await eor(e, f"Activated Echo For {user}.")
|
49 |
+
|
50 |
+
|
51 |
+
@ultroid_cmd(pattern="remecho ?(.*)")
|
52 |
+
async def rm(e):
|
53 |
+
r = await e.get_reply_message()
|
54 |
+
if r:
|
55 |
+
user = r.sender_id
|
56 |
+
else:
|
57 |
+
try:
|
58 |
+
user = e.text.split()[1]
|
59 |
+
if user.startswith("@"):
|
60 |
+
ok = await ultroid_bot.get_entity(user)
|
61 |
+
user = ok.id
|
62 |
+
else:
|
63 |
+
user = int(user)
|
64 |
+
except BaseException:
|
65 |
+
return await eod(e, "Reply To A User.")
|
66 |
+
if check_echo(e.chat_id, user):
|
67 |
+
rem_echo(e.chat_id, user)
|
68 |
+
ok = await ultroid_bot.get_entity(user)
|
69 |
+
user = f"[{get_display_name(ok)}](tg://user?id={ok.id})"
|
70 |
+
return await eor(e, f"Deactivated Echo For {user}.")
|
71 |
+
await eor(e, "Echo not activated for this user")
|
72 |
+
|
73 |
+
|
74 |
+
@ultroid_bot.on(events.NewMessage(incoming=True))
|
75 |
+
async def okk(e):
|
76 |
+
if check_echo(e.chat_id, e.sender_id):
|
77 |
+
try:
|
78 |
+
ok = await bot.get_messages(e.chat_id, ids=e.id)
|
79 |
+
return await ultroid_bot.send_message(e.chat_id, ok)
|
80 |
+
except Exception as er:
|
81 |
+
LOGS.info(er)
|
82 |
+
|
83 |
+
|
84 |
+
@ultroid_cmd(pattern="listecho$")
|
85 |
+
async def lstecho(e):
|
86 |
+
k = list_echo(e.chat_id)
|
87 |
+
if k:
|
88 |
+
user = "**Activated Echo For Users:**\n\n"
|
89 |
+
for x in k:
|
90 |
+
ok = await ultroid_bot.get_entity(int(x))
|
91 |
+
kk = f"[{get_display_name(ok)}](tg://user?id={ok.id})"
|
92 |
+
user += "•" + kk + "\n"
|
93 |
+
await eor(e, user)
|
94 |
+
else:
|
95 |
+
await eod(e, "`List is Empty, For echo`")
|
96 |
+
|
97 |
+
|
98 |
+
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
|
plugins/extra.py
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2020 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}del <reply to message>`
|
12 |
+
Delete the replied message.
|
13 |
+
|
14 |
+
• `{i}edit <new message>`
|
15 |
+
Edit your last message or replied msg.
|
16 |
+
|
17 |
+
• `{i}copy <reply to message>`
|
18 |
+
Copy replied message / media.
|
19 |
+
|
20 |
+
• `{i}reply`
|
21 |
+
Reply the last sent msg to replied user.
|
22 |
+
"""
|
23 |
+
|
24 |
+
import asyncio
|
25 |
+
|
26 |
+
from telethon.events import NewMessage as NewMsg
|
27 |
+
|
28 |
+
from . import *
|
29 |
+
|
30 |
+
_new_msgs = {}
|
31 |
+
|
32 |
+
|
33 |
+
@ultroid_bot.on(
|
34 |
+
NewMsg(
|
35 |
+
outgoing=True,
|
36 |
+
),
|
37 |
+
)
|
38 |
+
async def newmsg(event):
|
39 |
+
if event.message.message == f"{HNDLR}reply":
|
40 |
+
return
|
41 |
+
_new_msgs[event.chat_id] = event.message
|
42 |
+
|
43 |
+
|
44 |
+
@ultroid_cmd(
|
45 |
+
pattern="del$",
|
46 |
+
)
|
47 |
+
async def delete_it(delme):
|
48 |
+
msg_src = await delme.get_reply_message()
|
49 |
+
if delme.reply_to_msg_id:
|
50 |
+
try:
|
51 |
+
await msg_src.delete()
|
52 |
+
await delme.delete()
|
53 |
+
except BaseException:
|
54 |
+
await eod(
|
55 |
+
delme,
|
56 |
+
f"Couldn't delete the message.\n\n**ERROR:**\n`{str(e)}`",
|
57 |
+
time=5,
|
58 |
+
)
|
59 |
+
|
60 |
+
|
61 |
+
@ultroid_cmd(
|
62 |
+
pattern="copy$",
|
63 |
+
)
|
64 |
+
async def copy(e):
|
65 |
+
reply = await e.get_reply_message()
|
66 |
+
if reply:
|
67 |
+
if reply.text and not reply.media:
|
68 |
+
await eor(e, reply.text)
|
69 |
+
else:
|
70 |
+
await reply.reply(reply)
|
71 |
+
if e.sender_id == ultroid_bot.uid:
|
72 |
+
await e.delete()
|
73 |
+
else:
|
74 |
+
await eod(e, "`Reply To any message`")
|
75 |
+
|
76 |
+
|
77 |
+
@ultroid_cmd(
|
78 |
+
pattern="edit",
|
79 |
+
)
|
80 |
+
async def editer(edit):
|
81 |
+
message = edit.text
|
82 |
+
chat = await edit.get_input_chat()
|
83 |
+
string = str(message[6:])
|
84 |
+
reply = await edit.get_reply_message()
|
85 |
+
if reply and reply.text:
|
86 |
+
try:
|
87 |
+
await reply.edit(string)
|
88 |
+
await edit.delete()
|
89 |
+
except BaseException:
|
90 |
+
pass
|
91 |
+
else:
|
92 |
+
i = 1
|
93 |
+
async for message in ultroid_bot.iter_messages(chat, ultroid_bot.uid):
|
94 |
+
if i == 2:
|
95 |
+
await message.edit(string)
|
96 |
+
await edit.delete()
|
97 |
+
break
|
98 |
+
i = i + 1
|
99 |
+
|
100 |
+
|
101 |
+
@ultroid_cmd(
|
102 |
+
pattern="reply$",
|
103 |
+
)
|
104 |
+
async def _(e):
|
105 |
+
if e.reply_to_msg_id and e.chat_id in _new_msgs:
|
106 |
+
msg = _new_msgs[e.chat_id]
|
107 |
+
chat = await e.get_input_chat()
|
108 |
+
await asyncio.wait(
|
109 |
+
[
|
110 |
+
e.client.delete_messages(chat, [e.id, msg.id]),
|
111 |
+
e.client.send_message(chat, msg, reply_to=e.reply_to_msg_id),
|
112 |
+
]
|
113 |
+
)
|
114 |
+
else:
|
115 |
+
await e.delete()
|
116 |
+
|
117 |
+
|
118 |
+
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
|
plugins/fedutils.py
CHANGED
@@ -36,11 +36,10 @@ bot = "@MissRose_bot"
|
|
36 |
@ultroid_cmd(pattern="superfban ?(.*)")
|
37 |
async def _(event):
|
38 |
msg = await eor(event, "Starting a Mass-FedBan...")
|
39 |
-
fedList = []
|
40 |
if event.reply_to_msg_id:
|
41 |
previous_message = await event.get_reply_message()
|
42 |
if previous_message.media:
|
43 |
-
downloaded_file_name = await
|
44 |
previous_message,
|
45 |
"fedlist",
|
46 |
)
|
@@ -52,58 +51,50 @@ async def _(event):
|
|
52 |
except BaseException:
|
53 |
pass
|
54 |
arg = event.text.split(" ", maxsplit=2)
|
55 |
-
|
56 |
FBAN = arg[1]
|
57 |
REASON = arg[2]
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
61 |
else:
|
62 |
FBAN = previous_message.sender_id
|
63 |
try:
|
64 |
REASON = event.text.split(" ", maxsplit=1)[1]
|
65 |
-
except
|
66 |
-
REASON = ""
|
67 |
-
if REASON.strip() == "":
|
68 |
-
REASON = " #TBMassBanned "
|
69 |
else:
|
70 |
arg = event.text.split(" ", maxsplit=2)
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
except BaseException:
|
76 |
-
return await msg.edit("`No user designated!`")
|
77 |
-
else:
|
78 |
try:
|
79 |
FBAN = arg[1]
|
80 |
-
REASON = " #TBMassBanned "
|
81 |
except BaseException:
|
82 |
-
return await msg.edit("
|
|
|
83 |
try:
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
await msg.edit("You can't ban my dev you noob!!")
|
93 |
-
return
|
94 |
-
except Exception as e:
|
95 |
-
print(str(e))
|
96 |
-
return await msg.edit(str(e))
|
97 |
-
except Exception as e:
|
98 |
-
print(str(e))
|
99 |
-
return await msg.edit(str(e))
|
100 |
if udB.get("FBAN_GROUP_ID"):
|
101 |
chat = int(udB.get("FBAN_GROUP_ID"))
|
102 |
else:
|
103 |
chat = await event.get_chat()
|
|
|
|
|
104 |
if not len(fedList):
|
105 |
for a in range(3):
|
106 |
-
async with
|
107 |
await bot_conv.send_message("/start")
|
108 |
await asyncio.sleep(3)
|
109 |
await bot_conv.send_message("/myfeds")
|
@@ -121,7 +112,7 @@ async def _(event):
|
|
121 |
fedfile = await bot_conv.get_response()
|
122 |
await asyncio.sleep(3)
|
123 |
if fedfile.media:
|
124 |
-
downloaded_file_name = await
|
125 |
fedfile,
|
126 |
"fedlist",
|
127 |
)
|
@@ -163,7 +154,7 @@ async def _(event):
|
|
163 |
return
|
164 |
await msg.edit(f"FBaning in {len(fedList)} feds.")
|
165 |
try:
|
166 |
-
await
|
167 |
except BaseException:
|
168 |
await msg.edit("Specified FBan Group ID is incorrect.")
|
169 |
return
|
@@ -175,19 +166,19 @@ async def _(event):
|
|
175 |
exCount = 0
|
176 |
for fed in fedList:
|
177 |
if udB.get("EXCLUDE_FED") and fed in excludeFed:
|
178 |
-
await
|
179 |
exCount += 1
|
180 |
continue
|
181 |
-
await
|
182 |
await asyncio.sleep(3)
|
183 |
-
await
|
184 |
await asyncio.sleep(3)
|
185 |
try:
|
186 |
os.remove("fedlist")
|
187 |
except Exception as e:
|
188 |
print(f"Error in removing FedAdmin file.\n{str(e)}")
|
189 |
await msg.edit(
|
190 |
-
f"SuperFBan Completed.\nTotal Feds - {len(fedList)}.\nExcluded - {exCount}.\
|
191 |
)
|
192 |
|
193 |
|
@@ -198,7 +189,7 @@ async def _(event):
|
|
198 |
if event.reply_to_msg_id:
|
199 |
previous_message = await event.get_reply_message()
|
200 |
if previous_message.media:
|
201 |
-
downloaded_file_name = await
|
202 |
previous_message,
|
203 |
"fedlist",
|
204 |
)
|
@@ -238,20 +229,13 @@ async def _(event):
|
|
238 |
REASON = " #TBMassUnBanned "
|
239 |
except BaseException:
|
240 |
return await msg.edit("`No user designated!`")
|
241 |
-
try:
|
242 |
-
if str(FBAN) in DEVLIST:
|
243 |
-
await msg.edit("You can't ban my dev you noob!!")
|
244 |
-
return
|
245 |
-
except Exception as e:
|
246 |
-
print(str(e))
|
247 |
-
return await msg.edit(str(e))
|
248 |
if udB.get("FBAN_GROUP_ID"):
|
249 |
chat = int(udB.get("FBAN_GROUP_ID"))
|
250 |
else:
|
251 |
chat = await event.get_chat()
|
252 |
if not len(fedList):
|
253 |
for a in range(3):
|
254 |
-
async with
|
255 |
await bot_conv.send_message("/start")
|
256 |
await asyncio.sleep(3)
|
257 |
await bot_conv.send_message("/myfeds")
|
@@ -269,7 +253,7 @@ async def _(event):
|
|
269 |
fedfile = await bot_conv.get_response()
|
270 |
await asyncio.sleep(3)
|
271 |
if fedfile.media:
|
272 |
-
downloaded_file_name = await
|
273 |
fedfile,
|
274 |
"fedlist",
|
275 |
)
|
@@ -311,7 +295,7 @@ async def _(event):
|
|
311 |
return
|
312 |
await msg.edit(f"UnFBaning in {len(fedList)} feds.")
|
313 |
try:
|
314 |
-
await
|
315 |
except BaseException:
|
316 |
await msg.edit("Specified FBan Group ID is incorrect.")
|
317 |
return
|
@@ -323,12 +307,12 @@ async def _(event):
|
|
323 |
exCount = 0
|
324 |
for fed in fedList:
|
325 |
if udB.get("EXCLUDE_FED") and fed in excludeFed:
|
326 |
-
await
|
327 |
exCount += 1
|
328 |
continue
|
329 |
-
await
|
330 |
await asyncio.sleep(3)
|
331 |
-
await
|
332 |
await asyncio.sleep(3)
|
333 |
try:
|
334 |
os.remove("fedlist")
|
|
|
36 |
@ultroid_cmd(pattern="superfban ?(.*)")
|
37 |
async def _(event):
|
38 |
msg = await eor(event, "Starting a Mass-FedBan...")
|
|
|
39 |
if event.reply_to_msg_id:
|
40 |
previous_message = await event.get_reply_message()
|
41 |
if previous_message.media:
|
42 |
+
downloaded_file_name = await ultroid.download_media(
|
43 |
previous_message,
|
44 |
"fedlist",
|
45 |
)
|
|
|
51 |
except BaseException:
|
52 |
pass
|
53 |
arg = event.text.split(" ", maxsplit=2)
|
54 |
+
try:
|
55 |
FBAN = arg[1]
|
56 |
REASON = arg[2]
|
57 |
+
except IndexError:
|
58 |
+
try:
|
59 |
+
FBAN = arg[1]
|
60 |
+
except IndexError:
|
61 |
+
return await msg.edit("No user was designated.")
|
62 |
+
REASON = "#TBMassBanned "
|
63 |
else:
|
64 |
FBAN = previous_message.sender_id
|
65 |
try:
|
66 |
REASON = event.text.split(" ", maxsplit=1)[1]
|
67 |
+
except IndexError:
|
68 |
+
REASON = "#TBMassBanned"
|
|
|
|
|
69 |
else:
|
70 |
arg = event.text.split(" ", maxsplit=2)
|
71 |
+
try:
|
72 |
+
FBAN = arg[1]
|
73 |
+
REASON = arg[2]
|
74 |
+
except IndexError:
|
|
|
|
|
|
|
75 |
try:
|
76 |
FBAN = arg[1]
|
|
|
77 |
except BaseException:
|
78 |
+
return await msg.edit("No user was designated.")
|
79 |
+
REASON = "#TBMassBanned"
|
80 |
try:
|
81 |
+
uid = int(FBAN)
|
82 |
+
except ValueError:
|
83 |
+
x = await ultroid(GetFullUserRequest(FBAN))
|
84 |
+
uid = x.user.id
|
85 |
+
|
86 |
+
if str(uid) in DEVLIST:
|
87 |
+
return await msg.edit("The user is my Dev and cannot be FBanned!")
|
88 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
if udB.get("FBAN_GROUP_ID"):
|
90 |
chat = int(udB.get("FBAN_GROUP_ID"))
|
91 |
else:
|
92 |
chat = await event.get_chat()
|
93 |
+
|
94 |
+
fedList = []
|
95 |
if not len(fedList):
|
96 |
for a in range(3):
|
97 |
+
async with ultroid.conversation("@MissRose_bot") as bot_conv:
|
98 |
await bot_conv.send_message("/start")
|
99 |
await asyncio.sleep(3)
|
100 |
await bot_conv.send_message("/myfeds")
|
|
|
112 |
fedfile = await bot_conv.get_response()
|
113 |
await asyncio.sleep(3)
|
114 |
if fedfile.media:
|
115 |
+
downloaded_file_name = await ultroid.download_media(
|
116 |
fedfile,
|
117 |
"fedlist",
|
118 |
)
|
|
|
154 |
return
|
155 |
await msg.edit(f"FBaning in {len(fedList)} feds.")
|
156 |
try:
|
157 |
+
await ultroid.send_message(chat, f"/start")
|
158 |
except BaseException:
|
159 |
await msg.edit("Specified FBan Group ID is incorrect.")
|
160 |
return
|
|
|
166 |
exCount = 0
|
167 |
for fed in fedList:
|
168 |
if udB.get("EXCLUDE_FED") and fed in excludeFed:
|
169 |
+
await ultroid.send_message(chat, f"{fed} Excluded.")
|
170 |
exCount += 1
|
171 |
continue
|
172 |
+
await ultroid.send_message(chat, f"/joinfed {fed}")
|
173 |
await asyncio.sleep(3)
|
174 |
+
await ultroid.send_message(chat, f"/fban {uid} {REASON}")
|
175 |
await asyncio.sleep(3)
|
176 |
try:
|
177 |
os.remove("fedlist")
|
178 |
except Exception as e:
|
179 |
print(f"Error in removing FedAdmin file.\n{str(e)}")
|
180 |
await msg.edit(
|
181 |
+
f"SuperFBan Completed.\nTotal Feds - {len(fedList)}.\nExcluded - {exCount}.\nAffected {len(fedList) - exCount} feds.\n#TB",
|
182 |
)
|
183 |
|
184 |
|
|
|
189 |
if event.reply_to_msg_id:
|
190 |
previous_message = await event.get_reply_message()
|
191 |
if previous_message.media:
|
192 |
+
downloaded_file_name = await ultroid.download_media(
|
193 |
previous_message,
|
194 |
"fedlist",
|
195 |
)
|
|
|
229 |
REASON = " #TBMassUnBanned "
|
230 |
except BaseException:
|
231 |
return await msg.edit("`No user designated!`")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
if udB.get("FBAN_GROUP_ID"):
|
233 |
chat = int(udB.get("FBAN_GROUP_ID"))
|
234 |
else:
|
235 |
chat = await event.get_chat()
|
236 |
if not len(fedList):
|
237 |
for a in range(3):
|
238 |
+
async with ultroid.conversation("@MissRose_bot") as bot_conv:
|
239 |
await bot_conv.send_message("/start")
|
240 |
await asyncio.sleep(3)
|
241 |
await bot_conv.send_message("/myfeds")
|
|
|
253 |
fedfile = await bot_conv.get_response()
|
254 |
await asyncio.sleep(3)
|
255 |
if fedfile.media:
|
256 |
+
downloaded_file_name = await ultroid.download_media(
|
257 |
fedfile,
|
258 |
"fedlist",
|
259 |
)
|
|
|
295 |
return
|
296 |
await msg.edit(f"UnFBaning in {len(fedList)} feds.")
|
297 |
try:
|
298 |
+
await ultroid.send_message(chat, f"/start")
|
299 |
except BaseException:
|
300 |
await msg.edit("Specified FBan Group ID is incorrect.")
|
301 |
return
|
|
|
307 |
exCount = 0
|
308 |
for fed in fedList:
|
309 |
if udB.get("EXCLUDE_FED") and fed in excludeFed:
|
310 |
+
await ultroid.send_message(chat, f"{fed} Excluded.")
|
311 |
exCount += 1
|
312 |
continue
|
313 |
+
await ultroid.send_message(chat, f"/joinfed {fed}")
|
314 |
await asyncio.sleep(3)
|
315 |
+
await ultroid.send_message(chat, f"/unfban {FBAN} {REASON}")
|
316 |
await asyncio.sleep(3)
|
317 |
try:
|
318 |
os.remove("fedlist")
|
plugins/filter.py
CHANGED
@@ -22,6 +22,7 @@ import os
|
|
22 |
|
23 |
from pyUltroid.functions.filter_db import *
|
24 |
from telegraph import upload_file as uf
|
|
|
25 |
from telethon.utils import pack_bot_file_id
|
26 |
|
27 |
from . import *
|
@@ -81,6 +82,8 @@ async def lsnote(e):
|
|
81 |
|
82 |
@ultroid_bot.on(events.NewMessage())
|
83 |
async def fl(e):
|
|
|
|
|
84 |
xx = (e.text).lower()
|
85 |
chat = e.chat_id
|
86 |
x = get_filter(int(chat))
|
|
|
22 |
|
23 |
from pyUltroid.functions.filter_db import *
|
24 |
from telegraph import upload_file as uf
|
25 |
+
from telethon.tl.types import User
|
26 |
from telethon.utils import pack_bot_file_id
|
27 |
|
28 |
from . import *
|
|
|
82 |
|
83 |
@ultroid_bot.on(events.NewMessage())
|
84 |
async def fl(e):
|
85 |
+
if isinstance(e.sender, User) and e.sender.bot:
|
86 |
+
return
|
87 |
xx = (e.text).lower()
|
88 |
chat = e.chat_id
|
89 |
x = get_filter(int(chat))
|
plugins/forcesubscribe.py
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2020 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 |
+
"""
|
10 |
+
✘ Commands Available -
|
11 |
+
|
12 |
+
• `{i}fsub <chat username><id>`
|
13 |
+
Enable ForceSub in Used Chat !
|
14 |
+
|
15 |
+
• `{i}checkfsub`
|
16 |
+
Check/Get Active ForceSub Setting of Used Chat.
|
17 |
+
|
18 |
+
• `{i}remfsub`
|
19 |
+
Remove ForceSub from Used Chat !
|
20 |
+
|
21 |
+
Note - You Need to be Admin in Both Channel/Chats
|
22 |
+
in order to Use ForceSubscribe.
|
23 |
+
"""
|
24 |
+
|
25 |
+
|
26 |
+
import re
|
27 |
+
|
28 |
+
from pyUltroid.functions.forcesub_db import *
|
29 |
+
from telethon import events
|
30 |
+
from telethon.errors.rpcerrorlist import UserNotParticipantError
|
31 |
+
from telethon.tl.custom import Button
|
32 |
+
from telethon.tl.functions.channels import GetParticipantRequest
|
33 |
+
from telethon.tl.functions.messages import ExportChatInviteRequest
|
34 |
+
|
35 |
+
from . import *
|
36 |
+
|
37 |
+
|
38 |
+
@ultroid_bot.on(events.ChatAction())
|
39 |
+
async def forcesub(ult):
|
40 |
+
if not udB.get("FORCESUB"):
|
41 |
+
return
|
42 |
+
if not (ult.user_joined or ult.user_added):
|
43 |
+
return
|
44 |
+
if not get_forcesetting(ult.chat_id):
|
45 |
+
return
|
46 |
+
user = await ult.get_user()
|
47 |
+
if user.bot:
|
48 |
+
return
|
49 |
+
joinchat = get_forcesetting(ult.chat_id)
|
50 |
+
try:
|
51 |
+
await ultroid_bot(GetParticipantRequest(int(joinchat), user.id))
|
52 |
+
except UserNotParticipantError:
|
53 |
+
await ultroid_bot.edit_permissions(ult.chat_id, user.id, send_messages=False)
|
54 |
+
res = await ultroid_bot.inline_query(
|
55 |
+
asst.me.username, f"fsub {user.id}_{joinchat}"
|
56 |
+
)
|
57 |
+
await res[0].click(ult.chat_id, reply_to=ult.action_message.id)
|
58 |
+
|
59 |
+
|
60 |
+
@ultroid_cmd(pattern="fsub ?(.*)", admins_only=True, groups_only=True)
|
61 |
+
async def addfor(e):
|
62 |
+
match = e.pattern_match.group(1)
|
63 |
+
if not match:
|
64 |
+
return await eod(e, "Give Channel where you want User to Join !")
|
65 |
+
if match.startswith("@"):
|
66 |
+
ch = match
|
67 |
+
else:
|
68 |
+
try:
|
69 |
+
ch = int(match)
|
70 |
+
except BaseException:
|
71 |
+
return await eod(e, "Give Correct Channel Username or id")
|
72 |
+
try:
|
73 |
+
match = (await ultroid_bot.get_entity(ch)).id
|
74 |
+
except BaseException:
|
75 |
+
return await eod(e, "Give Correct Channel Username or id")
|
76 |
+
if not str(match).startswith("-100"):
|
77 |
+
match = int("-100" + str(match))
|
78 |
+
add_forcesub(e.chat_id, match)
|
79 |
+
await eor(e, "Added ForceSub in This Chat !")
|
80 |
+
|
81 |
+
|
82 |
+
@ultroid_cmd(pattern="remfsub$")
|
83 |
+
async def remor(e):
|
84 |
+
res = rem_forcesub(e.chat_id)
|
85 |
+
if not res:
|
86 |
+
return await eod(e, "ForceSub was not Active in this Chat !")
|
87 |
+
await eor(e, "Removed ForceSub...")
|
88 |
+
|
89 |
+
|
90 |
+
@ultroid_cmd(pattern="checkfsub$")
|
91 |
+
async def getfsr(e):
|
92 |
+
res = get_forcesetting(e.chat_id)
|
93 |
+
if not res:
|
94 |
+
return await eod(e, "ForceSub is Not Active In This Chat !")
|
95 |
+
cha = await ultroid_bot.get_entity(int(res))
|
96 |
+
await eor(e, f"**ForceSub Status** : `Active`\n- **{cha.title}** `({res})`")
|
97 |
+
|
98 |
+
|
99 |
+
@in_pattern("fsub ?(.*)")
|
100 |
+
@in_owner
|
101 |
+
async def fcall(e):
|
102 |
+
match = e.pattern_match.group(1)
|
103 |
+
spli = match.split("_")
|
104 |
+
user = await ultroid_bot.get_entity(int(spli[0]))
|
105 |
+
cl = await ultroid_bot.get_entity(int(spli[1]))
|
106 |
+
text = f"Hi [{user.first_name}](tg://user?id={user.id}), You Need to Join"
|
107 |
+
text += f" {cl.title} in order to Chat in this Group."
|
108 |
+
if not cl.username:
|
109 |
+
el = (await ultroid_bot(ExportChatInviteRequest(cl))).link
|
110 |
+
else:
|
111 |
+
el = "https://t.me/" + cl.username
|
112 |
+
res = [
|
113 |
+
await e.builder.article(
|
114 |
+
title="forcesub",
|
115 |
+
text=text,
|
116 |
+
buttons=[
|
117 |
+
[Button.url(text="Join Channel", url=el)],
|
118 |
+
[Button.inline("Unmute Me", data=f"unm_{match}")],
|
119 |
+
],
|
120 |
+
)
|
121 |
+
]
|
122 |
+
await e.answer(res)
|
123 |
+
|
124 |
+
|
125 |
+
@callback(re.compile("unm_(.*)"))
|
126 |
+
async def diesoon(e):
|
127 |
+
match = (e.data_match.group(1)).decode("UTF-8")
|
128 |
+
spli = match.split("_")
|
129 |
+
if not e.sender_id == int(spli[0]):
|
130 |
+
return await e.answer("This Message is Not for You", alert=True)
|
131 |
+
try:
|
132 |
+
await ultroid_bot(GetParticipantRequest(int(spli[1]), int(spli[0])))
|
133 |
+
except UserNotParticipantError:
|
134 |
+
return await e.answer(
|
135 |
+
"Please Join That Channel !\nThen Click This Button !", alert=True
|
136 |
+
)
|
137 |
+
await ultroid_bot.edit_permissions(
|
138 |
+
e.chat_id, int(spli[0]), send_messages=True, until_date=None
|
139 |
+
)
|
140 |
+
await e.edit("Thanks For Joining ! ")
|
141 |
+
|
142 |
+
|
143 |
+
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
|
plugins/giftools.py
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2020 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}invertgif`
|
12 |
+
Make Gif Inverted(negative).
|
13 |
+
|
14 |
+
•`{i}bwgif`
|
15 |
+
Make Gif black and white
|
16 |
+
|
17 |
+
•`{i}vtog`
|
18 |
+
Reply To Video , It will Create Gif
|
19 |
+
Video to Gif
|
20 |
+
|
21 |
+
•`{i}gif <query>`
|
22 |
+
Send video regarding to query.
|
23 |
+
"""
|
24 |
+
|
25 |
+
|
26 |
+
import os
|
27 |
+
import random
|
28 |
+
import time
|
29 |
+
from datetime import datetime as dt
|
30 |
+
|
31 |
+
from . import *
|
32 |
+
|
33 |
+
|
34 |
+
@ultroid_cmd(pattern="bwgif$")
|
35 |
+
async def igif(e):
|
36 |
+
a = await e.get_reply_message()
|
37 |
+
if not (a and a.media):
|
38 |
+
return await eod(e, "`Reply To gif only`")
|
39 |
+
wut = mediainfo(a.media)
|
40 |
+
if "gif" not in wut:
|
41 |
+
return await eod(e, "`Reply To Gif Only`")
|
42 |
+
xx = await eor(e, "`Processing...`")
|
43 |
+
z = await ultroid_bot.download_media(a.media)
|
44 |
+
try:
|
45 |
+
await bash(f'ffmpeg -i "{z}" -vf format=gray ult.gif -y')
|
46 |
+
await e.client.send_file(e.chat_id, "ult.gif", support_stream=True)
|
47 |
+
os.remove(z)
|
48 |
+
os.remove("ult.gif")
|
49 |
+
await xx.delete()
|
50 |
+
except Exception as er:
|
51 |
+
LOGS.info(er)
|
52 |
+
|
53 |
+
|
54 |
+
@ultroid_cmd(pattern="invertgif$")
|
55 |
+
async def igif(e):
|
56 |
+
a = await e.get_reply_message()
|
57 |
+
if not (a and a.media):
|
58 |
+
return await eod(e, "`Reply To gif only`")
|
59 |
+
wut = mediainfo(a.media)
|
60 |
+
if "gif" not in wut:
|
61 |
+
return await eod(e, "`Reply To Gif Only`")
|
62 |
+
xx = await eor(e, "`Processing...`")
|
63 |
+
z = await ultroid_bot.download_media(a.media)
|
64 |
+
try:
|
65 |
+
await bash(
|
66 |
+
f'ffmpeg -i "{z}" -vf lutyuv="y=negval:u=negval:v=negval" ult.gif -y'
|
67 |
+
)
|
68 |
+
await e.client.send_file(e.chat_id, "ult.gif", support_stream=True)
|
69 |
+
os.remove(z)
|
70 |
+
os.remove("ult.gif")
|
71 |
+
await xx.delete()
|
72 |
+
except Exception as er:
|
73 |
+
LOGS.info(er)
|
74 |
+
|
75 |
+
|
76 |
+
@ultroid_cmd(pattern="gif ?(.*)")
|
77 |
+
async def gifs(ult):
|
78 |
+
get = ult.pattern_match.group(1)
|
79 |
+
xx = random.randint(0, 5)
|
80 |
+
n = 0
|
81 |
+
if ";" in get:
|
82 |
+
try:
|
83 |
+
n = int(get.split(";")[-1])
|
84 |
+
except BaseException:
|
85 |
+
pass
|
86 |
+
if not get:
|
87 |
+
return await eor(ult, "`{i}gif <query>`")
|
88 |
+
m = await eor(ult, "`Searching gif ...`")
|
89 |
+
gifs = await ultroid_bot.inline_query("gif", get)
|
90 |
+
if not n:
|
91 |
+
await gifs[xx].click(
|
92 |
+
ult.chat.id, reply_to=ult.reply_to_msg_id, silent=True, hide_via=True
|
93 |
+
)
|
94 |
+
else:
|
95 |
+
for x in range(n):
|
96 |
+
await gifs[x].click(
|
97 |
+
ult.chat.id, reply_to=ult.reply_to_msg_id, silent=True, hide_via=True
|
98 |
+
)
|
99 |
+
await m.delete()
|
100 |
+
|
101 |
+
|
102 |
+
@ultroid_cmd(pattern="vtog$")
|
103 |
+
async def vtogif(e):
|
104 |
+
a = await e.get_reply_message()
|
105 |
+
if not (a and a.media):
|
106 |
+
return await eod(e, "`Reply To video only`")
|
107 |
+
wut = mediainfo(a.media)
|
108 |
+
if "video" not in wut:
|
109 |
+
return await eod(e, "`Reply To Video Only`")
|
110 |
+
xx = await eor(e, "`Processing...`")
|
111 |
+
dur = a.media.document.attributes[0].duration
|
112 |
+
tt = time.time()
|
113 |
+
if int(dur) < 120:
|
114 |
+
z = await ultroid_bot.download_media(a.media)
|
115 |
+
await bash(
|
116 |
+
f'ffmpeg -i {z} -vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 ult.gif -y'
|
117 |
+
)
|
118 |
+
await e.client.send_file(e.chat_id, "ult.gif", support_stream=True)
|
119 |
+
os.remove(z)
|
120 |
+
os.remove("ult.gif")
|
121 |
+
await xx.delete()
|
122 |
+
else:
|
123 |
+
filename = a.file.name
|
124 |
+
if not filename:
|
125 |
+
filename = "video_" + dt.now().isoformat("_", "seconds") + ".mp4"
|
126 |
+
vid = await downloader(filename, a.media.document, xx, tt, "Downloading...")
|
127 |
+
z = vid.name
|
128 |
+
await bash(
|
129 |
+
f'ffmpeg -ss 3 -t 100 -i {z} -vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 ult.gif'
|
130 |
+
)
|
131 |
+
await e.client.send_file(e.chat_id, "ult.gif", support_stream=True)
|
132 |
+
os.remove(z)
|
133 |
+
os.remove("ult.gif")
|
134 |
+
await xx.delete()
|
135 |
+
|
136 |
+
|
137 |
+
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
|
plugins/globaltools.py
CHANGED
@@ -9,19 +9,18 @@
|
|
9 |
✘ Commands Available -
|
10 |
|
11 |
• `{i}gban <reply user/ username>`
|
12 |
-
|
|
|
13 |
|
14 |
-
• `{i}
|
15 |
-
|
16 |
|
17 |
• `{i}listgban`
|
18 |
List all GBanned users.
|
19 |
|
20 |
• `{i}gmute <reply user/ username>`
|
21 |
-
|
22 |
-
|
23 |
-
• `{i}ungmute <reply user/ username>`
|
24 |
-
UnMute Globally.
|
25 |
|
26 |
• `{i}gkick <reply user/ username>`
|
27 |
Globally Kick User.
|
@@ -31,15 +30,372 @@
|
|
31 |
|
32 |
• `{i}gucast <Message>`
|
33 |
Globally Send that msg in all Ur Chat Users.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
"""
|
35 |
|
36 |
import os
|
37 |
|
38 |
from telethon import events
|
|
|
|
|
39 |
|
40 |
from . import *
|
41 |
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
@ultroid_cmd(
|
44 |
pattern="ungban ?(.*)",
|
45 |
)
|
@@ -84,6 +440,8 @@ async def _(e):
|
|
84 |
pattern="gban ?(.*)",
|
85 |
)
|
86 |
async def _(e):
|
|
|
|
|
87 |
xx = await eor(e, "`Gbanning...`")
|
88 |
reason = ""
|
89 |
if e.is_private:
|
@@ -235,6 +593,8 @@ async def gkick(e):
|
|
235 |
pattern="gmute ?(.*)",
|
236 |
)
|
237 |
async def _(e):
|
|
|
|
|
238 |
xx = await eor(e, "`Gmuting...`")
|
239 |
if e.is_private:
|
240 |
userid = (await e.get_chat()).id
|
@@ -346,7 +706,7 @@ async def list_gengbanned(event):
|
|
346 |
name = i
|
347 |
msg += "**User**: " + name + "\n"
|
348 |
reason = get_gban_reason(i)
|
349 |
-
if reason is not None:
|
350 |
msg += f"**Reason**: {reason}\n\n"
|
351 |
else:
|
352 |
msg += "\n"
|
@@ -365,4 +725,39 @@ async def list_gengbanned(event):
|
|
365 |
await x.edit(gbanned_users)
|
366 |
|
367 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
368 |
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
|
|
|
9 |
✘ Commands Available -
|
10 |
|
11 |
• `{i}gban <reply user/ username>`
|
12 |
+
• `{i}ungban`
|
13 |
+
Ban/Unban Globally.
|
14 |
|
15 |
+
• `{i}gstat <reply to user/userid/username>`
|
16 |
+
Check if user is GBanned.
|
17 |
|
18 |
• `{i}listgban`
|
19 |
List all GBanned users.
|
20 |
|
21 |
• `{i}gmute <reply user/ username>`
|
22 |
+
• `{i}ungmute`
|
23 |
+
Mute/UnMute Globally.
|
|
|
|
|
24 |
|
25 |
• `{i}gkick <reply user/ username>`
|
26 |
Globally Kick User.
|
|
|
30 |
|
31 |
• `{i}gucast <Message>`
|
32 |
Globally Send that msg in all Ur Chat Users.
|
33 |
+
|
34 |
+
•`{i}gpromote <reply to user> <channel/group/all> <rank>`
|
35 |
+
globally promote user where you are admin.
|
36 |
+
You can also set where To promote only groups or only channels or all.
|
37 |
+
Like. `gpromote group boss` ~ it promote repied user in all groups.
|
38 |
+
Or. `gpromote @username all sar` ~ it promote the users in all group and channel.
|
39 |
+
|
40 |
+
•`{i}gdemote`
|
41 |
+
Same function as gpromote.
|
42 |
"""
|
43 |
|
44 |
import os
|
45 |
|
46 |
from telethon import events
|
47 |
+
from telethon.tl.functions.channels import EditAdminRequest
|
48 |
+
from telethon.tl.types import ChatAdminRights
|
49 |
|
50 |
from . import *
|
51 |
|
52 |
|
53 |
+
@ultroid_cmd(pattern="gpromote ?(.*)")
|
54 |
+
async def _(e):
|
55 |
+
if not e.out and not is_fullsudo(e.sender_id):
|
56 |
+
return await eod(e, "`This Command Is Sudo Restricted.`")
|
57 |
+
x = e.pattern_match.group(1)
|
58 |
+
if not x:
|
59 |
+
return await eod(e, "`Incorrect Format`")
|
60 |
+
user = await e.get_reply_message()
|
61 |
+
if user:
|
62 |
+
ev = await eor(e, "`Promoting Replied User Globally`")
|
63 |
+
ok = e.text.split()
|
64 |
+
key = "all"
|
65 |
+
if len(ok) > 1:
|
66 |
+
if ("group" in ok[1]) or ("channel" in ok[1]):
|
67 |
+
key = ok[1]
|
68 |
+
rank = "AdMin"
|
69 |
+
if len(ok) > 2:
|
70 |
+
rank = ok[2]
|
71 |
+
c = 0
|
72 |
+
if e.is_private:
|
73 |
+
user.id = user.peer_id.user_id
|
74 |
+
else:
|
75 |
+
user.id = user.from_id.user_id
|
76 |
+
async for x in ultroid_bot.iter_dialogs():
|
77 |
+
if "group" in key.lower():
|
78 |
+
if x.is_group:
|
79 |
+
try:
|
80 |
+
await ultroid_bot(
|
81 |
+
EditAdminRequest(
|
82 |
+
x.id,
|
83 |
+
user.id,
|
84 |
+
ChatAdminRights(
|
85 |
+
add_admins=False,
|
86 |
+
invite_users=True,
|
87 |
+
change_info=False,
|
88 |
+
ban_users=True,
|
89 |
+
delete_messages=True,
|
90 |
+
pin_messages=True,
|
91 |
+
),
|
92 |
+
rank,
|
93 |
+
),
|
94 |
+
)
|
95 |
+
c += 1
|
96 |
+
except BaseException:
|
97 |
+
pass
|
98 |
+
elif "channel" in key.lower():
|
99 |
+
if x.is_channel:
|
100 |
+
try:
|
101 |
+
await ultroid_bot(
|
102 |
+
EditAdminRequest(
|
103 |
+
x.id,
|
104 |
+
user.id,
|
105 |
+
ChatAdminRights(
|
106 |
+
add_admins=False,
|
107 |
+
invite_users=True,
|
108 |
+
change_info=False,
|
109 |
+
ban_users=True,
|
110 |
+
delete_messages=True,
|
111 |
+
pin_messages=True,
|
112 |
+
),
|
113 |
+
rank,
|
114 |
+
),
|
115 |
+
)
|
116 |
+
c += 1
|
117 |
+
except BaseException:
|
118 |
+
pass
|
119 |
+
else:
|
120 |
+
if x.is_group or x.is_channel:
|
121 |
+
try:
|
122 |
+
await ultroid_bot(
|
123 |
+
EditAdminRequest(
|
124 |
+
x.id,
|
125 |
+
user.id,
|
126 |
+
ChatAdminRights(
|
127 |
+
add_admins=False,
|
128 |
+
invite_users=True,
|
129 |
+
change_info=False,
|
130 |
+
ban_users=True,
|
131 |
+
delete_messages=True,
|
132 |
+
pin_messages=True,
|
133 |
+
),
|
134 |
+
rank,
|
135 |
+
),
|
136 |
+
)
|
137 |
+
c += 1
|
138 |
+
except Exception as er:
|
139 |
+
LOGS.info(er)
|
140 |
+
return await eor(ev, f"Promoted The Replied Users in Total : {c} {key} chats")
|
141 |
+
else:
|
142 |
+
k = e.text.split()
|
143 |
+
if not k[1]:
|
144 |
+
return await eod(e, "`Give someone's username/id or replied to user.")
|
145 |
+
user = k[1]
|
146 |
+
if user.isdigit():
|
147 |
+
user = int(user)
|
148 |
+
try:
|
149 |
+
name = await ultroid_bot.get_entity(user)
|
150 |
+
except BaseException:
|
151 |
+
return await eod(e, f"`No User Found Regarding {user}`")
|
152 |
+
ev = await eor(e, f"`Promoting {name.first_name} globally.`")
|
153 |
+
key = "all"
|
154 |
+
if len(k) > 2:
|
155 |
+
if ("group" in k[2]) or ("channel" in k[2]):
|
156 |
+
key = k[2]
|
157 |
+
rank = "AdMin"
|
158 |
+
if len(k) > 3:
|
159 |
+
rank = k[3]
|
160 |
+
c = 0
|
161 |
+
async for x in ultroid_bot.iter_dialogs():
|
162 |
+
if "group" in key.lower():
|
163 |
+
if x.is_group:
|
164 |
+
try:
|
165 |
+
await ultroid_bot(
|
166 |
+
EditAdminRequest(
|
167 |
+
x.id,
|
168 |
+
user,
|
169 |
+
ChatAdminRights(
|
170 |
+
add_admins=False,
|
171 |
+
invite_users=True,
|
172 |
+
change_info=False,
|
173 |
+
ban_users=True,
|
174 |
+
delete_messages=True,
|
175 |
+
pin_messages=True,
|
176 |
+
),
|
177 |
+
rank,
|
178 |
+
),
|
179 |
+
)
|
180 |
+
c += 1
|
181 |
+
except BaseException:
|
182 |
+
pass
|
183 |
+
elif "channel" in key.lower():
|
184 |
+
if x.is_channel:
|
185 |
+
try:
|
186 |
+
await ultroid_bot(
|
187 |
+
EditAdminRequest(
|
188 |
+
x.id,
|
189 |
+
user,
|
190 |
+
ChatAdminRights(
|
191 |
+
add_admins=False,
|
192 |
+
invite_users=True,
|
193 |
+
change_info=False,
|
194 |
+
ban_users=True,
|
195 |
+
delete_messages=True,
|
196 |
+
pin_messages=True,
|
197 |
+
),
|
198 |
+
rank,
|
199 |
+
),
|
200 |
+
)
|
201 |
+
c += 1
|
202 |
+
except BaseException:
|
203 |
+
pass
|
204 |
+
else:
|
205 |
+
if x.is_group or x.is_channel:
|
206 |
+
try:
|
207 |
+
await ultroid_bot(
|
208 |
+
EditAdminRequest(
|
209 |
+
x.id,
|
210 |
+
user,
|
211 |
+
ChatAdminRights(
|
212 |
+
add_admins=False,
|
213 |
+
invite_users=True,
|
214 |
+
change_info=False,
|
215 |
+
ban_users=True,
|
216 |
+
delete_messages=True,
|
217 |
+
pin_messages=True,
|
218 |
+
),
|
219 |
+
rank,
|
220 |
+
),
|
221 |
+
)
|
222 |
+
c += 1
|
223 |
+
except BaseException:
|
224 |
+
pass
|
225 |
+
return await eor(ev, f"Promoted {name.first_name} in Total : {c} {key} chats.")
|
226 |
+
|
227 |
+
|
228 |
+
@ultroid_cmd(pattern="gdemote ?(.*)")
|
229 |
+
async def _(e):
|
230 |
+
if not e.out and not is_fullsudo(e.sender_id):
|
231 |
+
return await eod(e, "`This Command Is Sudo Restricted.`")
|
232 |
+
x = e.pattern_match.group(1)
|
233 |
+
if not x:
|
234 |
+
return await eod(e, "`Incorrect Format`")
|
235 |
+
user = await e.get_reply_message()
|
236 |
+
if user:
|
237 |
+
if e.is_private:
|
238 |
+
user.id = user.peer_id.user_id
|
239 |
+
else:
|
240 |
+
user.id = user.from_id.user_id
|
241 |
+
ev = await eor(e, "`Demoting Replied User Globally`")
|
242 |
+
ok = e.text.split()
|
243 |
+
key = "all"
|
244 |
+
if len(ok) > 1:
|
245 |
+
if ("group" in ok[1]) or ("channel" in ok[1]):
|
246 |
+
key = ok[1]
|
247 |
+
rank = "Not AdMin"
|
248 |
+
c = 0
|
249 |
+
async for x in ultroid_bot.iter_dialogs():
|
250 |
+
if "group" in key.lower():
|
251 |
+
if x.is_group:
|
252 |
+
try:
|
253 |
+
await ultroid_bot(
|
254 |
+
EditAdminRequest(
|
255 |
+
x.id,
|
256 |
+
user.id,
|
257 |
+
ChatAdminRights(
|
258 |
+
add_admins=False,
|
259 |
+
invite_users=False,
|
260 |
+
change_info=False,
|
261 |
+
ban_users=False,
|
262 |
+
delete_messages=False,
|
263 |
+
pin_messages=False,
|
264 |
+
),
|
265 |
+
rank,
|
266 |
+
),
|
267 |
+
)
|
268 |
+
c += 1
|
269 |
+
except BaseException:
|
270 |
+
pass
|
271 |
+
elif "channel" in key.lower():
|
272 |
+
if x.is_channel:
|
273 |
+
try:
|
274 |
+
await ultroid_bot(
|
275 |
+
EditAdminRequest(
|
276 |
+
x.id,
|
277 |
+
user.id,
|
278 |
+
ChatAdminRights(
|
279 |
+
add_admins=False,
|
280 |
+
invite_users=False,
|
281 |
+
change_info=False,
|
282 |
+
ban_users=False,
|
283 |
+
delete_messages=False,
|
284 |
+
pin_messages=False,
|
285 |
+
),
|
286 |
+
rank,
|
287 |
+
),
|
288 |
+
)
|
289 |
+
c += 1
|
290 |
+
except BaseException:
|
291 |
+
pass
|
292 |
+
else:
|
293 |
+
if x.is_group or x.is_channel:
|
294 |
+
try:
|
295 |
+
await ultroid_bot(
|
296 |
+
EditAdminRequest(
|
297 |
+
x.id,
|
298 |
+
user.id,
|
299 |
+
ChatAdminRights(
|
300 |
+
add_admins=False,
|
301 |
+
invite_users=False,
|
302 |
+
change_info=False,
|
303 |
+
ban_users=False,
|
304 |
+
delete_messages=False,
|
305 |
+
pin_messages=False,
|
306 |
+
),
|
307 |
+
rank,
|
308 |
+
),
|
309 |
+
)
|
310 |
+
c += 1
|
311 |
+
except BaseException:
|
312 |
+
pass
|
313 |
+
return await eor(ev, f"Demoted The Replied Users in Total : {c} {key} chats")
|
314 |
+
else:
|
315 |
+
k = e.text.split()
|
316 |
+
if not k[1]:
|
317 |
+
return await eod(e, "`Give someone's username/id or replied to user.")
|
318 |
+
user = k[1]
|
319 |
+
if user.isdigit():
|
320 |
+
user = int(user)
|
321 |
+
try:
|
322 |
+
name = await ultroid_bot.get_entity(user)
|
323 |
+
except BaseException:
|
324 |
+
return await eod(e, f"`No User Found Regarding {user}`")
|
325 |
+
ev = await eor(e, f"`Demoting {name.first_name} globally.`")
|
326 |
+
key = "all"
|
327 |
+
if len(k) > 2:
|
328 |
+
if ("group" in k[2]) or ("channel" in k[2]):
|
329 |
+
key = k[2]
|
330 |
+
rank = "Not AdMin"
|
331 |
+
c = 0
|
332 |
+
async for x in ultroid_bot.iter_dialogs():
|
333 |
+
if "group" in key.lower():
|
334 |
+
if x.is_group:
|
335 |
+
try:
|
336 |
+
await ultroid_bot(
|
337 |
+
EditAdminRequest(
|
338 |
+
x.id,
|
339 |
+
user,
|
340 |
+
ChatAdminRights(
|
341 |
+
add_admins=False,
|
342 |
+
invite_users=False,
|
343 |
+
change_info=False,
|
344 |
+
ban_users=False,
|
345 |
+
delete_messages=False,
|
346 |
+
pin_messages=False,
|
347 |
+
),
|
348 |
+
rank,
|
349 |
+
),
|
350 |
+
)
|
351 |
+
c += 1
|
352 |
+
except BaseException:
|
353 |
+
pass
|
354 |
+
elif "channel" in key.lower():
|
355 |
+
if x.is_channel:
|
356 |
+
try:
|
357 |
+
await ultroid_bot(
|
358 |
+
EditAdminRequest(
|
359 |
+
x.id,
|
360 |
+
user,
|
361 |
+
ChatAdminRights(
|
362 |
+
add_admins=False,
|
363 |
+
invite_users=False,
|
364 |
+
change_info=False,
|
365 |
+
ban_users=False,
|
366 |
+
delete_messages=False,
|
367 |
+
pin_messages=False,
|
368 |
+
),
|
369 |
+
rank,
|
370 |
+
),
|
371 |
+
)
|
372 |
+
c += 1
|
373 |
+
except BaseException:
|
374 |
+
pass
|
375 |
+
else:
|
376 |
+
if x.is_group or x.is_channel:
|
377 |
+
try:
|
378 |
+
await ultroid_bot(
|
379 |
+
EditAdminRequest(
|
380 |
+
x.id,
|
381 |
+
user,
|
382 |
+
ChatAdminRights(
|
383 |
+
add_admins=False,
|
384 |
+
invite_users=False,
|
385 |
+
change_info=False,
|
386 |
+
ban_users=False,
|
387 |
+
delete_messages=False,
|
388 |
+
pin_messages=False,
|
389 |
+
),
|
390 |
+
rank,
|
391 |
+
),
|
392 |
+
)
|
393 |
+
c += 1
|
394 |
+
except BaseException:
|
395 |
+
pass
|
396 |
+
return await eor(ev, f"Demoted {name.first_name} in Total : {c} {key} chats.")
|
397 |
+
|
398 |
+
|
399 |
@ultroid_cmd(
|
400 |
pattern="ungban ?(.*)",
|
401 |
)
|
|
|
440 |
pattern="gban ?(.*)",
|
441 |
)
|
442 |
async def _(e):
|
443 |
+
if not e.out and not is_fullsudo(e.sender_id):
|
444 |
+
return await eor(e, "`This Command Is Sudo Restricted.`")
|
445 |
xx = await eor(e, "`Gbanning...`")
|
446 |
reason = ""
|
447 |
if e.is_private:
|
|
|
593 |
pattern="gmute ?(.*)",
|
594 |
)
|
595 |
async def _(e):
|
596 |
+
if not e.out and not is_fullsudo(e.sender_id):
|
597 |
+
return await eor(e, "`This Command Is Sudo Restricted.`")
|
598 |
xx = await eor(e, "`Gmuting...`")
|
599 |
if e.is_private:
|
600 |
userid = (await e.get_chat()).id
|
|
|
706 |
name = i
|
707 |
msg += "**User**: " + name + "\n"
|
708 |
reason = get_gban_reason(i)
|
709 |
+
if reason is not None or "":
|
710 |
msg += f"**Reason**: {reason}\n\n"
|
711 |
else:
|
712 |
msg += "\n"
|
|
|
725 |
await x.edit(gbanned_users)
|
726 |
|
727 |
|
728 |
+
@ultroid_cmd(pattern="gstat ?(.*)")
|
729 |
+
async def gstat_(e):
|
730 |
+
xx = await eor(e, get_string("com_1"))
|
731 |
+
if e.is_private:
|
732 |
+
userid = (await e.get_chat()).id
|
733 |
+
elif e.reply_to_msg_id:
|
734 |
+
userid = (await e.get_reply_message()).sender_id
|
735 |
+
elif e.pattern_match.group(1):
|
736 |
+
if (e.pattern_match.group(1)).isdigit():
|
737 |
+
try:
|
738 |
+
userid = (await e.client.get_entity(int(e.pattern_match.group(1)))).id
|
739 |
+
except ValueError as err:
|
740 |
+
return await eod(xx, f"{str(err)}", time=5)
|
741 |
+
else:
|
742 |
+
try:
|
743 |
+
userid = (await e.client.get_entity(str(e.pattern_match.group(1)))).id
|
744 |
+
except ValueError as err:
|
745 |
+
return await eod(xx, f"{str(err)}", time=5)
|
746 |
+
else:
|
747 |
+
return await eod(xx, "`Reply to some msg or add their id.`", time=5)
|
748 |
+
name = (await e.client.get_entity(userid)).first_name
|
749 |
+
msg = "**" + name + " is "
|
750 |
+
is_banned = is_gbanned(userid)
|
751 |
+
reason = get_gban_reason(userid)
|
752 |
+
if is_banned:
|
753 |
+
msg += "Globally Banned"
|
754 |
+
if reason:
|
755 |
+
msg += f" with reason** `{reason}`"
|
756 |
+
else:
|
757 |
+
msg += ".**"
|
758 |
+
else:
|
759 |
+
msg += "not Globally Banned.**"
|
760 |
+
await xx.edit(msg)
|
761 |
+
|
762 |
+
|
763 |
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
|
plugins/imagetools.py
CHANGED
@@ -40,6 +40,10 @@
|
|
40 |
|
41 |
• `{i}blue <reply to any media>`
|
42 |
just cool.
|
|
|
|
|
|
|
|
|
43 |
"""
|
44 |
|
45 |
import asyncio
|
@@ -49,6 +53,10 @@ import cv2
|
|
49 |
import numpy as np
|
50 |
from PIL import Image
|
51 |
from telegraph import upload_file as upf
|
|
|
|
|
|
|
|
|
52 |
from validators.url import url
|
53 |
|
54 |
from . import *
|
@@ -492,6 +500,27 @@ async def ultd(event):
|
|
492 |
os.remove(ultt)
|
493 |
|
494 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
495 |
@ultroid_cmd(
|
496 |
pattern="blue$",
|
497 |
)
|
|
|
40 |
|
41 |
• `{i}blue <reply to any media>`
|
42 |
just cool.
|
43 |
+
|
44 |
+
• `{i}csample <color name /color code>`
|
45 |
+
example : `{i}csample red`
|
46 |
+
`{i}csample #ffffff`
|
47 |
"""
|
48 |
|
49 |
import asyncio
|
|
|
53 |
import numpy as np
|
54 |
from PIL import Image
|
55 |
from telegraph import upload_file as upf
|
56 |
+
from telethon.errors.rpcerrorlist import (
|
57 |
+
ChatSendMediaForbiddenError,
|
58 |
+
MessageDeleteForbiddenError,
|
59 |
+
)
|
60 |
from validators.url import url
|
61 |
|
62 |
from . import *
|
|
|
500 |
os.remove(ultt)
|
501 |
|
502 |
|
503 |
+
@ultroid_cmd(pattern="csample (.*)")
|
504 |
+
async def sampl(ult):
|
505 |
+
color = ult.pattern_match.group(1)
|
506 |
+
if color:
|
507 |
+
img = Image.new("RGB", (200, 100), f"{color}")
|
508 |
+
img.save("csample.png")
|
509 |
+
try:
|
510 |
+
try:
|
511 |
+
await ult.delete()
|
512 |
+
await ultroid_bot.send_message(
|
513 |
+
ult.chat_id, f"Colour Sample for `{color}` !", file="csample.png"
|
514 |
+
)
|
515 |
+
except MessageDeleteForbiddenError:
|
516 |
+
await ult.reply(f"Colour Sample for `{color}` !", file="csample.png")
|
517 |
+
except ChatSendMediaForbiddenError:
|
518 |
+
await eor(ult, "Umm! Sending Media is disabled here!")
|
519 |
+
|
520 |
+
else:
|
521 |
+
await eor(ult, f"Wrong Color Name/Hex Code specified!")
|
522 |
+
|
523 |
+
|
524 |
@ultroid_cmd(
|
525 |
pattern="blue$",
|
526 |
)
|
plugins/locks.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2020 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}lock <msgs/media/sticker/gif/games/inline/polls/invites/pin/changeinfo>`
|
12 |
+
Lock the Used Setting in Used Group.
|
13 |
+
|
14 |
+
• `{i}unlock <msgs/media/sticker/gif/games/inline/polls/invites/pin/changeinfo>`
|
15 |
+
UNLOCK the Used Setting in Used Group.
|
16 |
+
|
17 |
+
"""
|
18 |
+
|
19 |
+
from pyUltroid.functions.all import lucks, unlucks
|
20 |
+
from telethon.tl.functions.messages import EditChatDefaultBannedRightsRequest
|
21 |
+
|
22 |
+
from . import *
|
23 |
+
|
24 |
+
|
25 |
+
@ultroid_cmd(pattern="lock ?(.*)", groups_only=True, admins_only=True)
|
26 |
+
async def lockho(e):
|
27 |
+
mat = e.pattern_match.group(1)
|
28 |
+
if not mat:
|
29 |
+
return await eod(e, "`What to Lock ?`")
|
30 |
+
try:
|
31 |
+
ml = lucks(mat)
|
32 |
+
except BaseException:
|
33 |
+
return await eod(e, "`Incorrect Input`")
|
34 |
+
await ultroid_bot(EditChatDefaultBannedRightsRequest(e.chat_id, ml))
|
35 |
+
await eor(e, f"Locked - `{mat}` ! ")
|
36 |
+
|
37 |
+
|
38 |
+
@ultroid_cmd(pattern="unlock ?(.*)", groups_only=True, admins_only=True)
|
39 |
+
async def unlckho(e):
|
40 |
+
mat = e.pattern_match.group(1)
|
41 |
+
if not mat:
|
42 |
+
return await eod(e, "`What to Lock ?`")
|
43 |
+
try:
|
44 |
+
ml = unlucks(mat)
|
45 |
+
except BaseException:
|
46 |
+
return await eod(e, "`Incorrect Input`")
|
47 |
+
await ultroid_bot(EditChatDefaultBannedRightsRequest(e.chat_id, ml))
|
48 |
+
await eor(e, f"Unlocked - `{mat}` ! ")
|
49 |
+
|
50 |
+
|
51 |
+
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
|
plugins/logo.py
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2020 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}logo <text>`
|
12 |
+
Generate a logo of the given Text
|
13 |
+
Or Reply To image , to write ur text on it.
|
14 |
+
Or Reply To Font File, To write with that font.
|
15 |
+
|
16 |
+
"""
|
17 |
+
|
18 |
+
import os
|
19 |
+
import random
|
20 |
+
import time
|
21 |
+
|
22 |
+
from PIL import Image, ImageDraw, ImageFont
|
23 |
+
from telethon.tl.types import InputMessagesFilterPhotos
|
24 |
+
|
25 |
+
from . import *
|
26 |
+
|
27 |
+
|
28 |
+
@ultroid_cmd(pattern="logo ?(.*)")
|
29 |
+
async def logo_gen(event):
|
30 |
+
xx = await eor(event, get_string("com_1"))
|
31 |
+
name = event.pattern_match.group(1)
|
32 |
+
if not name:
|
33 |
+
await eod(xx, "`Give a name too!`")
|
34 |
+
bg_, font_ = "", ""
|
35 |
+
if event.reply_to_msg_id:
|
36 |
+
temp = await event.get_reply_message()
|
37 |
+
if temp.media:
|
38 |
+
if hasattr(temp.media, "document"):
|
39 |
+
if "font" in temp.file.mime_type:
|
40 |
+
font_ = await temp.download_media()
|
41 |
+
elif "pic" in mediainfo(temp.media):
|
42 |
+
bg_ = await temp.download_media()
|
43 |
+
else:
|
44 |
+
pics = []
|
45 |
+
async for i in ultroid.iter_messages(
|
46 |
+
"@UltroidLogos", filter=InputMessagesFilterPhotos
|
47 |
+
):
|
48 |
+
pics.append(i)
|
49 |
+
id_ = random.choice(pics)
|
50 |
+
bg_ = await id_.download_media()
|
51 |
+
fpath_ = "./resources/fonts/"
|
52 |
+
f = random.choice(os.listdir(fpath_))
|
53 |
+
font_ = fpath_ + f
|
54 |
+
if not bg_:
|
55 |
+
pics = []
|
56 |
+
async for i in ultroid.iter_messages(
|
57 |
+
"@UltroidLogos", filter=InputMessagesFilterPhotos
|
58 |
+
):
|
59 |
+
pics.append(i)
|
60 |
+
id_ = random.choice(pics)
|
61 |
+
bg_ = await id_.download_media()
|
62 |
+
if not font_:
|
63 |
+
fpath_ = "resources/fonts/"
|
64 |
+
f = random.choice(os.listdir(fpath_))
|
65 |
+
font_ = fpath_ + f
|
66 |
+
# next level logic, ignore
|
67 |
+
if len(name) < 8:
|
68 |
+
fnt_size = 150
|
69 |
+
strke = 10
|
70 |
+
elif len(name) > 10:
|
71 |
+
fnt_size = 50
|
72 |
+
strke = 5
|
73 |
+
else:
|
74 |
+
fnt_size = 130
|
75 |
+
strke = 20
|
76 |
+
img = Image.open(bg_)
|
77 |
+
draw = ImageDraw.Draw(img)
|
78 |
+
font = ImageFont.truetype(font_, fnt_size)
|
79 |
+
w, h = draw.textsize(name, font=font)
|
80 |
+
h += int(h * 0.21)
|
81 |
+
image_width, image_height = img.size
|
82 |
+
draw.text(
|
83 |
+
((image_width - w) / 2, (image_height - h) / 2),
|
84 |
+
name,
|
85 |
+
font=font,
|
86 |
+
fill=(255, 255, 255),
|
87 |
+
)
|
88 |
+
x = (image_width - w) / 2
|
89 |
+
y = (image_height - h) / 2
|
90 |
+
draw.text(
|
91 |
+
(x, y), name, font=font, fill="white", stroke_width=strke, stroke_fill="black"
|
92 |
+
)
|
93 |
+
flnme = f"ultd.png"
|
94 |
+
img.save(flnme, "png")
|
95 |
+
await xx.edit("`Done!`")
|
96 |
+
if os.path.exists(flnme):
|
97 |
+
tt = time.time()
|
98 |
+
up = await uploader(flnme, flnme, tt, xx, "Uploading...")
|
99 |
+
await ultroid.send_file(
|
100 |
+
event.chat_id,
|
101 |
+
file=up,
|
102 |
+
caption=f"Logo by [{OWNER_NAME}](tg://user?id={OWNER_ID})",
|
103 |
+
foce_document=True,
|
104 |
+
)
|
105 |
+
os.remove(flnme)
|
106 |
+
await xx.delete()
|
107 |
+
if os.path.exists(bg_):
|
108 |
+
os.remove(bg_)
|
109 |
+
if os.path.exists(font_):
|
110 |
+
if not font_.startswith("resources/fonts"):
|
111 |
+
os.remove(font_)
|
112 |
+
|
113 |
+
|
114 |
+
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
|
plugins/megadl.py
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2020 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}megadl <link>`
|
12 |
+
It Downloads and Upload Files from mega.nz links.
|
13 |
+
"""
|
14 |
+
|
15 |
+
import glob
|
16 |
+
import time
|
17 |
+
from datetime import datetime
|
18 |
+
|
19 |
+
from . import *
|
20 |
+
|
21 |
+
|
22 |
+
@ultroid_cmd(pattern="megadl ?(.*)")
|
23 |
+
async def _(e):
|
24 |
+
link = e.pattern_match.group(1)
|
25 |
+
if not os.path.isdir("mega"):
|
26 |
+
os.mkdir("mega")
|
27 |
+
else:
|
28 |
+
os.system("rm -rf mega")
|
29 |
+
os.mkdir("mega")
|
30 |
+
xx = await eor(e, f"Processing...\nTo Check Progress : `{HNDLR}ls mega`")
|
31 |
+
s = datetime.now()
|
32 |
+
x, y = await bash(f"megadl {link} --path mega")
|
33 |
+
afl = glob.glob("mega/*")
|
34 |
+
ok = [*sorted(afl)]
|
35 |
+
tt = time.time()
|
36 |
+
c = 0
|
37 |
+
k = []
|
38 |
+
for x in ok:
|
39 |
+
if os.path.isdir(x):
|
40 |
+
k.append(x)
|
41 |
+
break
|
42 |
+
if k:
|
43 |
+
await xx.edit(
|
44 |
+
"Your Unzipped File Saved in `mega` folder.\nDo `{i}ls mega` and browse storage\nUse `{i}ul <path>` To upload.".format(
|
45 |
+
i=HNDLR
|
46 |
+
)
|
47 |
+
)
|
48 |
+
else:
|
49 |
+
for kk in ok:
|
50 |
+
try:
|
51 |
+
res = await uploader(kk, kk, tt, xx, "Uploading...")
|
52 |
+
await ultroid_bot.send_file(
|
53 |
+
e.chat_id,
|
54 |
+
res,
|
55 |
+
caption="`" + kk.split("/")[-1] + "`",
|
56 |
+
force_document=True,
|
57 |
+
thumb="resources/extras/ultroid.jpg",
|
58 |
+
)
|
59 |
+
c += 1
|
60 |
+
except Exception as er:
|
61 |
+
LOGS.info(er)
|
62 |
+
ee = datetime.now()
|
63 |
+
t = time_formatter(((ee - s).seconds) * 1000)
|
64 |
+
size = 0
|
65 |
+
for path, dirs, files in os.walk("mega"):
|
66 |
+
for f in files:
|
67 |
+
fp = os.path.join(path, f)
|
68 |
+
size += os.path.getsize(fp)
|
69 |
+
await xx.delete()
|
70 |
+
await ultroid_bot.send_message(
|
71 |
+
e.chat_id,
|
72 |
+
f"Downloaded And Uploaded Total - `{c}` files of `{humanbytes(size)}` in `{t}`",
|
73 |
+
)
|
74 |
+
os.system("rm -rf mega")
|
75 |
+
|
76 |
+
|
77 |
+
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
|
plugins/mute.py
CHANGED
@@ -21,9 +21,10 @@
|
|
21 |
Unmute dmuted user in current chat.
|
22 |
|
23 |
• `{i}tmute <time> <reply to msg/ use id>`
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
27 |
Mute user in current chat with time.
|
28 |
"""
|
29 |
|
|
|
21 |
Unmute dmuted user in current chat.
|
22 |
|
23 |
• `{i}tmute <time> <reply to msg/ use id>`
|
24 |
+
s- seconds
|
25 |
+
m- minutes
|
26 |
+
h- hours
|
27 |
+
d- days
|
28 |
Mute user in current chat with time.
|
29 |
"""
|
30 |
|
plugins/pdftools.py
CHANGED
@@ -24,6 +24,7 @@
|
|
24 |
Merge nd send the Pdf to collected from .pdsave.
|
25 |
"""
|
26 |
|
|
|
27 |
import os
|
28 |
import shutil
|
29 |
import time
|
@@ -38,8 +39,8 @@ from skimage.filters import threshold_local
|
|
38 |
|
39 |
from . import *
|
40 |
|
41 |
-
if not os.path.
|
42 |
-
os.
|
43 |
|
44 |
|
45 |
@ultroid_cmd(
|
@@ -62,7 +63,7 @@ async def pdfseimg(event):
|
|
62 |
k,
|
63 |
"Downloading " + filename + "...",
|
64 |
)
|
65 |
-
await
|
66 |
pdfp = "pdf/hehe.pdf"
|
67 |
pdfp.replace(".pdf", "")
|
68 |
pdf = PdfFileReader(pdfp)
|
@@ -73,12 +74,12 @@ async def pdfseimg(event):
|
|
73 |
with open(os.path.join("pdf/ult{}.png".format(num + 1)), "wb") as f:
|
74 |
pw.write(f)
|
75 |
os.remove(pdfp)
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
await event.client.send_file(event.chat_id,
|
80 |
shutil.rmtree("pdf")
|
81 |
-
os.
|
82 |
await xx.delete()
|
83 |
if msg:
|
84 |
o = int(msg) - 1
|
@@ -115,7 +116,7 @@ async def pdfsetxt(event):
|
|
115 |
k,
|
116 |
"Downloading " + filename + "...",
|
117 |
)
|
118 |
-
await
|
119 |
dl = result.name
|
120 |
if not msg:
|
121 |
pdf = PdfFileReader(dl)
|
@@ -134,7 +135,6 @@ async def pdfsetxt(event):
|
|
134 |
)
|
135 |
os.remove(text)
|
136 |
os.remove(dl)
|
137 |
-
await xx.delete()
|
138 |
return
|
139 |
if "_" in msg:
|
140 |
u, d = msg.split("_")
|
@@ -309,9 +309,11 @@ async def sendpdf(event):
|
|
309 |
else:
|
310 |
ok = "My PDF File.pdf"
|
311 |
merger = PdfFileMerger()
|
312 |
-
|
|
|
|
|
313 |
if item.endswith("pdf"):
|
314 |
-
merger.append(
|
315 |
merger.write(ok)
|
316 |
await event.client.send_file(event.chat_id, ok, reply_to=event.reply_to_msg_id)
|
317 |
os.remove(ok)
|
|
|
24 |
Merge nd send the Pdf to collected from .pdsave.
|
25 |
"""
|
26 |
|
27 |
+
import glob
|
28 |
import os
|
29 |
import shutil
|
30 |
import time
|
|
|
39 |
|
40 |
from . import *
|
41 |
|
42 |
+
if not os.path.isdir("pdf"):
|
43 |
+
os.mkdir("pdf")
|
44 |
|
45 |
|
46 |
@ultroid_cmd(
|
|
|
63 |
k,
|
64 |
"Downloading " + filename + "...",
|
65 |
)
|
66 |
+
await xx.delete()
|
67 |
pdfp = "pdf/hehe.pdf"
|
68 |
pdfp.replace(".pdf", "")
|
69 |
pdf = PdfFileReader(pdfp)
|
|
|
74 |
with open(os.path.join("pdf/ult{}.png".format(num + 1)), "wb") as f:
|
75 |
pw.write(f)
|
76 |
os.remove(pdfp)
|
77 |
+
afl = glob.glob("pdf/*")
|
78 |
+
ok = [*sorted(afl)]
|
79 |
+
for z in ok:
|
80 |
+
await event.client.send_file(event.chat_id, z, album=True)
|
81 |
shutil.rmtree("pdf")
|
82 |
+
os.mkdir("pdf")
|
83 |
await xx.delete()
|
84 |
if msg:
|
85 |
o = int(msg) - 1
|
|
|
116 |
k,
|
117 |
"Downloading " + filename + "...",
|
118 |
)
|
119 |
+
await xx.delete()
|
120 |
dl = result.name
|
121 |
if not msg:
|
122 |
pdf = PdfFileReader(dl)
|
|
|
135 |
)
|
136 |
os.remove(text)
|
137 |
os.remove(dl)
|
|
|
138 |
return
|
139 |
if "_" in msg:
|
140 |
u, d = msg.split("_")
|
|
|
309 |
else:
|
310 |
ok = "My PDF File.pdf"
|
311 |
merger = PdfFileMerger()
|
312 |
+
afl = glob.glob("pdf/*")
|
313 |
+
ok = [*sorted(afl)]
|
314 |
+
for item in ok:
|
315 |
if item.endswith("pdf"):
|
316 |
+
merger.append(item)
|
317 |
merger.write(ok)
|
318 |
await event.client.send_file(event.chat_id, ok, reply_to=event.reply_to_msg_id)
|
319 |
os.remove(ok)
|
plugins/pinterest.py
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2020 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}pntrst <link/id>`
|
12 |
+
Download and send pinterest pins.
|
13 |
+
"""
|
14 |
+
|
15 |
+
|
16 |
+
import os
|
17 |
+
from urllib.request import urlretrieve as donl
|
18 |
+
|
19 |
+
from bs4 import BeautifulSoup as bs
|
20 |
+
from requests import get
|
21 |
+
|
22 |
+
from . import *
|
23 |
+
|
24 |
+
_base = "https://pinterestdownloader.com/download?url="
|
25 |
+
|
26 |
+
|
27 |
+
def gib_link(link):
|
28 |
+
colon = "%3A"
|
29 |
+
slash = "%2F"
|
30 |
+
if link.startswith("https"):
|
31 |
+
return _base + link.replace(":", colon).replace("/", slash)
|
32 |
+
else:
|
33 |
+
return _base + f"https{colon}{slash}{slash}pin.it{slash}{link}"
|
34 |
+
|
35 |
+
|
36 |
+
@ultroid_cmd(
|
37 |
+
pattern="pntrst ?(.*)",
|
38 |
+
)
|
39 |
+
async def pinterest(e):
|
40 |
+
m = e.pattern_match.group(1)
|
41 |
+
get_link = get(gib_link(m)).text
|
42 |
+
hehe = bs(get_link, "html.parser")
|
43 |
+
hulu = hehe.find_all("a", {"class": "download_button"})
|
44 |
+
if len(hulu) < 1:
|
45 |
+
return await eod(e, "`Wrong link or private pin.`")
|
46 |
+
elif len(hulu) > 1:
|
47 |
+
donl(hulu[0]["href"], "pinterest.mp4")
|
48 |
+
donl(hulu[1]["href"], "pinterest.jpg")
|
49 |
+
await e.delete()
|
50 |
+
await e.client.send_file(
|
51 |
+
e.chat_id, "pinterest.mp4", thumb="pinterest.jpg", caption=f"Pin:- {m}"
|
52 |
+
)
|
53 |
+
os.remove("pinterest.mp4")
|
54 |
+
os.remove("pinterest.jpg")
|
55 |
+
else:
|
56 |
+
await e.delete()
|
57 |
+
await e.client.send_file(e.chat_id, hulu[0]["href"], caption=f"Pin:- {m}")
|
58 |
+
|
59 |
+
|
60 |
+
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
|
plugins/pmpermit.py
CHANGED
@@ -25,6 +25,15 @@
|
|
25 |
|
26 |
• `{i}logpm`
|
27 |
Start logging again from that user.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
"""
|
29 |
|
30 |
import re
|
@@ -44,7 +53,7 @@ LASTMSG = {}
|
|
44 |
if Redis("PMPIC"):
|
45 |
PMPIC = Redis("PMPIC")
|
46 |
else:
|
47 |
-
PMPIC = "
|
48 |
|
49 |
UND = get_string("pmperm_1")
|
50 |
|
@@ -133,7 +142,7 @@ async def permitpm(event):
|
|
133 |
pl = udB.get("PMLOGGROUP")
|
134 |
if pl is not None:
|
135 |
return await event.forward_to(int(pl))
|
136 |
-
await event.forward_to(
|
137 |
|
138 |
|
139 |
sett = Redis("PMSETTING")
|
@@ -162,13 +171,16 @@ if sett == "True" and sett != "False":
|
|
162 |
await message.delete()
|
163 |
async for message in e.client.iter_messages(e.chat_id, search=UNS):
|
164 |
await message.delete()
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
|
|
|
|
|
|
172 |
|
173 |
@ultroid_bot.on(
|
174 |
events.NewMessage(
|
@@ -184,6 +196,13 @@ if sett == "True" and sett != "False":
|
|
184 |
return
|
185 |
apprv = is_approved(user.id)
|
186 |
if not apprv and event.text != UND:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
name = user.first_name
|
188 |
if user.last_name:
|
189 |
fullname = f"{name} {user.last_name}"
|
@@ -197,7 +216,7 @@ if sett == "True" and sett != "False":
|
|
197 |
except KeyError:
|
198 |
try:
|
199 |
await asst.send_message(
|
200 |
-
|
201 |
f"Incoming PM from {mention}!",
|
202 |
buttons=[
|
203 |
Button.inline("Approve PM", data=f"approve_{user.id}"),
|
@@ -206,7 +225,7 @@ if sett == "True" and sett != "False":
|
|
206 |
)
|
207 |
except BaseException:
|
208 |
await ultroid.send_message(
|
209 |
-
|
210 |
)
|
211 |
wrn = 1
|
212 |
if user.id in LASTMSG:
|
@@ -293,21 +312,37 @@ if sett == "True" and sett != "False":
|
|
293 |
del COUNT_PM[user.id]
|
294 |
del LASTMSG[user.id]
|
295 |
except KeyError:
|
296 |
-
if Var.LOG_CHANNEL:
|
297 |
-
await event.client.send_message(
|
298 |
-
Var.LOG_CHANNEL,
|
299 |
-
"PMPermit is messed! Pls restart the bot!!",
|
300 |
-
)
|
301 |
-
return LOGS.info("COUNT_PM is messed.")
|
302 |
-
await event.client(BlockRequest(user.id))
|
303 |
-
await event.client(ReportSpamRequest(peer=user.id))
|
304 |
-
if Var.LOG_CHANNEL:
|
305 |
-
name = await event.client.get_entity(user.id)
|
306 |
-
name0 = str(name.first_name)
|
307 |
await event.client.send_message(
|
308 |
-
|
309 |
-
|
310 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
311 |
|
312 |
@ultroid_cmd(
|
313 |
pattern="(a|approve)(?: |$)",
|
@@ -326,6 +361,10 @@ if sett == "True" and sett != "False":
|
|
326 |
uid = replied_user.id
|
327 |
if not is_approved(uid):
|
328 |
approve_user(uid)
|
|
|
|
|
|
|
|
|
329 |
await apprvpm.edit(f"[{name0}](tg://user?id={uid}) `approved to PM!`")
|
330 |
await asyncio.sleep(3)
|
331 |
await apprvpm.delete()
|
@@ -345,6 +384,10 @@ if sett == "True" and sett != "False":
|
|
345 |
uid = user.id
|
346 |
if not is_approved(uid):
|
347 |
approve_user(uid)
|
|
|
|
|
|
|
|
|
348 |
await apprvpm.edit(f"[{name0}](tg://user?id={uid}) `approved to PM!`")
|
349 |
async for message in apprvpm.client.iter_messages(user.id, search=UND):
|
350 |
await message.delete()
|
@@ -352,20 +395,18 @@ if sett == "True" and sett != "False":
|
|
352 |
await message.delete()
|
353 |
await asyncio.sleep(3)
|
354 |
await apprvpm.delete()
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
)
|
360 |
else:
|
361 |
await apprvpm.edit("`User may already be approved.`")
|
362 |
await asyncio.sleep(5)
|
363 |
await apprvpm.delete()
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
)
|
369 |
else:
|
370 |
await apprvpm.edit(NO_REPLY)
|
371 |
|
@@ -410,11 +451,10 @@ if sett == "True" and sett != "False":
|
|
410 |
await e.edit(f"[{name0}](tg://user?id={bbb.id}) `Disaproved to PM!`")
|
411 |
await asyncio.sleep(5)
|
412 |
await e.delete()
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
)
|
418 |
else:
|
419 |
await e.edit(f"[{name0}](tg://user?id={bbb.id}) was never approved!")
|
420 |
await asyncio.sleep(5)
|
@@ -422,64 +462,57 @@ if sett == "True" and sett != "False":
|
|
422 |
else:
|
423 |
await e.edit(NO_REPLY)
|
424 |
|
425 |
-
@ultroid_cmd(
|
426 |
-
pattern="block$",
|
427 |
-
)
|
428 |
-
async def blockpm(block):
|
429 |
-
if block.reply_to_msg_id:
|
430 |
-
reply = await block.get_reply_message()
|
431 |
-
replied_user = await block.client.get_entity(reply.sender_id)
|
432 |
-
aname = replied_user.id
|
433 |
-
if str(aname) in DEVLIST:
|
434 |
-
return await eor(
|
435 |
-
block,
|
436 |
-
"`Lol, He is my Developer\nHe Can't Be Blocked`",
|
437 |
-
)
|
438 |
-
name0 = str(replied_user.first_name)
|
439 |
-
await block.client(BlockRequest(replied_user.id))
|
440 |
-
await block.edit("`You've been blocked!`")
|
441 |
-
uid = replied_user.id
|
442 |
-
elif block.is_private:
|
443 |
-
bbb = await block.get_chat()
|
444 |
-
if str(bbb.id) in DEVLIST:
|
445 |
-
return await eor(
|
446 |
-
block,
|
447 |
-
"`Lol, He is my Developer\nHe Can't Be Blocked`",
|
448 |
-
)
|
449 |
-
await block.client(BlockRequest(bbb.id))
|
450 |
-
aname = await block.client.get_entity(bbb.id)
|
451 |
-
await block.edit("`You've been blocked!`")
|
452 |
-
name0 = str(aname.first_name)
|
453 |
-
uid = bbb.id
|
454 |
-
else:
|
455 |
-
await block.edit(NO_REPLY)
|
456 |
-
try:
|
457 |
-
disapprove_user(uid)
|
458 |
-
except AttributeError:
|
459 |
-
pass
|
460 |
-
if Var.LOG_CHANNEL:
|
461 |
-
await block.client.send_message(
|
462 |
-
Var.LOG_CHANNEL,
|
463 |
-
f"#BLOCKED\nUser: [{name0}](tg://user?id={uid})",
|
464 |
-
)
|
465 |
|
466 |
-
|
467 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
468 |
)
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
483 |
|
484 |
|
485 |
@callback(
|
@@ -494,6 +527,10 @@ async def apr_in(event):
|
|
494 |
await event.edit("It's a dev! Approved!")
|
495 |
if not is_approved(uid):
|
496 |
approve_user(uid)
|
|
|
|
|
|
|
|
|
497 |
try:
|
498 |
user_name = (await ultroid.get_entity(uid)).first_name
|
499 |
except BaseException:
|
|
|
25 |
|
26 |
• `{i}logpm`
|
27 |
Start logging again from that user.
|
28 |
+
|
29 |
+
• `{i}startarchive`
|
30 |
+
Will start adding new PMs to archive.
|
31 |
+
|
32 |
+
• `{i}stoparchive`
|
33 |
+
Will stop adding new PMs to archive.
|
34 |
+
|
35 |
+
• `{i}cleararchive`
|
36 |
+
Unarchive all chats.
|
37 |
"""
|
38 |
|
39 |
import re
|
|
|
53 |
if Redis("PMPIC"):
|
54 |
PMPIC = Redis("PMPIC")
|
55 |
else:
|
56 |
+
PMPIC = "resources/extras/teamultroid.jpg"
|
57 |
|
58 |
UND = get_string("pmperm_1")
|
59 |
|
|
|
142 |
pl = udB.get("PMLOGGROUP")
|
143 |
if pl is not None:
|
144 |
return await event.forward_to(int(pl))
|
145 |
+
await event.forward_to(int(udB.get("LOG_CHANNEL")))
|
146 |
|
147 |
|
148 |
sett = Redis("PMSETTING")
|
|
|
171 |
await message.delete()
|
172 |
async for message in e.client.iter_messages(e.chat_id, search=UNS):
|
173 |
await message.delete()
|
174 |
+
try:
|
175 |
+
await ultroid_bot.edit_folder(e.chat_id, folder=0)
|
176 |
+
except BaseException:
|
177 |
+
pass
|
178 |
+
name = await e.client.get_entity(e.chat_id)
|
179 |
+
name0 = str(name.first_name)
|
180 |
+
await asst.send_message(
|
181 |
+
int(udB.get("LOG_CHANNEL")),
|
182 |
+
f"#AutoApproved\nßecoz of outgoing msg\nUser - [{name0}](tg://user?id={e.chat_id})",
|
183 |
+
)
|
184 |
|
185 |
@ultroid_bot.on(
|
186 |
events.NewMessage(
|
|
|
196 |
return
|
197 |
apprv = is_approved(user.id)
|
198 |
if not apprv and event.text != UND:
|
199 |
+
if Redis("MOVE_ARCHIVE") == "True":
|
200 |
+
try:
|
201 |
+
await event.client.edit_folder(user.id, folder=1)
|
202 |
+
except BaseException:
|
203 |
+
pass
|
204 |
+
if event.media:
|
205 |
+
await event.delete()
|
206 |
name = user.first_name
|
207 |
if user.last_name:
|
208 |
fullname = f"{name} {user.last_name}"
|
|
|
216 |
except KeyError:
|
217 |
try:
|
218 |
await asst.send_message(
|
219 |
+
int(udB.get("LOG_CHANNEL")),
|
220 |
f"Incoming PM from {mention}!",
|
221 |
buttons=[
|
222 |
Button.inline("Approve PM", data=f"approve_{user.id}"),
|
|
|
225 |
)
|
226 |
except BaseException:
|
227 |
await ultroid.send_message(
|
228 |
+
int(udB.get("LOG_CHANNEL")), f"Incoming PM from {mention}!"
|
229 |
)
|
230 |
wrn = 1
|
231 |
if user.id in LASTMSG:
|
|
|
312 |
del COUNT_PM[user.id]
|
313 |
del LASTMSG[user.id]
|
314 |
except KeyError:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
await event.client.send_message(
|
316 |
+
int(udB.get("LOG_CHANNEL")),
|
317 |
+
"PMPermit is messed! Pls restart the bot!!",
|
318 |
)
|
319 |
+
return LOGS.info("COUNT_PM is messed.")
|
320 |
+
await event.client(BlockRequest(user.id))
|
321 |
+
await event.client(ReportSpamRequest(peer=user.id))
|
322 |
+
name = await event.client.get_entity(user.id)
|
323 |
+
name0 = str(name.first_name)
|
324 |
+
await event.client.send_message(
|
325 |
+
int(udB.get("LOG_CHANNEL")),
|
326 |
+
f"[{name0}](tg://user?id={user.id}) was Blocked for spamming.",
|
327 |
+
)
|
328 |
+
|
329 |
+
@ultroid_cmd(
|
330 |
+
pattern="(start|stop|clear)archive$",
|
331 |
+
)
|
332 |
+
async def _(e):
|
333 |
+
x = e.pattern_match.group(1)
|
334 |
+
if x == "start":
|
335 |
+
udB.set("MOVE_ARCHIVE", "True")
|
336 |
+
await eod(e, "Now I will move new Unapproved DM's to archive")
|
337 |
+
elif x == "stop":
|
338 |
+
udB.set("MOVE_ARCHIVE", "False")
|
339 |
+
await eod(e, "Now I won't move new Unapproved DM's to archive")
|
340 |
+
elif x == "clear":
|
341 |
+
try:
|
342 |
+
await e.client.edit_folder(unpack=1)
|
343 |
+
await eod(e, "Unarchived all chats")
|
344 |
+
except Exception as mm:
|
345 |
+
await eod(e, str(mm))
|
346 |
|
347 |
@ultroid_cmd(
|
348 |
pattern="(a|approve)(?: |$)",
|
|
|
361 |
uid = replied_user.id
|
362 |
if not is_approved(uid):
|
363 |
approve_user(uid)
|
364 |
+
try:
|
365 |
+
await apprvpm.client.edit_folder(uid, folder=0)
|
366 |
+
except BaseException:
|
367 |
+
pass
|
368 |
await apprvpm.edit(f"[{name0}](tg://user?id={uid}) `approved to PM!`")
|
369 |
await asyncio.sleep(3)
|
370 |
await apprvpm.delete()
|
|
|
384 |
uid = user.id
|
385 |
if not is_approved(uid):
|
386 |
approve_user(uid)
|
387 |
+
try:
|
388 |
+
await apprvpm.client.edit_folder(uid, folder=0)
|
389 |
+
except BaseException:
|
390 |
+
pass
|
391 |
await apprvpm.edit(f"[{name0}](tg://user?id={uid}) `approved to PM!`")
|
392 |
async for message in apprvpm.client.iter_messages(user.id, search=UND):
|
393 |
await message.delete()
|
|
|
395 |
await message.delete()
|
396 |
await asyncio.sleep(3)
|
397 |
await apprvpm.delete()
|
398 |
+
await apprvpm.client.send_message(
|
399 |
+
int(udB.get("LOG_CHANNEL")),
|
400 |
+
f"#APPROVED\nUser: [{name0}](tg://user?id={uid})",
|
401 |
+
)
|
|
|
402 |
else:
|
403 |
await apprvpm.edit("`User may already be approved.`")
|
404 |
await asyncio.sleep(5)
|
405 |
await apprvpm.delete()
|
406 |
+
await apprvpm.client.send_message(
|
407 |
+
int(udB.get("LOG_CHANNEL")),
|
408 |
+
f"#APPROVED\nUser: [{name0}](tg://user?id={uid})",
|
409 |
+
)
|
|
|
410 |
else:
|
411 |
await apprvpm.edit(NO_REPLY)
|
412 |
|
|
|
451 |
await e.edit(f"[{name0}](tg://user?id={bbb.id}) `Disaproved to PM!`")
|
452 |
await asyncio.sleep(5)
|
453 |
await e.delete()
|
454 |
+
await e.client.send_message(
|
455 |
+
int(udB.get("LOG_CHANNEL")),
|
456 |
+
f"[{name0}](tg://user?id={bbb.id}) was disapproved to PM you.",
|
457 |
+
)
|
|
|
458 |
else:
|
459 |
await e.edit(f"[{name0}](tg://user?id={bbb.id}) was never approved!")
|
460 |
await asyncio.sleep(5)
|
|
|
462 |
else:
|
463 |
await e.edit(NO_REPLY)
|
464 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
465 |
|
466 |
+
@ultroid_cmd(
|
467 |
+
pattern="block ?(.*)",
|
468 |
+
)
|
469 |
+
async def blockpm(block):
|
470 |
+
match = block.pattern_match.group(1)
|
471 |
+
if block.is_reply:
|
472 |
+
reply = await block.get_reply_message()
|
473 |
+
user = reply.sender_id
|
474 |
+
elif match:
|
475 |
+
user = await get_user_id(match)
|
476 |
+
elif block.is_private:
|
477 |
+
user = block.chat_id
|
478 |
+
else:
|
479 |
+
return await eod(block, NO_REPLY)
|
480 |
+
if str(user) in DEVLIST:
|
481 |
+
return await eor(
|
482 |
+
block,
|
483 |
+
"`Lol, He is my Developer\nHe Can't Be Blocked`",
|
484 |
+
)
|
485 |
+
await block.client(BlockRequest(user))
|
486 |
+
aname = await block.client.get_entity(user)
|
487 |
+
await eor(block, f"`{aname.first_name} has been blocked!`")
|
488 |
+
try:
|
489 |
+
disapprove_user(user)
|
490 |
+
except AttributeError:
|
491 |
+
pass
|
492 |
+
await ultroid_bot.send_message(
|
493 |
+
int(udB.get("LOG_CHANNEL")),
|
494 |
+
f"#BLOCKED\nUser: [{aname.first_name}](tg://user?id={user})",
|
495 |
)
|
496 |
+
|
497 |
+
|
498 |
+
@ultroid_cmd(
|
499 |
+
pattern="unblock ?(.*)",
|
500 |
+
)
|
501 |
+
async def unblockpm(unblock):
|
502 |
+
match = unblock.pattern_match.group(1)
|
503 |
+
if unblock.is_reply:
|
504 |
+
reply = await unblock.get_reply_message()
|
505 |
+
user = reply.sender_id
|
506 |
+
elif match:
|
507 |
+
user = await get_user_id(match)
|
508 |
+
else:
|
509 |
+
return await eod(unblock, NO_REPLY)
|
510 |
+
try:
|
511 |
+
await unblock.client(UnblockRequest(user))
|
512 |
+
aname = await unblock.client.get_entity(user)
|
513 |
+
await eor(unblock, f"`{aname.first_name} has been UnBlocked!`")
|
514 |
+
except Exception as et:
|
515 |
+
await eod(unblock, f"ERROR - {str(et)}")
|
516 |
|
517 |
|
518 |
@callback(
|
|
|
527 |
await event.edit("It's a dev! Approved!")
|
528 |
if not is_approved(uid):
|
529 |
approve_user(uid)
|
530 |
+
try:
|
531 |
+
await ultroid_bot.edit_folder(uid, folder=0)
|
532 |
+
except BaseException:
|
533 |
+
pass
|
534 |
try:
|
535 |
user_name = (await ultroid.get_entity(uid)).first_name
|
536 |
except BaseException:
|
plugins/polls.py
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2020 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}poll <question> ; <option> ; <option>`
|
12 |
+
Get the Anonymous Poll with Given Options
|
13 |
+
|
14 |
+
• `{i}poll <question> ; <option> ; <option> | <type>`
|
15 |
+
Get the poll specified with desired type!
|
16 |
+
type should be any of `public`, `multiple` or `quiz`
|
17 |
+
|
18 |
+
• `{i}poll <question> ; <option> ; <option> | quiz_<answerno>`
|
19 |
+
Get the quiz poll where answerno is the number of option which is correct
|
20 |
+
|
21 |
+
"""
|
22 |
+
|
23 |
+
from telethon.tl.types import InputMediaPoll, Poll, PollAnswer
|
24 |
+
|
25 |
+
from . import *
|
26 |
+
|
27 |
+
|
28 |
+
@ultroid_cmd(
|
29 |
+
pattern="poll ?(.*)",
|
30 |
+
groups_only=True,
|
31 |
+
)
|
32 |
+
async def uri_poll(e):
|
33 |
+
match = e.pattern_match.group(1)
|
34 |
+
if not match:
|
35 |
+
return await eod(e, "`Give Proper Input...`")
|
36 |
+
if ";" not in match:
|
37 |
+
return await eod(e, "`Unable to Determine Options.`.")
|
38 |
+
ques = match.split(";")[0]
|
39 |
+
option = match.split(";")[1::]
|
40 |
+
publ = None
|
41 |
+
quizo = None
|
42 |
+
karzo = None
|
43 |
+
mpp = None
|
44 |
+
if "|" in match:
|
45 |
+
ptype = match.split(" | ")[1]
|
46 |
+
option = match.split("|")[0].split(";")[1::]
|
47 |
+
if "_" in ptype:
|
48 |
+
karzo = [str(int(ptype.split("_")[1]) - 1).encode()]
|
49 |
+
ptype = ptype.split("_")[0]
|
50 |
+
if ptype not in ["public", "quiz", "multiple"]:
|
51 |
+
return await eod(e, "`Invalid Poll Type...`")
|
52 |
+
if ptype == "public":
|
53 |
+
publ = True
|
54 |
+
if ptype == "quiz":
|
55 |
+
quizo = True
|
56 |
+
if ptype == "multiple":
|
57 |
+
mpp = True
|
58 |
+
if len(option) <= 1:
|
59 |
+
return await eod(e, "`Options Should be More than 1..`")
|
60 |
+
m = await eor(e, "`Processing... `")
|
61 |
+
OUT = []
|
62 |
+
for on in range(len(option)):
|
63 |
+
OUT.append(PollAnswer(option[on], str(on).encode()))
|
64 |
+
await ultroid_bot.send_file(
|
65 |
+
e.chat_id,
|
66 |
+
InputMediaPoll(
|
67 |
+
Poll(20, ques, OUT, multiple_choice=mpp, public_voters=publ, quiz=quizo),
|
68 |
+
correct_answers=karzo,
|
69 |
+
),
|
70 |
+
)
|
71 |
+
await m.delete()
|
72 |
+
|
73 |
+
|
74 |
+
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
|
plugins/profile.py
CHANGED
@@ -159,6 +159,8 @@ async def gpoto(e):
|
|
159 |
if not ult and e.is_reply:
|
160 |
gs = await e.get_reply_message()
|
161 |
ult = gs.sender_id
|
|
|
|
|
162 |
try:
|
163 |
okla = await ultroid_bot.download_profile_photo(
|
164 |
ult,
|
|
|
159 |
if not ult and e.is_reply:
|
160 |
gs = await e.get_reply_message()
|
161 |
ult = gs.sender_id
|
162 |
+
if not (ult or e.is_reply):
|
163 |
+
ult = e.chat_id
|
164 |
try:
|
165 |
okla = await ultroid_bot.download_profile_photo(
|
166 |
ult,
|
plugins/qrcode.py
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2020 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 |
+
•`qrcode <text/reply to text>`
|
12 |
+
Makes qrcode of text
|
13 |
+
|
14 |
+
•`addqr <reply image> <text>`
|
15 |
+
Makes qr of text and add it to image.
|
16 |
+
|
17 |
+
•`qrdecode <reply to qrcode>`
|
18 |
+
It decodes the qrcode.
|
19 |
+
"""
|
20 |
+
|
21 |
+
|
22 |
+
import os
|
23 |
+
|
24 |
+
import cv2
|
25 |
+
import qrcode
|
26 |
+
from PIL import Image
|
27 |
+
from telethon.tl.types import MessageMediaDocument as doc
|
28 |
+
from telethon.tl.types import MessageMediaPhoto as photu
|
29 |
+
|
30 |
+
from . import *
|
31 |
+
|
32 |
+
|
33 |
+
@ultroid_cmd(pattern="qrcode ?(.*)")
|
34 |
+
async def cd(e):
|
35 |
+
reply = await e.get_reply_message()
|
36 |
+
msg = e.pattern_match.group(1)
|
37 |
+
if reply and reply.text:
|
38 |
+
msg = reply.text
|
39 |
+
elif msg:
|
40 |
+
msg = msg
|
41 |
+
else:
|
42 |
+
return await eod(e, "`Give Some Text or Reply")
|
43 |
+
kk = await eor(e, "`processing`")
|
44 |
+
pfp = await ultroid_bot.get_profile_photos(ultroid_bot.uid)
|
45 |
+
img = "resources/extras/teamultroid.jpg"
|
46 |
+
if len(pfp) >= 1:
|
47 |
+
img = await ultroid_bot.download_media(pfp[0])
|
48 |
+
ok = Image.open(img)
|
49 |
+
logo = ok.resize((60, 60))
|
50 |
+
cod = qrcode.QRCode(error_correction=qrcode.constants.ERROR_CORRECT_H)
|
51 |
+
cod.add_data(msg)
|
52 |
+
cod.make()
|
53 |
+
imgg = cod.make_image().convert("RGB")
|
54 |
+
pstn = ((imgg.size[0] - logo.size[0]) // 2, (imgg.size[1] - logo.size[1]) // 2)
|
55 |
+
imgg.paste(logo, pstn)
|
56 |
+
imgg.save(img)
|
57 |
+
await ultroid_bot.send_file(e.chat_id, img, support_stream=True)
|
58 |
+
await kk.delete()
|
59 |
+
os.remove(img)
|
60 |
+
|
61 |
+
|
62 |
+
@ultroid_cmd(pattern="addqr ?(.*)")
|
63 |
+
async def qrwater(e):
|
64 |
+
msg = e.pattern_match.group(1)
|
65 |
+
r = await e.get_reply_message()
|
66 |
+
if not (msg and r and r.media):
|
67 |
+
return await eod(e, "`Reply Any Media and Give Text`")
|
68 |
+
kk = await eor(e, "`processing`")
|
69 |
+
if isinstance(r.media, photu):
|
70 |
+
dl = await ultroid_bot.download_media(r.media)
|
71 |
+
elif isinstance(r.media, doc):
|
72 |
+
dl = await ultroid_bot.download_media(r, thumb=-1)
|
73 |
+
else:
|
74 |
+
return
|
75 |
+
img_bg = Image.open(dl)
|
76 |
+
qr = qrcode.QRCode(box_size=5)
|
77 |
+
qr.add_data(msg)
|
78 |
+
qr.make()
|
79 |
+
img_qr = qr.make_image()
|
80 |
+
pos = (img_bg.size[0] - img_qr.size[0], img_bg.size[1] - img_qr.size[1])
|
81 |
+
img_bg.paste(img_qr, pos)
|
82 |
+
img_bg.save(dl)
|
83 |
+
await ultroid_bot.send_file(e.chat_id, dl, support_stream=True)
|
84 |
+
await kk.delete()
|
85 |
+
os.remove(dl)
|
86 |
+
|
87 |
+
|
88 |
+
@ultroid_cmd(pattern="qrdecode$")
|
89 |
+
async def decod(e):
|
90 |
+
r = await e.get_reply_message()
|
91 |
+
if not (r and r.media):
|
92 |
+
return await eod(e, "`Reply to Qrcode Media`")
|
93 |
+
kk = await eor(e, "`processing`")
|
94 |
+
if isinstance(r.media, photu):
|
95 |
+
dl = await ultroid_bot.download_media(r.media)
|
96 |
+
elif isinstance(r.media, doc):
|
97 |
+
dl = await ultroid_bot.download_media(r, thumb=-1)
|
98 |
+
else:
|
99 |
+
return
|
100 |
+
im = cv2.imread(dl)
|
101 |
+
try:
|
102 |
+
det = cv2.QRCodeDetector()
|
103 |
+
tx, y, z = det.detectAndDecode(im)
|
104 |
+
await kk.edit("**Decoded Text:\n\n**" + tx)
|
105 |
+
except BaseException:
|
106 |
+
await kk.edit("`Reply To Media in Which Qr image present.`")
|
107 |
+
os.remove(dl)
|
108 |
+
|
109 |
+
|
110 |
+
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
|
plugins/resize.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2020 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}size <reply to media>`
|
12 |
+
To get size of it.
|
13 |
+
|
14 |
+
•`{i}resize <number> <number>`
|
15 |
+
To resize image on x, y axis.
|
16 |
+
eg. `{i}resize 690 960`
|
17 |
+
"""
|
18 |
+
|
19 |
+
from PIL import Image
|
20 |
+
|
21 |
+
from . import *
|
22 |
+
|
23 |
+
|
24 |
+
@ultroid_cmd(pattern="size$")
|
25 |
+
async def size(e):
|
26 |
+
r = await e.get_reply_message()
|
27 |
+
if not (r and r.media):
|
28 |
+
return await eor(e, "`Reply To image`")
|
29 |
+
k = await eor(e, "`Processing...`")
|
30 |
+
if hasattr(r.media, "document"):
|
31 |
+
img = await ultroid_bot.download_media(r, thumb=-1)
|
32 |
+
else:
|
33 |
+
img = await ultroid_bot.download_media(r.media)
|
34 |
+
im = Image.open(img)
|
35 |
+
x, y = im.size
|
36 |
+
await k.edit(f"Dimension Of This Image Is\n`{x} : {y}`")
|
37 |
+
os.remove(img)
|
38 |
+
|
39 |
+
|
40 |
+
@ultroid_cmd(pattern="resize ?(.*)")
|
41 |
+
async def size(e):
|
42 |
+
r = await e.get_reply_message()
|
43 |
+
if not (r and r.media):
|
44 |
+
return await eor(e, "`Reply To image`")
|
45 |
+
sz = e.pattern_match.group(1)
|
46 |
+
if not sz:
|
47 |
+
return await eod(f"Give Some Size To Resize, Like `{HNDLR}resize 720 1080` ")
|
48 |
+
k = await eor(e, "`Processing...`")
|
49 |
+
if hasattr(r.media, "document"):
|
50 |
+
img = await ultroid_bot.download_media(r, thumb=-1)
|
51 |
+
else:
|
52 |
+
img = await ultroid_bot.download_media(r.media)
|
53 |
+
sz = sz.split()
|
54 |
+
if not len(sz) == 2:
|
55 |
+
return await eod(f"Give Some Size To Resize, Like `{HNDLR}resize 720 1080` ")
|
56 |
+
x, y = int(sz[0]), int(sz[1])
|
57 |
+
im = Image.open(img)
|
58 |
+
ok = im.resize((x, y))
|
59 |
+
ok.save(img, format="PNG", optimize=True)
|
60 |
+
await ultroid_bot.send_file(e.chat_id, img)
|
61 |
+
os.remove(img)
|
62 |
+
await k.delete()
|
63 |
+
|
64 |
+
|
65 |
+
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
|
plugins/saavn.py
CHANGED
@@ -9,7 +9,8 @@
|
|
9 |
✘ Commands Available -
|
10 |
|
11 |
• `{i}saavn <search query>`
|
12 |
-
|
|
|
13 |
"""
|
14 |
|
15 |
import os
|
@@ -28,7 +29,7 @@ async def siesace(e):
|
|
28 |
if not song:
|
29 |
return await eod(e, "`Give me Something to Search")
|
30 |
hmm = time.time()
|
31 |
-
lol = await eor(e, "
|
32 |
sung = song.replace(" ", "%20")
|
33 |
url = f"https://jostapi.herokuapp.com/saavn?query={sung}"
|
34 |
try:
|
@@ -48,6 +49,7 @@ async def siesace(e):
|
|
48 |
await ultroid_bot.send_file(
|
49 |
e.chat_id,
|
50 |
okk,
|
|
|
51 |
attributes=[
|
52 |
DocumentAttributeAudio(
|
53 |
duration=int(duration),
|
|
|
9 |
✘ Commands Available -
|
10 |
|
11 |
• `{i}saavn <search query>`
|
12 |
+
Download songs from Saavn
|
13 |
+
|
14 |
"""
|
15 |
|
16 |
import os
|
|
|
29 |
if not song:
|
30 |
return await eod(e, "`Give me Something to Search")
|
31 |
hmm = time.time()
|
32 |
+
lol = await eor(e, "`Searching on Saavn...`")
|
33 |
sung = song.replace(" ", "%20")
|
34 |
url = f"https://jostapi.herokuapp.com/saavn?query={sung}"
|
35 |
try:
|
|
|
49 |
await ultroid_bot.send_file(
|
50 |
e.chat_id,
|
51 |
okk,
|
52 |
+
caption="`" + title + "`" + "\n`From Saavn`",
|
53 |
attributes=[
|
54 |
DocumentAttributeAudio(
|
55 |
duration=int(duration),
|