Spaces:
Paused
Paused
Devesh Pal
Danish
xditya
Amit Sharma
sppidy
Arnab Paryali
divkix
hellboi_atul
Programming Error
commited on

Commit
·
dc64e31
1
Parent(s):
ee4a7d4
Ultroid v0.1 Updates 13.09.2021
Browse filesCo-authored-by: Danish <[email protected]>
Co-authored-by: Aditya <[email protected]>
Co-authored-by: Amit Sharma <[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]>
Co-authored-by: Programming Error <[email protected]>
This view is limited to 50 files because it contains too many changes.
See raw diff
- .env.sample +6 -1
- .github/ISSUE_TEMPLATE/bug-reports.yml +1 -1
- .github/workflows/greetings.yml +16 -0
- .gitignore +18 -1
- Dockerfile +3 -7
- README.md +8 -11
- app.json +2 -2
- assistant/__init__.py +1 -2
- assistant/api_setter.py +15 -18
- assistant/callbackstuffs.py +291 -189
- assistant/initial.py +79 -0
- assistant/inlinestuff.py +70 -90
- assistant/manager/__init__.py +0 -2
- assistant/manager/_help.py +130 -0
- vcbot/vchelp.py → assistant/manager/_on_adds.py +13 -19
- assistant/manager/admins.py +38 -0
- assistant/manager/misc.py +46 -0
- assistant/ping.py +2 -4
- assistant/piston.py +45 -0
- assistant/pmbot/banuser.py +15 -15
- assistant/pmbot/incoming.py +3 -7
- assistant/pmbot/outgoing.py +4 -9
- assistant/start.py +63 -67
- assistant/ytdl.py +26 -17
- plugins/_ChatActions.py +60 -11
- plugins/__init__.py +12 -4
- plugins/_help.py +25 -19
- plugins/_inline.py +122 -48
- plugins/_ultroid.py +45 -8
- plugins/_userlogs.py +78 -74
- plugins/_wspr.py +1 -2
- plugins/admintools.py +162 -153
- plugins/afk.py +113 -212
- plugins/akinator.py +106 -0
- plugins/anime.py +11 -5
- plugins/antiflood.py +7 -10
- plugins/ascii.py +5 -4
- plugins/asst_cmd.py +9 -8
- plugins/audiotools.py +190 -0
- plugins/autocorrect.py +6 -10
- plugins/autopic.py +13 -22
- plugins/blacklist.py +12 -11
- plugins/bot.py +138 -30
- plugins/botecho.py +1 -1
- plugins/broadcast.py +11 -10
- plugins/calculator.py +39 -36
- plugins/carbon.py +39 -28
- plugins/channelhacks.py +11 -16
- plugins/chat_bot.py +15 -13
- plugins/chats.py +58 -25
.env.sample
CHANGED
@@ -4,4 +4,9 @@ API_ID=
|
|
4 |
API_HASH=
|
5 |
SESSION=
|
6 |
REDIS_URI=
|
7 |
-
REDIS_PASSWORD=
|
|
|
|
|
|
|
|
|
|
|
|
4 |
API_HASH=
|
5 |
SESSION=
|
6 |
REDIS_URI=
|
7 |
+
REDIS_PASSWORD=
|
8 |
+
|
9 |
+
# [OPTIONAL]
|
10 |
+
|
11 |
+
LOG_CHANNEL=
|
12 |
+
BOT_TOKEN=
|
.github/ISSUE_TEMPLATE/bug-reports.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
name: Bug Report
|
2 |
description: File a bug report
|
3 |
-
title: "[BUG REPORT]
|
4 |
labels: [bug]
|
5 |
assignees:
|
6 |
- xditya
|
|
|
1 |
name: Bug Report
|
2 |
description: File a bug report
|
3 |
+
title: "[BUG REPORT]"
|
4 |
labels: [bug]
|
5 |
assignees:
|
6 |
- xditya
|
.github/workflows/greetings.yml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Greetings
|
2 |
+
|
3 |
+
on: [pull_request, issues]
|
4 |
+
|
5 |
+
jobs:
|
6 |
+
greeting:
|
7 |
+
runs-on: ubuntu-latest
|
8 |
+
permissions:
|
9 |
+
issues: write
|
10 |
+
pull-requests: write
|
11 |
+
steps:
|
12 |
+
- uses: actions/first-interaction@v1
|
13 |
+
with:
|
14 |
+
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
15 |
+
issue-message: 'Thanks for Opening This Issue, we will look into it soon!'
|
16 |
+
pr-message: 'Thanks for Your Contribution. It will be reviewed soon, Useless Prs are Closed Immediately'
|
.gitignore
CHANGED
@@ -13,12 +13,29 @@ build
|
|
13 |
*.log
|
14 |
target/npmlist.json
|
15 |
package-lock.json
|
|
|
16 |
# Directories
|
17 |
addons/
|
|
|
18 |
__pycache__/
|
19 |
venv/
|
20 |
node_modules/
|
21 |
glitch_me/
|
|
|
22 |
.idea/
|
23 |
.vscode/
|
24 |
-
temp/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
*.log
|
14 |
target/npmlist.json
|
15 |
package-lock.json
|
16 |
+
|
17 |
# Directories
|
18 |
addons/
|
19 |
+
pyUltroid/
|
20 |
__pycache__/
|
21 |
venv/
|
22 |
node_modules/
|
23 |
glitch_me/
|
24 |
+
src/glitch-me
|
25 |
.idea/
|
26 |
.vscode/
|
27 |
+
temp/
|
28 |
+
bin-debug/
|
29 |
+
bin-release/
|
30 |
+
[Oo]bj/
|
31 |
+
[Bb]in/
|
32 |
+
.settings/
|
33 |
+
*.swf
|
34 |
+
*.air
|
35 |
+
*.ipa
|
36 |
+
*.apk
|
37 |
+
|
38 |
+
# temporary files
|
39 |
+
*.raw
|
40 |
+
tplugins
|
41 |
+
tassistant
|
Dockerfile
CHANGED
@@ -3,7 +3,7 @@
|
|
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
|
7 |
|
8 |
# set timezone
|
9 |
ENV TZ=Asia/Kolkata
|
@@ -14,12 +14,8 @@ RUN git clone https://github.com/TeamUltroid/Ultroid.git /root/TeamUltroid/
|
|
14 |
WORKDIR /root/TeamUltroid/
|
15 |
|
16 |
# install main requirements.
|
17 |
-
|
18 |
-
RUN pip3 install --no-
|
19 |
-
|
20 |
-
# install addons requirements
|
21 |
-
RUN wget -O /deploy/addons.txt https://git.io/JWdOk
|
22 |
-
RUN pip3 install --no-cache-dir -r /deploy/addons.txt
|
23 |
|
24 |
# start the bot
|
25 |
CMD ["bash", "resources/startup/startup.sh"]
|
|
|
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 theteamultroid/ultroid:main
|
7 |
|
8 |
# set timezone
|
9 |
ENV TZ=Asia/Kolkata
|
|
|
14 |
WORKDIR /root/TeamUltroid/
|
15 |
|
16 |
# install main requirements.
|
17 |
+
RUN pip3 install --no-cache-dir -r requirements.txt
|
18 |
+
RUN pip3 uninstall av -y && pip3 install av --no-binary av
|
|
|
|
|
|
|
|
|
19 |
|
20 |
# start the bot
|
21 |
CMD ["bash", "resources/startup/startup.sh"]
|
README.md
CHANGED
@@ -5,20 +5,20 @@
|
|
5 |
<b>Ultroid - UserBot</b>
|
6 |
</h1>
|
7 |
|
8 |
-
<b>A stable pluggable Telegram userbot +
|
9 |
|
10 |
[](https://github.com/TeamUltroid/Ultroid/stargazers)
|
11 |
[](https://github.com/TeamUltroid/Ultroid/fork)
|
12 |
[](https://github.com/TeamUltroid/Ultroid/)
|
13 |
-
[](https://www.python.org/)
|
|
|
14 |
[](https://github.com/TeamUltroid/Ultroid/graphs/commit-activity)
|
15 |
-
[](https://github.com/TeamUltroid/Ultroid)
|
17 |
[](https://github.com/TeamUltroid/Ultroid/graphs/contributors)
|
18 |
[](https://makeapullrequest.com)
|
19 |
[](https://github.com/TeamUltroid/Ultroid/blob/main/LICENSE)
|
20 |
[](https://stars.medv.io/TeamUltroid/Ultroid)
|
21 |
-
|
22 |
----
|
23 |
|
24 |
# Deploy
|
@@ -53,10 +53,10 @@ Get the [Necessary Variables](#Necessary-Variables) and then click the button be
|
|
53 |
|
54 |
### Local Deploy - Latest Method
|
55 |
This is the latest and most fastest method currently.<br>
|
56 |
-
First,
|
57 |
-
Then, do as
|
58 |
|
59 |
-
Further, take a look at the [`docs`](https://blue-devil1134.github.io/UltroidCli/) to get more information
|
60 |
|
61 |
|
62 |
### Local Deploy - Easy Method
|
@@ -93,8 +93,6 @@ Further, take a look at the [`docs`](https://blue-devil1134.github.io/UltroidCli
|
|
93 |
`python(3) -m pyUltroid`
|
94 |
|
95 |
## Necessary Variables
|
96 |
-
- `API_ID` - Your API_ID from [my.telegram.org](https://my.telegram.org/)
|
97 |
-
- `API_HASH` - Your API_HASH from [my.telegram.org](https://my.telegram.org/)
|
98 |
- `SESSION` - SessionString for your accounts login session. Get it from [here](#Session-String)
|
99 |
- `REDIS_URI` - Redis endpoint URL, from [redislabs](http://redislabs.com/), tutorial [here.](./resources/extras/redistut.md)
|
100 |
- `REDIS_PASSWORD ` - Redis endpoint Password, from [redislabs](http://redislabs.com/), tutorial [here.](./resources/extras/redistut.md)
|
@@ -117,6 +115,5 @@ Ultroid is licensed under [GNU Affero General Public License](https://www.gnu.or
|
|
117 |
# Credits
|
118 |
* [](https://t.me/UltroidDevs)
|
119 |
* [Lonami](https://github.com/LonamiWebs/) for [Telethon.](https://github.com/LonamiWebs/Telethon)
|
120 |
-
* [
|
121 |
-
* [Pytgcalls](https://github.com/pytgcalls) for [PyTgCalls.](https://github.com/pytgcalls/pytgcalls)
|
122 |
|
|
|
5 |
<b>Ultroid - UserBot</b>
|
6 |
</h1>
|
7 |
|
8 |
+
<b>A stable pluggable Telegram userbot + Voice & Video Call music bot, based on Telethon.</b>
|
9 |
|
10 |
[](https://github.com/TeamUltroid/Ultroid/stargazers)
|
11 |
[](https://github.com/TeamUltroid/Ultroid/fork)
|
12 |
[](https://github.com/TeamUltroid/Ultroid/)
|
13 |
+
[](https://www.python.org/)
|
14 |
+
[](https://www.codefactor.io/repository/github/teamultroid/ultroid/overview/main)
|
15 |
[](https://github.com/TeamUltroid/Ultroid/graphs/commit-activity)
|
16 |
+
[](https://img.shields.io/docker/pulls/theteamultroid/ultroid?style=flat-square)
|
17 |
[](https://github.com/TeamUltroid/Ultroid)
|
18 |
[](https://github.com/TeamUltroid/Ultroid/graphs/contributors)
|
19 |
[](https://makeapullrequest.com)
|
20 |
[](https://github.com/TeamUltroid/Ultroid/blob/main/LICENSE)
|
21 |
[](https://stars.medv.io/TeamUltroid/Ultroid)
|
|
|
22 |
----
|
23 |
|
24 |
# Deploy
|
|
|
53 |
|
54 |
### Local Deploy - Latest Method
|
55 |
This is the latest and most fastest method currently.<br>
|
56 |
+
First, go to [This Project](https://github.com/BLUE-DEVIL1134/UltroidCli) and install the latest release from the Github Releases.<br>
|
57 |
+
Then, do as it's given in the `README.md` to add the executable to your system path.
|
58 |
|
59 |
+
Further, take a look at the [`docs`](https://blue-devil1134.github.io/UltroidCli/) to get more information.
|
60 |
|
61 |
|
62 |
### Local Deploy - Easy Method
|
|
|
93 |
`python(3) -m pyUltroid`
|
94 |
|
95 |
## Necessary Variables
|
|
|
|
|
96 |
- `SESSION` - SessionString for your accounts login session. Get it from [here](#Session-String)
|
97 |
- `REDIS_URI` - Redis endpoint URL, from [redislabs](http://redislabs.com/), tutorial [here.](./resources/extras/redistut.md)
|
98 |
- `REDIS_PASSWORD ` - Redis endpoint Password, from [redislabs](http://redislabs.com/), tutorial [here.](./resources/extras/redistut.md)
|
|
|
115 |
# Credits
|
116 |
* [](https://t.me/UltroidDevs)
|
117 |
* [Lonami](https://github.com/LonamiWebs/) for [Telethon.](https://github.com/LonamiWebs/Telethon)
|
118 |
+
* [MarshalX](https://github.com/MarshalX) for [PyTgCalls.](https://github.com/MarshalX/tgcalls)
|
|
|
119 |
|
app.json
CHANGED
@@ -37,12 +37,12 @@
|
|
37 |
"value": ""
|
38 |
},
|
39 |
"HEROKU_API": {
|
40 |
-
"description": "Heroku API token.
|
41 |
"value": "",
|
42 |
"required": false
|
43 |
},
|
44 |
"HEROKU_APP_NAME": {
|
45 |
-
"description": "Name of your
|
46 |
"value": "",
|
47 |
"required": false
|
48 |
}
|
|
|
37 |
"value": ""
|
38 |
},
|
39 |
"HEROKU_API": {
|
40 |
+
"description": "Heroku API token. Mandatory for Heroku Deploy...",
|
41 |
"value": "",
|
42 |
"required": false
|
43 |
},
|
44 |
"HEROKU_APP_NAME": {
|
45 |
+
"description": "Name of your Heroku app, given in the first blank on this page. To be added if deploying to heroku ONLY.",
|
46 |
"value": "",
|
47 |
"required": false
|
48 |
}
|
assistant/__init__.py
CHANGED
@@ -24,5 +24,4 @@ async def setit(event, name, value):
|
|
24 |
|
25 |
|
26 |
def get_back_button(name):
|
27 |
-
|
28 |
-
return button
|
|
|
24 |
|
25 |
|
26 |
def get_back_button(name):
|
27 |
+
return [Button.inline("« Bᴀᴄᴋ", data=f"{name}")]
|
|
assistant/api_setter.py
CHANGED
@@ -41,12 +41,11 @@ async def rmbgapi(event):
|
|
41 |
"Cancelled!!",
|
42 |
buttons=get_back_button("apiset"),
|
43 |
)
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
)
|
50 |
|
51 |
|
52 |
@callback("dapi")
|
@@ -66,12 +65,11 @@ async def rmbgapi(event):
|
|
66 |
"Cancelled!!",
|
67 |
buttons=get_back_button("apiset"),
|
68 |
)
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
)
|
75 |
|
76 |
|
77 |
@callback("oapi")
|
@@ -91,9 +89,8 @@ async def rmbgapi(event):
|
|
91 |
"Cancelled!!",
|
92 |
buttons=get_back_button("apiset"),
|
93 |
)
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
)
|
|
|
41 |
"Cancelled!!",
|
42 |
buttons=get_back_button("apiset"),
|
43 |
)
|
44 |
+
await setit(event, var, themssg)
|
45 |
+
await conv.send_message(
|
46 |
+
f"{name} changed to {themssg}",
|
47 |
+
buttons=get_back_button("apiset"),
|
48 |
+
)
|
|
|
49 |
|
50 |
|
51 |
@callback("dapi")
|
|
|
65 |
"Cancelled!!",
|
66 |
buttons=get_back_button("apiset"),
|
67 |
)
|
68 |
+
await setit(event, var, themssg)
|
69 |
+
await conv.send_message(
|
70 |
+
f"{name} changed to {themssg}",
|
71 |
+
buttons=get_back_button("apiset"),
|
72 |
+
)
|
|
|
73 |
|
74 |
|
75 |
@callback("oapi")
|
|
|
89 |
"Cancelled!!",
|
90 |
buttons=get_back_button("apiset"),
|
91 |
)
|
92 |
+
await setit(event, var, themssg)
|
93 |
+
await conv.send_message(
|
94 |
+
f"{name} changed to {themssg}",
|
95 |
+
buttons=get_back_button("apiset"),
|
96 |
+
)
|
|
assistant/callbackstuffs.py
CHANGED
@@ -6,10 +6,8 @@
|
|
6 |
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
7 |
|
8 |
import re
|
9 |
-
import
|
10 |
-
from
|
11 |
-
from os import remove
|
12 |
-
from random import choices
|
13 |
|
14 |
from telegraph import Telegraph
|
15 |
from telegraph import upload_file as upl
|
@@ -26,90 +24,63 @@ auth_url = r["auth_url"]
|
|
26 |
TOKEN_FILE = "resources/auths/auth_token.txt"
|
27 |
|
28 |
|
29 |
-
@callback(
|
30 |
-
re.compile(
|
31 |
-
"ebk_(.*)",
|
32 |
-
),
|
33 |
-
)
|
34 |
-
async def eupload(event):
|
35 |
-
match = event.pattern_match.group(1).decode("utf-8")
|
36 |
-
await event.answer("Uploading..")
|
37 |
-
try:
|
38 |
-
await event.edit(
|
39 |
-
file=f"https://www.gutenberg.org/files/{match}/{match}-pdf.pdf"
|
40 |
-
)
|
41 |
-
except BaseException:
|
42 |
-
book = "Ultroid-Book.epub"
|
43 |
-
urllib.request.urlretrieve(
|
44 |
-
"https://www.gutenberg.org/ebooks/132.epub.images", book
|
45 |
-
)
|
46 |
-
fn, media, _ = await asst._file_to_media(
|
47 |
-
book, thumb="resources/extras/ultroid.jpg"
|
48 |
-
)
|
49 |
-
await event.edit(file=media)
|
50 |
-
remove(book)
|
51 |
-
|
52 |
-
|
53 |
@callback(
|
54 |
re.compile(
|
55 |
"sndplug_(.*)",
|
56 |
),
|
57 |
)
|
|
|
58 |
async def send(eve):
|
59 |
name = (eve.data_match.group(1)).decode("UTF-8")
|
60 |
-
thumb = ""
|
61 |
-
|
62 |
-
thumb += m
|
63 |
if name.startswith("def"):
|
64 |
-
plug_name = name.replace(
|
65 |
plugin = f"plugins/{plug_name}.py"
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
"« Pᴀsᴛᴇ »",
|
70 |
-
data=f"pasta-{plugin}",
|
71 |
-
)
|
72 |
-
],
|
73 |
-
[
|
74 |
-
Button.inline("« Bᴀᴄᴋ", data="back"),
|
75 |
-
Button.inline("••Cʟᴏꜱᴇ••", data="close"),
|
76 |
-
],
|
77 |
-
]
|
78 |
-
else:
|
79 |
-
plug_name = name.replace(f"add_plugin_", "")
|
80 |
plugin = f"addons/{plug_name}.py"
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
]
|
|
|
|
|
|
|
|
|
|
|
93 |
await eve.edit(file=plugin, thumb=thumb, buttons=buttons)
|
94 |
|
95 |
|
|
|
|
|
|
|
96 |
@callback("updatenow")
|
97 |
@owner
|
98 |
async def update(eve):
|
99 |
repo = Repo()
|
100 |
ac_br = repo.active_branch
|
101 |
ups_rem = repo.remote("upstream")
|
102 |
-
if
|
103 |
import heroku3
|
104 |
|
105 |
try:
|
106 |
-
heroku = heroku3.from_key(
|
107 |
heroku_app = None
|
108 |
heroku_applications = heroku.apps()
|
109 |
except BaseException:
|
110 |
return await eve.edit("`Wrong HEROKU_API.`")
|
111 |
for app in heroku_applications:
|
112 |
-
if app.name ==
|
113 |
heroku_app = app
|
114 |
if not heroku_app:
|
115 |
await eve.edit("`Wrong HEROKU_APP_NAME.`")
|
@@ -121,7 +92,7 @@ async def update(eve):
|
|
121 |
ups_rem.fetch(ac_br)
|
122 |
repo.git.reset("--hard", "FETCH_HEAD")
|
123 |
heroku_git_url = heroku_app.git_url.replace(
|
124 |
-
"https://", "https://api:" +
|
125 |
)
|
126 |
if "heroku" in repo.remotes:
|
127 |
remote = repo.remote("heroku")
|
@@ -139,42 +110,36 @@ async def update(eve):
|
|
139 |
await eve.edit(
|
140 |
"`Userbot dyno build in progress, please wait for it to complete.`"
|
141 |
)
|
142 |
-
|
143 |
-
|
144 |
-
except GitCommandError:
|
145 |
-
repo.git.reset("--hard", "FETCH_HEAD")
|
146 |
-
await updateme_requirements()
|
147 |
-
await eve.edit(
|
148 |
-
"`Successfully Updated!\nBot is restarting... Wait for a second!`"
|
149 |
-
)
|
150 |
execl(sys.executable, sys.executable, "-m", "pyUltroid")
|
151 |
|
152 |
|
153 |
@callback("changes")
|
154 |
@owner
|
155 |
async def changes(okk):
|
|
|
156 |
repo = Repo.init()
|
157 |
ac_br = repo.active_branch
|
158 |
-
changelog, tl_chnglog =
|
159 |
-
changelog_str = changelog +
|
160 |
if len(changelog_str) > 1024:
|
161 |
await okk.edit(get_string("upd_4"))
|
162 |
await asyncio.sleep(2)
|
163 |
-
with open(
|
164 |
file.write(tl_chnglog)
|
165 |
await okk.edit(
|
166 |
get_string("upd_5"),
|
167 |
file="ultroid_updates.txt",
|
168 |
buttons=Button.inline("Update Now", data="updatenow"),
|
169 |
)
|
170 |
-
remove(
|
171 |
return
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
)
|
178 |
|
179 |
|
180 |
@callback(
|
@@ -186,25 +151,20 @@ async def changes(okk):
|
|
186 |
async def _(e):
|
187 |
ok = (e.data_match.group(1)).decode("UTF-8")
|
188 |
with open(ok, "r") as hmm:
|
189 |
-
_, key = get_paste(hmm.read())
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
raw = "https://nekobin.com/raw/" + key
|
196 |
if ok.startswith("plugins"):
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
buttons = [
|
203 |
-
Button.inline("« Bᴀᴄᴋ", data="buck"),
|
204 |
-
Button.inline("••Cʟᴏꜱᴇ••", data="close"),
|
205 |
-
]
|
206 |
await e.edit(
|
207 |
-
f"<strong>Pasted\n
|
208 |
buttons=buttons,
|
209 |
link_preview=False,
|
210 |
parse_mode="html",
|
@@ -334,12 +294,77 @@ async def otvaar(event):
|
|
334 |
Button.inline("Eᴍᴏᴊɪ ɪɴ Hᴇʟᴘ", data="emoj"),
|
335 |
Button.inline("Sᴇᴛ ɢDʀɪᴠᴇ", data="gdrive"),
|
336 |
],
|
337 |
-
[
|
|
|
|
|
|
|
|
|
338 |
[Button.inline("« Bᴀᴄᴋ", data="setter")],
|
339 |
],
|
340 |
)
|
341 |
|
342 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
343 |
@callback("emoj")
|
344 |
@owner
|
345 |
async def emoji(event):
|
@@ -353,12 +378,12 @@ async def emoji(event):
|
|
353 |
response = await response
|
354 |
themssg = response.message.message
|
355 |
if themssg == "/cancel":
|
356 |
-
|
357 |
"Cancelled!!",
|
358 |
buttons=get_back_button("otvars"),
|
359 |
)
|
360 |
elif themssg.startswith(("/", HNDLR)):
|
361 |
-
|
362 |
"Incorrect Emoji",
|
363 |
buttons=get_back_button("otvars"),
|
364 |
)
|
@@ -385,12 +410,12 @@ async def pluginch(event):
|
|
385 |
response = await response
|
386 |
themssg = response.message.message
|
387 |
if themssg == "/cancel":
|
388 |
-
|
389 |
"Cancelled!!",
|
390 |
buttons=get_back_button("otvars"),
|
391 |
)
|
392 |
elif themssg.startswith(("/", HNDLR)):
|
393 |
-
|
394 |
"Incorrect channel",
|
395 |
buttons=get_back_button("otvars"),
|
396 |
)
|
@@ -420,17 +445,55 @@ async def hndlrr(event):
|
|
420 |
response = await response
|
421 |
themssg = response.message.message
|
422 |
if themssg == "/cancel":
|
423 |
-
|
424 |
"Cancelled!!",
|
425 |
buttons=get_back_button("otvars"),
|
426 |
)
|
427 |
elif len(themssg) > 1:
|
428 |
-
|
429 |
"Incorrect Handler",
|
430 |
buttons=get_back_button("otvars"),
|
431 |
)
|
432 |
elif themssg.startswith(("/", "#", "@")):
|
433 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
434 |
"This cannot be used as handler",
|
435 |
buttons=get_back_button("otvars"),
|
436 |
)
|
@@ -445,13 +508,13 @@ async def hndlrr(event):
|
|
445 |
@callback("taglog")
|
446 |
@owner
|
447 |
async def tagloggrr(e):
|
|
|
|
|
|
|
|
|
448 |
await e.edit(
|
449 |
"Choose Options",
|
450 |
-
buttons=[
|
451 |
-
[Button.inline("SET TAG LOG", data="settag")],
|
452 |
-
[Button.inline("DELETE TAG LOG", data="deltag")],
|
453 |
-
[Button.inline("« Bᴀᴄᴋ", data="otvars")],
|
454 |
-
],
|
455 |
)
|
456 |
|
457 |
|
@@ -481,22 +544,24 @@ async def taglogerr(event):
|
|
481 |
"Cancelled!!",
|
482 |
buttons=get_back_button("taglog"),
|
483 |
)
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
)
|
490 |
|
491 |
|
492 |
@callback("eaddon")
|
493 |
@owner
|
494 |
async def pmset(event):
|
|
|
|
|
|
|
|
|
495 |
await event.edit(
|
496 |
"ADDONS~ Extra Plugins:",
|
497 |
buttons=[
|
498 |
-
|
499 |
-
[Button.inline("Aᴅᴅᴏɴs Oғғ", data="edof")],
|
500 |
[Button.inline("« Bᴀᴄᴋ", data="otvars")],
|
501 |
],
|
502 |
)
|
@@ -516,8 +581,7 @@ async def eddon(event):
|
|
516 |
@callback("edof")
|
517 |
@owner
|
518 |
async def eddof(event):
|
519 |
-
|
520 |
-
await setit(event, var, "False")
|
521 |
await event.edit(
|
522 |
"Done! ADDONS has been turned off!! After Setting All Things Do Restart",
|
523 |
buttons=get_back_button("eaddon"),
|
@@ -527,11 +591,14 @@ async def eddof(event):
|
|
527 |
@callback("sudo")
|
528 |
@owner
|
529 |
async def pmset(event):
|
|
|
|
|
|
|
|
|
530 |
await event.edit(
|
531 |
f"SUDO MODE ~ Some peoples can use ur Bot which u selected. To know More use `{HNDLR}help sudo`",
|
532 |
buttons=[
|
533 |
-
|
534 |
-
[Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ Oғғ", data="ofsudo")],
|
535 |
[Button.inline("« Bᴀᴄᴋ", data="otvars")],
|
536 |
],
|
537 |
)
|
@@ -591,12 +658,11 @@ async def sfgrp(event):
|
|
591 |
"Cancelled!!",
|
592 |
buttons=get_back_button("sfban"),
|
593 |
)
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
)
|
600 |
|
601 |
|
602 |
@callback("sfexf")
|
@@ -608,8 +674,9 @@ async def sfexf(event):
|
|
608 |
pru = event.sender_id
|
609 |
async with asst.conversation(pru) as conv:
|
610 |
await conv.send_message(
|
611 |
-
|
612 |
)
|
|
|
613 |
response = conv.wait_event(events.NewMessage(chats=pru))
|
614 |
response = await response
|
615 |
themssg = response.message.message
|
@@ -618,12 +685,11 @@ async def sfexf(event):
|
|
618 |
"Cancelled!!",
|
619 |
buttons=get_back_button("sfban"),
|
620 |
)
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
)
|
627 |
|
628 |
|
629 |
@callback("alvcstm")
|
@@ -659,15 +725,14 @@ async def name(event):
|
|
659 |
"Cancelled!!",
|
660 |
buttons=get_back_button("alvcstm"),
|
661 |
)
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
)
|
671 |
|
672 |
|
673 |
@callback("alvmed")
|
@@ -679,7 +744,7 @@ async def media(event):
|
|
679 |
name = "Alive Media"
|
680 |
async with event.client.conversation(pru) as conv:
|
681 |
await conv.send_message(
|
682 |
-
"**Alive Media**\nSend me a pic/gif/
|
683 |
)
|
684 |
response = await conv.get_response()
|
685 |
try:
|
@@ -694,10 +759,12 @@ async def media(event):
|
|
694 |
media = await event.client.download_media(response, "alvpc")
|
695 |
if (
|
696 |
not (response.text).startswith("/")
|
697 |
-
and
|
698 |
and not response.media
|
699 |
):
|
700 |
url = response.text
|
|
|
|
|
701 |
else:
|
702 |
try:
|
703 |
x = upl(media)
|
@@ -771,7 +838,7 @@ async def inl_on(event):
|
|
771 |
var = "INLINE_PM"
|
772 |
await setit(event, var, "True")
|
773 |
await event.edit(
|
774 |
-
|
775 |
buttons=[[Button.inline("« Bᴀᴄᴋ", data="pmtype")]],
|
776 |
)
|
777 |
|
@@ -782,7 +849,7 @@ async def inl_on(event):
|
|
782 |
var = "INLINE_PM"
|
783 |
await setit(event, var, "False")
|
784 |
await event.edit(
|
785 |
-
|
786 |
buttons=[[Button.inline("« Bᴀᴄᴋ", data="pmtype")]],
|
787 |
)
|
788 |
|
@@ -806,20 +873,19 @@ async def name(event):
|
|
806 |
"Cancelled!!",
|
807 |
buttons=get_back_button("pmcstm"),
|
808 |
)
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
"Message too long!\nGive a shorter message please!!",
|
813 |
-
buttons=get_back_button("pmcstm"),
|
814 |
-
)
|
815 |
-
await setit(event, var, themssg)
|
816 |
-
await conv.send_message(
|
817 |
-
"{} changed to {}\n\nAfter Setting All Things Do restart".format(
|
818 |
-
name,
|
819 |
-
themssg,
|
820 |
-
),
|
821 |
buttons=get_back_button("pmcstm"),
|
822 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
823 |
|
824 |
|
825 |
@callback("swarn")
|
@@ -861,7 +927,7 @@ async def media(event):
|
|
861 |
name = "PM Media"
|
862 |
async with event.client.conversation(pru) as conv:
|
863 |
await conv.send_message(
|
864 |
-
"**PM Media**\nSend me a pic/gif/
|
865 |
)
|
866 |
response = await conv.get_response()
|
867 |
try:
|
@@ -876,10 +942,12 @@ async def media(event):
|
|
876 |
media = await event.client.download_media(response, "pmpc")
|
877 |
if (
|
878 |
not (response.text).startswith("/")
|
879 |
-
and
|
880 |
and not response.media
|
881 |
):
|
882 |
url = response.text
|
|
|
|
|
883 |
else:
|
884 |
try:
|
885 |
x = upl(media)
|
@@ -929,7 +997,7 @@ async def apon(event):
|
|
929 |
var = "AUTOAPPROVE"
|
930 |
await setit(event, var, "True")
|
931 |
await event.edit(
|
932 |
-
|
933 |
buttons=[[Button.inline("« Bᴀᴄᴋ", data="apauto")]],
|
934 |
)
|
935 |
|
@@ -953,23 +1021,59 @@ async def apof(event):
|
|
953 |
@callback("pml")
|
954 |
@owner
|
955 |
async def alvcs(event):
|
|
|
|
|
|
|
|
|
956 |
await event.edit(
|
957 |
"PMLOGGER This Will Forward Ur Pm to Ur Private Group -",
|
958 |
buttons=[
|
959 |
-
|
960 |
-
[Button.inline("
|
961 |
[Button.inline("« Bᴀᴄᴋ", data="pmcstm")],
|
962 |
],
|
963 |
)
|
964 |
|
965 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
966 |
@callback("pmlog")
|
967 |
@owner
|
968 |
async def pmlog(event):
|
969 |
var = "PMLOG"
|
970 |
await setit(event, var, "True")
|
971 |
await event.edit(
|
972 |
-
|
973 |
buttons=[[Button.inline("« Bᴀᴄᴋ", data="pml")]],
|
974 |
)
|
975 |
|
@@ -1010,7 +1114,7 @@ async def pmonn(event):
|
|
1010 |
var = "PMSETTING"
|
1011 |
await setit(event, var, "True")
|
1012 |
await event.edit(
|
1013 |
-
|
1014 |
buttons=[[Button.inline("« Bᴀᴄᴋ", data="ppmset")]],
|
1015 |
)
|
1016 |
|
@@ -1021,7 +1125,7 @@ async def pmofff(event):
|
|
1021 |
var = "PMSETTING"
|
1022 |
await setit(event, var, "False")
|
1023 |
await event.edit(
|
1024 |
-
|
1025 |
buttons=[[Button.inline("« Bᴀᴄᴋ", data="ppmset")]],
|
1026 |
)
|
1027 |
|
@@ -1030,7 +1134,7 @@ async def pmofff(event):
|
|
1030 |
@owner
|
1031 |
async def chbot(event):
|
1032 |
await event.edit(
|
1033 |
-
|
1034 |
buttons=[
|
1035 |
[Button.inline("Cʜᴀᴛ Bᴏᴛ Oɴ", data="onchbot")],
|
1036 |
[Button.inline("Cʜᴀᴛ Bᴏᴛ Oғғ", data="ofchbot")],
|
@@ -1060,15 +1164,14 @@ async def name(event):
|
|
1060 |
"Cancelled!!",
|
1061 |
buttons=get_back_button("chatbot"),
|
1062 |
)
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
)
|
1072 |
|
1073 |
|
1074 |
@callback("onchbot")
|
@@ -1097,7 +1200,7 @@ async def chon(event):
|
|
1097 |
@owner
|
1098 |
async def vcb(event):
|
1099 |
await event.edit(
|
1100 |
-
|
1101 |
buttons=[
|
1102 |
[Button.inline("VC Sᴇssɪᴏɴ", data="vcs")],
|
1103 |
[Button.inline("« Bᴀᴄᴋ", data="setter")],
|
@@ -1125,15 +1228,14 @@ async def name(event):
|
|
1125 |
"Cancelled!!",
|
1126 |
buttons=get_back_button("vcb"),
|
1127 |
)
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
)
|
1137 |
|
1138 |
|
1139 |
@callback("inli_pic")
|
@@ -1160,7 +1262,7 @@ async def media(event):
|
|
1160 |
media = await event.client.download_media(response, "inlpic")
|
1161 |
if (
|
1162 |
not (response.text).startswith("/")
|
1163 |
-
and
|
1164 |
and not response.media
|
1165 |
):
|
1166 |
url = response.text
|
|
|
6 |
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
7 |
|
8 |
import re
|
9 |
+
import sys
|
10 |
+
from os import execl, remove
|
|
|
|
|
11 |
|
12 |
from telegraph import Telegraph
|
13 |
from telegraph import upload_file as upl
|
|
|
24 |
TOKEN_FILE = "resources/auths/auth_token.txt"
|
25 |
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
@callback(
|
28 |
re.compile(
|
29 |
"sndplug_(.*)",
|
30 |
),
|
31 |
)
|
32 |
+
@owner
|
33 |
async def send(eve):
|
34 |
name = (eve.data_match.group(1)).decode("UTF-8")
|
35 |
+
thumb = "resources/extras/inline.jpg"
|
36 |
+
await eve.answer("■ Sending ■")
|
|
|
37 |
if name.startswith("def"):
|
38 |
+
plug_name = name.replace("def_plugin_", "")
|
39 |
plugin = f"plugins/{plug_name}.py"
|
40 |
+
data = "back"
|
41 |
+
elif name.startswith("add"):
|
42 |
+
plug_name = name.replace("add_plugin_", "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
plugin = f"addons/{plug_name}.py"
|
44 |
+
data = "buck"
|
45 |
+
else:
|
46 |
+
plug_name = name.replace("vc_plugin_", "")
|
47 |
+
plugin = f"vcbot/{plug_name}.py"
|
48 |
+
data = "vc_helper"
|
49 |
+
buttons = [
|
50 |
+
[
|
51 |
+
Button.inline(
|
52 |
+
"« Pᴀsᴛᴇ »",
|
53 |
+
data=f"pasta-{plugin}",
|
54 |
+
)
|
55 |
+
],
|
56 |
+
[
|
57 |
+
Button.inline("« Bᴀᴄᴋ", data=data),
|
58 |
+
Button.inline("••Cʟᴏꜱᴇ••", data="close"),
|
59 |
+
],
|
60 |
+
]
|
61 |
await eve.edit(file=plugin, thumb=thumb, buttons=buttons)
|
62 |
|
63 |
|
64 |
+
heroku_api, app_name = Var.HEROKU_API, Var.HEROKU_APP_NAME
|
65 |
+
|
66 |
+
|
67 |
@callback("updatenow")
|
68 |
@owner
|
69 |
async def update(eve):
|
70 |
repo = Repo()
|
71 |
ac_br = repo.active_branch
|
72 |
ups_rem = repo.remote("upstream")
|
73 |
+
if heroku_api:
|
74 |
import heroku3
|
75 |
|
76 |
try:
|
77 |
+
heroku = heroku3.from_key(heroku_api)
|
78 |
heroku_app = None
|
79 |
heroku_applications = heroku.apps()
|
80 |
except BaseException:
|
81 |
return await eve.edit("`Wrong HEROKU_API.`")
|
82 |
for app in heroku_applications:
|
83 |
+
if app.name == app_name:
|
84 |
heroku_app = app
|
85 |
if not heroku_app:
|
86 |
await eve.edit("`Wrong HEROKU_APP_NAME.`")
|
|
|
92 |
ups_rem.fetch(ac_br)
|
93 |
repo.git.reset("--hard", "FETCH_HEAD")
|
94 |
heroku_git_url = heroku_app.git_url.replace(
|
95 |
+
"https://", "https://api:" + heroku_api + "@"
|
96 |
)
|
97 |
if "heroku" in repo.remotes:
|
98 |
remote = repo.remote("heroku")
|
|
|
110 |
await eve.edit(
|
111 |
"`Userbot dyno build in progress, please wait for it to complete.`"
|
112 |
)
|
113 |
+
call_back()
|
114 |
+
await bash("git pull && pip3 install -r requirements.txt")
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
execl(sys.executable, sys.executable, "-m", "pyUltroid")
|
116 |
|
117 |
|
118 |
@callback("changes")
|
119 |
@owner
|
120 |
async def changes(okk):
|
121 |
+
await okk.answer("■ Generating Changelogs...")
|
122 |
repo = Repo.init()
|
123 |
ac_br = repo.active_branch
|
124 |
+
changelog, tl_chnglog = gen_chlog(repo, f"HEAD..upstream/{ac_br}")
|
125 |
+
changelog_str = changelog + "\n\nClick the below button to update!"
|
126 |
if len(changelog_str) > 1024:
|
127 |
await okk.edit(get_string("upd_4"))
|
128 |
await asyncio.sleep(2)
|
129 |
+
with open("ultroid_updates.txt", "w+") as file:
|
130 |
file.write(tl_chnglog)
|
131 |
await okk.edit(
|
132 |
get_string("upd_5"),
|
133 |
file="ultroid_updates.txt",
|
134 |
buttons=Button.inline("Update Now", data="updatenow"),
|
135 |
)
|
136 |
+
remove("ultroid_updates.txt")
|
137 |
return
|
138 |
+
await okk.edit(
|
139 |
+
changelog_str,
|
140 |
+
buttons=Button.inline("Update Now", data="updatenow"),
|
141 |
+
parse_mode="html",
|
142 |
+
)
|
|
|
143 |
|
144 |
|
145 |
@callback(
|
|
|
151 |
async def _(e):
|
152 |
ok = (e.data_match.group(1)).decode("UTF-8")
|
153 |
with open(ok, "r") as hmm:
|
154 |
+
_, key = await get_paste(hmm.read())
|
155 |
+
link = "https://spaceb.in/" + key
|
156 |
+
raw = f"https://spaceb.in/api/v1/documents/{key}/raw"
|
157 |
+
if not _:
|
158 |
+
return await e.answer(key[:30], alert=True)
|
159 |
+
data = "buck"
|
|
|
160 |
if ok.startswith("plugins"):
|
161 |
+
data = "back"
|
162 |
+
buttons = [
|
163 |
+
Button.inline("« Bᴀᴄᴋ", data=data),
|
164 |
+
Button.inline("••Cʟᴏꜱᴇ••", data="close"),
|
165 |
+
]
|
|
|
|
|
|
|
|
|
166 |
await e.edit(
|
167 |
+
f"<strong>Pasted\n👉 <a href={link}>[Link]</a>\n👉 <a href={raw}>[Raw Link]</a></strong>",
|
168 |
buttons=buttons,
|
169 |
link_preview=False,
|
170 |
parse_mode="html",
|
|
|
294 |
Button.inline("Eᴍᴏᴊɪ ɪɴ Hᴇʟᴘ", data="emoj"),
|
295 |
Button.inline("Sᴇᴛ ɢDʀɪᴠᴇ", data="gdrive"),
|
296 |
],
|
297 |
+
[
|
298 |
+
Button.inline("Iɴʟɪɴᴇ Pɪᴄ", data="inli_pic"),
|
299 |
+
Button.inline("Sᴜᴅᴏ HNDLR", data="shndlr"),
|
300 |
+
],
|
301 |
+
[Button.inline("Dᴜᴀʟ Mᴏᴅᴇ", "oofdm")],
|
302 |
[Button.inline("« Bᴀᴄᴋ", data="setter")],
|
303 |
],
|
304 |
)
|
305 |
|
306 |
|
307 |
+
@callback("oofdm")
|
308 |
+
@owner
|
309 |
+
async def euwhe(event):
|
310 |
+
BT = [
|
311 |
+
[Button.inline("Dᴜᴀʟ Mᴏᴅᴇ Oɴ", "dmof")],
|
312 |
+
[Button.inline("Dᴜᴀʟ Mᴏᴅᴇ Oғғ", "dmof")],
|
313 |
+
[Button.inline("Dᴜᴀʟ Mᴏᴅᴇ Hɴᴅʟʀ", "dmhn")],
|
314 |
+
]
|
315 |
+
await event.edit(
|
316 |
+
"About [Dual Mode](https://t.me/UltroidUpdates/18)",
|
317 |
+
buttons=BT,
|
318 |
+
link_preview=False,
|
319 |
+
)
|
320 |
+
|
321 |
+
|
322 |
+
@callback("dmof")
|
323 |
+
@owner
|
324 |
+
async def rhwhe(e):
|
325 |
+
if udB.get("DUAL_MODE"):
|
326 |
+
udB.delete("DUAL_MODE")
|
327 |
+
key = "Off"
|
328 |
+
else:
|
329 |
+
udB.set("DUAL_MODE", "True")
|
330 |
+
key = "On"
|
331 |
+
Msg = "Dual Mode : " + key
|
332 |
+
await e.edit(Msg, buttons=get_back_button("otvars"))
|
333 |
+
|
334 |
+
|
335 |
+
@callback("dmhn")
|
336 |
+
@owner
|
337 |
+
async def hndlrr(event):
|
338 |
+
await event.delete()
|
339 |
+
pru = event.sender_id
|
340 |
+
var = "DUAL_HNDLR"
|
341 |
+
name = "Dual Handler"
|
342 |
+
CH = udB.get(var) or "/"
|
343 |
+
async with event.client.conversation(pru) as conv:
|
344 |
+
await conv.send_message(
|
345 |
+
f"Send The Symbol Which u want as Handler/Trigger to use your Assistant bot\nUr Current Handler is [ `{CH}` ]\n\n use /cancel to cancel.",
|
346 |
+
)
|
347 |
+
response = conv.wait_event(events.NewMessage(chats=pru))
|
348 |
+
response = await response
|
349 |
+
themssg = response.message.message
|
350 |
+
if themssg == "/cancel":
|
351 |
+
await conv.send_message(
|
352 |
+
"Cancelled!!",
|
353 |
+
buttons=get_back_button("otvars"),
|
354 |
+
)
|
355 |
+
elif len(themssg) > 1:
|
356 |
+
await conv.send_message(
|
357 |
+
"Incorrect Handler",
|
358 |
+
buttons=get_back_button("otvars"),
|
359 |
+
)
|
360 |
+
else:
|
361 |
+
await setit(event, var, themssg)
|
362 |
+
await conv.send_message(
|
363 |
+
f"{name} changed to {themssg}",
|
364 |
+
buttons=get_back_button("otvars"),
|
365 |
+
)
|
366 |
+
|
367 |
+
|
368 |
@callback("emoj")
|
369 |
@owner
|
370 |
async def emoji(event):
|
|
|
378 |
response = await response
|
379 |
themssg = response.message.message
|
380 |
if themssg == "/cancel":
|
381 |
+
await conv.send_message(
|
382 |
"Cancelled!!",
|
383 |
buttons=get_back_button("otvars"),
|
384 |
)
|
385 |
elif themssg.startswith(("/", HNDLR)):
|
386 |
+
await conv.send_message(
|
387 |
"Incorrect Emoji",
|
388 |
buttons=get_back_button("otvars"),
|
389 |
)
|
|
|
410 |
response = await response
|
411 |
themssg = response.message.message
|
412 |
if themssg == "/cancel":
|
413 |
+
await conv.send_message(
|
414 |
"Cancelled!!",
|
415 |
buttons=get_back_button("otvars"),
|
416 |
)
|
417 |
elif themssg.startswith(("/", HNDLR)):
|
418 |
+
await conv.send_message(
|
419 |
"Incorrect channel",
|
420 |
buttons=get_back_button("otvars"),
|
421 |
)
|
|
|
445 |
response = await response
|
446 |
themssg = response.message.message
|
447 |
if themssg == "/cancel":
|
448 |
+
await conv.send_message(
|
449 |
"Cancelled!!",
|
450 |
buttons=get_back_button("otvars"),
|
451 |
)
|
452 |
elif len(themssg) > 1:
|
453 |
+
await conv.send_message(
|
454 |
"Incorrect Handler",
|
455 |
buttons=get_back_button("otvars"),
|
456 |
)
|
457 |
elif themssg.startswith(("/", "#", "@")):
|
458 |
+
await conv.send_message(
|
459 |
+
"This cannot be used as handler",
|
460 |
+
buttons=get_back_button("otvars"),
|
461 |
+
)
|
462 |
+
else:
|
463 |
+
await setit(event, var, themssg)
|
464 |
+
await conv.send_message(
|
465 |
+
f"{name} changed to {themssg}",
|
466 |
+
buttons=get_back_button("otvars"),
|
467 |
+
)
|
468 |
+
|
469 |
+
|
470 |
+
@callback("shndlr")
|
471 |
+
@owner
|
472 |
+
async def hndlrr(event):
|
473 |
+
await event.delete()
|
474 |
+
pru = event.sender_id
|
475 |
+
var = "SUDO_HNDLR"
|
476 |
+
name = "Sudo Handler"
|
477 |
+
async with event.client.conversation(pru) as conv:
|
478 |
+
await conv.send_message(
|
479 |
+
"Send The Symbol Which u want as Sudo Handler/Trigger to use bot\n\n use /cancel to cancel."
|
480 |
+
)
|
481 |
+
|
482 |
+
response = conv.wait_event(events.NewMessage(chats=pru))
|
483 |
+
response = await response
|
484 |
+
themssg = response.message.message
|
485 |
+
if themssg == "/cancel":
|
486 |
+
await conv.send_message(
|
487 |
+
"Cancelled!!",
|
488 |
+
buttons=get_back_button("otvars"),
|
489 |
+
)
|
490 |
+
elif len(themssg) > 1:
|
491 |
+
await conv.send_message(
|
492 |
+
"Incorrect Handler",
|
493 |
+
buttons=get_back_button("otvars"),
|
494 |
+
)
|
495 |
+
elif themssg.startswith(("/", "#", "@")):
|
496 |
+
await conv.send_message(
|
497 |
"This cannot be used as handler",
|
498 |
buttons=get_back_button("otvars"),
|
499 |
)
|
|
|
508 |
@callback("taglog")
|
509 |
@owner
|
510 |
async def tagloggrr(e):
|
511 |
+
if not udB.get("TAG_LOG"):
|
512 |
+
BUTTON = [Button.inline("SET TAG LOG", data="settag")]
|
513 |
+
else:
|
514 |
+
BUTTON = [Button.inline("DELETE TAG LOG", data="deltag")]
|
515 |
await e.edit(
|
516 |
"Choose Options",
|
517 |
+
buttons=[BUTTON, [Button.inline("« Bᴀᴄᴋ", data="otvars")]],
|
|
|
|
|
|
|
|
|
518 |
)
|
519 |
|
520 |
|
|
|
544 |
"Cancelled!!",
|
545 |
buttons=get_back_button("taglog"),
|
546 |
)
|
547 |
+
await setit(event, var, themssg)
|
548 |
+
await conv.send_message(
|
549 |
+
f"{name} changed to {themssg}",
|
550 |
+
buttons=get_back_button("taglog"),
|
551 |
+
)
|
|
|
552 |
|
553 |
|
554 |
@callback("eaddon")
|
555 |
@owner
|
556 |
async def pmset(event):
|
557 |
+
if not udB.get("ADDONS"):
|
558 |
+
BT = [Button.inline("Aᴅᴅᴏɴs Oɴ", data="edon")]
|
559 |
+
else:
|
560 |
+
BT = [Button.inline("Aᴅᴅᴏɴs Oғғ", data="edof")]
|
561 |
await event.edit(
|
562 |
"ADDONS~ Extra Plugins:",
|
563 |
buttons=[
|
564 |
+
BT,
|
|
|
565 |
[Button.inline("« Bᴀᴄᴋ", data="otvars")],
|
566 |
],
|
567 |
)
|
|
|
581 |
@callback("edof")
|
582 |
@owner
|
583 |
async def eddof(event):
|
584 |
+
udB.set("ADDONS", "False")
|
|
|
585 |
await event.edit(
|
586 |
"Done! ADDONS has been turned off!! After Setting All Things Do Restart",
|
587 |
buttons=get_back_button("eaddon"),
|
|
|
591 |
@callback("sudo")
|
592 |
@owner
|
593 |
async def pmset(event):
|
594 |
+
if not udB.get("SUDO"):
|
595 |
+
BT = [Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ Oɴ", data="onsudo")]
|
596 |
+
else:
|
597 |
+
BT = [Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ Oғғ", data="ofsudo")]
|
598 |
await event.edit(
|
599 |
f"SUDO MODE ~ Some peoples can use ur Bot which u selected. To know More use `{HNDLR}help sudo`",
|
600 |
buttons=[
|
601 |
+
BT,
|
|
|
602 |
[Button.inline("« Bᴀᴄᴋ", data="otvars")],
|
603 |
],
|
604 |
)
|
|
|
658 |
"Cancelled!!",
|
659 |
buttons=get_back_button("sfban"),
|
660 |
)
|
661 |
+
await setit(event, var, themssg)
|
662 |
+
await conv.send_message(
|
663 |
+
f"{name} changed to {themssg}",
|
664 |
+
buttons=get_back_button("sfban"),
|
665 |
+
)
|
|
|
666 |
|
667 |
|
668 |
@callback("sfexf")
|
|
|
674 |
pru = event.sender_id
|
675 |
async with asst.conversation(pru) as conv:
|
676 |
await conv.send_message(
|
677 |
+
"Send the Fed IDs you want to exclude in the ban. Split by a space.\neg`id1 id2 id3`\nSet is as `None` if you dont want any.\nUse /cancel to go back."
|
678 |
)
|
679 |
+
|
680 |
response = conv.wait_event(events.NewMessage(chats=pru))
|
681 |
response = await response
|
682 |
themssg = response.message.message
|
|
|
685 |
"Cancelled!!",
|
686 |
buttons=get_back_button("sfban"),
|
687 |
)
|
688 |
+
await setit(event, var, themssg)
|
689 |
+
await conv.send_message(
|
690 |
+
f"{name} changed to {themssg}",
|
691 |
+
buttons=get_back_button("sfban"),
|
692 |
+
)
|
|
|
693 |
|
694 |
|
695 |
@callback("alvcstm")
|
|
|
725 |
"Cancelled!!",
|
726 |
buttons=get_back_button("alvcstm"),
|
727 |
)
|
728 |
+
await setit(event, var, themssg)
|
729 |
+
await conv.send_message(
|
730 |
+
"{} changed to {}\n\nAfter Setting All Things Do restart".format(
|
731 |
+
name,
|
732 |
+
themssg,
|
733 |
+
),
|
734 |
+
buttons=get_back_button("alvcstm"),
|
735 |
+
)
|
|
|
736 |
|
737 |
|
738 |
@callback("alvmed")
|
|
|
744 |
name = "Alive Media"
|
745 |
async with event.client.conversation(pru) as conv:
|
746 |
await conv.send_message(
|
747 |
+
"**Alive Media**\nSend me a pic/gif/media to set as alive media.\n\nUse /cancel to terminate the operation.",
|
748 |
)
|
749 |
response = await conv.get_response()
|
750 |
try:
|
|
|
759 |
media = await event.client.download_media(response, "alvpc")
|
760 |
if (
|
761 |
not (response.text).startswith("/")
|
762 |
+
and response.text != ""
|
763 |
and not response.media
|
764 |
):
|
765 |
url = response.text
|
766 |
+
elif response.sticker:
|
767 |
+
url = response.file.id
|
768 |
else:
|
769 |
try:
|
770 |
x = upl(media)
|
|
|
838 |
var = "INLINE_PM"
|
839 |
await setit(event, var, "True")
|
840 |
await event.edit(
|
841 |
+
"Done!! PMPermit type has been set to inline!",
|
842 |
buttons=[[Button.inline("« Bᴀᴄᴋ", data="pmtype")]],
|
843 |
)
|
844 |
|
|
|
849 |
var = "INLINE_PM"
|
850 |
await setit(event, var, "False")
|
851 |
await event.edit(
|
852 |
+
"Done!! PMPermit type has been set to normal!",
|
853 |
buttons=[[Button.inline("« Bᴀᴄᴋ", data="pmtype")]],
|
854 |
)
|
855 |
|
|
|
873 |
"Cancelled!!",
|
874 |
buttons=get_back_button("pmcstm"),
|
875 |
)
|
876 |
+
if len(themssg) > 4090:
|
877 |
+
return await conv.send_message(
|
878 |
+
"Message too long!\nGive a shorter message please!!",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
879 |
buttons=get_back_button("pmcstm"),
|
880 |
)
|
881 |
+
await setit(event, var, themssg)
|
882 |
+
await conv.send_message(
|
883 |
+
"{} changed to {}\n\nAfter Setting All Things Do restart".format(
|
884 |
+
name,
|
885 |
+
themssg,
|
886 |
+
),
|
887 |
+
buttons=get_back_button("pmcstm"),
|
888 |
+
)
|
889 |
|
890 |
|
891 |
@callback("swarn")
|
|
|
927 |
name = "PM Media"
|
928 |
async with event.client.conversation(pru) as conv:
|
929 |
await conv.send_message(
|
930 |
+
"**PM Media**\nSend me a pic/gif/sticker/link to set as pmpermit media.\n\nUse /cancel to terminate the operation.",
|
931 |
)
|
932 |
response = await conv.get_response()
|
933 |
try:
|
|
|
942 |
media = await event.client.download_media(response, "pmpc")
|
943 |
if (
|
944 |
not (response.text).startswith("/")
|
945 |
+
and response.text != ""
|
946 |
and not response.media
|
947 |
):
|
948 |
url = response.text
|
949 |
+
elif response.sticker:
|
950 |
+
url = response.file.id
|
951 |
else:
|
952 |
try:
|
953 |
x = upl(media)
|
|
|
997 |
var = "AUTOAPPROVE"
|
998 |
await setit(event, var, "True")
|
999 |
await event.edit(
|
1000 |
+
"Done!! AUTOAPPROVE Started!!",
|
1001 |
buttons=[[Button.inline("« Bᴀᴄᴋ", data="apauto")]],
|
1002 |
)
|
1003 |
|
|
|
1021 |
@callback("pml")
|
1022 |
@owner
|
1023 |
async def alvcs(event):
|
1024 |
+
if not udB.get("PMLOG"):
|
1025 |
+
BT = [Button.inline("PMLOGGER ON", data="pmlog")]
|
1026 |
+
else:
|
1027 |
+
BT = [Button.inline("PMLOGGER OFF", data="pmlogof")]
|
1028 |
await event.edit(
|
1029 |
"PMLOGGER This Will Forward Ur Pm to Ur Private Group -",
|
1030 |
buttons=[
|
1031 |
+
BT,
|
1032 |
+
[Button.inline("PᴍLᴏɢɢᴇʀ Gʀᴏᴜᴘ", "pmlgg")],
|
1033 |
[Button.inline("« Bᴀᴄᴋ", data="pmcstm")],
|
1034 |
],
|
1035 |
)
|
1036 |
|
1037 |
|
1038 |
+
@callback("pmlgg")
|
1039 |
+
@owner
|
1040 |
+
async def disus(event):
|
1041 |
+
await event.delete()
|
1042 |
+
pru = event.sender_id
|
1043 |
+
var = "PMLOGGROUP"
|
1044 |
+
name = "Pm Logger Group"
|
1045 |
+
async with event.client.conversation(pru) as conv:
|
1046 |
+
await conv.send_message(
|
1047 |
+
f"Send The Symbol Which u want as your {name}\n\n use /cancel to cancel.",
|
1048 |
+
)
|
1049 |
+
response = conv.wait_event(events.NewMessage(chats=pru))
|
1050 |
+
response = await response
|
1051 |
+
themssg = response.message.message
|
1052 |
+
if themssg == "/cancel":
|
1053 |
+
await conv.send_message(
|
1054 |
+
"Cancelled!!",
|
1055 |
+
buttons=get_back_button("pml"),
|
1056 |
+
)
|
1057 |
+
elif len(themssg) > 1:
|
1058 |
+
await conv.send_message(
|
1059 |
+
"Incorrect Value",
|
1060 |
+
buttons=get_back_button("pml"),
|
1061 |
+
)
|
1062 |
+
else:
|
1063 |
+
await setit(event, var, themssg)
|
1064 |
+
await conv.send_message(
|
1065 |
+
f"{name} changed to `{themssg}`",
|
1066 |
+
buttons=get_back_button("pml"),
|
1067 |
+
)
|
1068 |
+
|
1069 |
+
|
1070 |
@callback("pmlog")
|
1071 |
@owner
|
1072 |
async def pmlog(event):
|
1073 |
var = "PMLOG"
|
1074 |
await setit(event, var, "True")
|
1075 |
await event.edit(
|
1076 |
+
"Done!! PMLOGGER Started!!",
|
1077 |
buttons=[[Button.inline("« Bᴀᴄᴋ", data="pml")]],
|
1078 |
)
|
1079 |
|
|
|
1114 |
var = "PMSETTING"
|
1115 |
await setit(event, var, "True")
|
1116 |
await event.edit(
|
1117 |
+
"Done! PMPermit has been turned on!!",
|
1118 |
buttons=[[Button.inline("« Bᴀᴄᴋ", data="ppmset")]],
|
1119 |
)
|
1120 |
|
|
|
1125 |
var = "PMSETTING"
|
1126 |
await setit(event, var, "False")
|
1127 |
await event.edit(
|
1128 |
+
"Done! PMPermit has been turned off!!",
|
1129 |
buttons=[[Button.inline("« Bᴀᴄᴋ", data="ppmset")]],
|
1130 |
)
|
1131 |
|
|
|
1134 |
@owner
|
1135 |
async def chbot(event):
|
1136 |
await event.edit(
|
1137 |
+
"From This Feature U can chat with ppls Via ur Assistant Bot.\n[More info](https://t.me/UltroidUpdates/2)",
|
1138 |
buttons=[
|
1139 |
[Button.inline("Cʜᴀᴛ Bᴏᴛ Oɴ", data="onchbot")],
|
1140 |
[Button.inline("Cʜᴀᴛ Bᴏᴛ Oғғ", data="ofchbot")],
|
|
|
1164 |
"Cancelled!!",
|
1165 |
buttons=get_back_button("chatbot"),
|
1166 |
)
|
1167 |
+
await setit(event, var, themssg)
|
1168 |
+
await conv.send_message(
|
1169 |
+
"{} changed to {}".format(
|
1170 |
+
name,
|
1171 |
+
themssg,
|
1172 |
+
),
|
1173 |
+
buttons=get_back_button("chatbot"),
|
1174 |
+
)
|
|
|
1175 |
|
1176 |
|
1177 |
@callback("onchbot")
|
|
|
1200 |
@owner
|
1201 |
async def vcb(event):
|
1202 |
await event.edit(
|
1203 |
+
"From This Feature U can play songs in group voice chat\n\n[moreinfo](https://t.me/UltroidUpdates/4)",
|
1204 |
buttons=[
|
1205 |
[Button.inline("VC Sᴇssɪᴏɴ", data="vcs")],
|
1206 |
[Button.inline("« Bᴀᴄᴋ", data="setter")],
|
|
|
1228 |
"Cancelled!!",
|
1229 |
buttons=get_back_button("vcb"),
|
1230 |
)
|
1231 |
+
await setit(event, var, themssg)
|
1232 |
+
await conv.send_message(
|
1233 |
+
"{} changed to {}\n\nAfter Setting All Things Do restart".format(
|
1234 |
+
name,
|
1235 |
+
themssg,
|
1236 |
+
),
|
1237 |
+
buttons=get_back_button("vcb"),
|
1238 |
+
)
|
|
|
1239 |
|
1240 |
|
1241 |
@callback("inli_pic")
|
|
|
1262 |
media = await event.client.download_media(response, "inlpic")
|
1263 |
if (
|
1264 |
not (response.text).startswith("/")
|
1265 |
+
and response.text != ""
|
1266 |
and not response.media
|
1267 |
):
|
1268 |
url = response.text
|
assistant/initial.py
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021 TeamUltroid
|
3 |
+
#
|
4 |
+
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
+
# PLease read the GNU Affero General Public License in
|
6 |
+
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
7 |
+
|
8 |
+
import re
|
9 |
+
|
10 |
+
from . import *
|
11 |
+
|
12 |
+
STRINGS = {
|
13 |
+
1: """🎇 **Thanks for Deploying Ultroid Userbot!**
|
14 |
+
|
15 |
+
• Here, are the Some Basic stuff from, where you can Know, about its Usage.""",
|
16 |
+
2: """🎉** About Ultroid**
|
17 |
+
|
18 |
+
🧿 Ultroid is Pluggable and powerful Telethon Userbot, made in Python from Scratch. It is Aimed to Increase Security along with Addition of Other Useful Features.
|
19 |
+
|
20 |
+
❣ Made by **@TeamUltroid**""",
|
21 |
+
3: """**💡• FAQs •**
|
22 |
+
|
23 |
+
-> [Setting up TimeZone](https://t.me/UltroidUpdates/22)
|
24 |
+
-> [About Inline PmPermit](https://t.me/UltroidUpdates/21)
|
25 |
+
-> [About Dual Mode](https://t.me/UltroidUpdates/18)
|
26 |
+
-> [Custom Thumbnail](https://t.me/UltroidUpdates/13)
|
27 |
+
-> [About FullSudo](https://t.me/UltroidUpdates/11)
|
28 |
+
-> [Setting Up PmBot](https://t.me/UltroidUpdates/2)
|
29 |
+
-> [Also Check](https://t.me/UltroidUpdates/14)
|
30 |
+
|
31 |
+
**• To Know About Updates**
|
32 |
+
- Join @TheUltroid.""",
|
33 |
+
4: f"""• `To Know All Available Commands`
|
34 |
+
|
35 |
+
- `{HNDLR}help`
|
36 |
+
- `{HNDLR}cmds`""",
|
37 |
+
5: """• **For Any Other Query or Suggestion**
|
38 |
+
- Move to **@UltroidSupport**.
|
39 |
+
|
40 |
+
• Thanks for Reaching till END.""",
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
@callback(re.compile("initft_(\\d+)"))
|
45 |
+
async def init_depl(e):
|
46 |
+
CURRENT = int(e.data_match.group(1))
|
47 |
+
if CURRENT == 5:
|
48 |
+
return await e.edit(
|
49 |
+
STRINGS[5],
|
50 |
+
buttons=Button.inline("<< Back", "initbk_" + str(4)),
|
51 |
+
link_preview=False,
|
52 |
+
)
|
53 |
+
await e.edit(
|
54 |
+
STRINGS[CURRENT],
|
55 |
+
buttons=[
|
56 |
+
Button.inline("<<", "initbk_" + str(CURRENT - 1)),
|
57 |
+
Button.inline(">>", "initft_" + str(CURRENT + 1)),
|
58 |
+
],
|
59 |
+
link_preview=False,
|
60 |
+
)
|
61 |
+
|
62 |
+
|
63 |
+
@callback(re.compile("initbk_(\\d+)"))
|
64 |
+
async def ineiq(e):
|
65 |
+
CURRENT = int(e.data_match.group(1))
|
66 |
+
if CURRENT == 1:
|
67 |
+
return await e.edit(
|
68 |
+
STRINGS[1],
|
69 |
+
buttons=Button.inline("Start Back >>", "initft_" + str(2)),
|
70 |
+
link_preview=False,
|
71 |
+
)
|
72 |
+
await e.edit(
|
73 |
+
STRINGS[CURRENT],
|
74 |
+
buttons=[
|
75 |
+
Button.inline("<<", "initbk_" + str(CURRENT - 1)),
|
76 |
+
Button.inline(">>", "initft_" + str(CURRENT + 1)),
|
77 |
+
],
|
78 |
+
link_preview=False,
|
79 |
+
)
|
assistant/inlinestuff.py
CHANGED
@@ -6,13 +6,13 @@
|
|
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 |
|
13 |
import requests
|
14 |
-
from bs4 import BeautifulSoup
|
15 |
-
from orangefoxapi import OrangeFoxAPI
|
16 |
from play_scraper import search
|
17 |
from search_engine_parser import GoogleSearch, YahooSearch
|
18 |
from telethon import Button
|
@@ -21,16 +21,12 @@ from telethon.tl.types import InputWebDocument as wb
|
|
21 |
from plugins._inline import SUP_BUTTONS
|
22 |
|
23 |
from . import *
|
24 |
-
from . import humanbytes as hb
|
25 |
|
26 |
ofox = "https://telegra.ph/file/231f0049fcd722824f13b.jpg"
|
27 |
gugirl = "https://telegra.ph/file/0df54ae4541abca96aa11.jpg"
|
28 |
yeah = "https://telegra.ph/file/e3c67885e16a194937516.jpg"
|
29 |
-
ps = "https://telegra.ph/file/de0b8d9c858c62fae3b6e.jpg"
|
30 |
ultpic = "https://telegra.ph/file/4136aa1650bc9d4109cc5.jpg"
|
31 |
|
32 |
-
ofox_api = OrangeFoxAPI()
|
33 |
-
|
34 |
api1 = base64.b64decode("QUl6YVN5QXlEQnNZM1dSdEI1WVBDNmFCX3c4SkF5NlpkWE5jNkZV").decode(
|
35 |
"ascii"
|
36 |
)
|
@@ -45,6 +41,7 @@ api3 = base64.b64decode("QUl6YVN5RGRPS253blB3VklRX2xiSDVzWUU0Rm9YakFLSVFWMERR").
|
|
45 |
@in_pattern("ofox")
|
46 |
@in_owner
|
47 |
async def _(e):
|
|
|
48 |
try:
|
49 |
match = e.text.split(" ", maxsplit=1)[1]
|
50 |
except IndexError:
|
@@ -54,39 +51,43 @@ async def _(e):
|
|
54 |
text="**OFᴏx🦊Rᴇᴄᴏᴠᴇʀʏ**\n\nYou didn't search anything",
|
55 |
buttons=Button.switch_inline("Sᴇᴀʀᴄʜ Aɢᴀɪɴ", query="ofox ", same_peer=True),
|
56 |
)
|
57 |
-
await e.answer([kkkk])
|
58 |
-
|
59 |
-
|
60 |
-
if len(a.data) > 0:
|
61 |
fox = []
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
|
|
89 |
)
|
|
|
90 |
await e.answer(
|
91 |
fox, switch_pm="OrangeFox Recovery Search.", switch_pm_param="start"
|
92 |
)
|
@@ -301,7 +302,7 @@ async def _(e):
|
|
301 |
await e.builder.article(
|
302 |
title=name,
|
303 |
description=ids,
|
304 |
-
thumb=wb(
|
305 |
text=text,
|
306 |
link_preview=True,
|
307 |
buttons=[
|
@@ -373,60 +374,39 @@ async def _(e):
|
|
373 |
await e.answer(modss, switch_pm="Search Mod Applications.", switch_pm_param="start")
|
374 |
|
375 |
|
376 |
-
@
|
|
|
|
|
|
|
377 |
@in_owner
|
378 |
-
async def
|
|
|
379 |
try:
|
380 |
-
|
381 |
except IndexError:
|
382 |
-
await
|
383 |
-
[], switch_pm="Enter Query to
|
384 |
-
)
|
385 |
-
return
|
386 |
-
quer = quer.replace(" ", "+")
|
387 |
-
sear = f"http://www.gutenberg.org/ebooks/search/?query={quer}&submit_search=Go%21"
|
388 |
-
magma = requests.get(sear).content
|
389 |
-
bs = BeautifulSoup(magma, "html.parser", from_encoding="utf-8")
|
390 |
-
out = bs.find_all("img")
|
391 |
-
Alink = bs.find_all("a", "link")
|
392 |
-
if len(out) == 0:
|
393 |
-
return await e.answer(
|
394 |
-
[], switch_pm="No Results Found !", switch_pm_param="start"
|
395 |
)
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
"
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
pass
|
414 |
-
for rs in range(len(out)):
|
415 |
-
if "/cache/epub" in out[rs]["src"]:
|
416 |
-
link = out[rs]["src"]
|
417 |
-
num = link.split("/")[3]
|
418 |
-
link = "https://gutenberg.org" + link.replace("small", "medium")
|
419 |
-
file = wb(link, 0, "image/jpeg", [])
|
420 |
-
hm.append(
|
421 |
-
buil.article(
|
422 |
-
title=titles[rs],
|
423 |
-
type="photo",
|
424 |
-
description="GutenBerg Search",
|
425 |
-
thumb=file,
|
426 |
-
content=file,
|
427 |
-
include_media=True,
|
428 |
-
text=f"**• Ebook Search**\n\n->> `{titles[rs]}`",
|
429 |
-
buttons=Button.inline("Get as Doc", data=f"ebk_{num}"),
|
430 |
-
)
|
431 |
)
|
432 |
-
|
|
|
|
|
|
|
|
|
|
6 |
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
7 |
|
8 |
import base64
|
9 |
+
from datetime import datetime
|
10 |
from random import choice
|
11 |
from re import compile as re_compile
|
12 |
from re import findall
|
13 |
|
14 |
import requests
|
15 |
+
from bs4 import BeautifulSoup as bs
|
|
|
16 |
from play_scraper import search
|
17 |
from search_engine_parser import GoogleSearch, YahooSearch
|
18 |
from telethon import Button
|
|
|
21 |
from plugins._inline import SUP_BUTTONS
|
22 |
|
23 |
from . import *
|
|
|
24 |
|
25 |
ofox = "https://telegra.ph/file/231f0049fcd722824f13b.jpg"
|
26 |
gugirl = "https://telegra.ph/file/0df54ae4541abca96aa11.jpg"
|
27 |
yeah = "https://telegra.ph/file/e3c67885e16a194937516.jpg"
|
|
|
28 |
ultpic = "https://telegra.ph/file/4136aa1650bc9d4109cc5.jpg"
|
29 |
|
|
|
|
|
30 |
api1 = base64.b64decode("QUl6YVN5QXlEQnNZM1dSdEI1WVBDNmFCX3c4SkF5NlpkWE5jNkZV").decode(
|
31 |
"ascii"
|
32 |
)
|
|
|
41 |
@in_pattern("ofox")
|
42 |
@in_owner
|
43 |
async def _(e):
|
44 |
+
match = None
|
45 |
try:
|
46 |
match = e.text.split(" ", maxsplit=1)[1]
|
47 |
except IndexError:
|
|
|
51 |
text="**OFᴏx🦊Rᴇᴄᴏᴠᴇʀʏ**\n\nYou didn't search anything",
|
52 |
buttons=Button.switch_inline("Sᴇᴀʀᴄʜ Aɢᴀɪɴ", query="ofox ", same_peer=True),
|
53 |
)
|
54 |
+
return await e.answer([kkkk])
|
55 |
+
device, releases = await get_ofox(match)
|
56 |
+
if device.get("detail") is None:
|
|
|
57 |
fox = []
|
58 |
+
fullname = device["full_name"]
|
59 |
+
codename = device["codename"]
|
60 |
+
str(device["supported"])
|
61 |
+
maintainer = device["maintainer"]["name"]
|
62 |
+
link = f"https://orangefox.download/device/{codename}"
|
63 |
+
for data in releases["data"]:
|
64 |
+
release = data["type"]
|
65 |
+
version = data["version"]
|
66 |
+
size = humanbytes(data["size"])
|
67 |
+
release_date = datetime.utcfromtimestamp(data["date"]).strftime("%Y-%m-%d")
|
68 |
+
text = f"[\xad]({ofox})**OʀᴀɴɢᴇFᴏx Rᴇᴄᴏᴠᴇʀʏ Fᴏʀ**\n\n"
|
69 |
+
text += f"` Fᴜʟʟ Nᴀᴍᴇ: {fullname}`\n"
|
70 |
+
text += f"` Cᴏᴅᴇɴᴀᴍᴇ: {codename}`\n"
|
71 |
+
text += f"` Mᴀɪɴᴛᴀɪɴᴇʀ: {maintainer}`\n"
|
72 |
+
text += f"` Bᴜɪʟᴅ Tʏᴘᴇ: {release}`\n"
|
73 |
+
text += f"` Vᴇʀsɪᴏɴ: {version}`\n"
|
74 |
+
text += f"` Sɪᴢᴇ: {size}`\n"
|
75 |
+
text += f"` Bᴜɪʟᴅ Dᴀᴛᴇ: {release_date}`"
|
76 |
+
fox.append(
|
77 |
+
await e.builder.article(
|
78 |
+
title=f"{fullname}",
|
79 |
+
description=f"{version}\n{release_date}",
|
80 |
+
text=text,
|
81 |
+
thumb=wb(ofox, 0, "image/jpeg", []),
|
82 |
+
link_preview=True,
|
83 |
+
buttons=[
|
84 |
+
Button.url("Dᴏᴡɴʟᴏᴀᴅ", url=f"{link}"),
|
85 |
+
Button.switch_inline(
|
86 |
+
"Sᴇᴀʀᴄʜ Aɢᴀɪɴ", query="ofox ", same_peer=True
|
87 |
+
),
|
88 |
+
],
|
89 |
)
|
90 |
+
)
|
91 |
await e.answer(
|
92 |
fox, switch_pm="OrangeFox Recovery Search.", switch_pm_param="start"
|
93 |
)
|
|
|
302 |
await e.builder.article(
|
303 |
title=name,
|
304 |
description=ids,
|
305 |
+
thumb=wb(icon, 0, "image/jpeg", []),
|
306 |
text=text,
|
307 |
link_preview=True,
|
308 |
buttons=[
|
|
|
374 |
await e.answer(modss, switch_pm="Search Mod Applications.", switch_pm_param="start")
|
375 |
|
376 |
|
377 |
+
# Inspired by @FindXDaBot
|
378 |
+
|
379 |
+
|
380 |
+
@in_pattern("xda")
|
381 |
@in_owner
|
382 |
+
async def xda_dev(event):
|
383 |
+
QUERY = event.text.split(" ", maxsplit=1)
|
384 |
try:
|
385 |
+
query = QUERY[1]
|
386 |
except IndexError:
|
387 |
+
return await event.answer(
|
388 |
+
[], switch_pm="Enter Query to Search", switch_pm_param="start"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
389 |
)
|
390 |
+
le = "https://www.xda-developers.com/search/" + query.replace(" ", "+")
|
391 |
+
ct = requests.get(le).content
|
392 |
+
ml = bs(ct, "html.parser", from_encoding="utf-8")
|
393 |
+
ml = ml.find_all("div", re_compile("layout_post_"), id=re_compile("post-"))
|
394 |
+
out = []
|
395 |
+
builder = event.builder
|
396 |
+
for on in ml:
|
397 |
+
data = on.find_all("img", "xda_image")[0]
|
398 |
+
title = data["alt"]
|
399 |
+
thumb = data["src"]
|
400 |
+
hre = on.find_all("div", "item_content")[0].find("h4").find("a")["href"]
|
401 |
+
desc = on.find_all("div", "item_meta clearfix")[0].text
|
402 |
+
thumb = wb(thumb, 0, "image/jpeg", [])
|
403 |
+
text = f"[{title}]({hre})"
|
404 |
+
out.append(
|
405 |
+
await builder.article(
|
406 |
+
title=title, description=desc, url=hre, thumb=thumb, text=text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
)
|
408 |
+
)
|
409 |
+
uppar = "|| XDA Search Results ||"
|
410 |
+
if len(out) == 0:
|
411 |
+
uppar = "No Results Found :("
|
412 |
+
await event.answer(out, switch_pm=uppar, switch_pm_param="start")
|
assistant/manager/__init__.py
CHANGED
@@ -7,5 +7,3 @@
|
|
7 |
|
8 |
|
9 |
from plugins import *
|
10 |
-
|
11 |
-
asst = asst
|
|
|
7 |
|
8 |
|
9 |
from plugins import *
|
|
|
|
assistant/manager/_help.py
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021 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 |
+
START = """
|
11 |
+
🪅 **Help Menu** 🪅
|
12 |
+
|
13 |
+
✘ /start : Check I am Alive or not.
|
14 |
+
✘ /help : Get This Message.
|
15 |
+
✘ /repo : Get Bot's Repo..
|
16 |
+
|
17 |
+
🧑💻 Join **@TheUltroid**
|
18 |
+
"""
|
19 |
+
|
20 |
+
ADMINTOOLS = """✘ **AdminTools** ✘
|
21 |
+
|
22 |
+
• /pin : Pins the Replied Message
|
23 |
+
• /pinned : Get Pinned message in chat.
|
24 |
+
• /unpin : Unpin the Replied message
|
25 |
+
• /unpin all : Unpin all Pinned Messages.
|
26 |
+
|
27 |
+
• /ban (username/id/reply) : Ban the User
|
28 |
+
• /unban (username/id/reply) : UnBan the User.
|
29 |
+
|
30 |
+
• /mute (username/id/reply) : Mute the User.
|
31 |
+
• /unmute (username/id/reply) : Unmute the User.
|
32 |
+
|
33 |
+
• /tban (username/id/reply) (time) : Temporary ban a user
|
34 |
+
• /tmute (username/id/reply) (time) : temporary Mutes a User.
|
35 |
+
|
36 |
+
• /purge (purge messages)
|
37 |
+
|
38 |
+
• /setgpic (reply photo) : keep Chat Photo of Group.
|
39 |
+
• /delgpic : remove current chat Photo."""
|
40 |
+
|
41 |
+
UTILITIES = """
|
42 |
+
✘ ** Utilities ** ✘
|
43 |
+
|
44 |
+
• /info (reply/username/id) : get detailed info of user.
|
45 |
+
• /id : get chat/user id.
|
46 |
+
• /tr : Translate Languages..
|
47 |
+
|
48 |
+
• /paste (reply file/text) : paste content on Spaceb.in
|
49 |
+
• /meaning (text) : Get Meaning of that Word.
|
50 |
+
• /google (query) : Search Something on Google..
|
51 |
+
|
52 |
+
• /suggest (query/reply) : Creates a Yes / No Poll.
|
53 |
+
"""
|
54 |
+
|
55 |
+
LOCKS = """
|
56 |
+
✘ ** Locks ** ✘
|
57 |
+
|
58 |
+
• /lock (query) : lock particular content in chat.
|
59 |
+
• /unlock (query) : Unlock some content.
|
60 |
+
|
61 |
+
• All Queries
|
62 |
+
- `msgs` : for messages.
|
63 |
+
- `inlines` : for inline queries.
|
64 |
+
- `media` : for all medias.
|
65 |
+
- `games` : for games.
|
66 |
+
- `sticker` : for stickers.
|
67 |
+
- `polls` : for polls.
|
68 |
+
- `gif` : for gifs.
|
69 |
+
- `pin` : for pins.
|
70 |
+
- `changeinfo` : for change info right.
|
71 |
+
"""
|
72 |
+
|
73 |
+
MISC = """
|
74 |
+
✘ **Misc** ✘
|
75 |
+
|
76 |
+
• /joke : Get Random Jokes.
|
77 |
+
"""
|
78 |
+
|
79 |
+
STRINGS = {"Admintools": ADMINTOOLS, "locks": LOCKS, "Utils": UTILITIES, "Misc": MISC}
|
80 |
+
|
81 |
+
MNGE = udB.get("MNGR_EMOJI") or "•"
|
82 |
+
|
83 |
+
|
84 |
+
def get_buttons():
|
85 |
+
BTTS = []
|
86 |
+
keys = STRINGS.copy()
|
87 |
+
while keys:
|
88 |
+
BT = []
|
89 |
+
for i in list(keys)[:2]:
|
90 |
+
text = MNGE + " " + i + " " + MNGE
|
91 |
+
BT.append(Button.inline(text, "hlp_" + i))
|
92 |
+
del keys[i]
|
93 |
+
BTTS.append(BT)
|
94 |
+
url = "https://t.me/" + asst.me.username + "?startgroup=true"
|
95 |
+
BTTS.append([Button.url("Add me to Group", url)])
|
96 |
+
return BTTS
|
97 |
+
|
98 |
+
|
99 |
+
@asst_cmd("help")
|
100 |
+
async def helpish(event):
|
101 |
+
if not event.is_private:
|
102 |
+
url = "https://t.me/" + asst.me.username + "?start=start"
|
103 |
+
return await event.reply(
|
104 |
+
"Contact me in PM for help!", buttons=Button.url("Click me for Help", url)
|
105 |
+
)
|
106 |
+
if str(event.sender_id) in owner_and_sudos() and (
|
107 |
+
udB.get("DUAL_MODE") and (udB.get("DUAL_HNDLR") == "/")
|
108 |
+
):
|
109 |
+
return
|
110 |
+
BTTS = get_buttons()
|
111 |
+
await event.reply(START, buttons=BTTS)
|
112 |
+
|
113 |
+
|
114 |
+
@callback("mngbtn")
|
115 |
+
@owner
|
116 |
+
async def ehwhshd(e):
|
117 |
+
buttons = get_buttons()
|
118 |
+
buttons[-1].append(Button.inline("<< Back", "open"))
|
119 |
+
await e.edit(buttons=buttons)
|
120 |
+
|
121 |
+
|
122 |
+
@callback("mnghome")
|
123 |
+
async def home_aja(e):
|
124 |
+
await e.edit(START, buttons=get_buttons())
|
125 |
+
|
126 |
+
|
127 |
+
@callback(re.compile("hlp_(.*)"))
|
128 |
+
async def do_something(event):
|
129 |
+
match = event.pattern_match.group(1).decode("utf-8")
|
130 |
+
await event.edit(STRINGS[match], buttons=Button.inline("<< Back", "mnghome"))
|
vcbot/vchelp.py → assistant/manager/_on_adds.py
RENAMED
@@ -7,23 +7,17 @@
|
|
7 |
|
8 |
from . import *
|
9 |
|
10 |
-
HELP_TEXT = "**View All Vc Commands Here :**\nhttps://telegra.ph/Vc-Commands-07-17-2"
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
& filters.outgoing
|
26 |
-
& ~(filters.edited | filters.forwarded)
|
27 |
-
)
|
28 |
-
async def always(_, message):
|
29 |
-
await eor(message, HELP_TEXT)
|
|
|
7 |
|
8 |
from . import *
|
9 |
|
|
|
10 |
|
11 |
+
@asst.on(events.ChatAction())
|
12 |
+
async def dueha(e):
|
13 |
+
if not e.user_added:
|
14 |
+
return
|
15 |
+
user = await e.get_user()
|
16 |
+
if not user.is_self:
|
17 |
+
return
|
18 |
+
sm = udB.get("ON_MNGR_ADD")
|
19 |
+
if sm == "OFF":
|
20 |
+
return
|
21 |
+
if not sm:
|
22 |
+
sm = "Thanks for Adding me :)"
|
23 |
+
await e.reply(sm, link_preview=False)
|
|
|
|
|
|
|
|
|
|
assistant/manager/admins.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021 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 |
+
|
11 |
+
@ultroid_cmd(pattern="dkick", type=["manager", "official"])
|
12 |
+
async def dowj(e):
|
13 |
+
replied = await e.get_reply_message()
|
14 |
+
if replied:
|
15 |
+
user = replied.sender_id
|
16 |
+
else:
|
17 |
+
return await eor(e, "Reply to a message...")
|
18 |
+
try:
|
19 |
+
await replied.delete()
|
20 |
+
await e.client.kick_participant(e.chat_id, user)
|
21 |
+
await eor(e, "Kicked Successfully!")
|
22 |
+
except Exception as E:
|
23 |
+
await eor(e, str(E))
|
24 |
+
|
25 |
+
|
26 |
+
@ultroid_cmd(pattern="dban", type=["manager", "official"])
|
27 |
+
async def dowj(e):
|
28 |
+
replied = await e.get_reply_message()
|
29 |
+
if replied:
|
30 |
+
user = replied.sender_id
|
31 |
+
else:
|
32 |
+
return await eor(e, "Reply to a message...")
|
33 |
+
try:
|
34 |
+
await replied.delete()
|
35 |
+
await e.client.edit_permissions(e.chat_id, user, view_messages=False)
|
36 |
+
await eor(e, "Banned Successfully!")
|
37 |
+
except Exception as E:
|
38 |
+
await eor(e, str(E))
|
assistant/manager/misc.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021 TeamUltroid
|
3 |
+
#
|
4 |
+
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
+
# PLease read the GNU Affero General Public License in
|
6 |
+
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
7 |
+
|
8 |
+
|
9 |
+
import aiohttp
|
10 |
+
|
11 |
+
from . import *
|
12 |
+
|
13 |
+
|
14 |
+
@ultroid_cmd(pattern="echo ?(.*)", type=["manager"])
|
15 |
+
async def oqha(e):
|
16 |
+
match = e.pattern_match.group(1)
|
17 |
+
if match:
|
18 |
+
text = match
|
19 |
+
reply_to = e
|
20 |
+
elif e.is_reply:
|
21 |
+
text = (await e.get_reply_message()).text
|
22 |
+
reply_to = e.reply_to_msg_id
|
23 |
+
else:
|
24 |
+
return await eor(e, "What to Echo?", time=5)
|
25 |
+
await e.client.send_message(e.chat_id, text, reply_to=reply_to)
|
26 |
+
|
27 |
+
|
28 |
+
@ultroid_cmd(pattern="kickme$", type=["manager"], allow_all=True)
|
29 |
+
async def doit(e):
|
30 |
+
if e.sender_id in DEVLIST:
|
31 |
+
return await eod(e, "`I will Not Kick You, my Developer..`")
|
32 |
+
try:
|
33 |
+
await e.client.kick_participant(e.chat_id, e.sender_id)
|
34 |
+
except Exception as Fe:
|
35 |
+
return await eor(e, str(Fe), time=5)
|
36 |
+
await eor(e, "Yes, You are right, get out.", time=5)
|
37 |
+
|
38 |
+
|
39 |
+
@ultroid_cmd(pattern="joke$", type=["manager"])
|
40 |
+
async def do_joke(e):
|
41 |
+
e = await e.get_reply_message() if e.is_reply else e
|
42 |
+
link = "https://v2.jokeapi.dev/joke/Any?blacklistFlags=nsfw,religious,political,racist,sexist,explicit&type=single"
|
43 |
+
async with aiohttp.ClientSession() as ses:
|
44 |
+
async with ses.get(link) as out:
|
45 |
+
out = await out.json()
|
46 |
+
await e.reply(out["joke"])
|
assistant/ping.py
CHANGED
@@ -12,9 +12,7 @@ from datetime import datetime
|
|
12 |
@owner
|
13 |
async def _(event):
|
14 |
start = datetime.now()
|
|
|
15 |
end = datetime.now()
|
16 |
ms = (end - start).microseconds / 1000
|
17 |
-
await
|
18 |
-
event.chat_id,
|
19 |
-
f"**Pong!!**\n `{ms} milliseconds`",
|
20 |
-
)
|
|
|
12 |
@owner
|
13 |
async def _(event):
|
14 |
start = datetime.now()
|
15 |
+
msg = await event.reply("Pong!")
|
16 |
end = datetime.now()
|
17 |
ms = (end - start).microseconds / 1000
|
18 |
+
await msg.edit(f"**Pong!!**\n `{ms} ms`")
|
|
|
|
|
|
assistant/piston.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021 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 pistonapi import PistonAPI
|
9 |
+
|
10 |
+
from . import *
|
11 |
+
|
12 |
+
|
13 |
+
@in_pattern("run")
|
14 |
+
async def piston_run(event):
|
15 |
+
piston = PistonAPI()
|
16 |
+
version = None
|
17 |
+
try:
|
18 |
+
lang = event.text.split()[1]
|
19 |
+
code = event.text.split(maxsplit=2)[2]
|
20 |
+
except IndexError:
|
21 |
+
result = await event.builder.article(
|
22 |
+
title="Bad Query",
|
23 |
+
description="Usage: [Language] [code]",
|
24 |
+
text=f'**Inline Usage**\n\n`@{asst.me.username} run python print("hello world")`\n\n[Language List](https://telegra.ph/Ultroid-09-01-6)',
|
25 |
+
)
|
26 |
+
return await event.answer([result])
|
27 |
+
if lang in piston.languages.keys():
|
28 |
+
version = piston.languages[lang]["version"]
|
29 |
+
if not version:
|
30 |
+
result = await event.builder.article(
|
31 |
+
title="Unsupported Language",
|
32 |
+
description="Usage: [Language] [code]",
|
33 |
+
text=f'**Inline Usage**\n\n`@{asst.me.username} run python print("hello world")`\n\n[Language List](https://telegra.ph/Ultroid-09-01-6)',
|
34 |
+
)
|
35 |
+
return await event.answer([result])
|
36 |
+
output = piston.execute(language=lang, version=version, code=code) or "Success"
|
37 |
+
if len(output) > 3000:
|
38 |
+
output = output[:3000] + "..."
|
39 |
+
result = await event.builder.article(
|
40 |
+
title="Result",
|
41 |
+
description=output,
|
42 |
+
text=f"• **Language:**\n`{lang}`\n\n• **Code:**\n`{code}`\n\n• **Result:**\n`{output}`",
|
43 |
+
buttons=Button.switch_inline("Fork", query=event.text, same_peer=True),
|
44 |
+
)
|
45 |
+
await event.answer([result], switch_pm="• Piston •", switch_pm_param="start")
|
assistant/pmbot/banuser.py
CHANGED
@@ -17,15 +17,15 @@ async def banhammer(event):
|
|
17 |
if x is None:
|
18 |
return await event.edit("Please reply to someone to ban him.")
|
19 |
target = get_who(x.id)
|
20 |
-
if
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
|
31 |
@asst_cmd("unban")
|
@@ -37,9 +37,9 @@ async def banhammer(event):
|
|
37 |
if x is None:
|
38 |
return await event.edit("Please reply to someone to ban him.")
|
39 |
target = get_who(x.id)
|
40 |
-
if is_blacklisted(target):
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
17 |
if x is None:
|
18 |
return await event.edit("Please reply to someone to ban him.")
|
19 |
target = get_who(x.id)
|
20 |
+
if is_blacklisted(target):
|
21 |
+
return await asst.send_message(event.chat_id, "User is already banned!")
|
22 |
+
|
23 |
+
blacklist_user(target)
|
24 |
+
await asst.send_message(event.chat_id, f"#BAN\nUser - {target}")
|
25 |
+
await asst.send_message(
|
26 |
+
target,
|
27 |
+
"`GoodBye! You have been banned.`\n**Further messages you send will not be forwarded.**",
|
28 |
+
)
|
29 |
|
30 |
|
31 |
@asst_cmd("unban")
|
|
|
37 |
if x is None:
|
38 |
return await event.edit("Please reply to someone to ban him.")
|
39 |
target = get_who(x.id)
|
40 |
+
if not is_blacklisted(target):
|
41 |
+
return await asst.send_message(event.chat_id, "User was never banned!")
|
42 |
+
|
43 |
+
rem_blacklist(target)
|
44 |
+
await asst.send_message(event.chat_id, f"#UNBAN\nUser - {target}")
|
45 |
+
await asst.send_message(target, "`Congrats! You have been unbanned.`")
|
assistant/pmbot/incoming.py
CHANGED
@@ -19,15 +19,11 @@ from . import *
|
|
19 |
|
20 |
@asst.on(events.NewMessage(incoming=True, func=lambda e: e.is_private))
|
21 |
async def on_new_mssg(event):
|
22 |
-
incoming = event.raw_text
|
23 |
who = event.sender_id
|
24 |
if is_blacklisted(who):
|
25 |
return
|
26 |
# doesn't reply to that user anymore
|
27 |
-
if
|
28 |
-
pass
|
29 |
-
elif who == OWNER_ID:
|
30 |
return
|
31 |
-
|
32 |
-
|
33 |
-
add_stuff(xx.id, who)
|
|
|
19 |
|
20 |
@asst.on(events.NewMessage(incoming=True, func=lambda e: e.is_private))
|
21 |
async def on_new_mssg(event):
|
|
|
22 |
who = event.sender_id
|
23 |
if is_blacklisted(who):
|
24 |
return
|
25 |
# doesn't reply to that user anymore
|
26 |
+
if event.text.startswith("/") or who == OWNER_ID:
|
|
|
|
|
27 |
return
|
28 |
+
xx = await event.forward_to(OWNER_ID)
|
29 |
+
add_stuff(xx.id, who)
|
|
assistant/pmbot/outgoing.py
CHANGED
@@ -17,23 +17,18 @@ from . import *
|
|
17 |
@asst.on(events.NewMessage(incoming=True, func=lambda e: e.is_private))
|
18 |
async def on_out_mssg(event):
|
19 |
x = await event.get_reply_message()
|
20 |
-
if x
|
21 |
return
|
22 |
who = event.sender_id
|
23 |
if who == OWNER_ID:
|
24 |
to_user = get_who(x.id)
|
25 |
if event.text.startswith("/who"):
|
26 |
try:
|
27 |
-
k = await asst.get_entity(
|
28 |
return await event.reply(f"[{k.first_name}](tg://user?id={k.id})")
|
29 |
except BaseException:
|
30 |
return
|
31 |
elif event.text.startswith("/"):
|
32 |
return
|
33 |
-
if
|
34 |
-
|
35 |
-
await asst.send_file(int(to_user), event.media, caption=event.text)
|
36 |
-
else:
|
37 |
-
await asst.send_file(int(to_user), event.media)
|
38 |
-
else:
|
39 |
-
await asst.send_message(int(to_user), event.text)
|
|
|
17 |
@asst.on(events.NewMessage(incoming=True, func=lambda e: e.is_private))
|
18 |
async def on_out_mssg(event):
|
19 |
x = await event.get_reply_message()
|
20 |
+
if not x:
|
21 |
return
|
22 |
who = event.sender_id
|
23 |
if who == OWNER_ID:
|
24 |
to_user = get_who(x.id)
|
25 |
if event.text.startswith("/who"):
|
26 |
try:
|
27 |
+
k = await asst.get_entity(to_user)
|
28 |
return await event.reply(f"[{k.first_name}](tg://user?id={k.id})")
|
29 |
except BaseException:
|
30 |
return
|
31 |
elif event.text.startswith("/"):
|
32 |
return
|
33 |
+
if to_user:
|
34 |
+
await asst.send_message(to_user, event.message)
|
|
|
|
|
|
|
|
|
|
assistant/start.py
CHANGED
@@ -19,11 +19,11 @@ from . import *
|
|
19 |
|
20 |
Owner_info_msg = f"""
|
21 |
<strong>Owner</strong> - {OWNER_NAME}
|
22 |
-
<
|
23 |
|
24 |
<strong>Message Forwards</strong> - {udB.get("PMBOT")}
|
25 |
|
26 |
-
<
|
27 |
"""
|
28 |
|
29 |
_settings = [
|
@@ -35,8 +35,10 @@ _settings = [
|
|
35 |
Button.inline("Aʟɪᴠᴇ", data="alvcstm"),
|
36 |
Button.inline("PᴍPᴇʀᴍɪᴛ", data="ppmset"),
|
37 |
],
|
38 |
-
[
|
39 |
-
|
|
|
|
|
40 |
[Button.inline("« Bᴀᴄᴋ", data="mainmenu")],
|
41 |
]
|
42 |
|
@@ -57,7 +59,7 @@ _start = [
|
|
57 |
async def own(event):
|
58 |
await event.edit(
|
59 |
Owner_info_msg,
|
60 |
-
buttons=[Button.inline("Close", data=
|
61 |
link_preview=False,
|
62 |
parse_mode="html",
|
63 |
)
|
@@ -72,41 +74,37 @@ async def closet(lol):
|
|
72 |
async def ultroid(event):
|
73 |
if event.is_group:
|
74 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
else:
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
ok = ""
|
83 |
-
u = await event.client.get_entity(event.chat_id)
|
84 |
-
if not udB.get("STARTMSG"):
|
85 |
-
if udB.get("PMBOT") == "True":
|
86 |
-
ok = "You can contact my master using this bot!!\n\nSend your Message, I will Deliver it To Master."
|
87 |
-
await event.reply(
|
88 |
-
f"Hey there [{get_display_name(u)}](tg://user?id={u.id}), this is Ultroid Assistant of [{ultroid_bot.me.first_name}](tg://user?id={ultroid_bot.uid})!\n\n{ok}",
|
89 |
-
buttons=[Button.inline("Info.", data="ownerinfo")],
|
90 |
-
)
|
91 |
-
else:
|
92 |
-
me = f"[{ultroid_bot.me.first_name}](tg://user?id={ultroid_bot.uid})"
|
93 |
-
mention = f"[{get_display_name(u)}](tg://user?id={u.id})"
|
94 |
-
await event.reply(
|
95 |
-
Redis("STARTMSG").format(me=me, mention=mention),
|
96 |
-
buttons=[Button.inline("Info.", data="ownerinfo")],
|
97 |
-
)
|
98 |
else:
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
buttons=_settings,
|
104 |
-
)
|
105 |
-
else:
|
106 |
-
await event.reply(
|
107 |
-
get_string("ast_3").format(name),
|
108 |
-
buttons=_start,
|
109 |
-
)
|
110 |
|
111 |
|
112 |
@callback("mainmenu")
|
@@ -145,26 +143,25 @@ async def bdcast(event):
|
|
145 |
themssg = response.message.message
|
146 |
if themssg == "/cancel":
|
147 |
return await conv.send_message("Cancelled!!")
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
f"""
|
163 |
Broadcast completed in {time_taken} seconds.
|
164 |
Total Users in Bot - {len(ok)}
|
165 |
Sent to {success} users.
|
166 |
Failed for {fail} user(s).""",
|
167 |
-
|
168 |
|
169 |
|
170 |
@callback("setter")
|
@@ -195,16 +192,15 @@ async def timezone_(event):
|
|
195 |
"Cancelled!!",
|
196 |
buttons=get_back_button("mainmenu"),
|
197 |
)
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
)
|
|
|
19 |
|
20 |
Owner_info_msg = f"""
|
21 |
<strong>Owner</strong> - {OWNER_NAME}
|
22 |
+
<strong>OwnerID</strong> - <code>{OWNER_ID}</code>
|
23 |
|
24 |
<strong>Message Forwards</strong> - {udB.get("PMBOT")}
|
25 |
|
26 |
+
<strong>Ultroid <a href=https://github.com/TeamUltroid/Ultroid>[v{ultroid_version}]</a>, powered by @TeamUltroid</strong>
|
27 |
"""
|
28 |
|
29 |
_settings = [
|
|
|
35 |
Button.inline("Aʟɪᴠᴇ", data="alvcstm"),
|
36 |
Button.inline("PᴍPᴇʀᴍɪᴛ", data="ppmset"),
|
37 |
],
|
38 |
+
[
|
39 |
+
Button.inline("Fᴇᴀᴛᴜʀᴇs", data="otvars"),
|
40 |
+
Button.inline("VC Sᴏɴɢ Bᴏᴛ", data="vcb"),
|
41 |
+
],
|
42 |
[Button.inline("« Bᴀᴄᴋ", data="mainmenu")],
|
43 |
]
|
44 |
|
|
|
59 |
async def own(event):
|
60 |
await event.edit(
|
61 |
Owner_info_msg,
|
62 |
+
buttons=[Button.inline("Close", data="closeit")],
|
63 |
link_preview=False,
|
64 |
parse_mode="html",
|
65 |
)
|
|
|
74 |
async def ultroid(event):
|
75 |
if event.is_group:
|
76 |
return
|
77 |
+
if not is_added(event.sender_id) and str(event.sender_id) not in owner_and_sudos():
|
78 |
+
add_user(event.sender_id)
|
79 |
+
if str(event.sender_id) not in owner_and_sudos():
|
80 |
+
ok = ""
|
81 |
+
u = await event.client.get_entity(event.chat_id)
|
82 |
+
if not udB.get("STARTMSG"):
|
83 |
+
if udB.get("PMBOT") == "True":
|
84 |
+
ok = "You can contact my master using this bot!!\n\nSend your Message, I will Deliver it To Master."
|
85 |
+
await event.reply(
|
86 |
+
f"Hey there [{get_display_name(u)}](tg://user?id={u.id}), this is Ultroid Assistant of [{ultroid_bot.me.first_name}](tg://user?id={ultroid_bot.uid})!\n\n{ok}",
|
87 |
+
buttons=[Button.inline("Info.", data="ownerinfo")],
|
88 |
+
)
|
89 |
+
else:
|
90 |
+
me = f"[{ultroid_bot.me.first_name}](tg://user?id={ultroid_bot.uid})"
|
91 |
+
mention = f"[{get_display_name(u)}](tg://user?id={u.id})"
|
92 |
+
await event.reply(
|
93 |
+
Redis("STARTMSG").format(me=me, mention=mention),
|
94 |
+
buttons=[Button.inline("Info.", data="ownerinfo")],
|
95 |
+
)
|
96 |
else:
|
97 |
+
name = get_display_name(event.sender_id)
|
98 |
+
if event.pattern_match.group(1) == "set":
|
99 |
+
await event.reply(
|
100 |
+
"Choose from the below options -",
|
101 |
+
buttons=_settings,
|
102 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
else:
|
104 |
+
await event.reply(
|
105 |
+
get_string("ast_3").format(name),
|
106 |
+
buttons=_start,
|
107 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
|
110 |
@callback("mainmenu")
|
|
|
143 |
themssg = response.message.message
|
144 |
if themssg == "/cancel":
|
145 |
return await conv.send_message("Cancelled!!")
|
146 |
+
success = 0
|
147 |
+
fail = 0
|
148 |
+
await conv.send_message(f"Starting a broadcast to {len(ok)} users...")
|
149 |
+
start = datetime.now()
|
150 |
+
for i in ok:
|
151 |
+
try:
|
152 |
+
await asst.send_message(int(i), f"{themssg}")
|
153 |
+
success += 1
|
154 |
+
except BaseException:
|
155 |
+
fail += 1
|
156 |
+
end = datetime.now()
|
157 |
+
time_taken = (end - start).seconds
|
158 |
+
await conv.send_message(
|
159 |
+
f"""
|
|
|
160 |
Broadcast completed in {time_taken} seconds.
|
161 |
Total Users in Bot - {len(ok)}
|
162 |
Sent to {success} users.
|
163 |
Failed for {fail} user(s).""",
|
164 |
+
)
|
165 |
|
166 |
|
167 |
@callback("setter")
|
|
|
192 |
"Cancelled!!",
|
193 |
buttons=get_back_button("mainmenu"),
|
194 |
)
|
195 |
+
try:
|
196 |
+
tz(themssg)
|
197 |
+
await setit(event, var, themssg)
|
198 |
+
await conv.send_message(
|
199 |
+
f"{name} changed to {themssg}\n",
|
200 |
+
buttons=get_back_button("mainmenu"),
|
201 |
+
)
|
202 |
+
except BaseException:
|
203 |
+
await conv.send_message(
|
204 |
+
"Wrong TimeZone, Try again",
|
205 |
+
buttons=get_back_button("mainmenu"),
|
206 |
+
)
|
|
assistant/ytdl.py
CHANGED
@@ -9,14 +9,12 @@
|
|
9 |
import os
|
10 |
import re
|
11 |
import time
|
12 |
-
from urllib.request import urlretrieve
|
13 |
|
14 |
from numerize import numerize
|
15 |
from pyUltroid.functions.all import *
|
16 |
from telethon import Button
|
17 |
from telethon.tl.types import DocumentAttributeAudio, DocumentAttributeVideo
|
18 |
from telethon.tl.types import InputWebDocument as wb
|
19 |
-
from youtube_dl import YoutubeDL
|
20 |
from youtubesearchpython import VideosSearch
|
21 |
|
22 |
ytt = "https://telegra.ph/file/afd04510c13914a06dd03.jpg"
|
@@ -24,6 +22,7 @@ _yt_base_url = "https://www.youtube.com/watch?v="
|
|
24 |
|
25 |
|
26 |
@in_pattern("yt")
|
|
|
27 |
async def _(event):
|
28 |
try:
|
29 |
string = event.text.split(" ", maxsplit=1)[1]
|
@@ -128,12 +127,18 @@ async def _(event):
|
|
128 |
"quiet": True,
|
129 |
"logtostderr": False,
|
130 |
}
|
131 |
-
ytdl_data = await dler(event, link)
|
132 |
-
YoutubeDL(opts).download([link])
|
133 |
title = ytdl_data["title"]
|
134 |
-
|
|
|
|
|
|
|
|
|
|
|
135 |
views = numerize.numerize(ytdl_data["view_count"])
|
136 |
-
|
|
|
|
|
137 |
thumb = f"{title}.jpg"
|
138 |
duration = ytdl_data["duration"]
|
139 |
os.rename(f"{ytdl_data['id']}.mp3", f"{title}.mp3")
|
@@ -159,13 +164,19 @@ async def _(event):
|
|
159 |
"logtostderr": False,
|
160 |
"quiet": True,
|
161 |
}
|
162 |
-
ytdl_data = await dler(event, link)
|
163 |
-
YoutubeDL(opts).download([link])
|
164 |
title = ytdl_data["title"]
|
165 |
-
|
|
|
|
|
|
|
|
|
|
|
166 |
views = numerize.numerize(ytdl_data["view_count"])
|
167 |
-
|
168 |
-
|
|
|
|
|
169 |
duration = ytdl_data["duration"]
|
170 |
try:
|
171 |
os.rename(f"{ytdl_data['id']}.mp4", f"{title}.mp4")
|
@@ -173,11 +184,9 @@ async def _(event):
|
|
173 |
try:
|
174 |
os.rename(f"{ytdl_data['id']}.mkv", f"{title}.mp4")
|
175 |
except FileNotFoundError:
|
176 |
-
os.rename(f"{ytdl_data['id']}.webm", f"{title}.mp4")
|
177 |
except Exception as ex:
|
178 |
return await event.edit(str(ex))
|
179 |
-
wi, _ = await bash(f'mediainfo "{title}.mp4" | grep "Width"')
|
180 |
-
hi, _ = await bash(f'mediainfo "{title}.mp4" | grep "Height"')
|
181 |
c_time = time.time()
|
182 |
file = await uploader(
|
183 |
f"{title}.mp4", f"{title}.mp4", c_time, event, "Uploading " + title + "..."
|
@@ -185,8 +194,8 @@ async def _(event):
|
|
185 |
attributes = [
|
186 |
DocumentAttributeVideo(
|
187 |
duration=int(duration),
|
188 |
-
w=
|
189 |
-
h=
|
190 |
supports_streaming=True,
|
191 |
),
|
192 |
]
|
@@ -201,4 +210,4 @@ async def _(event):
|
|
201 |
attributes=attributes,
|
202 |
thumb=thumb,
|
203 |
)
|
204 |
-
|
|
|
9 |
import os
|
10 |
import re
|
11 |
import time
|
|
|
12 |
|
13 |
from numerize import numerize
|
14 |
from pyUltroid.functions.all import *
|
15 |
from telethon import Button
|
16 |
from telethon.tl.types import DocumentAttributeAudio, DocumentAttributeVideo
|
17 |
from telethon.tl.types import InputWebDocument as wb
|
|
|
18 |
from youtubesearchpython import VideosSearch
|
19 |
|
20 |
ytt = "https://telegra.ph/file/afd04510c13914a06dd03.jpg"
|
|
|
22 |
|
23 |
|
24 |
@in_pattern("yt")
|
25 |
+
@in_owner
|
26 |
async def _(event):
|
27 |
try:
|
28 |
string = event.text.split(" ", maxsplit=1)[1]
|
|
|
127 |
"quiet": True,
|
128 |
"logtostderr": False,
|
129 |
}
|
130 |
+
ytdl_data = await dler(event, link, opts, True)
|
|
|
131 |
title = ytdl_data["title"]
|
132 |
+
if ytdl_data.get("artist"):
|
133 |
+
artist = ytdl_data["artist"]
|
134 |
+
elif ytdl_data.get("creator"):
|
135 |
+
artist = ytdl_data["creator"]
|
136 |
+
elif ytdl_data.get("channel"):
|
137 |
+
artist = ytdl_data["channel"]
|
138 |
views = numerize.numerize(ytdl_data["view_count"])
|
139 |
+
await download_file(
|
140 |
+
f"https://i.ytimg.com/vi/{vid_id}/hqdefault.jpg", f"{title}.jpg"
|
141 |
+
)
|
142 |
thumb = f"{title}.jpg"
|
143 |
duration = ytdl_data["duration"]
|
144 |
os.rename(f"{ytdl_data['id']}.mp3", f"{title}.mp3")
|
|
|
164 |
"logtostderr": False,
|
165 |
"quiet": True,
|
166 |
}
|
167 |
+
ytdl_data = await dler(event, link, opts, True)
|
|
|
168 |
title = ytdl_data["title"]
|
169 |
+
if ytdl_data.get("artist"):
|
170 |
+
artist = ytdl_data["artist"]
|
171 |
+
elif ytdl_data.get("creator"):
|
172 |
+
artist = ytdl_data["creator"]
|
173 |
+
elif ytdl_data.get("channel"):
|
174 |
+
artist = ytdl_data["channel"]
|
175 |
views = numerize.numerize(ytdl_data["view_count"])
|
176 |
+
thumb = await fast_download(
|
177 |
+
f"https://i.ytimg.com/vi/{vid_id}/hqdefault.jpg", filename=f"{title}.jpg"
|
178 |
+
)
|
179 |
+
hi, wi = ytdl_data["height"], ytdl_data["width"]
|
180 |
duration = ytdl_data["duration"]
|
181 |
try:
|
182 |
os.rename(f"{ytdl_data['id']}.mp4", f"{title}.mp4")
|
|
|
184 |
try:
|
185 |
os.rename(f"{ytdl_data['id']}.mkv", f"{title}.mp4")
|
186 |
except FileNotFoundError:
|
187 |
+
os.rename(f"{ytdl_data['id']}.mp4.webm", f"{title}.mp4")
|
188 |
except Exception as ex:
|
189 |
return await event.edit(str(ex))
|
|
|
|
|
190 |
c_time = time.time()
|
191 |
file = await uploader(
|
192 |
f"{title}.mp4", f"{title}.mp4", c_time, event, "Uploading " + title + "..."
|
|
|
194 |
attributes = [
|
195 |
DocumentAttributeVideo(
|
196 |
duration=int(duration),
|
197 |
+
w=wi,
|
198 |
+
h=hi,
|
199 |
supports_streaming=True,
|
200 |
),
|
201 |
]
|
|
|
210 |
attributes=attributes,
|
211 |
thumb=thumb,
|
212 |
)
|
213 |
+
await bash(f'rm "{title}"*')
|
plugins/_ChatActions.py
CHANGED
@@ -1,9 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from pyUltroid.functions.all import get_chatbot_reply
|
2 |
from pyUltroid.functions.chatBot_db import chatbot_stats
|
3 |
from pyUltroid.functions.clean_db import *
|
4 |
from pyUltroid.functions.forcesub_db import *
|
5 |
from pyUltroid.functions.gban_mute_db import *
|
6 |
from pyUltroid.functions.greetings_db import *
|
|
|
7 |
from telethon.errors.rpcerrorlist import UserNotParticipantError
|
8 |
from telethon.tl.functions.channels import GetParticipantRequest
|
9 |
from telethon.utils import get_display_name
|
@@ -48,21 +57,20 @@ async def ChatActionsHandler(ult): # sourcery no-metrics
|
|
48 |
await res[0].click(ult.chat_id, reply_to=ult.action_message.id)
|
49 |
|
50 |
# gban checks
|
51 |
-
if ult.user_joined
|
52 |
user = await ult.get_user()
|
53 |
chat = await ult.get_chat()
|
54 |
-
|
|
|
55 |
try:
|
56 |
await ultroid_bot.edit_permissions(
|
57 |
chat.id,
|
58 |
user.id,
|
59 |
view_messages=False,
|
60 |
)
|
61 |
-
reason = get_gban_reason(user.id)
|
62 |
gban_watch = f"#GBanned_User Joined.\n\n**User** - [{user.first_name}](tg://user?id={user.id})\n"
|
63 |
-
|
64 |
-
|
65 |
-
gban_watch += f"`User Banned.`"
|
66 |
await ult.reply(gban_watch)
|
67 |
except BaseException:
|
68 |
pass
|
@@ -80,6 +88,7 @@ async def ChatActionsHandler(ult): # sourcery no-metrics
|
|
80 |
fullname = f"{name} {last}" if last else name
|
81 |
uu = user.username
|
82 |
username = f"@{uu}" if uu else mention
|
|
|
83 |
msgg = wel["welcome"]
|
84 |
med = wel["media"]
|
85 |
userid = user.id
|
@@ -98,7 +107,7 @@ async def ChatActionsHandler(ult): # sourcery no-metrics
|
|
98 |
)
|
99 |
await asyncio.sleep(150)
|
100 |
await send.delete()
|
101 |
-
elif not is_gbanned(
|
102 |
await ult.reply(file=med)
|
103 |
if (ult.user_left or ult.user_kicked) and get_goodbye(ult.chat_id):
|
104 |
user = await ult.get_user()
|
@@ -112,6 +121,7 @@ async def ChatActionsHandler(ult): # sourcery no-metrics
|
|
112 |
fullname = f"{name} {last}" if last else name
|
113 |
uu = user.username
|
114 |
username = f"@{uu}" if uu else mention
|
|
|
115 |
msgg = wel["goodbye"]
|
116 |
med = wel["media"]
|
117 |
userid = user.id
|
@@ -135,8 +145,47 @@ async def ChatActionsHandler(ult): # sourcery no-metrics
|
|
135 |
|
136 |
|
137 |
@ultroid_bot.on(events.NewMessage(incoming=True))
|
138 |
-
async def chatBot_replies(
|
139 |
-
|
140 |
-
|
|
|
|
|
|
|
141 |
if msg:
|
142 |
-
await
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021 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 |
from pyUltroid.functions.all import get_chatbot_reply
|
10 |
from pyUltroid.functions.chatBot_db import chatbot_stats
|
11 |
from pyUltroid.functions.clean_db import *
|
12 |
from pyUltroid.functions.forcesub_db import *
|
13 |
from pyUltroid.functions.gban_mute_db import *
|
14 |
from pyUltroid.functions.greetings_db import *
|
15 |
+
from pyUltroid.functions.username_db import *
|
16 |
from telethon.errors.rpcerrorlist import UserNotParticipantError
|
17 |
from telethon.tl.functions.channels import GetParticipantRequest
|
18 |
from telethon.utils import get_display_name
|
|
|
57 |
await res[0].click(ult.chat_id, reply_to=ult.action_message.id)
|
58 |
|
59 |
# gban checks
|
60 |
+
if ult.user_joined or ult.added_by:
|
61 |
user = await ult.get_user()
|
62 |
chat = await ult.get_chat()
|
63 |
+
reason = is_gbanned(user.id)
|
64 |
+
if reason and chat.admin_rights:
|
65 |
try:
|
66 |
await ultroid_bot.edit_permissions(
|
67 |
chat.id,
|
68 |
user.id,
|
69 |
view_messages=False,
|
70 |
)
|
|
|
71 |
gban_watch = f"#GBanned_User Joined.\n\n**User** - [{user.first_name}](tg://user?id={user.id})\n"
|
72 |
+
gban_watch += f"**Reason**: {reason}\n\n"
|
73 |
+
gban_watch += "`User Banned.`"
|
|
|
74 |
await ult.reply(gban_watch)
|
75 |
except BaseException:
|
76 |
pass
|
|
|
88 |
fullname = f"{name} {last}" if last else name
|
89 |
uu = user.username
|
90 |
username = f"@{uu}" if uu else mention
|
91 |
+
wel = get_welcome(ult.chat_id)
|
92 |
msgg = wel["welcome"]
|
93 |
med = wel["media"]
|
94 |
userid = user.id
|
|
|
107 |
)
|
108 |
await asyncio.sleep(150)
|
109 |
await send.delete()
|
110 |
+
elif not is_gbanned(user.id):
|
111 |
await ult.reply(file=med)
|
112 |
if (ult.user_left or ult.user_kicked) and get_goodbye(ult.chat_id):
|
113 |
user = await ult.get_user()
|
|
|
121 |
fullname = f"{name} {last}" if last else name
|
122 |
uu = user.username
|
123 |
username = f"@{uu}" if uu else mention
|
124 |
+
wel = get_goodbye(ult.chat_id)
|
125 |
msgg = wel["goodbye"]
|
126 |
med = wel["media"]
|
127 |
userid = user.id
|
|
|
145 |
|
146 |
|
147 |
@ultroid_bot.on(events.NewMessage(incoming=True))
|
148 |
+
async def chatBot_replies(e):
|
149 |
+
sender = await e.get_sender()
|
150 |
+
if not isinstance(sender, types.User):
|
151 |
+
return
|
152 |
+
if e.text and chatbot_stats(e.chat_id, e.sender_id):
|
153 |
+
msg = get_chatbot_reply(e, e.message.message)
|
154 |
if msg:
|
155 |
+
await e.reply(msg)
|
156 |
+
chat = await e.get_chat()
|
157 |
+
if e.is_group and not sender.bot:
|
158 |
+
if sender.username:
|
159 |
+
await uname_stuff(e.sender_id, sender.username, sender.first_name)
|
160 |
+
elif e.is_private and not sender.bot:
|
161 |
+
if chat.username:
|
162 |
+
await uname_stuff(e.sender_id, chat.username, chat.first_name)
|
163 |
+
|
164 |
+
|
165 |
+
@ultroid_bot.on(events.Raw(types.UpdateUserName))
|
166 |
+
async def uname_change(e):
|
167 |
+
await uname_stuff(e.user_id, e.username, e.first_name)
|
168 |
+
|
169 |
+
|
170 |
+
async def uname_stuff(id, uname, name):
|
171 |
+
if udB.get("USERNAME_LOG") == "True":
|
172 |
+
old = get_username(id)
|
173 |
+
# Ignore Name Logs
|
174 |
+
if old and old == uname:
|
175 |
+
return
|
176 |
+
if old and uname:
|
177 |
+
await asst.send_message(
|
178 |
+
LOG_CHANNEL,
|
179 |
+
f"∆ #UsernameUpdate\n\n@{old} changed username to @{uname}",
|
180 |
+
)
|
181 |
+
elif old and not uname:
|
182 |
+
await asst.send_message(
|
183 |
+
LOG_CHANNEL,
|
184 |
+
f"∆ #UsernameUpdate\n\n[{name}](tg://user?id={id}) removed its username. (@{old})",
|
185 |
+
)
|
186 |
+
elif not old and uname:
|
187 |
+
await asst.send_message(
|
188 |
+
LOG_CHANNEL,
|
189 |
+
f"∆ #UsernameUpdate\n\n[{name}](tg://user?id={id})'s new username --> @{uname}",
|
190 |
+
)
|
191 |
+
update_username(id, uname)
|
plugins/__init__.py
CHANGED
@@ -6,6 +6,7 @@
|
|
6 |
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
7 |
|
8 |
import asyncio
|
|
|
9 |
import time
|
10 |
|
11 |
from pyUltroid import *
|
@@ -15,6 +16,7 @@ from pyUltroid.functions.sudos import *
|
|
15 |
from pyUltroid.version import ultroid_version
|
16 |
from telethon import Button
|
17 |
from telethon.tl import functions, types
|
|
|
18 |
|
19 |
from strings import get_string
|
20 |
|
@@ -30,16 +32,22 @@ start_time = time.time()
|
|
30 |
|
31 |
OWNER_NAME = ultroid_bot.me.first_name
|
32 |
OWNER_ID = ultroid_bot.me.id
|
|
|
33 |
|
34 |
List = []
|
35 |
Dict = {}
|
36 |
N = 0
|
37 |
|
|
|
|
|
|
|
|
|
38 |
NOSPAM_CHAT = [
|
39 |
-
-
|
40 |
-
-
|
41 |
-
-
|
42 |
-
-
|
|
|
43 |
]
|
44 |
|
45 |
KANGING_STR = [
|
|
|
6 |
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
7 |
|
8 |
import asyncio
|
9 |
+
import os
|
10 |
import time
|
11 |
|
12 |
from pyUltroid import *
|
|
|
16 |
from pyUltroid.version import ultroid_version
|
17 |
from telethon import Button
|
18 |
from telethon.tl import functions, types
|
19 |
+
from telethon.utils import get_display_name
|
20 |
|
21 |
from strings import get_string
|
22 |
|
|
|
32 |
|
33 |
OWNER_NAME = ultroid_bot.me.first_name
|
34 |
OWNER_ID = ultroid_bot.me.id
|
35 |
+
LOG_CHANNEL = int(udB.get("LOG_CHANNEL"))
|
36 |
|
37 |
List = []
|
38 |
Dict = {}
|
39 |
N = 0
|
40 |
|
41 |
+
# Chats, which needs to be ignore for some cases
|
42 |
+
# Considerably, there can be many
|
43 |
+
# Feel Free to Add Any other...
|
44 |
+
|
45 |
NOSPAM_CHAT = [
|
46 |
+
-1001327032795, # UltroidSupport
|
47 |
+
-1001387666944, # PyrogramChat
|
48 |
+
-1001109500936, # TelethonChat
|
49 |
+
-1001050982793, # Python
|
50 |
+
-1001256902287, # DurovsChat
|
51 |
]
|
52 |
|
53 |
KANGING_STR = [
|
plugins/_help.py
CHANGED
@@ -12,6 +12,25 @@ from telethon.errors.rpcerrorlist import BotResponseTimeoutError as rep
|
|
12 |
|
13 |
from . import *
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
@ultroid_cmd(pattern="help ?(.*)")
|
17 |
async def _help(ult):
|
@@ -37,7 +56,7 @@ async def _help(ult):
|
|
37 |
x += "\n© @TeamUltroid"
|
38 |
await eor(ult, x)
|
39 |
except BaseException:
|
40 |
-
await
|
41 |
except BaseException:
|
42 |
await eor(ult, "Error 🤔 occured.")
|
43 |
else:
|
@@ -50,30 +69,17 @@ async def _help(ult):
|
|
50 |
for y in x:
|
51 |
z.append(y)
|
52 |
cmd = len(z) + 10
|
53 |
-
|
54 |
-
|
|
|
55 |
get_string("inline_4").format(
|
56 |
OWNER_NAME,
|
57 |
len(PLUGINS) - 5,
|
58 |
len(ADDONS),
|
59 |
cmd,
|
60 |
),
|
61 |
-
|
62 |
-
|
63 |
-
Button.inline("• Pʟᴜɢɪɴs", data="hrrrr"),
|
64 |
-
Button.inline("• Aᴅᴅᴏɴs", data="frrr"),
|
65 |
-
],
|
66 |
-
[
|
67 |
-
Button.inline("Oᴡɴᴇʀ•ᴛᴏᴏʟꜱ", data="ownr"),
|
68 |
-
Button.inline("Iɴʟɪɴᴇ•Pʟᴜɢɪɴs", data="inlone"),
|
69 |
-
],
|
70 |
-
[
|
71 |
-
Button.url(
|
72 |
-
"⚙️Sᴇᴛᴛɪɴɢs⚙️", url=f"https://t.me/{tgbot}?start=set"
|
73 |
-
),
|
74 |
-
],
|
75 |
-
[Button.inline("••Cʟᴏꜱᴇ••", data="close")],
|
76 |
-
],
|
77 |
)
|
78 |
except rep:
|
79 |
return await eor(
|
|
|
12 |
|
13 |
from . import *
|
14 |
|
15 |
+
C_PIC = udB.get("INLINE_PIC")
|
16 |
+
_file_to_replace = C_PIC or "resources/extras/inline.jpg"
|
17 |
+
|
18 |
+
_main_help_menu = [
|
19 |
+
[
|
20 |
+
Button.inline("• Plugins", data="hrrrr"),
|
21 |
+
Button.inline("• Addons", data="frrr"),
|
22 |
+
],
|
23 |
+
[
|
24 |
+
Button.inline("••Voice Chat", data="vc_helper"),
|
25 |
+
Button.inline("Inline Plugins••", data="inlone"),
|
26 |
+
],
|
27 |
+
[
|
28 |
+
Button.inline("⚙️ Owner Tools", data="ownr"),
|
29 |
+
Button.url("Settings ⚙️", url=f"https://t.me/{asst.me.username}?start=set"),
|
30 |
+
],
|
31 |
+
[Button.inline("••Cʟᴏꜱᴇ••", data="close")],
|
32 |
+
]
|
33 |
+
|
34 |
|
35 |
@ultroid_cmd(pattern="help ?(.*)")
|
36 |
async def _help(ult):
|
|
|
56 |
x += "\n© @TeamUltroid"
|
57 |
await eor(ult, x)
|
58 |
except BaseException:
|
59 |
+
await eor(ult, get_string("help_1").format(plug), time=5)
|
60 |
except BaseException:
|
61 |
await eor(ult, "Error 🤔 occured.")
|
62 |
else:
|
|
|
69 |
for y in x:
|
70 |
z.append(y)
|
71 |
cmd = len(z) + 10
|
72 |
+
if udB.get("MANAGER") and udB.get("DUAL_HNDLR") == "/":
|
73 |
+
_main_help_menu[2:3] = [[Button.inline("• Manager Help •", "mngbtn")]]
|
74 |
+
return await ult.reply(
|
75 |
get_string("inline_4").format(
|
76 |
OWNER_NAME,
|
77 |
len(PLUGINS) - 5,
|
78 |
len(ADDONS),
|
79 |
cmd,
|
80 |
),
|
81 |
+
file=_file_to_replace,
|
82 |
+
buttons=_main_help_menu,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
)
|
84 |
except rep:
|
85 |
return await eor(
|
plugins/_inline.py
CHANGED
@@ -18,6 +18,7 @@ from support import *
|
|
18 |
from telethon.tl.types import InputBotInlineResult, InputWebDocument
|
19 |
|
20 |
from . import *
|
|
|
21 |
|
22 |
# ================================================#
|
23 |
notmine = f"This bot is for {OWNER_NAME}"
|
@@ -38,32 +39,18 @@ if C_PIC:
|
|
38 |
TLINK = C_PIC
|
39 |
else:
|
40 |
_file_to_replace = "resources/extras/inline.jpg"
|
|
|
|
|
41 |
# ============================================#
|
42 |
|
43 |
|
44 |
# --------------------BUTTONS--------------------#
|
45 |
|
46 |
-
_main_help_menu = [
|
47 |
-
[
|
48 |
-
Button.inline("• Pʟᴜɢɪɴs", data="hrrrr"),
|
49 |
-
Button.inline("• Aᴅᴅᴏɴs", data="frrr"),
|
50 |
-
],
|
51 |
-
[
|
52 |
-
Button.inline("Oᴡɴᴇʀ•ᴛᴏᴏʟꜱ", data="ownr"),
|
53 |
-
Button.inline("Iɴʟɪɴᴇ•Pʟᴜɢɪɴs", data="inlone"),
|
54 |
-
],
|
55 |
-
[
|
56 |
-
Button.url("⚙️Sᴇᴛᴛɪɴɢs⚙️", url=f"https://t.me/{asst.me.username}?start=set"),
|
57 |
-
],
|
58 |
-
[Button.inline("••Cʟᴏꜱᴇ••", data="close")],
|
59 |
-
]
|
60 |
-
|
61 |
SUP_BUTTONS = [
|
62 |
[
|
63 |
-
Button.url("Repo", url="https://github.com/TeamUltroid/Ultroid"),
|
64 |
-
Button.url("
|
65 |
],
|
66 |
-
[Button.url("Support", url="t.me/UltroidSupport")],
|
67 |
]
|
68 |
|
69 |
# --------------------BUTTONS--------------------#
|
@@ -75,9 +62,6 @@ async def inline_alive(o):
|
|
75 |
if len(o.text) == 0:
|
76 |
b = o.builder
|
77 |
MSG = "• **Ultroid Userbot •**"
|
78 |
-
uptime = time_formatter((time.time() - start_time) * 1000)
|
79 |
-
MSG += f"\n\n• **Uptime** - `{uptime}`\n"
|
80 |
-
MSG += f"• **OWNER** - `{OWNER_NAME}`"
|
81 |
WEB0 = InputWebDocument(
|
82 |
"https://telegra.ph/file/55dd0f381c70e72557cb1.jpg", 0, "image/jpg", []
|
83 |
)
|
@@ -97,7 +81,7 @@ async def inline_alive(o):
|
|
97 |
content=InputWebDocument(TLINK, 0, "image/jpg", []),
|
98 |
)
|
99 |
]
|
100 |
-
await o.answer(RES, switch_pm=
|
101 |
|
102 |
|
103 |
@in_pattern("ultd")
|
@@ -121,18 +105,19 @@ async def inline_handler(event):
|
|
121 |
await event.answer([result], gallery=True)
|
122 |
|
123 |
|
124 |
-
@in_pattern("
|
125 |
@in_owner
|
126 |
async def _(event):
|
127 |
-
ok = event.text.split("
|
128 |
-
link = "https://
|
129 |
-
|
|
|
130 |
title="Paste",
|
131 |
-
text="
|
132 |
buttons=[
|
133 |
[
|
134 |
-
Button.url("
|
135 |
-
Button.url("Raw", url=
|
136 |
],
|
137 |
],
|
138 |
)
|
@@ -170,23 +155,32 @@ async def setting(event):
|
|
170 |
)
|
171 |
|
172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
@callback("doupdate")
|
174 |
@owner
|
175 |
async def _(event):
|
176 |
-
check =
|
177 |
if not check:
|
178 |
return await event.answer(
|
179 |
"You Are Already On Latest Version", cache_time=0, alert=True
|
180 |
)
|
181 |
repo = Repo.init()
|
182 |
ac_br = repo.active_branch
|
183 |
-
changelog, tl_chnglog =
|
184 |
-
changelog_str = changelog +
|
185 |
if len(changelog_str) > 1024:
|
186 |
await event.edit(get_string("upd_4"))
|
187 |
-
|
188 |
-
|
189 |
-
file.close()
|
190 |
await event.edit(
|
191 |
get_string("upd_5"),
|
192 |
file="ultroid_updates.txt",
|
@@ -195,8 +189,7 @@ async def _(event):
|
|
195 |
[Button.inline("« Bᴀᴄᴋ", data="ownr")],
|
196 |
],
|
197 |
)
|
198 |
-
remove(
|
199 |
-
return
|
200 |
else:
|
201 |
await event.edit(
|
202 |
changelog_str,
|
@@ -266,8 +259,8 @@ async def _(e):
|
|
266 |
],
|
267 |
[
|
268 |
Button.switch_inline(
|
269 |
-
"
|
270 |
-
query="
|
271 |
same_peer=True,
|
272 |
),
|
273 |
Button.switch_inline(
|
@@ -276,6 +269,7 @@ async def _(e):
|
|
276 |
same_peer=True,
|
277 |
),
|
278 |
],
|
|
|
279 |
[
|
280 |
Button.inline(
|
281 |
"« Bᴀᴄᴋ",
|
@@ -339,6 +333,30 @@ async def on_plug_in_callback_query_handler(event):
|
|
339 |
await event.edit(buttons=buttons, link_preview=False)
|
340 |
|
341 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
@callback(
|
343 |
re.compile(
|
344 |
rb"addon_next\((.+?)\)",
|
@@ -391,6 +409,22 @@ async def backr(event):
|
|
391 |
)
|
392 |
|
393 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
394 |
@callback("open")
|
395 |
@owner
|
396 |
async def opner(event):
|
@@ -465,6 +499,51 @@ async def on_plug_in_callback_query_handler(event):
|
|
465 |
await event.edit(halps, buttons=buttons)
|
466 |
|
467 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
468 |
@callback(
|
469 |
re.compile(
|
470 |
b"add_plugin_(.*)",
|
@@ -524,19 +603,14 @@ async def on_plug_in_callback_query_handler(event):
|
|
524 |
await event.edit(halps, buttons=buttons)
|
525 |
|
526 |
|
527 |
-
def page_num(page_number, loaded_plugins, prefix,
|
528 |
number_of_rows = 5
|
529 |
number_of_cols = 2
|
530 |
emoji = Redis("EMOJI_IN_HELP")
|
531 |
-
|
532 |
-
multi = emoji
|
533 |
-
else:
|
534 |
-
multi = "✘"
|
535 |
-
helpable_plugins = []
|
536 |
global upage
|
537 |
upage = page_number
|
538 |
-
for p in loaded_plugins
|
539 |
-
helpable_plugins.append(p)
|
540 |
helpable_plugins = sorted(helpable_plugins)
|
541 |
modules = [
|
542 |
Button.inline(
|
@@ -545,7 +619,7 @@ def page_num(page_number, loaded_plugins, prefix, type):
|
|
545 |
x,
|
546 |
multi,
|
547 |
),
|
548 |
-
data=f"{
|
549 |
)
|
550 |
for x in helpable_plugins
|
551 |
]
|
|
|
18 |
from telethon.tl.types import InputBotInlineResult, InputWebDocument
|
19 |
|
20 |
from . import *
|
21 |
+
from ._help import _main_help_menu
|
22 |
|
23 |
# ================================================#
|
24 |
notmine = f"This bot is for {OWNER_NAME}"
|
|
|
39 |
TLINK = C_PIC
|
40 |
else:
|
41 |
_file_to_replace = "resources/extras/inline.jpg"
|
42 |
+
|
43 |
+
upage = 0
|
44 |
# ============================================#
|
45 |
|
46 |
|
47 |
# --------------------BUTTONS--------------------#
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
SUP_BUTTONS = [
|
50 |
[
|
51 |
+
Button.url("• Repo •", url="https://github.com/TeamUltroid/Ultroid"),
|
52 |
+
Button.url("• Support •", url="t.me/UltroidSupport"),
|
53 |
],
|
|
|
54 |
]
|
55 |
|
56 |
# --------------------BUTTONS--------------------#
|
|
|
62 |
if len(o.text) == 0:
|
63 |
b = o.builder
|
64 |
MSG = "• **Ultroid Userbot •**"
|
|
|
|
|
|
|
65 |
WEB0 = InputWebDocument(
|
66 |
"https://telegra.ph/file/55dd0f381c70e72557cb1.jpg", 0, "image/jpg", []
|
67 |
)
|
|
|
81 |
content=InputWebDocument(TLINK, 0, "image/jpg", []),
|
82 |
)
|
83 |
]
|
84 |
+
await o.answer(RES, switch_pm="👥 ULTROID PORTAL", switch_pm_param="start")
|
85 |
|
86 |
|
87 |
@in_pattern("ultd")
|
|
|
105 |
await event.answer([result], gallery=True)
|
106 |
|
107 |
|
108 |
+
@in_pattern("pasta")
|
109 |
@in_owner
|
110 |
async def _(event):
|
111 |
+
ok = event.text.split("-")[1]
|
112 |
+
link = "https://spaceb.in/" + ok
|
113 |
+
raw = f"https://spaceb.in/api/v1/documents/{ok}/raw"
|
114 |
+
result = await event.builder.article(
|
115 |
title="Paste",
|
116 |
+
text="Pasted to Spacebin 🌌",
|
117 |
buttons=[
|
118 |
[
|
119 |
+
Button.url("SpaceBin", url=link),
|
120 |
+
Button.url("Raw", url=raw),
|
121 |
],
|
122 |
],
|
123 |
)
|
|
|
155 |
)
|
156 |
|
157 |
|
158 |
+
@callback("vc_helper")
|
159 |
+
@owner
|
160 |
+
async def on_vc_callback_query_handler(event):
|
161 |
+
xhelps = "**Voice Chat Help Menu for {}**\n**Available Commands:** `{}`\n\n@TeamUltroid".format(
|
162 |
+
OWNER_NAME, len(VC_HELP)
|
163 |
+
)
|
164 |
+
buttons = page_num(0, VC_HELP, "vchelp", "vc")
|
165 |
+
await event.edit(f"{xhelps}", buttons=buttons, link_preview=False)
|
166 |
+
|
167 |
+
|
168 |
@callback("doupdate")
|
169 |
@owner
|
170 |
async def _(event):
|
171 |
+
check = updater()
|
172 |
if not check:
|
173 |
return await event.answer(
|
174 |
"You Are Already On Latest Version", cache_time=0, alert=True
|
175 |
)
|
176 |
repo = Repo.init()
|
177 |
ac_br = repo.active_branch
|
178 |
+
changelog, tl_chnglog = gen_chlog(repo, f"HEAD..upstream/{ac_br}")
|
179 |
+
changelog_str = changelog + "\n\nClick the below button to update!"
|
180 |
if len(changelog_str) > 1024:
|
181 |
await event.edit(get_string("upd_4"))
|
182 |
+
with open("ultroid_updates.txt", "w+") as file:
|
183 |
+
file.write(tl_chnglog)
|
|
|
184 |
await event.edit(
|
185 |
get_string("upd_5"),
|
186 |
file="ultroid_updates.txt",
|
|
|
189 |
[Button.inline("« Bᴀᴄᴋ", data="ownr")],
|
190 |
],
|
191 |
)
|
192 |
+
remove("ultroid_updates.txt")
|
|
|
193 |
else:
|
194 |
await event.edit(
|
195 |
changelog_str,
|
|
|
259 |
],
|
260 |
[
|
261 |
Button.switch_inline(
|
262 |
+
"Piston Eval",
|
263 |
+
query="run javascript console.log('Hello Ultroid')",
|
264 |
same_peer=True,
|
265 |
),
|
266 |
Button.switch_inline(
|
|
|
269 |
same_peer=True,
|
270 |
),
|
271 |
],
|
272 |
+
[Button.switch_inline("xda Search", query="xda telegram", same_peer=True)],
|
273 |
[
|
274 |
Button.inline(
|
275 |
"« Bᴀᴄᴋ",
|
|
|
333 |
await event.edit(buttons=buttons, link_preview=False)
|
334 |
|
335 |
|
336 |
+
@callback(
|
337 |
+
re.compile(
|
338 |
+
rb"vchelp_next\((.+?)\)",
|
339 |
+
),
|
340 |
+
)
|
341 |
+
@owner
|
342 |
+
async def on_vc_callback_query_handler(event):
|
343 |
+
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
|
344 |
+
buttons = page_num(current_page_number + 1, VC_HELP, "vchelp", "vc")
|
345 |
+
await event.edit(buttons=buttons, link_preview=False)
|
346 |
+
|
347 |
+
|
348 |
+
@callback(
|
349 |
+
re.compile(
|
350 |
+
rb"vchelp_prev\((.+?)\)",
|
351 |
+
),
|
352 |
+
)
|
353 |
+
@owner
|
354 |
+
async def on_vc_callback_query_handler(event):
|
355 |
+
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
|
356 |
+
buttons = page_num(current_page_number - 1, VC_HELP, "vchelp", "vc")
|
357 |
+
await event.edit(buttons=buttons, link_preview=False)
|
358 |
+
|
359 |
+
|
360 |
@callback(
|
361 |
re.compile(
|
362 |
rb"addon_next\((.+?)\)",
|
|
|
409 |
)
|
410 |
|
411 |
|
412 |
+
@callback("bvck")
|
413 |
+
@owner
|
414 |
+
async def bvckr(event):
|
415 |
+
xhelps = "**Voice Chat Help Menu for {}**\n**Available Commands:** `{}`\n\n@TeamUltroid".format(
|
416 |
+
OWNER_NAME, len(VC_HELP)
|
417 |
+
)
|
418 |
+
current_page_number = int(upage)
|
419 |
+
buttons = page_num(current_page_number, VC_HELP, "vchelp", "vc")
|
420 |
+
await event.edit(
|
421 |
+
f"{xhelps}",
|
422 |
+
file=_file_to_replace,
|
423 |
+
buttons=buttons,
|
424 |
+
link_preview=False,
|
425 |
+
)
|
426 |
+
|
427 |
+
|
428 |
@callback("open")
|
429 |
@owner
|
430 |
async def opner(event):
|
|
|
499 |
await event.edit(halps, buttons=buttons)
|
500 |
|
501 |
|
502 |
+
@callback(
|
503 |
+
re.compile(
|
504 |
+
b"vc_plugin_(.*)",
|
505 |
+
),
|
506 |
+
)
|
507 |
+
@owner
|
508 |
+
async def on_vc_plg_callback_query_handler(event):
|
509 |
+
plugin_name = event.data_match.group(1).decode("UTF-8")
|
510 |
+
help_string = f"Plugin Name - `{plugin_name}`\n"
|
511 |
+
try:
|
512 |
+
for i in VC_HELP[plugin_name]:
|
513 |
+
help_string += i
|
514 |
+
except BaseException:
|
515 |
+
pass
|
516 |
+
if help_string == "**Commands Available:**\n\n":
|
517 |
+
reply_pop_up_alert = f"{plugin_name} has no detailed help..."
|
518 |
+
else:
|
519 |
+
reply_pop_up_alert = help_string
|
520 |
+
reply_pop_up_alert += "\n© @TeamUltroid"
|
521 |
+
buttons = [
|
522 |
+
[
|
523 |
+
Button.inline(
|
524 |
+
"« Sᴇɴᴅ Pʟᴜɢɪɴ »",
|
525 |
+
data=f"sndplug_{(event.data).decode('UTF-8')}",
|
526 |
+
)
|
527 |
+
],
|
528 |
+
[
|
529 |
+
Button.inline("« Bᴀᴄᴋ", data="bvck"),
|
530 |
+
Button.inline("••Cʟᴏꜱᴇ••", data="close"),
|
531 |
+
],
|
532 |
+
]
|
533 |
+
try:
|
534 |
+
if str(event.query.user_id) in owner_and_sudos():
|
535 |
+
await event.edit(
|
536 |
+
reply_pop_up_alert,
|
537 |
+
buttons=buttons,
|
538 |
+
)
|
539 |
+
else:
|
540 |
+
reply_pop_up_alert = notmine
|
541 |
+
await event.answer(reply_pop_up_alert, cache_time=0)
|
542 |
+
except BaseException:
|
543 |
+
halps = f"Do .help {plugin_name} to get the list of commands."
|
544 |
+
await event.edit(halps, buttons=buttons)
|
545 |
+
|
546 |
+
|
547 |
@callback(
|
548 |
re.compile(
|
549 |
b"add_plugin_(.*)",
|
|
|
603 |
await event.edit(halps, buttons=buttons)
|
604 |
|
605 |
|
606 |
+
def page_num(page_number, loaded_plugins, prefix, type_):
|
607 |
number_of_rows = 5
|
608 |
number_of_cols = 2
|
609 |
emoji = Redis("EMOJI_IN_HELP")
|
610 |
+
multi = emoji or "✘"
|
|
|
|
|
|
|
|
|
611 |
global upage
|
612 |
upage = page_number
|
613 |
+
helpable_plugins = [p for p in loaded_plugins]
|
|
|
614 |
helpable_plugins = sorted(helpable_plugins)
|
615 |
modules = [
|
616 |
Button.inline(
|
|
|
619 |
x,
|
620 |
multi,
|
621 |
),
|
622 |
+
data=f"{type_}_plugin_{x}",
|
623 |
)
|
624 |
for x in helpable_plugins
|
625 |
]
|
plugins/_ultroid.py
CHANGED
@@ -4,8 +4,12 @@
|
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
6 |
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
7 |
-
|
8 |
-
from telethon.errors
|
|
|
|
|
|
|
|
|
9 |
|
10 |
from . import *
|
11 |
|
@@ -16,13 +20,46 @@ REPOMSG = """
|
|
16 |
• Support - @UltroidSupport
|
17 |
"""
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
async def repify(e):
|
22 |
try:
|
23 |
-
q = await e.client.inline_query(asst.me.username, "
|
24 |
await q[0].click(e.chat_id)
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
6 |
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
7 |
+
|
8 |
+
from telethon.errors import (
|
9 |
+
BotMethodInvalidError,
|
10 |
+
ChatSendInlineForbiddenError,
|
11 |
+
ChatSendMediaForbiddenError,
|
12 |
+
)
|
13 |
|
14 |
from . import *
|
15 |
|
|
|
20 |
• Support - @UltroidSupport
|
21 |
"""
|
22 |
|
23 |
+
RP_BUTTONS = [
|
24 |
+
[
|
25 |
+
Button.url("Repo", "https://github.com/TeamUltroid/Ultroid"),
|
26 |
+
Button.url("Addons", "https://github.com/TeamUltroid/UltroidAddons"),
|
27 |
+
],
|
28 |
+
[Button.url("Support Group", "t.me/ultroidsupport")],
|
29 |
+
]
|
30 |
+
|
31 |
+
ULTSTRING = """🎇 **Thanks for Deploying Ultroid Userbot!**
|
32 |
+
|
33 |
+
• Here, are the Some Basic stuff from, where you can Know, about its Usage."""
|
34 |
|
35 |
+
|
36 |
+
@ultroid_cmd(
|
37 |
+
pattern="repo$",
|
38 |
+
type=["official", "manager"],
|
39 |
+
)
|
40 |
async def repify(e):
|
41 |
try:
|
42 |
+
q = await e.client.inline_query(asst.me.username, "")
|
43 |
await q[0].click(e.chat_id)
|
44 |
+
return await e.delete()
|
45 |
+
except (
|
46 |
+
ChatSendInlineForbiddenError,
|
47 |
+
ChatSendMediaForbiddenError,
|
48 |
+
BotMethodInvalidError,
|
49 |
+
):
|
50 |
+
pass
|
51 |
+
except Exception as er:
|
52 |
+
LOGS.info("Error while repo command : " + str(er))
|
53 |
+
await eor(e, REPOMSG)
|
54 |
+
|
55 |
+
|
56 |
+
@ultroid_cmd(pattern="ultroid")
|
57 |
+
async def useUltroid(rs):
|
58 |
+
button = Button.inline("Start >>", "initft_2")
|
59 |
+
msg = await asst.send_message(
|
60 |
+
LOG_CHANNEL,
|
61 |
+
ULTSTRING,
|
62 |
+
file="https://telegra.ph/file/54a917cc9dbb94733ea5f.jpg",
|
63 |
+
buttons=button,
|
64 |
+
)
|
65 |
+
await eor(rs, f"**[Click Here]({msg.message_link})**")
|
plugins/_userlogs.py
CHANGED
@@ -5,18 +5,21 @@
|
|
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 |
-
|
20 |
|
21 |
|
22 |
@ultroid_bot.on(
|
@@ -32,65 +35,78 @@ async def all_messages_catcher(e):
|
|
32 |
NEEDTOLOG = int(udB.get("TAG_LOG"))
|
33 |
except Exception:
|
34 |
return LOGS.info("you given Wrong Grp/Channel ID in TAG_LOG.")
|
35 |
-
x = e.
|
36 |
-
if x.bot or x.verified:
|
37 |
return
|
38 |
y = e.chat
|
39 |
where_n = get_display_name(y)
|
40 |
who_n = get_display_name(x)
|
41 |
-
where_l =
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
43 |
try:
|
44 |
-
|
45 |
-
|
46 |
-
await asst.send_message(
|
47 |
-
NEEDTOLOG,
|
48 |
-
send,
|
49 |
-
buttons=[
|
50 |
-
[Button.url(who_n, who_l)],
|
51 |
-
[Button.url(where_n, where_l)],
|
52 |
-
],
|
53 |
-
)
|
54 |
-
else:
|
55 |
-
await asst.send_message(
|
56 |
-
NEEDTOLOG,
|
57 |
-
send,
|
58 |
-
buttons=[
|
59 |
-
[Button.inline(who_n, data=f"who{x.id}")],
|
60 |
-
[Button.url(where_n, where_l)],
|
61 |
-
],
|
62 |
-
)
|
63 |
except MediaEmptyError:
|
64 |
-
|
65 |
-
|
66 |
-
await asst.send_message(
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
)
|
83 |
-
except PeerIdInvalidError:
|
84 |
-
await ultroid_bot.send_message(
|
85 |
int(udB.get("LOG_CHANNEL")),
|
86 |
"The Chat Id You Set In Tag Logger Is Wrong , Please Correct It",
|
87 |
)
|
88 |
except ChatWriteForbiddenError:
|
89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
except Exception as er:
|
91 |
LOGS.info(str(er))
|
92 |
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
@callback(re.compile("who(.*)"))
|
95 |
async def _(e):
|
96 |
wah = e.pattern_match.group(1).decode("UTF-8")
|
@@ -112,7 +128,7 @@ async def when_asst_added_to_chat(event):
|
|
112 |
chat = f"[{chat.title}](https://t.me/{chat.username}/{event.action_message.id})"
|
113 |
else:
|
114 |
chat = f"[{chat.title}](https://t.me/c/{chat.id}/{event.action_message.id})"
|
115 |
-
if user.is_self:
|
116 |
tmp = event.added_by
|
117 |
buttons = Button.inline("Leave Chat", data=f"leave_ch_{event.chat_id}|bot")
|
118 |
return await asst.send_message(
|
@@ -127,35 +143,23 @@ async def when_asst_added_to_chat(event):
|
|
127 |
|
128 |
@ultroid.on(events.ChatAction)
|
129 |
async def when_ultd_added_to_chat(event):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
if event.user_added:
|
131 |
-
|
132 |
-
|
133 |
-
if hasattr(chat, "username") and chat.username:
|
134 |
-
chat = f"[{chat.title}](https://t.me/{chat.username}/{event.action_message.id})"
|
135 |
-
else:
|
136 |
-
chat = f"[{chat.title}](https://t.me/c/{chat.id}/{event.action_message.id})"
|
137 |
-
if user.is_self:
|
138 |
-
tmp = event.added_by
|
139 |
-
buttons = Button.inline("Leave Chat", data=f"leave_ch_{event.chat_id}|user")
|
140 |
-
return await asst.send_message(
|
141 |
-
int(udB.get("LOG_CHANNEL")),
|
142 |
-
f"#ADD_LOG\n\n{inline_mention(tmp)} just added {inline_mention(user)} to {chat}.",
|
143 |
-
buttons=buttons,
|
144 |
-
)
|
145 |
elif event.user_joined:
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
else:
|
151 |
-
chat = f"[{chat.title}](https://t.me/c/{chat.id}/{event.action_message.id})"
|
152 |
-
if user.is_self:
|
153 |
-
buttons = Button.inline("Leave Chat", data=f"leave_ch_{event.chat_id}|user")
|
154 |
-
return await asst.send_message(
|
155 |
-
int(udB.get("LOG_CHANNEL")),
|
156 |
-
f"#JOIN_LOG\n\n[{user.first_name}](tg://user?id={user.id}) just joined {chat}.",
|
157 |
-
buttons=buttons,
|
158 |
-
)
|
159 |
|
160 |
|
161 |
@callback(
|
|
|
5 |
# PLease read the GNU Affero General Public License in
|
6 |
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
7 |
|
8 |
+
import os
|
9 |
import re
|
10 |
|
11 |
+
from pyUltroid.functions.botchat_db import tag_add, who_tag
|
12 |
from telethon.errors.rpcerrorlist import (
|
13 |
ChatWriteForbiddenError,
|
14 |
MediaEmptyError,
|
15 |
PeerIdInvalidError,
|
16 |
+
UserNotParticipantError,
|
17 |
)
|
18 |
from telethon.utils import get_display_name
|
19 |
|
20 |
from . import *
|
21 |
|
22 |
+
CACHE_SPAM = {}
|
23 |
|
24 |
|
25 |
@ultroid_bot.on(
|
|
|
35 |
NEEDTOLOG = int(udB.get("TAG_LOG"))
|
36 |
except Exception:
|
37 |
return LOGS.info("you given Wrong Grp/Channel ID in TAG_LOG.")
|
38 |
+
x = await e.get_sender()
|
39 |
+
if isinstance(x, types.User) and (x.bot or x.verified):
|
40 |
return
|
41 |
y = e.chat
|
42 |
where_n = get_display_name(y)
|
43 |
who_n = get_display_name(x)
|
44 |
+
where_l = e.message.message_link
|
45 |
+
buttons = [[Button.url(where_n, where_l)]]
|
46 |
+
if x.username:
|
47 |
+
who_l = f"https://t.me/{x.username}"
|
48 |
+
buttons.append([Button.url(who_n, who_l)])
|
49 |
+
else:
|
50 |
+
buttons.append([Button.inline(who_n, data=f"who{x.id}")])
|
51 |
try:
|
52 |
+
sent = await asst.send_message(NEEDTOLOG, e.message, buttons=buttons)
|
53 |
+
tag_add(sent.id, e.chat_id, e.id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
except MediaEmptyError:
|
55 |
+
try:
|
56 |
+
msg = await asst.get_messages(e.chat_id, ids=e.id)
|
57 |
+
sent = await asst.send_message(NEEDTOLOG, msg, buttons=buttons)
|
58 |
+
tag_add(sent.id, e.chat_id, e.id)
|
59 |
+
except Exception as me:
|
60 |
+
LOGS.info(me)
|
61 |
+
if e.photo or e.sticker or e.gif:
|
62 |
+
try:
|
63 |
+
media = await e.download_media()
|
64 |
+
await asst.send_message(
|
65 |
+
NEEDTOLOG, e.message.text, file=media, buttons=buttons
|
66 |
+
)
|
67 |
+
return os.remove(media)
|
68 |
+
except Exception as er:
|
69 |
+
LOGS.info(er)
|
70 |
+
await asst.send_message(NEEDTOLOG, "`Unsupported Media`", buttons=buttons)
|
71 |
+
except (PeerIdInvalidError, ValueError):
|
72 |
+
await asst.send_message(
|
|
|
|
|
|
|
73 |
int(udB.get("LOG_CHANNEL")),
|
74 |
"The Chat Id You Set In Tag Logger Is Wrong , Please Correct It",
|
75 |
)
|
76 |
except ChatWriteForbiddenError:
|
77 |
+
try:
|
78 |
+
await asst.get_permissions(NEEDTOLOG, "me")
|
79 |
+
MSG = "Your Asst Cant Send Messages in Tag Log Chat."
|
80 |
+
MSG += "\n\nPlease Review the case or you can off"
|
81 |
+
MSG += "Your TagLogger, if you dont want to use it"
|
82 |
+
except UserNotParticipantError:
|
83 |
+
MSG = "Add me to Your Tag Logger Chat to Log Tags"
|
84 |
+
try:
|
85 |
+
CACHE_SPAM[NEEDTOLOG]
|
86 |
+
except KeyError:
|
87 |
+
await asst.send_message(LOG_CHANNEL, MSG)
|
88 |
+
CACHE_SPAM.update({NEEDTOLOG: True})
|
89 |
except Exception as er:
|
90 |
LOGS.info(str(er))
|
91 |
|
92 |
|
93 |
+
if udB.get("TAG_LOG"):
|
94 |
+
|
95 |
+
@ultroid_bot.on(
|
96 |
+
events.NewMessage(
|
97 |
+
outgoing=True, chats=[int(udB["TAG_LOG"])], func=lambda e: e.reply_to
|
98 |
+
)
|
99 |
+
)
|
100 |
+
async def idk(e):
|
101 |
+
id = e.reply_to_msg_id
|
102 |
+
chat, msg = who_tag(id)
|
103 |
+
if chat and msg:
|
104 |
+
try:
|
105 |
+
await ultroid_bot.send_message(chat, e.message, reply_to=msg)
|
106 |
+
except BaseException:
|
107 |
+
pass
|
108 |
+
|
109 |
+
|
110 |
@callback(re.compile("who(.*)"))
|
111 |
async def _(e):
|
112 |
wah = e.pattern_match.group(1).decode("UTF-8")
|
|
|
128 |
chat = f"[{chat.title}](https://t.me/{chat.username}/{event.action_message.id})"
|
129 |
else:
|
130 |
chat = f"[{chat.title}](https://t.me/c/{chat.id}/{event.action_message.id})"
|
131 |
+
if user and user.is_self:
|
132 |
tmp = event.added_by
|
133 |
buttons = Button.inline("Leave Chat", data=f"leave_ch_{event.chat_id}|bot")
|
134 |
return await asst.send_message(
|
|
|
143 |
|
144 |
@ultroid.on(events.ChatAction)
|
145 |
async def when_ultd_added_to_chat(event):
|
146 |
+
user = await event.get_user()
|
147 |
+
chat = await event.get_chat()
|
148 |
+
if not (user and user.is_self):
|
149 |
+
return
|
150 |
+
if chat.username:
|
151 |
+
chat = f"[{chat.title}](https://t.me/{chat.username}/{event.action_message.id})"
|
152 |
+
else:
|
153 |
+
chat = f"[{chat.title}](https://t.me/c/{chat.id}/{event.action_message.id})"
|
154 |
+
buttons = Button.inline("Leave Chat", data=f"leave_ch_{event.chat_id}|user")
|
155 |
if event.user_added:
|
156 |
+
tmp = event.added_by
|
157 |
+
text = f"#ADD_LOG\n\n{inline_mention(tmp)} just added {inline_mention(user)} to {chat}."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
elif event.user_joined:
|
159 |
+
text = f"#JOIN_LOG\n\n[{user.first_name}](tg://user?id={user.id}) just joined {chat}."
|
160 |
+
else:
|
161 |
+
return
|
162 |
+
await asst.send_message(int(udB["LOG_CHANNEL"]), text, buttons=buttons)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
|
164 |
|
165 |
@callback(
|
plugins/_wspr.py
CHANGED
@@ -142,8 +142,7 @@ async def _(e):
|
|
142 |
snap.update({e.id: desc})
|
143 |
except ValueError:
|
144 |
sur = e.builder.article(
|
145 |
-
title="Type ur msg",
|
146 |
-
text=f"You Didn't Type Your Msg",
|
147 |
)
|
148 |
await e.answer([sur])
|
149 |
|
|
|
142 |
snap.update({e.id: desc})
|
143 |
except ValueError:
|
144 |
sur = e.builder.article(
|
145 |
+
title="Type ur msg", text="You Didn't Type Your Msg"
|
|
|
146 |
)
|
147 |
await e.answer([sur])
|
148 |
|
plugins/admintools.py
CHANGED
@@ -18,6 +18,11 @@
|
|
18 |
• `{i}kick <reply to user/userid/username> <reason>`
|
19 |
Kick the user from the chat.
|
20 |
|
|
|
|
|
|
|
|
|
|
|
21 |
• `{i}pin <reply to message>`
|
22 |
Pin the message in the chat
|
23 |
for silent pin use ({i}pin silent).
|
@@ -28,7 +33,7 @@
|
|
28 |
• `{i}pinned`
|
29 |
Get pinned message in the current chat.
|
30 |
|
31 |
-
• `{i}autodelete <24h/7d/off>`
|
32 |
Enable Auto Delete Messages in Chat.
|
33 |
|
34 |
• `{i}listpinned`
|
@@ -43,24 +48,20 @@
|
|
43 |
• `{i}purgeall`
|
44 |
Delete all msgs of replied user.
|
45 |
"""
|
46 |
-
import asyncio
|
47 |
|
48 |
from telethon.errors import BadRequestError
|
49 |
from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidError
|
50 |
-
from telethon.tl.functions.channels import
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
54 |
|
55 |
from . import *
|
56 |
|
57 |
|
58 |
-
@ultroid_cmd(
|
59 |
-
pattern="promote ?(.*)",
|
60 |
-
admins_only=True,
|
61 |
-
type=["official", "manager"],
|
62 |
-
ignore_dualmode=True,
|
63 |
-
)
|
64 |
async def prmte(ult):
|
65 |
xx = await eor(ult, get_string("com_1"))
|
66 |
await ult.get_chat()
|
@@ -70,35 +71,28 @@ async def prmte(ult):
|
|
70 |
if not user:
|
71 |
return await xx.edit("`Reply to a user to promote him!`")
|
72 |
try:
|
73 |
-
await ult.client(
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
delete_messages=True,
|
83 |
-
pin_messages=True,
|
84 |
-
),
|
85 |
-
rank,
|
86 |
-
),
|
87 |
)
|
88 |
-
await
|
|
|
89 |
f"{inline_mention(user)} `is now an admin in {ult.chat.title} with title {rank}.`",
|
90 |
)
|
91 |
-
except
|
92 |
-
return await xx.edit("`
|
93 |
-
await asyncio.sleep(5)
|
94 |
-
await xx.delete()
|
95 |
|
96 |
|
97 |
@ultroid_cmd(
|
98 |
pattern="demote ?(.*)",
|
99 |
admins_only=True,
|
100 |
type=["official", "manager"],
|
101 |
-
ignore_dualmode=True,
|
102 |
)
|
103 |
async def dmote(ult):
|
104 |
xx = await eor(ult, get_string("com_1"))
|
@@ -109,62 +103,50 @@ async def dmote(ult):
|
|
109 |
if not user:
|
110 |
return await xx.edit("`Reply to a user to demote him!`")
|
111 |
try:
|
112 |
-
await ult.client(
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
delete_messages=None,
|
122 |
-
pin_messages=None,
|
123 |
-
),
|
124 |
-
rank,
|
125 |
-
),
|
126 |
)
|
127 |
-
await
|
128 |
-
f"{inline_mention(user)} `is no longer an admin in {ult.chat.title}`"
|
129 |
)
|
130 |
-
except
|
131 |
-
return await xx.edit("`
|
132 |
-
await asyncio.sleep(5)
|
133 |
-
await xx.delete()
|
134 |
|
135 |
|
136 |
-
@ultroid_cmd(
|
137 |
-
pattern="ban ?(.*)",
|
138 |
-
admins_only=True,
|
139 |
-
type=["official", "manager"],
|
140 |
-
ignore_dualmode=True,
|
141 |
-
)
|
142 |
async def bban(ult):
|
143 |
xx = await eor(ult, get_string("com_1"))
|
144 |
user, reason = await get_user_info(ult)
|
145 |
if not user:
|
146 |
return await xx.edit("`Reply to a user or give username to ban him!`")
|
147 |
-
if
|
148 |
return await xx.edit(" `LoL, I can't Ban my Developer 😂`")
|
149 |
try:
|
150 |
await ult.client.edit_permissions(ult.chat_id, user.id, view_messages=False)
|
151 |
except BadRequestError:
|
152 |
-
return await xx.edit("`I don't have the right to ban a user.`")
|
153 |
except UserIdInvalidError:
|
154 |
return await xx.edit("`I couldn't get who he is!`")
|
|
|
155 |
try:
|
156 |
reply = await ult.get_reply_message()
|
157 |
if reply:
|
158 |
await reply.delete()
|
159 |
except BadRequestError:
|
160 |
return await xx.edit(
|
161 |
-
f"{inline_mention(user)}**was banned by** {
|
162 |
)
|
163 |
userme = inline_mention(user)
|
164 |
-
senderme = inline_mention(ult.sender)
|
165 |
if reason:
|
166 |
await xx.edit(
|
167 |
-
f"{userme} **was banned by** {senderme}**in** `{ult.chat.title}`\n**Reason**: `{reason}`",
|
168 |
)
|
169 |
else:
|
170 |
await xx.edit(
|
@@ -176,7 +158,6 @@ async def bban(ult):
|
|
176 |
pattern="unban ?(.*)",
|
177 |
admins_only=True,
|
178 |
type=["official", "manager"],
|
179 |
-
ignore_dualmode=True,
|
180 |
)
|
181 |
async def uunban(ult):
|
182 |
xx = await eor(ult, get_string("com_1"))
|
@@ -189,7 +170,10 @@ async def uunban(ult):
|
|
189 |
return await xx.edit("`I don't have the right to unban a user.`")
|
190 |
except UserIdInvalidError:
|
191 |
await xx.edit("`I couldn't get who he is!`")
|
192 |
-
|
|
|
|
|
|
|
193 |
if reason:
|
194 |
text += f"\n**Reason**: `{reason}`"
|
195 |
await xx.edit(text)
|
@@ -199,97 +183,113 @@ async def uunban(ult):
|
|
199 |
pattern="kick ?(.*)",
|
200 |
admins_only=True,
|
201 |
type=["official", "manager"],
|
202 |
-
ignore_dualmode=True,
|
203 |
)
|
204 |
async def kck(ult):
|
205 |
-
|
|
|
206 |
return
|
207 |
xx = await eor(ult, get_string("com_1"))
|
208 |
-
await ult.get_chat()
|
209 |
user, reason = await get_user_info(ult)
|
210 |
if not user:
|
211 |
return await xx.edit("`Kick? Whom? I couldn't get his info...`")
|
212 |
-
if
|
213 |
return await xx.edit(" `Lol, I can't Kick my Developer`😂")
|
214 |
-
if user.
|
215 |
-
return await xx.edit("`
|
216 |
try:
|
217 |
await ult.client.kick_participant(ult.chat_id, user.id)
|
218 |
-
await asyncio.sleep(0.5)
|
219 |
except BadRequestError:
|
220 |
return await xx.edit("`I don't have the right to kick a user.`")
|
221 |
except Exception as e:
|
222 |
return await xx.edit(
|
223 |
f"`I don't have the right to kick a user.`\n\n**ERROR**:\n`{str(e)}`",
|
224 |
)
|
225 |
-
text = f"{inline_mention(user)} **was kicked by** {inline_mention(ult.
|
226 |
if reason:
|
227 |
text += f"\n**Reason**: `{reason}`"
|
228 |
await xx.edit(text)
|
229 |
|
230 |
|
231 |
-
@ultroid_cmd(pattern="
|
232 |
-
async def
|
233 |
-
|
234 |
-
tt = msg.text
|
235 |
try:
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
|
|
|
|
240 |
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
if not msg.is_reply:
|
242 |
return await eor(msg, "Reply a Message to Pin !")
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
ch = msg.pattern_match.group(1)
|
247 |
-
if ch != "silent":
|
248 |
-
pass
|
249 |
else:
|
250 |
-
|
251 |
try:
|
252 |
-
await msg.client.pin_message(msg.chat_id,
|
253 |
except BadRequestError:
|
254 |
return await eor(msg, "`Hmm.. Guess I have no rights here!`")
|
255 |
except Exception as e:
|
256 |
-
return await eor(msg, f"**ERROR:**`{
|
257 |
-
|
258 |
-
await msg.delete()
|
259 |
|
260 |
|
261 |
@ultroid_cmd(
|
262 |
-
pattern="unpin($| (.*))",
|
|
|
263 |
)
|
264 |
async def unp(ult):
|
265 |
xx = await eor(ult, get_string("com_1"))
|
266 |
-
if not ult.is_private:
|
267 |
-
# for (un)pin(s) in private messages
|
268 |
-
await ult.get_chat()
|
269 |
ch = (ult.pattern_match.group(1)).strip()
|
270 |
msg = ult.reply_to_msg_id
|
271 |
-
if msg
|
272 |
-
|
273 |
-
await ult.client.unpin_message(ult.chat_id, msg)
|
274 |
-
except BadRequestError:
|
275 |
-
return await xx.edit("`Hmm.. Guess I have no rights here!`")
|
276 |
-
except Exception as e:
|
277 |
-
return await xx.edit(f"**ERROR:**\n`{str(e)}`")
|
278 |
elif ch == "all":
|
279 |
-
|
280 |
-
await ult.client.unpin_message(ult.chat_id)
|
281 |
-
except BadRequestError:
|
282 |
-
return await xx.edit("`Hmm.. Guess I have no rights here!`")
|
283 |
-
except Exception as e:
|
284 |
-
return await xx.edit(f"**ERROR:**`{str(e)}`")
|
285 |
else:
|
286 |
return await xx.edit(f"Either reply to a message, or, use `{hndlr}unpin all`")
|
287 |
-
|
288 |
-
|
|
|
|
|
|
|
|
|
289 |
await xx.edit("`Unpinned!`")
|
290 |
|
291 |
|
292 |
-
@ultroid_cmd(
|
|
|
|
|
|
|
293 |
async def fastpurger(purg):
|
294 |
chat = await purg.get_input_chat()
|
295 |
match = purg.pattern_match.group(1)
|
@@ -299,32 +299,22 @@ async def fastpurger(purg):
|
|
299 |
ABC = None
|
300 |
if ABC and purg.text[6] in ["m", "a"]:
|
301 |
return
|
302 |
-
if purg.
|
303 |
-
return await purg.client.delete_messages(
|
304 |
-
purg.chat_id, [a for a in range(purg.reply_to_msg_id, purg.id)]
|
305 |
-
)
|
306 |
-
if match and not purg.is_reply:
|
307 |
p = 0
|
308 |
async for msg in purg.client.iter_messages(purg.chat_id, limit=int(match)):
|
309 |
await msg.delete()
|
310 |
p += 0
|
311 |
-
return await
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
msgs = []
|
323 |
-
|
324 |
-
if msgs:
|
325 |
-
await purg.client.delete_messages(chat, msgs)
|
326 |
-
await eod(
|
327 |
-
purg,
|
328 |
"__Fast purge complete!__\n**Purged** `" + str(count) + "` **messages.**",
|
329 |
)
|
330 |
|
@@ -338,7 +328,7 @@ async def fastpurgerme(purg):
|
|
338 |
try:
|
339 |
nnt = int(num)
|
340 |
except BaseException:
|
341 |
-
await
|
342 |
return
|
343 |
mp = 0
|
344 |
async for mm in purg.client.iter_messages(
|
@@ -346,7 +336,7 @@ async def fastpurgerme(purg):
|
|
346 |
):
|
347 |
await mm.delete()
|
348 |
mp += 1
|
349 |
-
await
|
350 |
return
|
351 |
chat = await purg.get_input_chat()
|
352 |
msgs = []
|
@@ -363,7 +353,7 @@ async def fastpurgerme(purg):
|
|
363 |
min_id=purg.reply_to_msg_id,
|
364 |
):
|
365 |
msgs.append(msg)
|
366 |
-
count
|
367 |
msgs.append(purg.reply_to_msg_id)
|
368 |
if len(msgs) == 100:
|
369 |
await ultroid_bot.delete_messages(chat, msgs)
|
@@ -381,20 +371,35 @@ async def fastpurgerme(purg):
|
|
381 |
pattern="purgeall$",
|
382 |
)
|
383 |
async def _(e):
|
384 |
-
|
385 |
-
if e.reply_to_msg_id:
|
386 |
-
name = (await e.get_reply_message()).sender
|
387 |
-
try:
|
388 |
-
await e.client(DeleteUserHistoryRequest(e.chat_id, name.id))
|
389 |
-
await eod(e, f"Successfully Purged All Messages from {name.first_name}")
|
390 |
-
except Exception as er:
|
391 |
-
return await eod(xx, str(er))
|
392 |
-
else:
|
393 |
return await eod(
|
394 |
-
|
395 |
"`Reply to someone's msg to delete.`",
|
396 |
)
|
397 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
398 |
|
399 |
@ultroid_cmd(
|
400 |
pattern="listpinned$",
|
@@ -422,7 +427,7 @@ async def get_all_pinned(event):
|
|
422 |
m = f"<b>List of pinned message(s) in {chat_name}:</b>\n\n"
|
423 |
|
424 |
if a == "":
|
425 |
-
return await
|
426 |
|
427 |
await x.edit(m + a, parse_mode="html")
|
428 |
|
@@ -431,18 +436,22 @@ async def get_all_pinned(event):
|
|
431 |
pattern="autodelete ?(.*)",
|
432 |
admins_only=True,
|
433 |
)
|
434 |
-
async def autodelte(ult):
|
435 |
match = ult.pattern_match.group(1)
|
436 |
-
if not match or match not in ["24h", "7d", "off"]:
|
437 |
-
return await
|
438 |
if match == "24h":
|
439 |
tt = 3600 * 24
|
440 |
elif match == "7d":
|
441 |
tt = 3600 * 24 * 7
|
|
|
|
|
442 |
else:
|
443 |
tt = 0
|
444 |
try:
|
445 |
await ult.client(SetHistoryTTLRequest(ult.chat_id, period=tt))
|
446 |
except ChatNotModifiedError:
|
447 |
-
return await
|
448 |
-
|
|
|
|
|
|
18 |
• `{i}kick <reply to user/userid/username> <reason>`
|
19 |
Kick the user from the chat.
|
20 |
|
21 |
+
• `{i}tban <time> <reply to msg/ use id>`
|
22 |
+
s- seconds | m- minutes
|
23 |
+
h- hours | d- days
|
24 |
+
Ban user in current chat with time.
|
25 |
+
|
26 |
• `{i}pin <reply to message>`
|
27 |
Pin the message in the chat
|
28 |
for silent pin use ({i}pin silent).
|
|
|
33 |
• `{i}pinned`
|
34 |
Get pinned message in the current chat.
|
35 |
|
36 |
+
• `{i}autodelete <24h/7d/1m/off>`
|
37 |
Enable Auto Delete Messages in Chat.
|
38 |
|
39 |
• `{i}listpinned`
|
|
|
48 |
• `{i}purgeall`
|
49 |
Delete all msgs of replied user.
|
50 |
"""
|
|
|
51 |
|
52 |
from telethon.errors import BadRequestError
|
53 |
from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidError
|
54 |
+
from telethon.tl.functions.channels import (
|
55 |
+
DeleteUserHistoryRequest,
|
56 |
+
GetFullChannelRequest,
|
57 |
+
)
|
58 |
+
from telethon.tl.functions.messages import GetFullChatRequest, SetHistoryTTLRequest
|
59 |
+
from telethon.tl.types import InputMessagesFilterPinned
|
60 |
|
61 |
from . import *
|
62 |
|
63 |
|
64 |
+
@ultroid_cmd(pattern="promote ?(.*)", admins_only=True, type=["official", "manager"])
|
|
|
|
|
|
|
|
|
|
|
65 |
async def prmte(ult):
|
66 |
xx = await eor(ult, get_string("com_1"))
|
67 |
await ult.get_chat()
|
|
|
71 |
if not user:
|
72 |
return await xx.edit("`Reply to a user to promote him!`")
|
73 |
try:
|
74 |
+
await ult.client.edit_admin(
|
75 |
+
ult.chat_id,
|
76 |
+
user.id,
|
77 |
+
invite_users=True,
|
78 |
+
ban_users=True,
|
79 |
+
delete_messages=True,
|
80 |
+
pin_messages=True,
|
81 |
+
manage_call=True,
|
82 |
+
title=rank,
|
|
|
|
|
|
|
|
|
|
|
83 |
)
|
84 |
+
await eod(
|
85 |
+
xx,
|
86 |
f"{inline_mention(user)} `is now an admin in {ult.chat.title} with title {rank}.`",
|
87 |
)
|
88 |
+
except Exception as ex:
|
89 |
+
return await xx.edit("`" + str(ex) + "`")
|
|
|
|
|
90 |
|
91 |
|
92 |
@ultroid_cmd(
|
93 |
pattern="demote ?(.*)",
|
94 |
admins_only=True,
|
95 |
type=["official", "manager"],
|
|
|
96 |
)
|
97 |
async def dmote(ult):
|
98 |
xx = await eor(ult, get_string("com_1"))
|
|
|
103 |
if not user:
|
104 |
return await xx.edit("`Reply to a user to demote him!`")
|
105 |
try:
|
106 |
+
await ult.client.edit_admin(
|
107 |
+
ult.chat_id,
|
108 |
+
user.id,
|
109 |
+
invite_users=None,
|
110 |
+
ban_users=None,
|
111 |
+
delete_messages=None,
|
112 |
+
pin_messages=None,
|
113 |
+
manage_call=None,
|
114 |
+
title=rank,
|
|
|
|
|
|
|
|
|
|
|
115 |
)
|
116 |
+
await eod(
|
117 |
+
xx, f"{inline_mention(user)} `is no longer an admin in {ult.chat.title}`"
|
118 |
)
|
119 |
+
except Exception as ex:
|
120 |
+
return await xx.edit("`" + str(ex) + "`")
|
|
|
|
|
121 |
|
122 |
|
123 |
+
@ultroid_cmd(pattern="ban ?(.*)", admins_only=True, type=["official", "manager"])
|
|
|
|
|
|
|
|
|
|
|
124 |
async def bban(ult):
|
125 |
xx = await eor(ult, get_string("com_1"))
|
126 |
user, reason = await get_user_info(ult)
|
127 |
if not user:
|
128 |
return await xx.edit("`Reply to a user or give username to ban him!`")
|
129 |
+
if user.id in DEVLIST:
|
130 |
return await xx.edit(" `LoL, I can't Ban my Developer 😂`")
|
131 |
try:
|
132 |
await ult.client.edit_permissions(ult.chat_id, user.id, view_messages=False)
|
133 |
except BadRequestError:
|
134 |
+
return await xx.edit(f"`I don't have the right to ban a user.`")
|
135 |
except UserIdInvalidError:
|
136 |
return await xx.edit("`I couldn't get who he is!`")
|
137 |
+
senderme = inline_mention(await ult.get_sender())
|
138 |
try:
|
139 |
reply = await ult.get_reply_message()
|
140 |
if reply:
|
141 |
await reply.delete()
|
142 |
except BadRequestError:
|
143 |
return await xx.edit(
|
144 |
+
f"{inline_mention(user)}**was banned by** {senderme} **in** `{ult.chat.title}`\n**Reason**: `{reason}`\n**Messages Deleted**: `False`",
|
145 |
)
|
146 |
userme = inline_mention(user)
|
|
|
147 |
if reason:
|
148 |
await xx.edit(
|
149 |
+
f"{userme} **was banned by** {senderme} **in** `{ult.chat.title}`\n**Reason**: `{reason}`",
|
150 |
)
|
151 |
else:
|
152 |
await xx.edit(
|
|
|
158 |
pattern="unban ?(.*)",
|
159 |
admins_only=True,
|
160 |
type=["official", "manager"],
|
|
|
161 |
)
|
162 |
async def uunban(ult):
|
163 |
xx = await eor(ult, get_string("com_1"))
|
|
|
170 |
return await xx.edit("`I don't have the right to unban a user.`")
|
171 |
except UserIdInvalidError:
|
172 |
await xx.edit("`I couldn't get who he is!`")
|
173 |
+
sender = inline_mention(await ult.get_sender())
|
174 |
+
text = (
|
175 |
+
f"{inline_mention(user)} **was unbanned by** {sender} **in** `{ult.chat.title}`"
|
176 |
+
)
|
177 |
if reason:
|
178 |
text += f"\n**Reason**: `{reason}`"
|
179 |
await xx.edit(text)
|
|
|
183 |
pattern="kick ?(.*)",
|
184 |
admins_only=True,
|
185 |
type=["official", "manager"],
|
|
|
186 |
)
|
187 |
async def kck(ult):
|
188 |
+
ml = ult.text.split(" ", maxsplit=1)[0]
|
189 |
+
if "kickme" in ult.text:
|
190 |
return
|
191 |
xx = await eor(ult, get_string("com_1"))
|
|
|
192 |
user, reason = await get_user_info(ult)
|
193 |
if not user:
|
194 |
return await xx.edit("`Kick? Whom? I couldn't get his info...`")
|
195 |
+
if user.id in DEVLIST:
|
196 |
return await xx.edit(" `Lol, I can't Kick my Developer`😂")
|
197 |
+
if user.is_self:
|
198 |
+
return await xx.edit("`I Cant kick him ever...`")
|
199 |
try:
|
200 |
await ult.client.kick_participant(ult.chat_id, user.id)
|
|
|
201 |
except BadRequestError:
|
202 |
return await xx.edit("`I don't have the right to kick a user.`")
|
203 |
except Exception as e:
|
204 |
return await xx.edit(
|
205 |
f"`I don't have the right to kick a user.`\n\n**ERROR**:\n`{str(e)}`",
|
206 |
)
|
207 |
+
text = f"{inline_mention(user)} **was kicked by** {inline_mention(await ult.get_sender())} **in** `{ult.chat.title}`"
|
208 |
if reason:
|
209 |
text += f"\n**Reason**: `{reason}`"
|
210 |
await xx.edit(text)
|
211 |
|
212 |
|
213 |
+
@ultroid_cmd(pattern="tban ?(.*)", type=["official", "manager"])
|
214 |
+
async def tkicki(e):
|
215 |
+
huh = e.text.split(" ")
|
|
|
216 |
try:
|
217 |
+
tme = huh[1]
|
218 |
+
except IndexError:
|
219 |
+
return await eor(e, "`Time till kick?`", time=15)
|
220 |
+
try:
|
221 |
+
inputt = huh[2]
|
222 |
+
except IndexError:
|
223 |
pass
|
224 |
+
chat = await e.get_chat()
|
225 |
+
if e.is_reply:
|
226 |
+
replied = await e.get_reply_message()
|
227 |
+
userid = replied.sender_id
|
228 |
+
fn = (await e.get_sender()).first_name
|
229 |
+
elif inputt:
|
230 |
+
userid = await get_user_id(inputt)
|
231 |
+
fn = (await e.client.get_entity(userid)).first_name
|
232 |
+
else:
|
233 |
+
return await eor(e, "`Reply to someone or use its id...`", time=3)
|
234 |
+
try:
|
235 |
+
bun = await ban_time(e, tme)
|
236 |
+
await e.client.edit_permissions(
|
237 |
+
e.chat_id, userid, until_date=bun, view_messages=False
|
238 |
+
)
|
239 |
+
await eod(
|
240 |
+
e,
|
241 |
+
f"`Successfully Banned` `{fn}` `in {chat.title} for {tme}`",
|
242 |
+
time=15,
|
243 |
+
)
|
244 |
+
except Exception as m:
|
245 |
+
return await eor(e, str(m))
|
246 |
+
|
247 |
+
|
248 |
+
@ultroid_cmd(pattern="pin$", type=["official", "manager"])
|
249 |
+
async def pin(msg):
|
250 |
if not msg.is_reply:
|
251 |
return await eor(msg, "Reply a Message to Pin !")
|
252 |
+
me = await msg.get_reply_message()
|
253 |
+
if me.is_private:
|
254 |
+
text = "`Pinned.`"
|
|
|
|
|
|
|
255 |
else:
|
256 |
+
text = f"Pinned [This Message]({me.message_link}) !"
|
257 |
try:
|
258 |
+
await msg.client.pin_message(msg.chat_id, me.id, notify=False)
|
259 |
except BadRequestError:
|
260 |
return await eor(msg, "`Hmm.. Guess I have no rights here!`")
|
261 |
except Exception as e:
|
262 |
+
return await eor(msg, f"**ERROR:**`{e}`")
|
263 |
+
await eor(msg, text)
|
|
|
264 |
|
265 |
|
266 |
@ultroid_cmd(
|
267 |
+
pattern="unpin($| (.*))",
|
268 |
+
type=["official", "manager"],
|
269 |
)
|
270 |
async def unp(ult):
|
271 |
xx = await eor(ult, get_string("com_1"))
|
|
|
|
|
|
|
272 |
ch = (ult.pattern_match.group(1)).strip()
|
273 |
msg = ult.reply_to_msg_id
|
274 |
+
if msg:
|
275 |
+
pass
|
|
|
|
|
|
|
|
|
|
|
276 |
elif ch == "all":
|
277 |
+
msg = None
|
|
|
|
|
|
|
|
|
|
|
278 |
else:
|
279 |
return await xx.edit(f"Either reply to a message, or, use `{hndlr}unpin all`")
|
280 |
+
try:
|
281 |
+
await ult.client.unpin_message(ult.chat_id, msg)
|
282 |
+
except BadRequestError:
|
283 |
+
return await xx.edit("`Hmm.. Guess I have no rights here!`")
|
284 |
+
except Exception as e:
|
285 |
+
return await xx.edit(f"**ERROR:**`{e}`")
|
286 |
await xx.edit("`Unpinned!`")
|
287 |
|
288 |
|
289 |
+
@ultroid_cmd(
|
290 |
+
pattern="purge ?(.*)",
|
291 |
+
type=["official", "manager"],
|
292 |
+
)
|
293 |
async def fastpurger(purg):
|
294 |
chat = await purg.get_input_chat()
|
295 |
match = purg.pattern_match.group(1)
|
|
|
299 |
ABC = None
|
300 |
if ABC and purg.text[6] in ["m", "a"]:
|
301 |
return
|
302 |
+
if not purg._client._bot and match and not purg.is_reply:
|
|
|
|
|
|
|
|
|
303 |
p = 0
|
304 |
async for msg in purg.client.iter_messages(purg.chat_id, limit=int(match)):
|
305 |
await msg.delete()
|
306 |
p += 0
|
307 |
+
return await eor(purg, f"Purged {p} Messages! ", time=5)
|
308 |
+
if not purg.reply_to_msg_id:
|
309 |
+
return await eor(purg, "`Reply to a message to purge from.`", time=10)
|
310 |
+
try:
|
311 |
+
await purg.client.delete_messages(
|
312 |
+
chat, [a for a in range(purg.reply_to_msg_id, purg.id + 1)]
|
313 |
+
)
|
314 |
+
except Exception as er:
|
315 |
+
LOGS.info(er)
|
316 |
+
count = purg.id - purg.reply_to_msg_id
|
317 |
+
await purg.respond(
|
|
|
|
|
|
|
|
|
|
|
|
|
318 |
"__Fast purge complete!__\n**Purged** `" + str(count) + "` **messages.**",
|
319 |
)
|
320 |
|
|
|
328 |
try:
|
329 |
nnt = int(num)
|
330 |
except BaseException:
|
331 |
+
await eor(purg, "`Give a Valid Input.. `", time=5)
|
332 |
return
|
333 |
mp = 0
|
334 |
async for mm in purg.client.iter_messages(
|
|
|
336 |
):
|
337 |
await mm.delete()
|
338 |
mp += 1
|
339 |
+
await eor(purg, f"Purged {mp} Messages!", time=5)
|
340 |
return
|
341 |
chat = await purg.get_input_chat()
|
342 |
msgs = []
|
|
|
353 |
min_id=purg.reply_to_msg_id,
|
354 |
):
|
355 |
msgs.append(msg)
|
356 |
+
count += 1
|
357 |
msgs.append(purg.reply_to_msg_id)
|
358 |
if len(msgs) == 100:
|
359 |
await ultroid_bot.delete_messages(chat, msgs)
|
|
|
371 |
pattern="purgeall$",
|
372 |
)
|
373 |
async def _(e):
|
374 |
+
if not e.is_reply:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
375 |
return await eod(
|
376 |
+
e,
|
377 |
"`Reply to someone's msg to delete.`",
|
378 |
)
|
379 |
|
380 |
+
name = (await e.get_reply_message()).sender
|
381 |
+
try:
|
382 |
+
await e.client(DeleteUserHistoryRequest(e.chat_id, name.id))
|
383 |
+
await eor(e, f"Successfully Purged All Messages from {name.first_name}", time=5)
|
384 |
+
except Exception as er:
|
385 |
+
return await eor(e, str(er), time=5)
|
386 |
+
|
387 |
+
|
388 |
+
@ultroid_cmd(pattern="pinned", type=["official", "manager"], groups_only=True)
|
389 |
+
async def djshsh(event):
|
390 |
+
chat = await event.get_chat()
|
391 |
+
if isinstance(chat, types.Chat):
|
392 |
+
FChat = await event.client(GetFullChatRequest(chat.id))
|
393 |
+
elif isinstance(chat, types.Channel):
|
394 |
+
FChat = await event.client(GetFullChannelRequest(chat.id))
|
395 |
+
else:
|
396 |
+
return
|
397 |
+
msg_id = FChat.full_chat.pinned_msg_id
|
398 |
+
if not msg_id:
|
399 |
+
return await eor(event, "No Pinned Message Found!")
|
400 |
+
msg = await event.client.get_messages(chat.id, ids=msg_id)
|
401 |
+
await eor(event, f"Pinned Message in Current chat is [here]({msg.message_link}).")
|
402 |
+
|
403 |
|
404 |
@ultroid_cmd(
|
405 |
pattern="listpinned$",
|
|
|
427 |
m = f"<b>List of pinned message(s) in {chat_name}:</b>\n\n"
|
428 |
|
429 |
if a == "":
|
430 |
+
return await eor(x, "There is no message pinned in this group!", time=5)
|
431 |
|
432 |
await x.edit(m + a, parse_mode="html")
|
433 |
|
|
|
436 |
pattern="autodelete ?(.*)",
|
437 |
admins_only=True,
|
438 |
)
|
439 |
+
async def autodelte(ult):
|
440 |
match = ult.pattern_match.group(1)
|
441 |
+
if not match or match not in ["24h", "7d", "1m", "off"]:
|
442 |
+
return await eor(ult, "`Please Use Proper Format..`", time=5)
|
443 |
if match == "24h":
|
444 |
tt = 3600 * 24
|
445 |
elif match == "7d":
|
446 |
tt = 3600 * 24 * 7
|
447 |
+
elif match == "1m":
|
448 |
+
tt = 3600 * 24 * 31
|
449 |
else:
|
450 |
tt = 0
|
451 |
try:
|
452 |
await ult.client(SetHistoryTTLRequest(ult.chat_id, period=tt))
|
453 |
except ChatNotModifiedError:
|
454 |
+
return await eor(
|
455 |
+
ult, f"Auto Delete Setting is Already same to `{match}`", time=5
|
456 |
+
)
|
457 |
+
await eor(ult, f"Auto Delete Status Changed to `{match}` !")
|
plugins/afk.py
CHANGED
@@ -10,245 +10,146 @@
|
|
10 |
|
11 |
• `{i}afk <optional reason>`
|
12 |
AFK means away from keyboard,
|
13 |
-
|
14 |
After u active this if Someone tag or msg u then It auto Reply Him/her,
|
|
|
15 |
(Note : By Reply To any media U can set media afk too).
|
16 |
|
17 |
"""
|
18 |
|
19 |
import asyncio
|
20 |
-
from datetime import datetime
|
21 |
|
|
|
22 |
from pyUltroid.functions.pmpermit_db import *
|
|
|
23 |
from telethon import events
|
24 |
-
from telethon.tl.functions.account import GetPrivacyRequest
|
25 |
-
from telethon.tl.types import InputPrivacyKeyStatusTimestamp, PrivacyValueAllowAll
|
26 |
|
27 |
from . import *
|
28 |
|
29 |
-
|
30 |
-
global afk_time
|
31 |
-
global last_afk_message
|
32 |
-
global last_afk_msg
|
33 |
-
global afk_start
|
34 |
-
global afk_end
|
35 |
-
USER_AFK = {}
|
36 |
-
afk_time = None
|
37 |
-
last_afk_message = {}
|
38 |
-
last_afk_msg = {}
|
39 |
-
afk_start = {}
|
40 |
-
|
41 |
-
LOG = int(udB.get("LOG_CHANNEL"))
|
42 |
|
43 |
|
44 |
-
@
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
shites = await ultroid_bot.send_message(
|
66 |
-
event.chat_id,
|
67 |
-
get_string("afk_1").format(total_afk_time),
|
68 |
-
)
|
69 |
else:
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
get_string("
|
79 |
)
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
try:
|
82 |
-
|
83 |
-
await ultroid_bot.send_message(LOG, file=pic)
|
84 |
-
await ultroid_bot.send_message(
|
85 |
-
LOG,
|
86 |
-
get_string("afk_2").format(total_afk_time),
|
87 |
-
)
|
88 |
-
else:
|
89 |
-
await ultroid_bot.send_message(
|
90 |
-
LOG,
|
91 |
-
get_string("afk_2").format(total_afk_time),
|
92 |
-
file=pic,
|
93 |
-
)
|
94 |
except BaseException:
|
95 |
-
|
96 |
-
LOG,
|
97 |
-
get_string("afk_2").format(total_afk_time),
|
98 |
-
)
|
99 |
-
except BaseException:
|
100 |
-
pass
|
101 |
await asyncio.sleep(3)
|
102 |
-
await
|
103 |
-
try:
|
104 |
-
await shites.delete()
|
105 |
-
except BaseException:
|
106 |
-
pass
|
107 |
-
USER_AFK = {}
|
108 |
-
afk_time = None
|
109 |
|
110 |
|
111 |
@ultroid_bot.on(
|
112 |
events.NewMessage(incoming=True, func=lambda e: bool(e.mentioned or e.is_private)),
|
113 |
)
|
114 |
async def on_afk(event):
|
115 |
-
if
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
if
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
msg = None
|
134 |
-
if reason:
|
135 |
-
message_to_reply = get_string("afk_3").format(total_afk_time, reason)
|
136 |
else:
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
except BaseException:
|
145 |
-
msg = await event.reply(message_to_reply)
|
146 |
-
await asyncio.sleep(2.5)
|
147 |
-
if event.chat_id in last_afk_message:
|
148 |
-
await last_afk_message[event.chat_id].delete()
|
149 |
-
try:
|
150 |
-
if event.chat_id in last_afk_msg:
|
151 |
-
await last_afk_msg[event.chat_id].delete()
|
152 |
-
except BaseException:
|
153 |
-
pass
|
154 |
-
last_afk_message[event.chat_id] = msg
|
155 |
-
try:
|
156 |
-
if msgs:
|
157 |
-
last_afk_msg[event.chat_id] = msgs
|
158 |
-
except BaseException:
|
159 |
-
pass
|
160 |
-
|
161 |
-
|
162 |
-
@ultroid_cmd(pattern=r"afk ?(.*)")
|
163 |
-
async def _(event):
|
164 |
-
if not event.out and not is_fullsudo(event.sender_id):
|
165 |
-
return await eor(event, "`This Command Is Full Sudo Restricted.`")
|
166 |
-
reply = await event.get_reply_message()
|
167 |
-
if event.client._bot:
|
168 |
-
return await eor(event, "Master, I am a Bot, I cant go AFK..")
|
169 |
-
global USER_AFK
|
170 |
-
global afk_time
|
171 |
-
global last_afk_message
|
172 |
-
global last_afk_msg
|
173 |
-
global afk_start
|
174 |
-
global afk_end
|
175 |
-
global reason
|
176 |
-
global pic
|
177 |
-
USER_AFK = {}
|
178 |
-
afk_time = None
|
179 |
-
last_afk_message = {}
|
180 |
-
last_afk_msg = {}
|
181 |
-
afk_end = {}
|
182 |
-
start_1 = datetime.now()
|
183 |
-
afk_start = start_1.replace(microsecond=0)
|
184 |
-
reason = event.pattern_match.group(1)
|
185 |
-
if reply:
|
186 |
-
pic = await event.client.download_media(reply)
|
187 |
-
else:
|
188 |
-
pic = None
|
189 |
-
if not USER_AFK:
|
190 |
-
last_seen_status = await ultroid_bot(
|
191 |
-
GetPrivacyRequest(InputPrivacyKeyStatusTimestamp()),
|
192 |
-
)
|
193 |
-
if isinstance(last_seen_status.rules, PrivacyValueAllowAll):
|
194 |
-
afk_time = datetime.datetime.now()
|
195 |
-
USER_AFK = f"yes: {reason} {pic}"
|
196 |
-
if reason:
|
197 |
-
try:
|
198 |
-
if pic.endswith((".tgs", ".webp")):
|
199 |
-
await ultroid_bot.send_message(event.chat_id, file=pic)
|
200 |
-
await ultroid_bot.send_message(
|
201 |
-
event.chat_id,
|
202 |
-
get_string("afk_5").format(reason),
|
203 |
-
)
|
204 |
-
else:
|
205 |
-
await ultroid_bot.send_message(
|
206 |
-
event.chat_id,
|
207 |
-
get_string("afk_5").format(reason),
|
208 |
-
file=pic,
|
209 |
-
)
|
210 |
-
except BaseException:
|
211 |
-
await ultroid_bot.send_message(
|
212 |
-
event.chat_id,
|
213 |
-
get_string("afk_5").format(reason),
|
214 |
-
)
|
215 |
else:
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
event.chat_id,
|
223 |
-
get_string("afk_6"),
|
224 |
-
file=pic,
|
225 |
-
)
|
226 |
-
except BaseException:
|
227 |
-
await ultroid_bot.send_message(event.chat_id, get_string("afk_6"))
|
228 |
-
await event.delete()
|
229 |
try:
|
230 |
-
|
231 |
-
if pic.endswith((".tgs", ".webp")):
|
232 |
-
await ultroid_bot.send_message(LOG, file=pic)
|
233 |
-
await ultroid_bot.send_message(
|
234 |
-
LOG,
|
235 |
-
get_string("afk_7").format(reason),
|
236 |
-
)
|
237 |
-
else:
|
238 |
-
await ultroid_bot.send_message(
|
239 |
-
LOG,
|
240 |
-
get_string("afk_7").format(reason),
|
241 |
-
file=pic,
|
242 |
-
)
|
243 |
-
elif reason:
|
244 |
-
await ultroid_bot.send_message(LOG, get_string("afk_7").format(reason))
|
245 |
-
elif pic:
|
246 |
-
if pic.endswith((".tgs", ".webp")):
|
247 |
-
await ultroid_bot.send_message(LOG, file=pic)
|
248 |
-
await ultroid_bot.send_message(LOG, get_string("afk_8"))
|
249 |
-
else:
|
250 |
-
await ultroid_bot.send_message(LOG, get_string("afk_8"), file=pic)
|
251 |
-
else:
|
252 |
-
await ultroid_bot.send_message(LOG, get_string("afk_8"))
|
253 |
except BaseException:
|
254 |
pass
|
|
|
|
|
|
|
|
10 |
|
11 |
• `{i}afk <optional reason>`
|
12 |
AFK means away from keyboard,
|
|
|
13 |
After u active this if Someone tag or msg u then It auto Reply Him/her,
|
14 |
+
|
15 |
(Note : By Reply To any media U can set media afk too).
|
16 |
|
17 |
"""
|
18 |
|
19 |
import asyncio
|
|
|
20 |
|
21 |
+
from pyUltroid.functions.afk_db import *
|
22 |
from pyUltroid.functions.pmpermit_db import *
|
23 |
+
from telegraph import upload_file as uf
|
24 |
from telethon import events
|
|
|
|
|
25 |
|
26 |
from . import *
|
27 |
|
28 |
+
old_afk_msg = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
|
31 |
+
@ultroid_cmd(pattern="afk ?(.*)", fullsudo=True)
|
32 |
+
async def set_afk(event):
|
33 |
+
if event.client._bot:
|
34 |
+
await eor(event, "Master, I am a Bot, I cant go AFK..")
|
35 |
+
elif is_afk():
|
36 |
+
return
|
37 |
+
text, media, media_type = None, None, None
|
38 |
+
if event.pattern_match.group(1):
|
39 |
+
text = event.text.split(maxsplit=1)[1]
|
40 |
+
reply = await event.get_reply_message()
|
41 |
+
if reply:
|
42 |
+
if reply.text and not text:
|
43 |
+
text = reply.text
|
44 |
+
if reply.media:
|
45 |
+
media_type = mediainfo(reply.media)
|
46 |
+
if media_type.startswith(("pic", "gif")):
|
47 |
+
file = await event.client.download_media(reply.media)
|
48 |
+
iurl = uf(file)
|
49 |
+
media = f"https://telegra.ph{iurl[0]}"
|
50 |
+
elif "sticker" in media_type:
|
51 |
+
media = reply.file.id
|
|
|
|
|
|
|
|
|
52 |
else:
|
53 |
+
return await eor(event, "`Unsupported media`", time=5)
|
54 |
+
await eor(event, "`Done`", time=2)
|
55 |
+
add_afk(text, media_type, media)
|
56 |
+
msg1, msg2 = None, None
|
57 |
+
if text and media:
|
58 |
+
if "sticker" in media_type:
|
59 |
+
msg1 = await ultroid_bot.send_file(event.chat_id, file=media)
|
60 |
+
msg2 = await ultroid_bot.send_message(
|
61 |
+
event.chat_id, get_string("afk_5").format(text)
|
62 |
)
|
63 |
+
else:
|
64 |
+
msg1 = await ultroid_bot.send_message(
|
65 |
+
event.chat_id, get_string("afk_5").format(text), file=media
|
66 |
+
)
|
67 |
+
elif media:
|
68 |
+
if "sticker" in media_type:
|
69 |
+
msg1 = await ultroid_bot.send_file(event.chat_id, file=media)
|
70 |
+
msg2 = await ultroid_bot.send_message(event.chat_id, get_string("afk_6"))
|
71 |
+
else:
|
72 |
+
msg1 = await ultroid_bot.send_message(
|
73 |
+
event.chat_id, get_string("afk_6"), file=media
|
74 |
+
)
|
75 |
+
elif text:
|
76 |
+
msg1 = await ultroid_bot.send_message(
|
77 |
+
event.chat_id, get_string("afk_5").format(text)
|
78 |
+
)
|
79 |
+
else:
|
80 |
+
msg1 = await ultroid_bot.send_message(event.chat_id, get_string("afk_6"))
|
81 |
+
old_afk_msg.append(msg1)
|
82 |
+
if msg2:
|
83 |
+
old_afk_msg.append(msg2)
|
84 |
+
return await asst.send_message(LOG_CHANNEL, msg2.text)
|
85 |
+
await asst.send_message(LOG_CHANNEL, msg1.text)
|
86 |
+
|
87 |
+
|
88 |
+
@ultroid_bot.on(events.NewMessage(outgoing=True))
|
89 |
+
async def remove_afk(event):
|
90 |
+
if (
|
91 |
+
event.is_private
|
92 |
+
and Redis("PMSETTING") == "True"
|
93 |
+
and not is_approved(event.chat_id)
|
94 |
+
):
|
95 |
+
return
|
96 |
+
elif "afk" in event.text.lower():
|
97 |
+
return
|
98 |
+
if is_afk():
|
99 |
+
_, _, _, afk_time = is_afk()
|
100 |
+
del_afk()
|
101 |
+
off = await event.reply(get_string("afk_1").format(afk_time))
|
102 |
+
await asst.send_message(LOG_CHANNEL, get_string("afk_2").format(afk_time))
|
103 |
+
for x in old_afk_msg:
|
104 |
try:
|
105 |
+
await x.delete()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
except BaseException:
|
107 |
+
pass
|
|
|
|
|
|
|
|
|
|
|
108 |
await asyncio.sleep(3)
|
109 |
+
await off.delete()
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
|
112 |
@ultroid_bot.on(
|
113 |
events.NewMessage(incoming=True, func=lambda e: bool(e.mentioned or e.is_private)),
|
114 |
)
|
115 |
async def on_afk(event):
|
116 |
+
if (
|
117 |
+
event.is_private
|
118 |
+
and Redis("PMSETTING") == "True"
|
119 |
+
and not is_approved(event.chat_id)
|
120 |
+
):
|
121 |
+
return
|
122 |
+
elif "afk" in event.text.lower():
|
123 |
+
return
|
124 |
+
elif not is_afk():
|
125 |
+
return
|
126 |
+
elif event.chat_id in NOSPAM_CHAT:
|
127 |
+
return
|
128 |
+
text, media_type, media, afk_time = is_afk()
|
129 |
+
msg1, msg2 = None, None
|
130 |
+
if text and media:
|
131 |
+
if "sticker" in media_type:
|
132 |
+
msg1 = await event.reply(file=media)
|
133 |
+
msg2 = await event.reply(get_string("afk_3").format(afk_time, text))
|
|
|
|
|
|
|
134 |
else:
|
135 |
+
msg1 = await event.reply(
|
136 |
+
get_string("afk_3").format(afk_time, text), file=media
|
137 |
+
)
|
138 |
+
elif media:
|
139 |
+
if "sticker" in media_type:
|
140 |
+
msg1 = await event.reply(file=media)
|
141 |
+
msg2 = await event.reply(get_string("afk_4").format(afk_time))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
else:
|
143 |
+
msg1 = await event.reply(get_string("afk_4").format(afk_time), file=media)
|
144 |
+
elif text:
|
145 |
+
msg1 = await event.reply(get_string("afk_3").format(afk_time, text))
|
146 |
+
else:
|
147 |
+
msg1 = await event.reply(get_string("afk_4").format(afk_time))
|
148 |
+
for x in old_afk_msg:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
try:
|
150 |
+
await x.delete()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
except BaseException:
|
152 |
pass
|
153 |
+
old_afk_msg.append(msg1)
|
154 |
+
if msg2:
|
155 |
+
old_afk_msg.append(msg2)
|
plugins/akinator.py
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021 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}akinator`
|
12 |
+
`Start Akinator Game`.
|
13 |
+
|
14 |
+
"""
|
15 |
+
|
16 |
+
import akinator
|
17 |
+
from telethon.errors import BotMethodInvalidError
|
18 |
+
|
19 |
+
from . import *
|
20 |
+
|
21 |
+
games = {}
|
22 |
+
aki_photo = "https://telegra.ph/file/b0ff07069e8637783fdae.jpg"
|
23 |
+
|
24 |
+
|
25 |
+
@ultroid_cmd(pattern="akinator")
|
26 |
+
async def doit(e):
|
27 |
+
sta = akinator.Akinator()
|
28 |
+
games.update({e.chat_id: {e.id: sta}})
|
29 |
+
try:
|
30 |
+
m = await e.client.inline_query(asst.me.username, f"aki_{e.chat_id}_{e.id}")
|
31 |
+
await m[0].click(e.chat_id)
|
32 |
+
except BotMethodInvalidError:
|
33 |
+
return await asst.send_file(
|
34 |
+
e.chat_id,
|
35 |
+
aki_photo,
|
36 |
+
buttons=Button.inline("Start Game", data=f"aki_{e.chat_id}_{e.id}"),
|
37 |
+
)
|
38 |
+
if e.out:
|
39 |
+
await e.delete()
|
40 |
+
|
41 |
+
|
42 |
+
@callback(re.compile("aki_?(.*)"))
|
43 |
+
@owner
|
44 |
+
async def doai(e):
|
45 |
+
adt = e.pattern_match.group(1).decode("utf-8")
|
46 |
+
dt = adt.split("_")
|
47 |
+
ch = int(dt[0])
|
48 |
+
mid = int(dt[1])
|
49 |
+
await e.edit("Processing... ")
|
50 |
+
try:
|
51 |
+
qu = games[ch][mid].start_game(child_mode=True)
|
52 |
+
# child mode should be promoted
|
53 |
+
except KeyError:
|
54 |
+
return await e.answer("Game has been Terminated....", alert=True)
|
55 |
+
bts = [Button.inline(o, f"aka_{adt}_{o}") for o in ["Yes", "No", "Idk"]]
|
56 |
+
cts = [Button.inline(o, f"aka_{adt}_{o}") for o in ["Probably", "Probably Not"]]
|
57 |
+
|
58 |
+
bts = [bts, cts]
|
59 |
+
# ignored Back Button since it makes the Pagination looks Bad
|
60 |
+
await e.edit("Q. " + qu, buttons=bts)
|
61 |
+
|
62 |
+
|
63 |
+
@callback(re.compile("aka_?(.*)"))
|
64 |
+
@owner
|
65 |
+
async def okah(e):
|
66 |
+
mk = e.pattern_match.group(1).decode("utf-8").split("_")
|
67 |
+
ch = int(mk[0])
|
68 |
+
mid = int(mk[1])
|
69 |
+
ans = mk[2]
|
70 |
+
try:
|
71 |
+
gm = games[ch][mid]
|
72 |
+
except KeyError:
|
73 |
+
await e.answer("Timeout !")
|
74 |
+
return
|
75 |
+
text = gm.answer(ans)
|
76 |
+
if gm.progression >= 80:
|
77 |
+
gm.win()
|
78 |
+
gs = gm.first_guess
|
79 |
+
text = "It's " + gs["name"] + "\n " + gs["description"]
|
80 |
+
return await e.edit(text, file=gs["absolute_picture_path"])
|
81 |
+
bts = [Button.inline(o, f"aka_{ch}_{mid}_{o}") for o in ["Yes", "No", "Idk"]]
|
82 |
+
cts = [
|
83 |
+
Button.inline(o, f"aka_{ch}_{mid}_{o}") for o in ["Probably", "Probably Not"]
|
84 |
+
]
|
85 |
+
|
86 |
+
bts = [bts, cts]
|
87 |
+
await e.edit(text, buttons=bts)
|
88 |
+
|
89 |
+
|
90 |
+
@in_pattern(re.compile("aki_?(.*)"))
|
91 |
+
@in_owner
|
92 |
+
async def eiagx(e):
|
93 |
+
bts = Button.inline("Start Game", data=e.text)
|
94 |
+
ci = types.InputWebDocument(aki_photo, 0, "image/jpeg", [])
|
95 |
+
ans = [
|
96 |
+
await e.builder.article(
|
97 |
+
"Akinator",
|
98 |
+
type="photo",
|
99 |
+
content=ci,
|
100 |
+
text="Akinator",
|
101 |
+
thumb=ci,
|
102 |
+
buttons=bts,
|
103 |
+
include_media=True,
|
104 |
+
)
|
105 |
+
]
|
106 |
+
await e.answer(ans)
|
plugins/anime.py
CHANGED
@@ -27,10 +27,16 @@ from . import *
|
|
27 |
@ultroid_cmd(pattern="airing")
|
28 |
async def airing_anime(event):
|
29 |
try:
|
30 |
-
await eor(event, airing_eps())
|
31 |
except BaseException:
|
32 |
info = airing_eps()
|
33 |
-
t =
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
with open("animes.txt", "w") as f:
|
35 |
f.write(t)
|
36 |
await event.reply(file="animes.txt")
|
@@ -43,7 +49,7 @@ async def anilist(event):
|
|
43 |
name = event.pattern_match.group(1)
|
44 |
x = await eor(event, get_string("com_1"))
|
45 |
if not name:
|
46 |
-
return await
|
47 |
banner, title, year, episodes, info = get_anime_src_res(name)
|
48 |
msg = f"**{title}**\n{year} | {episodes} Episodes.\n\n{info}"
|
49 |
try:
|
@@ -74,12 +80,12 @@ async def anime_char_search(event):
|
|
74 |
xx = await eor(event, get_string("com_1"))
|
75 |
char_name = event.pattern_match.group(1)
|
76 |
if not char_name:
|
77 |
-
await
|
78 |
jikan = jikanpy.jikan.Jikan()
|
79 |
try:
|
80 |
s = jikan.search("character", char_name)
|
81 |
except jikanpy.exceptions.APIException:
|
82 |
-
return await
|
83 |
a = s["results"][0]["mal_id"]
|
84 |
char_json = jikan.character(a)
|
85 |
pic = char_json["image_url"]
|
|
|
27 |
@ultroid_cmd(pattern="airing")
|
28 |
async def airing_anime(event):
|
29 |
try:
|
30 |
+
await eor(event, airing_eps(), link_preview=False)
|
31 |
except BaseException:
|
32 |
info = airing_eps()
|
33 |
+
t = (
|
34 |
+
info.replace("*", "")
|
35 |
+
.replace("[", "")
|
36 |
+
.replace("]", "")
|
37 |
+
.replace("(", " ")
|
38 |
+
.replace(")", "")
|
39 |
+
)
|
40 |
with open("animes.txt", "w") as f:
|
41 |
f.write(t)
|
42 |
await event.reply(file="animes.txt")
|
|
|
49 |
name = event.pattern_match.group(1)
|
50 |
x = await eor(event, get_string("com_1"))
|
51 |
if not name:
|
52 |
+
return await eor(x, "`Enter a anime name!`", time=5)
|
53 |
banner, title, year, episodes, info = get_anime_src_res(name)
|
54 |
msg = f"**{title}**\n{year} | {episodes} Episodes.\n\n{info}"
|
55 |
try:
|
|
|
80 |
xx = await eor(event, get_string("com_1"))
|
81 |
char_name = event.pattern_match.group(1)
|
82 |
if not char_name:
|
83 |
+
await eor(xx, "`Enter the name of a character too please!`", time=5)
|
84 |
jikan = jikanpy.jikan.Jikan()
|
85 |
try:
|
86 |
s = jikan.search("character", char_name)
|
87 |
except jikanpy.exceptions.APIException:
|
88 |
+
return await eor(xx, "`Couldn't find character!`", time=5)
|
89 |
a = s["results"][0]["mal_id"]
|
90 |
char_json = jikan.character(a)
|
91 |
pic = char_json["image_url"]
|
plugins/antiflood.py
CHANGED
@@ -54,7 +54,7 @@ if Redis("ANTIFLOOD") is not (None or ""):
|
|
54 |
_check_flood[event.chat_id] = {event.sender_id: count}
|
55 |
if await check_if_admin(event) or event.sender.bot:
|
56 |
return
|
57 |
-
if
|
58 |
return
|
59 |
if _check_flood[event.chat_id][event.sender_id] >= int(
|
60 |
get_flood_limit(event.chat_id)
|
@@ -97,14 +97,13 @@ async def unmuting(e):
|
|
97 |
@ultroid_cmd(
|
98 |
pattern="setflood ?(\\d+)",
|
99 |
admins_only=True,
|
100 |
-
ignore_dualmode=True,
|
101 |
)
|
102 |
async def setflood(e):
|
103 |
input = e.pattern_match.group(1)
|
104 |
if not input:
|
105 |
-
return await
|
106 |
if not input.isdigit():
|
107 |
-
return await
|
108 |
m = set_flood(e.chat_id, input)
|
109 |
if m:
|
110 |
return await eod(
|
@@ -115,7 +114,6 @@ async def setflood(e):
|
|
115 |
@ultroid_cmd(
|
116 |
pattern="remflood$",
|
117 |
admins_only=True,
|
118 |
-
ignore_dualmode=True,
|
119 |
)
|
120 |
async def remove_flood(e):
|
121 |
hmm = rem_flood(e.chat_id)
|
@@ -124,17 +122,16 @@ async def remove_flood(e):
|
|
124 |
except BaseException:
|
125 |
pass
|
126 |
if hmm:
|
127 |
-
return await
|
128 |
-
await
|
129 |
|
130 |
|
131 |
@ultroid_cmd(
|
132 |
pattern="getflood$",
|
133 |
admins_only=True,
|
134 |
-
ignore_dualmode=True,
|
135 |
)
|
136 |
async def getflood(e):
|
137 |
ok = get_flood_limit(e.chat_id)
|
138 |
if ok:
|
139 |
-
return await
|
140 |
-
await
|
|
|
54 |
_check_flood[event.chat_id] = {event.sender_id: count}
|
55 |
if await check_if_admin(event) or event.sender.bot:
|
56 |
return
|
57 |
+
if event.sender_id in DEVLIST:
|
58 |
return
|
59 |
if _check_flood[event.chat_id][event.sender_id] >= int(
|
60 |
get_flood_limit(event.chat_id)
|
|
|
97 |
@ultroid_cmd(
|
98 |
pattern="setflood ?(\\d+)",
|
99 |
admins_only=True,
|
|
|
100 |
)
|
101 |
async def setflood(e):
|
102 |
input = e.pattern_match.group(1)
|
103 |
if not input:
|
104 |
+
return await eor(e, "`What?`", time=5)
|
105 |
if not input.isdigit():
|
106 |
+
return await eor(e, "`Invalid Input`", time=5)
|
107 |
m = set_flood(e.chat_id, input)
|
108 |
if m:
|
109 |
return await eod(
|
|
|
114 |
@ultroid_cmd(
|
115 |
pattern="remflood$",
|
116 |
admins_only=True,
|
|
|
117 |
)
|
118 |
async def remove_flood(e):
|
119 |
hmm = rem_flood(e.chat_id)
|
|
|
122 |
except BaseException:
|
123 |
pass
|
124 |
if hmm:
|
125 |
+
return await eor(e, "`Antiflood Settings Disabled`", time=5)
|
126 |
+
await eor(e, "`No flood limits in this chat.`", time=5)
|
127 |
|
128 |
|
129 |
@ultroid_cmd(
|
130 |
pattern="getflood$",
|
131 |
admins_only=True,
|
|
|
132 |
)
|
133 |
async def getflood(e):
|
134 |
ok = get_flood_limit(e.chat_id)
|
135 |
if ok:
|
136 |
+
return await eor(e, f"`Flood limit for this chat is {ok}.`", time=5)
|
137 |
+
await eor(e, "`No flood limits in this chat.`", time=5)
|
plugins/ascii.py
CHANGED
@@ -12,6 +12,7 @@
|
|
12 |
"""
|
13 |
import os
|
14 |
|
|
|
15 |
from img2html.converter import Img2HTMLConverter
|
16 |
|
17 |
from . import *
|
@@ -28,9 +29,9 @@ async def _(e):
|
|
28 |
char = "■" if not e.pattern_match.group(1) else e.pattern_match.group(1)
|
29 |
converter = Img2HTMLConverter(char=char)
|
30 |
html = converter.convert(img)
|
31 |
-
|
32 |
-
|
33 |
-
await e.reply(file="html.html")
|
34 |
await m.delete()
|
|
|
|
|
35 |
os.remove(img)
|
36 |
-
os.remove("html.html")
|
|
|
12 |
"""
|
13 |
import os
|
14 |
|
15 |
+
from htmlwebshot import WebShot
|
16 |
from img2html.converter import Img2HTMLConverter
|
17 |
|
18 |
from . import *
|
|
|
29 |
char = "■" if not e.pattern_match.group(1) else e.pattern_match.group(1)
|
30 |
converter = Img2HTMLConverter(char=char)
|
31 |
html = converter.convert(img)
|
32 |
+
shot = WebShot(quality=85)
|
33 |
+
pic = await shot.create_pic_async(html=html)
|
|
|
34 |
await m.delete()
|
35 |
+
await e.reply(file=pic)
|
36 |
+
os.remove(pic)
|
37 |
os.remove(img)
|
|
plugins/asst_cmd.py
CHANGED
@@ -30,7 +30,9 @@ async def ac(e):
|
|
30 |
wrd = (e.pattern_match.group(1)).lower()
|
31 |
wt = await e.get_reply_message()
|
32 |
if not (wt and wrd):
|
33 |
-
return await
|
|
|
|
|
34 |
if "/" in wrd:
|
35 |
wrd = wrd.replace("/", "")
|
36 |
if wt and wt.media:
|
@@ -42,12 +44,11 @@ async def ac(e):
|
|
42 |
m = "https://telegra.ph" + variable[0]
|
43 |
elif wut == "video":
|
44 |
if wt.media.document.size > 8 * 1000 * 1000:
|
45 |
-
return await
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
m = "https://telegra.ph" + variable[0]
|
51 |
else:
|
52 |
m = pack_bot_file_id(wt.media)
|
53 |
if wt.text:
|
@@ -63,7 +64,7 @@ async def ac(e):
|
|
63 |
async def rc(e):
|
64 |
wrd = (e.pattern_match.group(1)).lower()
|
65 |
if not wrd:
|
66 |
-
return await
|
67 |
if wrd.startswith("/"):
|
68 |
wrd = wrd.replace("/", "")
|
69 |
rem_cmd(wrd)
|
|
|
30 |
wrd = (e.pattern_match.group(1)).lower()
|
31 |
wt = await e.get_reply_message()
|
32 |
if not (wt and wrd):
|
33 |
+
return await eor(
|
34 |
+
e, "`Use this Command with Reply and word to use a command.`", time=5
|
35 |
+
)
|
36 |
if "/" in wrd:
|
37 |
wrd = wrd.replace("/", "")
|
38 |
if wt and wt.media:
|
|
|
44 |
m = "https://telegra.ph" + variable[0]
|
45 |
elif wut == "video":
|
46 |
if wt.media.document.size > 8 * 1000 * 1000:
|
47 |
+
return await eor(x, "`Unsupported Media`", time=5)
|
48 |
+
dl = await e.client.download_media(wt.media)
|
49 |
+
variable = uf(dl)
|
50 |
+
os.remove(dl)
|
51 |
+
m = "https://telegra.ph" + variable[0]
|
|
|
52 |
else:
|
53 |
m = pack_bot_file_id(wt.media)
|
54 |
if wt.text:
|
|
|
64 |
async def rc(e):
|
65 |
wrd = (e.pattern_match.group(1)).lower()
|
66 |
if not wrd:
|
67 |
+
return await eor(e, "`Give me the command which you want to remove.`", time=5)
|
68 |
if wrd.startswith("/"):
|
69 |
wrd = wrd.replace("/", "")
|
70 |
rem_cmd(wrd)
|
plugins/audiotools.py
ADDED
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021 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}makevoice <reply to audio>`
|
12 |
+
creates a voice note from Audio.
|
13 |
+
|
14 |
+
`{i}atrim <from time> - <to time>`
|
15 |
+
trim audio as per given time.
|
16 |
+
time must be in seconds. `{i}atrim 50-70`
|
17 |
+
|
18 |
+
`{i}extractaudio <reply to media>`
|
19 |
+
To extract the audio from it.
|
20 |
+
|
21 |
+
"""
|
22 |
+
|
23 |
+
import os
|
24 |
+
import time
|
25 |
+
from datetime import datetime as dt
|
26 |
+
|
27 |
+
from hachoir.metadata import extractMetadata
|
28 |
+
from hachoir.parser import createParser
|
29 |
+
from telethon.tl.types import DocumentAttributeAudio
|
30 |
+
|
31 |
+
from . import *
|
32 |
+
|
33 |
+
|
34 |
+
@ultroid_cmd(pattern="makevoice$")
|
35 |
+
async def vnc(e):
|
36 |
+
if not e.reply_to:
|
37 |
+
return await eod(e, "Reply To Audio or video")
|
38 |
+
r = await e.get_reply_message()
|
39 |
+
if not mediainfo(r.media).startswith(("audio", "video")):
|
40 |
+
return await eod(e, "Reply To Audio or video")
|
41 |
+
xxx = await eor(e, "`processing...`")
|
42 |
+
dl = r.file.name
|
43 |
+
c_time = time.time()
|
44 |
+
file = await downloader(
|
45 |
+
"resources/downloads/" + dl,
|
46 |
+
r.media.document,
|
47 |
+
xxx,
|
48 |
+
c_time,
|
49 |
+
"Downloading " + dl + "...",
|
50 |
+
)
|
51 |
+
await xxx.edit(f"Downloaded Successfully, Now Converting to voice")
|
52 |
+
await bash(
|
53 |
+
f"ffmpeg -i '{file.name}' -map 0:a -codec:a libopus -b:a 100k -vbr on out.opus"
|
54 |
+
)
|
55 |
+
await e.client.send_message(
|
56 |
+
e.chat_id, file="out.opus", force_document=False, reply_to=r
|
57 |
+
)
|
58 |
+
await xxx.delete()
|
59 |
+
os.remove(file.name)
|
60 |
+
os.remove("out.opus")
|
61 |
+
|
62 |
+
|
63 |
+
@ultroid_cmd(pattern="atrim ?(.*)")
|
64 |
+
async def trim_aud(e):
|
65 |
+
sec = e.pattern_match.group(1)
|
66 |
+
if not sec or "-" not in sec:
|
67 |
+
return await eod(e, "`Give time in format to trim`")
|
68 |
+
a, b = sec.split("-")
|
69 |
+
if int(a) >= int(b):
|
70 |
+
return await eod(e, "`Incorrect Data`")
|
71 |
+
vido = await e.get_reply_message()
|
72 |
+
if vido and vido.media and mediainfo(vido.media).startswith(("video", "audio")):
|
73 |
+
if hasattr(vido.media, "document"):
|
74 |
+
vfile = vido.media.document
|
75 |
+
name = vido.file.name
|
76 |
+
else:
|
77 |
+
vfile = vido.media
|
78 |
+
name = ""
|
79 |
+
if not name:
|
80 |
+
name = dt.now().isoformat("_", "seconds") + ".mp4"
|
81 |
+
xxx = await eor(e, "`Trying To Download...`")
|
82 |
+
c_time = time.time()
|
83 |
+
file = await downloader(
|
84 |
+
"resources/downloads/" + name,
|
85 |
+
vfile,
|
86 |
+
xxx,
|
87 |
+
c_time,
|
88 |
+
"Downloading " + name + "...",
|
89 |
+
)
|
90 |
+
o_size = os.path.getsize(file.name)
|
91 |
+
d_time = time.time()
|
92 |
+
diff = time_formatter((d_time - c_time) * 1000)
|
93 |
+
file_name = (file.name).split("/")[-1]
|
94 |
+
out = file_name.replace(file_name.split(".")[-1], "_trimmed.aac")
|
95 |
+
if int(b) > int(genss(file.name)):
|
96 |
+
os.remove(file.name)
|
97 |
+
return await eod(xxx, "`Wrong trim duration`")
|
98 |
+
ss, dd = stdr(int(a)), stdr(int(b))
|
99 |
+
xxx = await xxx.edit(
|
100 |
+
f"Downloaded `{file.name}` of `{humanbytes(o_size)}` in `{diff}`.\n\nNow Trimming Audio from `{ss}` to `{dd}`..."
|
101 |
+
)
|
102 |
+
cmd = f'ffmpeg -i "{file.name}" -preset ultrafast -ss {ss} -to {dd} -vn -acodec copy "{out}" -y'
|
103 |
+
await bash(cmd)
|
104 |
+
os.remove(file.name)
|
105 |
+
f_time = time.time()
|
106 |
+
mmmm = await uploader(
|
107 |
+
out,
|
108 |
+
out,
|
109 |
+
f_time,
|
110 |
+
xxx,
|
111 |
+
"Uploading " + out + "...",
|
112 |
+
)
|
113 |
+
metadata = extractMetadata(createParser(out))
|
114 |
+
duration = vido.file.duration or 0
|
115 |
+
artist = udB.get("artist") or ultroid_bot.first_name
|
116 |
+
try:
|
117 |
+
if metadata.has("duration"):
|
118 |
+
duration = metadata.get("duration").seconds
|
119 |
+
if metadata.has("artist"):
|
120 |
+
artist = metadata.get("artist")
|
121 |
+
except BaseException:
|
122 |
+
pass
|
123 |
+
attributes = [
|
124 |
+
DocumentAttributeAudio(
|
125 |
+
duration=duration,
|
126 |
+
title=out.split(".")[0],
|
127 |
+
performer=artist,
|
128 |
+
)
|
129 |
+
]
|
130 |
+
caption = f"Trimmed Audio From `{ss}` To `{dd}`"
|
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 |
+
await xxx.delete()
|
141 |
+
else:
|
142 |
+
await eor(e, "`Reply To Video\\Audio File Only`", time=5)
|
143 |
+
|
144 |
+
|
145 |
+
@ultroid_cmd(pattern="extractaudio$")
|
146 |
+
async def ex_aud(e):
|
147 |
+
reply = await e.get_reply_message()
|
148 |
+
if not (reply and reply.video):
|
149 |
+
return await eor(e, "`Reply to Video File..`")
|
150 |
+
name = reply.file.name or "video.mp4"
|
151 |
+
vfile = reply.media.document
|
152 |
+
msg = await eor(e, "`Processing...`")
|
153 |
+
c_time = time.time()
|
154 |
+
file = await downloader(
|
155 |
+
"resources/downloads/" + name,
|
156 |
+
vfile,
|
157 |
+
msg,
|
158 |
+
c_time,
|
159 |
+
"Downloading " + name + "...",
|
160 |
+
)
|
161 |
+
out_file = file.name + ".aac"
|
162 |
+
cmd = f"ffmpeg -i {file.name} -vn -acodec copy {out_file}"
|
163 |
+
o, err = await bash(cmd)
|
164 |
+
os.remove(file.name)
|
165 |
+
duration = reply.file.duration
|
166 |
+
artist = ultroid_bot.me.first_name
|
167 |
+
attributes = [
|
168 |
+
DocumentAttributeAudio(
|
169 |
+
duration=duration,
|
170 |
+
title=reply.file.name.split(".")[0],
|
171 |
+
performer=artist,
|
172 |
+
)
|
173 |
+
]
|
174 |
+
f_time = time.time()
|
175 |
+
fo = await uploader(
|
176 |
+
out_file,
|
177 |
+
out_file,
|
178 |
+
f_time,
|
179 |
+
msg,
|
180 |
+
"Uploading " + out_file + "...",
|
181 |
+
)
|
182 |
+
await e.client.send_file(
|
183 |
+
e.chat_id,
|
184 |
+
fo,
|
185 |
+
caption="`Extracted Audio from Video...`",
|
186 |
+
thumb="resources/extras/ultroid.jpg",
|
187 |
+
attributes=attributes,
|
188 |
+
reply_to=e.reply_to_msg_id,
|
189 |
+
)
|
190 |
+
await e.delete()
|
plugins/autocorrect.py
CHANGED
@@ -14,24 +14,20 @@
|
|
14 |
"""
|
15 |
|
16 |
from gingerit.gingerit import GingerIt
|
17 |
-
from
|
18 |
from telethon import events
|
19 |
|
20 |
from . import *
|
21 |
|
22 |
-
tr = Translator()
|
23 |
|
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
|
32 |
else:
|
33 |
udB.delete("AUTOCORRECT")
|
34 |
-
await
|
35 |
|
36 |
|
37 |
@ultroid_bot.on(events.NewMessage(outgoing=True))
|
@@ -39,12 +35,12 @@ async def gramme(event):
|
|
39 |
if Redis("AUTOCORRECT") != "True":
|
40 |
return
|
41 |
t = event.text
|
42 |
-
tt = tr.translate(t)
|
43 |
if t.startswith((HNDLR, ".", "?", "#", "_", "*", "'", "@", "[", "(", "+")):
|
44 |
return
|
45 |
if t.endswith(".."):
|
46 |
return
|
47 |
-
|
|
|
48 |
return
|
49 |
xx = GingerIt()
|
50 |
x = xx.parse(t)
|
|
|
14 |
"""
|
15 |
|
16 |
from gingerit.gingerit import GingerIt
|
17 |
+
from google_trans_new import google_translator
|
18 |
from telethon import events
|
19 |
|
20 |
from . import *
|
21 |
|
|
|
22 |
|
23 |
+
@ultroid_cmd(pattern="autocorrect", fullsudo=True)
|
|
|
24 |
async def acc(e):
|
|
|
|
|
25 |
if Redis("AUTOCORRECT") != "True":
|
26 |
udB.set("AUTOCORRECT", "True")
|
27 |
+
await eor(e, "AUTOCORRECT Feature On", time=5)
|
28 |
else:
|
29 |
udB.delete("AUTOCORRECT")
|
30 |
+
await eor(e, "AUTOCORRECT Feature Off", time=5)
|
31 |
|
32 |
|
33 |
@ultroid_bot.on(events.NewMessage(outgoing=True))
|
|
|
35 |
if Redis("AUTOCORRECT") != "True":
|
36 |
return
|
37 |
t = event.text
|
|
|
38 |
if t.startswith((HNDLR, ".", "?", "#", "_", "*", "'", "@", "[", "(", "+")):
|
39 |
return
|
40 |
if t.endswith(".."):
|
41 |
return
|
42 |
+
tt = google_translator().detect(t)
|
43 |
+
if tt[0] != "en":
|
44 |
return
|
45 |
xx = GingerIt()
|
46 |
x = xx.parse(t)
|
plugins/autopic.py
CHANGED
@@ -16,11 +16,9 @@
|
|
16 |
"""
|
17 |
import asyncio
|
18 |
import os
|
19 |
-
import urllib
|
20 |
|
21 |
import requests as r
|
22 |
from bs4 import BeautifulSoup as bs
|
23 |
-
from telethon.tl.functions.messages import GetWebPagePreviewRequest as getweb
|
24 |
from telethon.tl.functions.photos import UploadProfilePhotoRequest
|
25 |
|
26 |
from . import *
|
@@ -30,33 +28,26 @@ from . import *
|
|
30 |
async def autopic(e):
|
31 |
search = e.pattern_match.group(1)
|
32 |
if not search:
|
33 |
-
return await
|
34 |
clls = autopicsearch(search)
|
35 |
if len(clls) == 0:
|
36 |
-
return await
|
37 |
await eor(e, get_string("autopic_3").format(search))
|
38 |
udB.set("AUTOPIC", "True")
|
39 |
ST = udB.get("SLEEP_TIME")
|
40 |
-
if ST
|
41 |
-
SLEEP_TIME = int(ST)
|
42 |
-
else:
|
43 |
-
SLEEP_TIME = 1221
|
44 |
while True:
|
45 |
for lie in clls:
|
46 |
ge = udB.get("AUTOPIC")
|
47 |
-
if
|
48 |
return
|
49 |
au = "https://unsplash.com" + lie["href"]
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
ft = bsc.find_all("img", "_2UpQX")
|
57 |
-
li = ft[0]["src"]
|
58 |
-
kar = "autopic.png"
|
59 |
-
urllib.request.urlretrieve(li, kar)
|
60 |
file = await e.client.upload_file(kar)
|
61 |
await e.client(UploadProfilePhotoRequest(file))
|
62 |
os.remove(kar)
|
@@ -66,7 +57,7 @@ async def autopic(e):
|
|
66 |
@ultroid_cmd(pattern="stoppic$")
|
67 |
async def stoppo(ult):
|
68 |
gt = udB.get("AUTOPIC")
|
69 |
-
if
|
70 |
-
return await
|
71 |
udB.set("AUTOPIC", "None")
|
72 |
-
await
|
|
|
16 |
"""
|
17 |
import asyncio
|
18 |
import os
|
|
|
19 |
|
20 |
import requests as r
|
21 |
from bs4 import BeautifulSoup as bs
|
|
|
22 |
from telethon.tl.functions.photos import UploadProfilePhotoRequest
|
23 |
|
24 |
from . import *
|
|
|
28 |
async def autopic(e):
|
29 |
search = e.pattern_match.group(1)
|
30 |
if not search:
|
31 |
+
return await eor(e, get_string("autopic_1"), time=5)
|
32 |
clls = autopicsearch(search)
|
33 |
if len(clls) == 0:
|
34 |
+
return await eor(e, get_string("autopic_2").format(search), time=5)
|
35 |
await eor(e, get_string("autopic_3").format(search))
|
36 |
udB.set("AUTOPIC", "True")
|
37 |
ST = udB.get("SLEEP_TIME")
|
38 |
+
SLEEP_TIME = int(ST) if ST else 1221
|
|
|
|
|
|
|
39 |
while True:
|
40 |
for lie in clls:
|
41 |
ge = udB.get("AUTOPIC")
|
42 |
+
if ge != "True":
|
43 |
return
|
44 |
au = "https://unsplash.com" + lie["href"]
|
45 |
+
ct = r.get(au).content
|
46 |
+
bsc = bs(ct, "html.parser", from_encoding="utf-8")
|
47 |
+
ft = bsc.find_all("img", "oCCRx")
|
48 |
+
li = ft[0]["src"]
|
49 |
+
kar = "autopic.png"
|
50 |
+
await download_file(li, kar)
|
|
|
|
|
|
|
|
|
51 |
file = await e.client.upload_file(kar)
|
52 |
await e.client(UploadProfilePhotoRequest(file))
|
53 |
os.remove(kar)
|
|
|
57 |
@ultroid_cmd(pattern="stoppic$")
|
58 |
async def stoppo(ult):
|
59 |
gt = udB.get("AUTOPIC")
|
60 |
+
if gt != "True":
|
61 |
+
return await eor(ult, "AUTOPIC was not in use !!", time=5)
|
62 |
udB.set("AUTOPIC", "None")
|
63 |
+
await eor(ult, "AUTOPIC Stopped !!", time=5)
|
plugins/blacklist.py
CHANGED
@@ -32,7 +32,7 @@ async def af(e):
|
|
32 |
wrd = e.pattern_match.group(1)
|
33 |
chat = e.chat_id
|
34 |
if not (wrd):
|
35 |
-
return await
|
36 |
wrd = e.text[11:]
|
37 |
heh = wrd.split(" ")
|
38 |
for z in heh:
|
@@ -45,7 +45,7 @@ async def rf(e):
|
|
45 |
wrd = e.pattern_match.group(1)
|
46 |
chat = e.chat_id
|
47 |
if not wrd:
|
48 |
-
return await
|
49 |
wrd = e.text[14:]
|
50 |
heh = wrd.split(" ")
|
51 |
for z in heh:
|
@@ -65,12 +65,13 @@ async def lsnote(e):
|
|
65 |
|
66 |
@ultroid_bot.on(events.NewMessage(incoming=True))
|
67 |
async def bl(e):
|
68 |
-
|
69 |
-
x
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
|
32 |
wrd = e.pattern_match.group(1)
|
33 |
chat = e.chat_id
|
34 |
if not (wrd):
|
35 |
+
return await eor(e, "`Give the word to blacklist..`", time=5)
|
36 |
wrd = e.text[11:]
|
37 |
heh = wrd.split(" ")
|
38 |
for z in heh:
|
|
|
45 |
wrd = e.pattern_match.group(1)
|
46 |
chat = e.chat_id
|
47 |
if not wrd:
|
48 |
+
return await eor(e, "`Give the word to remove from blacklist..`", time=5)
|
49 |
wrd = e.text[14:]
|
50 |
heh = wrd.split(" ")
|
51 |
for z in heh:
|
|
|
65 |
|
66 |
@ultroid_bot.on(events.NewMessage(incoming=True))
|
67 |
async def bl(e):
|
68 |
+
x = get_blacklist(e.chat_id)
|
69 |
+
if x:
|
70 |
+
for z in e.text.lower().split():
|
71 |
+
for zz in x:
|
72 |
+
if z == zz:
|
73 |
+
try:
|
74 |
+
await e.delete()
|
75 |
+
break
|
76 |
+
except BaseException:
|
77 |
+
break
|
plugins/bot.py
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
"""
|
8 |
✘ Commands Available
|
9 |
|
10 |
-
• `{i}alive`
|
11 |
Check if your bot is working.
|
12 |
|
13 |
• `{i}ping`
|
@@ -28,17 +28,35 @@
|
|
28 |
• `{i}shutdown`
|
29 |
Turn off your bot.
|
30 |
"""
|
|
|
|
|
31 |
import time
|
32 |
from datetime import datetime as dt
|
33 |
from platform import python_version as pyver
|
34 |
|
35 |
from git import Repo
|
36 |
from pyUltroid.version import __version__ as UltVer
|
37 |
-
from telethon import __version__
|
38 |
from telethon.errors.rpcerrorlist import ChatSendMediaForbiddenError
|
|
|
39 |
|
40 |
from . import *
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
@ultroid_cmd(
|
44 |
pattern="alive$",
|
@@ -46,7 +64,7 @@ from . import *
|
|
46 |
async def lol(ult):
|
47 |
pic = udB.get("ALIVE_PIC")
|
48 |
uptime = time_formatter((time.time() - start_time) * 1000)
|
49 |
-
header = udB.get("ALIVE_TEXT")
|
50 |
y = Repo().active_branch
|
51 |
xx = Repo().remotes[0].config_reader.get("url")
|
52 |
rep = xx.replace(".git", f"/tree/{y}")
|
@@ -62,8 +80,8 @@ async def lol(ult):
|
|
62 |
kk,
|
63 |
)
|
64 |
if pic is None:
|
65 |
-
|
66 |
-
elif
|
67 |
try:
|
68 |
await ult.reply(als, file=pic, link_preview=False)
|
69 |
await ult.delete()
|
@@ -78,12 +96,50 @@ async def lol(ult):
|
|
78 |
await eor(ult, als, link_preview=False)
|
79 |
|
80 |
|
81 |
-
@
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
if not
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
start = dt.now()
|
88 |
x = await eor(event, "`Pong !`")
|
89 |
end = dt.now()
|
@@ -99,38 +155,90 @@ async def cmds(event):
|
|
99 |
await allcmds(event)
|
100 |
|
101 |
|
|
|
|
|
|
|
102 |
@ultroid_cmd(
|
103 |
pattern="restart$",
|
|
|
104 |
)
|
105 |
async def restartbt(ult):
|
106 |
-
ok = await eor(ult, "`Restarting...`")
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
111 |
|
112 |
|
113 |
-
@ultroid_cmd(
|
|
|
|
|
|
|
114 |
async def shutdownbot(ult):
|
115 |
-
if not ult.out and not is_fullsudo(ult.sender_id):
|
116 |
-
return await eod(ult, "`This Command Is Sudo Restricted.`")
|
117 |
await shutdown(ult)
|
118 |
|
119 |
|
120 |
-
@
|
121 |
-
|
|
|
|
|
122 |
async def _(event):
|
123 |
-
|
124 |
-
return
|
125 |
-
if not event.out and not is_sudo(event.sender_id):
|
126 |
-
return
|
127 |
-
try:
|
128 |
-
opt = event.text.split(" ", maxsplit=1)[1]
|
129 |
-
except IndexError:
|
130 |
-
return await def_logs(event)
|
131 |
if opt == "heroku":
|
132 |
await heroku_logs(event)
|
133 |
else:
|
134 |
await def_logs(event)
|
135 |
-
|
136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
"""
|
8 |
✘ Commands Available
|
9 |
|
10 |
+
• `{i}alive` | `{i}ialive`
|
11 |
Check if your bot is working.
|
12 |
|
13 |
• `{i}ping`
|
|
|
28 |
• `{i}shutdown`
|
29 |
Turn off your bot.
|
30 |
"""
|
31 |
+
import os
|
32 |
+
import sys
|
33 |
import time
|
34 |
from datetime import datetime as dt
|
35 |
from platform import python_version as pyver
|
36 |
|
37 |
from git import Repo
|
38 |
from pyUltroid.version import __version__ as UltVer
|
39 |
+
from telethon import __version__
|
40 |
from telethon.errors.rpcerrorlist import ChatSendMediaForbiddenError
|
41 |
+
from telethon.utils import resolve_bot_file_id
|
42 |
|
43 |
from . import *
|
44 |
|
45 |
+
# Will move to strings
|
46 |
+
alive_txt = """
|
47 |
+
The Ultroid Userbot
|
48 |
+
|
49 |
+
◍ Version - {}
|
50 |
+
◍ Py-Ultroid - {}
|
51 |
+
◍ Telethon - {}
|
52 |
+
"""
|
53 |
+
|
54 |
+
|
55 |
+
@callback("alive")
|
56 |
+
async def alive(event):
|
57 |
+
text = alive_txt.format(ultroid_version, UltVer, __version__)
|
58 |
+
await event.answer(text, alert=True)
|
59 |
+
|
60 |
|
61 |
@ultroid_cmd(
|
62 |
pattern="alive$",
|
|
|
64 |
async def lol(ult):
|
65 |
pic = udB.get("ALIVE_PIC")
|
66 |
uptime = time_formatter((time.time() - start_time) * 1000)
|
67 |
+
header = udB.get("ALIVE_TEXT") or "Hey, I am alive."
|
68 |
y = Repo().active_branch
|
69 |
xx = Repo().remotes[0].config_reader.get("url")
|
70 |
rep = xx.replace(".git", f"/tree/{y}")
|
|
|
80 |
kk,
|
81 |
)
|
82 |
if pic is None:
|
83 |
+
await eor(ult, als)
|
84 |
+
elif "telegra" in pic:
|
85 |
try:
|
86 |
await ult.reply(als, file=pic, link_preview=False)
|
87 |
await ult.delete()
|
|
|
96 |
await eor(ult, als, link_preview=False)
|
97 |
|
98 |
|
99 |
+
@ultroid_cmd(
|
100 |
+
pattern="ialive$",
|
101 |
+
)
|
102 |
+
async def is_on(ult):
|
103 |
+
if not ult.client._bot:
|
104 |
+
await ult.delete()
|
105 |
+
try:
|
106 |
+
res = await ult.client.inline_query(asst.me.username, "alive")
|
107 |
+
return await res[0].click(ult.chat_id)
|
108 |
+
except Exception as er:
|
109 |
+
LOGS.info(er)
|
110 |
return
|
111 |
+
pic = udB.get("ALIVE_PIC")
|
112 |
+
uptime = time_formatter((time.time() - start_time) * 1000)
|
113 |
+
header = udB.get("ALIVE_TEXT") or "Hey, I am alive."
|
114 |
+
y = Repo().active_branch
|
115 |
+
xx = Repo().remotes[0].config_reader.get("url")
|
116 |
+
rep = xx.replace(".git", f"/tree/{y}")
|
117 |
+
kk = f" `[{y}]({rep})` "
|
118 |
+
als = (get_string("alive_1")).format(
|
119 |
+
header,
|
120 |
+
OWNER_NAME,
|
121 |
+
ultroid_version,
|
122 |
+
UltVer,
|
123 |
+
uptime,
|
124 |
+
pyver(),
|
125 |
+
__version__,
|
126 |
+
kk,
|
127 |
+
)
|
128 |
+
buttons = [
|
129 |
+
Button.inline("Stats", "alive"),
|
130 |
+
[
|
131 |
+
Button.url("Repo", "https://github.com/TeamUltroid/Ultroid"),
|
132 |
+
Button.url("Support", "t.me/UltroidSupport"),
|
133 |
+
],
|
134 |
+
]
|
135 |
+
await ult.client.send_message(ult.chat_id, als, file=pic, buttons=buttons)
|
136 |
+
|
137 |
+
|
138 |
+
@ultroid_cmd(
|
139 |
+
pattern="ping$",
|
140 |
+
chats=[],
|
141 |
+
)
|
142 |
+
async def _(event):
|
143 |
start = dt.now()
|
144 |
x = await eor(event, "`Pong !`")
|
145 |
end = dt.now()
|
|
|
155 |
await allcmds(event)
|
156 |
|
157 |
|
158 |
+
heroku_api = Var.HEROKU_API
|
159 |
+
|
160 |
+
|
161 |
@ultroid_cmd(
|
162 |
pattern="restart$",
|
163 |
+
fullsudo=True,
|
164 |
)
|
165 |
async def restartbt(ult):
|
166 |
+
ok = await eor(ult, "• `Restarting...`")
|
167 |
+
call_back()
|
168 |
+
if heroku_api:
|
169 |
+
return await restart(ok)
|
170 |
+
await bash("git pull && pip3 install -r requirements.txt")
|
171 |
+
os.execl(sys.executable, sys.executable, "-m", "pyUltroid")
|
172 |
|
173 |
|
174 |
+
@ultroid_cmd(
|
175 |
+
pattern="shutdown$",
|
176 |
+
fullsudo=True,
|
177 |
+
)
|
178 |
async def shutdownbot(ult):
|
|
|
|
|
179 |
await shutdown(ult)
|
180 |
|
181 |
|
182 |
+
@ultroid_cmd(
|
183 |
+
pattern="logs ?(|heroku|sys)",
|
184 |
+
chats=[],
|
185 |
+
)
|
186 |
async def _(event):
|
187 |
+
opt = event.pattern_match.group(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
if opt == "heroku":
|
189 |
await heroku_logs(event)
|
190 |
else:
|
191 |
await def_logs(event)
|
192 |
+
|
193 |
+
|
194 |
+
@in_pattern("alive")
|
195 |
+
@in_owner
|
196 |
+
async def inline_alive(ult):
|
197 |
+
pic = udB.get("ALIVE_PIC")
|
198 |
+
uptime = time_formatter((time.time() - start_time) * 1000)
|
199 |
+
header = udB.get("ALIVE_TEXT") or "Hey, I am alive."
|
200 |
+
y = Repo().active_branch
|
201 |
+
xx = Repo().remotes[0].config_reader.get("url")
|
202 |
+
rep = xx.replace(".git", f"/tree/{y}")
|
203 |
+
kk = f" `[{y}]({rep})` "
|
204 |
+
als = (get_string("alive_1")).format(
|
205 |
+
header,
|
206 |
+
OWNER_NAME,
|
207 |
+
ultroid_version,
|
208 |
+
UltVer,
|
209 |
+
uptime,
|
210 |
+
pyver(),
|
211 |
+
__version__,
|
212 |
+
kk,
|
213 |
+
)
|
214 |
+
buttons = [
|
215 |
+
[
|
216 |
+
Button.url("Repo", "https://github.com/TeamUltroid/Ultroid"),
|
217 |
+
Button.url("Support", "t.me/UltroidSupport"),
|
218 |
+
]
|
219 |
+
]
|
220 |
+
builder = ult.builder
|
221 |
+
if pic:
|
222 |
+
try:
|
223 |
+
if ".jpg" in pic:
|
224 |
+
results = [await builder.photo(pic, text=als, buttons=buttons)]
|
225 |
+
else:
|
226 |
+
_pic = resolve_bot_file_id(pic)
|
227 |
+
if _pic:
|
228 |
+
pic = _pic
|
229 |
+
buttons.insert(0, [Button.inline("Stats", data="alive")])
|
230 |
+
results = [
|
231 |
+
await builder.document(
|
232 |
+
pic,
|
233 |
+
title="Inline Alive",
|
234 |
+
description="@TheUltroid",
|
235 |
+
buttons=buttons,
|
236 |
+
)
|
237 |
+
]
|
238 |
+
return await ult.answer(results)
|
239 |
+
except BaseException as er:
|
240 |
+
LOGS.info(er)
|
241 |
+
result = [
|
242 |
+
await builder.article("Alive", text=als, link_preview=False, buttons=buttons)
|
243 |
+
]
|
244 |
+
await ult.answer(result)
|
plugins/botecho.py
CHANGED
@@ -57,4 +57,4 @@ async def button_parser(event):
|
|
57 |
await asst.send_message(event.chat_id, text, buttons=buttons)
|
58 |
await eor(event, "Done. Message sent.")
|
59 |
except Exception as e:
|
60 |
-
await
|
|
|
57 |
await asst.send_message(event.chat_id, text, buttons=buttons)
|
58 |
await eor(event, "Done. Message sent.")
|
59 |
except Exception as e:
|
60 |
+
await eor(event, "**ERROR:**\n{}".format(str(e)), time=5)
|
plugins/broadcast.py
CHANGED
@@ -47,12 +47,14 @@ async def broadcast_adder(event):
|
|
47 |
]
|
48 |
for i in chats:
|
49 |
try:
|
50 |
-
if
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
|
|
56 |
except Exception as Ex:
|
57 |
LOGS.info(Ex)
|
58 |
await x.edit(get_string("bd_3").format(get_no_channels(), new))
|
@@ -123,7 +125,7 @@ async def list_all(event):
|
|
123 |
channels = get_channels()
|
124 |
num = get_no_channels()
|
125 |
if num == 0:
|
126 |
-
return await
|
127 |
msg = "Channels in database:\n"
|
128 |
for channel in channels:
|
129 |
name = ""
|
@@ -194,15 +196,12 @@ async def forw(event):
|
|
194 |
@ultroid_cmd(
|
195 |
pattern="broadcast ?(.*)",
|
196 |
allow_sudo=False,
|
197 |
-
ignore_dualmode=True,
|
198 |
)
|
199 |
async def sending(event):
|
200 |
x = await eor(event, "`Processing...`")
|
201 |
if not event.is_reply:
|
202 |
return await x.edit("Reply to a message to broadcast.")
|
203 |
channels = get_channels()
|
204 |
-
error_count = 0
|
205 |
-
sent_count = 0
|
206 |
if get_no_channels() == 0:
|
207 |
return await x.edit(f"Please add channels by using `{hndlr}add` in them.")
|
208 |
await x.edit("Sending....")
|
@@ -211,6 +210,8 @@ async def sending(event):
|
|
211 |
if previous_message.poll:
|
212 |
return await x.edit(f"Reply `{hndlr}forward` for polls.")
|
213 |
if previous_message:
|
|
|
|
|
214 |
for channel in channels:
|
215 |
try:
|
216 |
await ultroid_bot.send_message(int(channel), previous_message)
|
|
|
47 |
]
|
48 |
for i in chats:
|
49 |
try:
|
50 |
+
if (
|
51 |
+
i.broadcast
|
52 |
+
and (i.creator or i.admin_rights)
|
53 |
+
and not is_channel_added(i.id)
|
54 |
+
):
|
55 |
+
new += 1
|
56 |
+
cid = f"-100{i.id}"
|
57 |
+
add_channel(int(cid))
|
58 |
except Exception as Ex:
|
59 |
LOGS.info(Ex)
|
60 |
await x.edit(get_string("bd_3").format(get_no_channels(), new))
|
|
|
125 |
channels = get_channels()
|
126 |
num = get_no_channels()
|
127 |
if num == 0:
|
128 |
+
return await eor(x, "No chats were added.", time=5)
|
129 |
msg = "Channels in database:\n"
|
130 |
for channel in channels:
|
131 |
name = ""
|
|
|
196 |
@ultroid_cmd(
|
197 |
pattern="broadcast ?(.*)",
|
198 |
allow_sudo=False,
|
|
|
199 |
)
|
200 |
async def sending(event):
|
201 |
x = await eor(event, "`Processing...`")
|
202 |
if not event.is_reply:
|
203 |
return await x.edit("Reply to a message to broadcast.")
|
204 |
channels = get_channels()
|
|
|
|
|
205 |
if get_no_channels() == 0:
|
206 |
return await x.edit(f"Please add channels by using `{hndlr}add` in them.")
|
207 |
await x.edit("Sending....")
|
|
|
210 |
if previous_message.poll:
|
211 |
return await x.edit(f"Reply `{hndlr}forward` for polls.")
|
212 |
if previous_message:
|
213 |
+
error_count = 0
|
214 |
+
sent_count = 0
|
215 |
for channel in channels:
|
216 |
try:
|
217 |
await ultroid_bot.send_message(int(channel), previous_message)
|
plugins/calculator.py
CHANGED
@@ -14,10 +14,38 @@ import re
|
|
14 |
|
15 |
from . import *
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
@ultroid_cmd(pattern="calc")
|
19 |
async def icalc(e):
|
20 |
udB.delete("calc")
|
|
|
|
|
21 |
results = await e.client.inline_query(asst.me.username, "calc")
|
22 |
await results[0].click(e.chat_id, silent=True, hide_via=True)
|
23 |
await e.delete()
|
@@ -26,31 +54,6 @@ async def icalc(e):
|
|
26 |
@in_pattern("calc")
|
27 |
@in_owner
|
28 |
async def _(e):
|
29 |
-
m = [
|
30 |
-
"AC",
|
31 |
-
"C",
|
32 |
-
"⌫",
|
33 |
-
"%",
|
34 |
-
"7",
|
35 |
-
"8",
|
36 |
-
"9",
|
37 |
-
"+",
|
38 |
-
"4",
|
39 |
-
"5",
|
40 |
-
"6",
|
41 |
-
"-",
|
42 |
-
"1",
|
43 |
-
"2",
|
44 |
-
"3",
|
45 |
-
"x",
|
46 |
-
"00",
|
47 |
-
"0",
|
48 |
-
".",
|
49 |
-
"÷",
|
50 |
-
]
|
51 |
-
tultd = [Button.inline(f"{x}", data=f"calc{x}") for x in m]
|
52 |
-
lst = list(zip(tultd[::4], tultd[1::4], tultd[2::4], tultd[3::4]))
|
53 |
-
lst.append([Button.inline("=", data="calc=")])
|
54 |
calc = e.builder.article("Calc", text="• Ultroid Inline Calculator •", buttons=lst)
|
55 |
await e.answer([calc])
|
56 |
|
@@ -61,33 +64,33 @@ async def _(e):
|
|
61 |
x = (e.data_match.group(1)).decode()
|
62 |
if x == "AC":
|
63 |
udB.delete("calc")
|
64 |
-
|
65 |
"• Ultroid Inline Calculator •",
|
66 |
buttons=[Button.inline("Open Calculator Again", data="recalc")],
|
67 |
)
|
68 |
elif x == "C":
|
69 |
udB.delete("calc")
|
70 |
-
|
71 |
elif x == "⌫":
|
72 |
get = udB.get("calc")
|
73 |
if get:
|
74 |
udB.set("calc", get[:-1])
|
75 |
-
|
76 |
elif x == "%":
|
77 |
get = udB.get("calc")
|
78 |
if get:
|
79 |
udB.set("calc", get + "/100")
|
80 |
-
|
81 |
elif x == "÷":
|
82 |
get = udB.get("calc")
|
83 |
if get:
|
84 |
udB.set("calc", get + "/")
|
85 |
-
|
86 |
elif x == "x":
|
87 |
get = udB.get("calc")
|
88 |
if get:
|
89 |
udB.set("calc", get + "*")
|
90 |
-
|
91 |
elif x == "=":
|
92 |
get = udB.get("calc")
|
93 |
if get:
|
@@ -96,18 +99,18 @@ async def _(e):
|
|
96 |
out = await calcc(get, e)
|
97 |
try:
|
98 |
num = float(out)
|
99 |
-
|
100 |
except BaseException:
|
101 |
udB.delete("calc")
|
102 |
-
|
103 |
-
|
104 |
else:
|
105 |
get = udB.get("calc")
|
106 |
if get:
|
107 |
udB.set("calc", get + x)
|
108 |
-
|
109 |
udB.set("calc", x)
|
110 |
-
|
111 |
|
112 |
|
113 |
@callback("recalc")
|
|
|
14 |
|
15 |
from . import *
|
16 |
|
17 |
+
m = [
|
18 |
+
"AC",
|
19 |
+
"C",
|
20 |
+
"⌫",
|
21 |
+
"%",
|
22 |
+
"7",
|
23 |
+
"8",
|
24 |
+
"9",
|
25 |
+
"+",
|
26 |
+
"4",
|
27 |
+
"5",
|
28 |
+
"6",
|
29 |
+
"-",
|
30 |
+
"1",
|
31 |
+
"2",
|
32 |
+
"3",
|
33 |
+
"x",
|
34 |
+
"00",
|
35 |
+
"0",
|
36 |
+
".",
|
37 |
+
"÷",
|
38 |
+
]
|
39 |
+
tultd = [Button.inline(f"{x}", data=f"calc{x}") for x in m]
|
40 |
+
lst = list(zip(tultd[::4], tultd[1::4], tultd[2::4], tultd[3::4]))
|
41 |
+
lst.append([Button.inline("=", data="calc=")])
|
42 |
+
|
43 |
|
44 |
@ultroid_cmd(pattern="calc")
|
45 |
async def icalc(e):
|
46 |
udB.delete("calc")
|
47 |
+
if e.client._bot:
|
48 |
+
return await e.reply("• Ultroid Inline Calculator •", buttons=lst)
|
49 |
results = await e.client.inline_query(asst.me.username, "calc")
|
50 |
await results[0].click(e.chat_id, silent=True, hide_via=True)
|
51 |
await e.delete()
|
|
|
54 |
@in_pattern("calc")
|
55 |
@in_owner
|
56 |
async def _(e):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
calc = e.builder.article("Calc", text="• Ultroid Inline Calculator •", buttons=lst)
|
58 |
await e.answer([calc])
|
59 |
|
|
|
64 |
x = (e.data_match.group(1)).decode()
|
65 |
if x == "AC":
|
66 |
udB.delete("calc")
|
67 |
+
await e.edit(
|
68 |
"• Ultroid Inline Calculator •",
|
69 |
buttons=[Button.inline("Open Calculator Again", data="recalc")],
|
70 |
)
|
71 |
elif x == "C":
|
72 |
udB.delete("calc")
|
73 |
+
await e.answer("cleared")
|
74 |
elif x == "⌫":
|
75 |
get = udB.get("calc")
|
76 |
if get:
|
77 |
udB.set("calc", get[:-1])
|
78 |
+
await e.answer(str(get[:-1]))
|
79 |
elif x == "%":
|
80 |
get = udB.get("calc")
|
81 |
if get:
|
82 |
udB.set("calc", get + "/100")
|
83 |
+
await e.answer(str(get + "/100"))
|
84 |
elif x == "÷":
|
85 |
get = udB.get("calc")
|
86 |
if get:
|
87 |
udB.set("calc", get + "/")
|
88 |
+
await e.answer(str(get + "/"))
|
89 |
elif x == "x":
|
90 |
get = udB.get("calc")
|
91 |
if get:
|
92 |
udB.set("calc", get + "*")
|
93 |
+
await e.answer(str(get + "*"))
|
94 |
elif x == "=":
|
95 |
get = udB.get("calc")
|
96 |
if get:
|
|
|
99 |
out = await calcc(get, e)
|
100 |
try:
|
101 |
num = float(out)
|
102 |
+
await e.answer(f"Answer : {num}", cache_time=0, alert=True)
|
103 |
except BaseException:
|
104 |
udB.delete("calc")
|
105 |
+
await e.answer("Error", cache_time=0, alert=True)
|
106 |
+
await e.answer("None")
|
107 |
else:
|
108 |
get = udB.get("calc")
|
109 |
if get:
|
110 |
udB.set("calc", get + x)
|
111 |
+
await e.answer(str(get + x))
|
112 |
udB.set("calc", x)
|
113 |
+
await e.answer(str(x))
|
114 |
|
115 |
|
116 |
@callback("recalc")
|
plugins/carbon.py
CHANGED
@@ -12,10 +12,12 @@
|
|
12 |
|
13 |
• `{i}rcarbon <text/reply to msg/reply to document>`
|
14 |
Carbonise the text, with random bg colours.
|
|
|
|
|
|
|
15 |
"""
|
16 |
import random
|
17 |
|
18 |
-
import requests
|
19 |
from carbonnow import Carbon
|
20 |
|
21 |
from . import *
|
@@ -173,28 +175,33 @@ all_col = [
|
|
173 |
|
174 |
|
175 |
@ultroid_cmd(
|
176 |
-
pattern="
|
177 |
)
|
178 |
async def crbn(event):
|
179 |
-
xxxx = await eor(event,
|
|
|
|
|
|
|
|
|
|
|
180 |
if event.reply_to_msg_id:
|
181 |
temp = await event.get_reply_message()
|
182 |
if temp.media:
|
183 |
b = await event.client.download_media(temp)
|
184 |
-
|
185 |
-
|
186 |
-
a.close()
|
187 |
os.remove(b)
|
188 |
else:
|
189 |
code = temp.message
|
190 |
else:
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
|
|
198 |
xx = await carbon.memorize("ultroid_carbon")
|
199 |
await xxxx.delete()
|
200 |
await event.reply(
|
@@ -204,33 +211,37 @@ async def crbn(event):
|
|
204 |
|
205 |
|
206 |
@ultroid_cmd(
|
207 |
-
pattern="
|
208 |
)
|
209 |
async def crbn(event):
|
210 |
-
|
|
|
|
|
|
|
211 |
if event.reply_to_msg_id:
|
212 |
temp = await event.get_reply_message()
|
213 |
if temp.media:
|
214 |
b = await event.client.download_media(temp)
|
215 |
-
|
216 |
-
|
217 |
-
a.close()
|
218 |
os.remove(b)
|
219 |
else:
|
220 |
code = temp.message
|
221 |
else:
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
)
|
229 |
carbon = Carbon(
|
230 |
-
base_url="https://carbonara.vercel.app/api/cook", code=code, background=
|
231 |
)
|
232 |
-
|
233 |
-
|
|
|
|
|
|
|
234 |
await event.reply(
|
235 |
f"Carbonised by {inline_mention(event.sender)}",
|
236 |
file=xx,
|
|
|
12 |
|
13 |
• `{i}rcarbon <text/reply to msg/reply to document>`
|
14 |
Carbonise the text, with random bg colours.
|
15 |
+
|
16 |
+
• `{i}ccarbon <color ><text/reply to msg/reply to document>`
|
17 |
+
Carbonise the text, with custom bg colours.
|
18 |
"""
|
19 |
import random
|
20 |
|
|
|
21 |
from carbonnow import Carbon
|
22 |
|
23 |
from . import *
|
|
|
175 |
|
176 |
|
177 |
@ultroid_cmd(
|
178 |
+
pattern="^(rc|c)arbon",
|
179 |
)
|
180 |
async def crbn(event):
|
181 |
+
xxxx = await eor(event, "Processing")
|
182 |
+
te = event.text
|
183 |
+
if te[1] == "r":
|
184 |
+
col = random.choice(all_col)
|
185 |
+
else:
|
186 |
+
col = None
|
187 |
if event.reply_to_msg_id:
|
188 |
temp = await event.get_reply_message()
|
189 |
if temp.media:
|
190 |
b = await event.client.download_media(temp)
|
191 |
+
with open(b) as a:
|
192 |
+
code = a.read()
|
|
|
193 |
os.remove(b)
|
194 |
else:
|
195 |
code = temp.message
|
196 |
else:
|
197 |
+
try:
|
198 |
+
code = event.text.split(" ", maxsplit=1)[1]
|
199 |
+
except IndexError:
|
200 |
+
return await eor(xxxx, "`Reply to Message or readable file..`")
|
201 |
+
col = random.choice(all_col)
|
202 |
+
carbon = Carbon(
|
203 |
+
base_url="https://carbonara.vercel.app/api/cook", code=code, background=col
|
204 |
+
)
|
205 |
xx = await carbon.memorize("ultroid_carbon")
|
206 |
await xxxx.delete()
|
207 |
await event.reply(
|
|
|
211 |
|
212 |
|
213 |
@ultroid_cmd(
|
214 |
+
pattern="ccarbon ?(.*)",
|
215 |
)
|
216 |
async def crbn(event):
|
217 |
+
match = event.pattern_match.group(1)
|
218 |
+
if not match:
|
219 |
+
return await eor(event, "`Give Custom Color to Create Carbon...`")
|
220 |
+
msg = await eor(event, "Processing")
|
221 |
if event.reply_to_msg_id:
|
222 |
temp = await event.get_reply_message()
|
223 |
if temp.media:
|
224 |
b = await event.client.download_media(temp)
|
225 |
+
with open(b) as a:
|
226 |
+
code = a.read()
|
|
|
227 |
os.remove(b)
|
228 |
else:
|
229 |
code = temp.message
|
230 |
else:
|
231 |
+
try:
|
232 |
+
match = match.split(" ", maxsplit=1)
|
233 |
+
code = match[1]
|
234 |
+
match = match[0]
|
235 |
+
except IndexError:
|
236 |
+
return await eor(msg, "`Reply to Message or readable file..`")
|
|
|
237 |
carbon = Carbon(
|
238 |
+
base_url="https://carbonara.vercel.app/api/cook", code=code, background=match
|
239 |
)
|
240 |
+
try:
|
241 |
+
xx = await carbon.memorize("ultroid_carbon")
|
242 |
+
except Exception as er:
|
243 |
+
return await msg.edit(str(er))
|
244 |
+
await msg.delete()
|
245 |
await event.reply(
|
246 |
f"Carbonised by {inline_mention(event.sender)}",
|
247 |
file=xx,
|
plugins/channelhacks.py
CHANGED
@@ -45,7 +45,7 @@ from . import *
|
|
45 |
|
46 |
@ultroid_bot.on(events.NewMessage())
|
47 |
async def _(e):
|
48 |
-
if
|
49 |
return
|
50 |
x = get_source_channels()
|
51 |
th = await e.get_chat()
|
@@ -54,14 +54,9 @@ async def _(e):
|
|
54 |
y = get_destinations()
|
55 |
for ys in y:
|
56 |
try:
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
await ultroid_bot.send_file(int(ys), e.media, caption=e.text)
|
61 |
-
else:
|
62 |
-
await ultroid_bot.send_file(int(ys), e.media)
|
63 |
-
except Exception as e:
|
64 |
-
await ultroid_bot.send_message(bot.me.id, str(e))
|
65 |
|
66 |
|
67 |
@ultroid_cmd(pattern="shift (.*)")
|
@@ -131,12 +126,12 @@ async def dd(event):
|
|
131 |
return
|
132 |
if is_source_channel_added(y):
|
133 |
rem_source_channel(y)
|
134 |
-
await
|
135 |
elif is_source_channel_added(y):
|
136 |
rem_source_channel(y)
|
137 |
-
await
|
138 |
elif not is_source_channel_added(y):
|
139 |
-
await
|
140 |
|
141 |
|
142 |
@ultroid_cmd(pattern="listsource")
|
@@ -145,7 +140,7 @@ async def list_all(event):
|
|
145 |
channels = get_source_channels()
|
146 |
num = get_no_source_channels()
|
147 |
if num == 0:
|
148 |
-
return await
|
149 |
msg = "Source channels in database:\n"
|
150 |
for channel in channels:
|
151 |
name = ""
|
@@ -212,9 +207,9 @@ async def dd(event):
|
|
212 |
await eor(x, "Destination removed from database")
|
213 |
elif is_destination_added(y):
|
214 |
rem_destination(y)
|
215 |
-
await
|
216 |
elif not is_destination_added(y):
|
217 |
-
await
|
218 |
|
219 |
|
220 |
@ultroid_cmd(pattern="listdest")
|
@@ -224,7 +219,7 @@ async def list_all(event):
|
|
224 |
channels = get_destinations()
|
225 |
num = get_no_destinations()
|
226 |
if num == 0:
|
227 |
-
return await
|
228 |
msg = "Destination channels in database:\n"
|
229 |
for channel in channels:
|
230 |
name = ""
|
|
|
45 |
|
46 |
@ultroid_bot.on(events.NewMessage())
|
47 |
async def _(e):
|
48 |
+
if udB.get("AUTOPOST") != "True":
|
49 |
return
|
50 |
x = get_source_channels()
|
51 |
th = await e.get_chat()
|
|
|
54 |
y = get_destinations()
|
55 |
for ys in y:
|
56 |
try:
|
57 |
+
await ultroid_bot.send_message(int(ys), e.message)
|
58 |
+
except Exception as ex:
|
59 |
+
await asst.send_message(int(udB["LOG_CHANNEL"]), str(ex))
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
|
62 |
@ultroid_cmd(pattern="shift (.*)")
|
|
|
126 |
return
|
127 |
if is_source_channel_added(y):
|
128 |
rem_source_channel(y)
|
129 |
+
await eor(x, "Source removed from database", time=3)
|
130 |
elif is_source_channel_added(y):
|
131 |
rem_source_channel(y)
|
132 |
+
await eor(x, "Source removed from database", time=5)
|
133 |
elif not is_source_channel_added(y):
|
134 |
+
await eor(x, "Source channel is already removed from database. ", time=3)
|
135 |
|
136 |
|
137 |
@ultroid_cmd(pattern="listsource")
|
|
|
140 |
channels = get_source_channels()
|
141 |
num = get_no_source_channels()
|
142 |
if num == 0:
|
143 |
+
return await eor(x, "No chats were added.", time=5)
|
144 |
msg = "Source channels in database:\n"
|
145 |
for channel in channels:
|
146 |
name = ""
|
|
|
207 |
await eor(x, "Destination removed from database")
|
208 |
elif is_destination_added(y):
|
209 |
rem_destination(y)
|
210 |
+
await eor(x, "Destination removed from database", time=5)
|
211 |
elif not is_destination_added(y):
|
212 |
+
await eor(x, "Destination channel is already removed from database. ", time=5)
|
213 |
|
214 |
|
215 |
@ultroid_cmd(pattern="listdest")
|
|
|
219 |
channels = get_destinations()
|
220 |
num = get_no_destinations()
|
221 |
if num == 0:
|
222 |
+
return await eor(x, "No chats were added.", time=5)
|
223 |
msg = "Destination channels in database:\n"
|
224 |
for channel in channels:
|
225 |
name = ""
|
plugins/chat_bot.py
CHANGED
@@ -52,9 +52,9 @@ async def rem_chatBot(event):
|
|
52 |
|
53 |
@ultroid_cmd(pattern="listai")
|
54 |
async def lister(event):
|
55 |
-
users = get_all_added()
|
56 |
if udB.get("CHATBOT_USERS") is None:
|
57 |
-
return await
|
58 |
msg = ""
|
59 |
for i in users:
|
60 |
try:
|
@@ -70,19 +70,21 @@ async def chat_bot_fn(event, type_):
|
|
70 |
if event.reply_to_msg_id:
|
71 |
user = (await event.get_reply_message()).sender
|
72 |
else:
|
73 |
-
temp = event.text.split(
|
74 |
try:
|
75 |
-
|
76 |
-
except
|
77 |
-
|
78 |
-
event
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
|
|
82 |
if type_ == "add":
|
83 |
-
add_chatbot(event.
|
84 |
if type_ == "remov":
|
85 |
-
rem_chatbot(event.
|
86 |
await eor(
|
87 |
-
event, f"**ChatBot:**\n{type_}ed [{user.first_name}](tg://user?id={user.id})
|
88 |
)
|
|
|
52 |
|
53 |
@ultroid_cmd(pattern="listai")
|
54 |
async def lister(event):
|
55 |
+
users = get_all_added(event.chat.id)
|
56 |
if udB.get("CHATBOT_USERS") is None:
|
57 |
+
return await eor(event, "`No user has AI added.`", time=5)
|
58 |
msg = ""
|
59 |
for i in users:
|
60 |
try:
|
|
|
70 |
if event.reply_to_msg_id:
|
71 |
user = (await event.get_reply_message()).sender
|
72 |
else:
|
73 |
+
temp = event.text.split(maxsplit=1)
|
74 |
try:
|
75 |
+
user = await event.client.get_entity(temp[1])
|
76 |
+
except BaseException:
|
77 |
+
if event.is_private:
|
78 |
+
user = event.chat
|
79 |
+
else:
|
80 |
+
return await eod(
|
81 |
+
event,
|
82 |
+
"Reply to a user or give me his id/username to add an AI ChatBot!",
|
83 |
+
)
|
84 |
if type_ == "add":
|
85 |
+
add_chatbot(event.chat_id, user.id)
|
86 |
if type_ == "remov":
|
87 |
+
rem_chatbot(event.chat_id, user.id)
|
88 |
await eor(
|
89 |
+
event, f"**ChatBot:**\n{type_}ed [{user.first_name}](tg://user?id={user.id})"
|
90 |
)
|
plugins/chats.py
CHANGED
@@ -8,13 +8,13 @@
|
|
8 |
"""
|
9 |
✘ Commands Available -
|
10 |
|
11 |
-
• `{i}delchat
|
12 |
Delete the group this cmd is used in.
|
13 |
|
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
|
@@ -23,28 +23,39 @@
|
|
23 |
|
24 |
|
25 |
from telethon.errors import ChatAdminRequiredError as no_admin
|
26 |
-
from telethon.tl.functions.channels import
|
|
|
|
|
|
|
|
|
|
|
27 |
from telethon.tl.functions.messages import (
|
28 |
CreateChatRequest,
|
29 |
DeleteChatUserRequest,
|
30 |
ExportChatInviteRequest,
|
|
|
31 |
)
|
32 |
|
33 |
from . import *
|
34 |
|
35 |
|
36 |
@ultroid_cmd(
|
37 |
-
pattern="delchat
|
38 |
groups_only=True,
|
39 |
)
|
40 |
async def _(e):
|
41 |
xx = await eor(e, "`Processing...`")
|
42 |
try:
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
44 |
except TypeError:
|
45 |
-
return await
|
46 |
except no_admin:
|
47 |
-
return await
|
48 |
await e.client.send_message(
|
49 |
int(udB.get("LOG_CHANNEL")), f"#Deleted\nDeleted {e.chat_id}"
|
50 |
)
|
@@ -54,17 +65,27 @@ async def _(e):
|
|
54 |
pattern="getlink$",
|
55 |
groups_only=True,
|
56 |
type=["official", "manager"],
|
57 |
-
ignore_dualmode=True,
|
58 |
)
|
59 |
async def _(e):
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
)
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
|
70 |
@ultroid_cmd(
|
@@ -73,6 +94,11 @@ async def _(e):
|
|
73 |
async def _(e):
|
74 |
type_of_group = e.pattern_match.group(1)
|
75 |
group_name = e.pattern_match.group(2)
|
|
|
|
|
|
|
|
|
|
|
76 |
xx = await eor(e, "`Processing...`")
|
77 |
if type_of_group == "b":
|
78 |
try:
|
@@ -100,23 +126,30 @@ async def _(e):
|
|
100 |
)
|
101 |
except Exception as ex:
|
102 |
await xx.edit(str(ex))
|
103 |
-
elif type_of_group
|
104 |
try:
|
105 |
r = await e.client(
|
106 |
CreateChannelRequest(
|
107 |
title=group_name,
|
108 |
about="Join @TeamUltroid",
|
109 |
-
megagroup=
|
110 |
-
)
|
111 |
)
|
|
|
112 |
created_chat_id = r.chats[0].id
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
await xx.edit(
|
119 |
-
f"Your [{group_name}]({result
|
120 |
link_preview=False,
|
121 |
)
|
122 |
except Exception as ex:
|
|
|
8 |
"""
|
9 |
✘ Commands Available -
|
10 |
|
11 |
+
• `{i}delchat <optional- username/id>`
|
12 |
Delete the group this cmd is used in.
|
13 |
|
14 |
• `{i}getlink`
|
15 |
Get link of group this cmd is used in.
|
16 |
|
17 |
+
• `{i}create (g|b|c) <group_name> ; <optional-username>`
|
18 |
Create group woth a specific name.
|
19 |
g - megagroup/supergroup
|
20 |
b - small group
|
|
|
23 |
|
24 |
|
25 |
from telethon.errors import ChatAdminRequiredError as no_admin
|
26 |
+
from telethon.tl.functions.channels import (
|
27 |
+
CreateChannelRequest,
|
28 |
+
DeleteChannelRequest,
|
29 |
+
GetFullChannelRequest,
|
30 |
+
UpdateUsernameRequest,
|
31 |
+
)
|
32 |
from telethon.tl.functions.messages import (
|
33 |
CreateChatRequest,
|
34 |
DeleteChatUserRequest,
|
35 |
ExportChatInviteRequest,
|
36 |
+
GetFullChatRequest,
|
37 |
)
|
38 |
|
39 |
from . import *
|
40 |
|
41 |
|
42 |
@ultroid_cmd(
|
43 |
+
pattern="delchat",
|
44 |
groups_only=True,
|
45 |
)
|
46 |
async def _(e):
|
47 |
xx = await eor(e, "`Processing...`")
|
48 |
try:
|
49 |
+
match = e.text.split(" ", maxsplit=1)[1]
|
50 |
+
chat = "-100" + str(await get_user_id(match))
|
51 |
+
except IndexError:
|
52 |
+
chat = e.chat_id
|
53 |
+
try:
|
54 |
+
await e.client(DeleteChannelRequest(chat))
|
55 |
except TypeError:
|
56 |
+
return await eor(xx, "`Cant delete this chat`", time=10)
|
57 |
except no_admin:
|
58 |
+
return await eor(xx, "`I m not an admin`", time=10)
|
59 |
await e.client.send_message(
|
60 |
int(udB.get("LOG_CHANNEL")), f"#Deleted\nDeleted {e.chat_id}"
|
61 |
)
|
|
|
65 |
pattern="getlink$",
|
66 |
groups_only=True,
|
67 |
type=["official", "manager"],
|
|
|
68 |
)
|
69 |
async def _(e):
|
70 |
+
chat = await e.get_chat()
|
71 |
+
if chat.username:
|
72 |
+
return await eor(e, f"Username: @{chat.username}")
|
73 |
+
if isinstance(chat, types.Chat):
|
74 |
+
FC = await e.client(GetFullChatRequest(chat.id))
|
75 |
+
elif isinstance(chat, types.Channel):
|
76 |
+
FC = await e.client(GetFullChannelRequest(chat.id))
|
77 |
+
Inv = FC.full_chat.exported_invite
|
78 |
+
if Inv and not Inv.revoked:
|
79 |
+
link = Inv.link
|
80 |
+
else:
|
81 |
+
try:
|
82 |
+
r = await e.client(
|
83 |
+
ExportChatInviteRequest(e.chat_id),
|
84 |
+
)
|
85 |
+
except no_admin:
|
86 |
+
return await eor(e, "`I m not an admin`", time=10)
|
87 |
+
link = r.link
|
88 |
+
await eor(e, f"Link:- {link}")
|
89 |
|
90 |
|
91 |
@ultroid_cmd(
|
|
|
94 |
async def _(e):
|
95 |
type_of_group = e.pattern_match.group(1)
|
96 |
group_name = e.pattern_match.group(2)
|
97 |
+
username = None
|
98 |
+
if " ; " in group_name:
|
99 |
+
group_ = group_name.split(" ; ", maxsplit=1)
|
100 |
+
group_name = group_[0]
|
101 |
+
username = group_[1]
|
102 |
xx = await eor(e, "`Processing...`")
|
103 |
if type_of_group == "b":
|
104 |
try:
|
|
|
126 |
)
|
127 |
except Exception as ex:
|
128 |
await xx.edit(str(ex))
|
129 |
+
elif type_of_group in ["g", "c"]:
|
130 |
try:
|
131 |
r = await e.client(
|
132 |
CreateChannelRequest(
|
133 |
title=group_name,
|
134 |
about="Join @TeamUltroid",
|
135 |
+
megagroup=type_of_group != "c",
|
136 |
+
)
|
137 |
)
|
138 |
+
|
139 |
created_chat_id = r.chats[0].id
|
140 |
+
if username:
|
141 |
+
await e.client(UpdateUsernameRequest(created_chat_id, username))
|
142 |
+
result = "https://t.me/" + username
|
143 |
+
else:
|
144 |
+
result = (
|
145 |
+
await e.client(
|
146 |
+
ExportChatInviteRequest(
|
147 |
+
peer=created_chat_id,
|
148 |
+
),
|
149 |
+
)
|
150 |
+
).link
|
151 |
await xx.edit(
|
152 |
+
f"Your [{group_name}]({result}) Group/Channel Has been made Boss!",
|
153 |
link_preview=False,
|
154 |
)
|
155 |
except Exception as ex:
|