Spaces:
Paused
Paused
Devesh Pal
Aditya
Danish
Amit Sharma
TechiError
Avish Kumar
Vɪɴᴀʏᴀᴋ Pᴀɴᴅᴇʏ
Shrimadhav U K
Dark
Muhamad Risman Aziz
Ashik Muhammed
MMETMA
amirmehdinzri
commited on
Commit
·
ea7f80a
1
Parent(s):
838003a
Ultroid v0.3 Updates
Browse filesCo-authored-by: Aditya <[email protected]>
Co-authored-by: Danish <[email protected]>
Co-authored-by: Amit Sharma <[email protected]>
Co-authored-by: TechiError <[email protected]>
Co-authored-by: Avish Kumar <[email protected]>
Co-authored-by: Vɪɴᴀʏᴀᴋ Pᴀɴᴅᴇʏ <[email protected]>
Co-authored-by: Shrimadhav U K <[email protected]>
Co-authored-by: Dark <[email protected]>
Co-authored-by: Muhamad Risman Aziz <[email protected]>
Co-authored-by: Ashik Muhammed <[email protected]>
Co-authored-by: MMETMA <[email protected]>
Co-authored-by: amirmehdinzri <[email protected]>
This view is limited to 50 files because it contains too many changes.
See raw diff
- .github/ISSUE_TEMPLATE/bug-reports.yml +2 -1
- .github/ISSUE_TEMPLATE/config.yml +1 -1
- .github/PULL_REQUEST_TEMPLATE/pull_request_template.md +1 -4
- .github/stalebot.yml +13 -0
- .github/workflows/codeql-analysis.yml +1 -3
- CONTRIBUTING.md +6 -0
- Dockerfile +3 -4
- README.md +31 -23
- assistant/__init__.py +6 -4
- assistant/api_setter.py +0 -94
- assistant/callbackstuffs.py +454 -470
- assistant/games.py +308 -0
- assistant/initial.py +1 -1
- assistant/inlinestuff.py +327 -47
- assistant/localization.py +2 -2
- assistant/manager/__init__.py +4 -3
- assistant/manager/_help.py +9 -5
- assistant/manager/_on_adds.py +5 -4
- assistant/manager/admins.py +29 -18
- assistant/manager/afk.py +109 -0
- assistant/manager/misc.py +17 -12
- assistant/manager/stickermanager.py +166 -0
- assistant/pmbot.py +32 -29
- assistant/start.py +54 -38
- assistant/ytdl.py +139 -89
- plugins/__init__.py +14 -9
- plugins/_chatactions.py +31 -12
- plugins/_help.py +17 -17
- plugins/_inline.py +129 -337
- plugins/_ultroid.py +3 -3
- plugins/_userlogs.py +158 -74
- plugins/_wspr.py +43 -39
- plugins/admintools.py +67 -65
- plugins/afk.py +26 -23
- plugins/akinator.py +0 -104
- plugins/antiflood.py +11 -21
- plugins/asstcmd.py +28 -14
- plugins/audiotools.py +6 -6
- plugins/autocorrect.py +21 -10
- plugins/autopic.py +68 -27
- plugins/blacklist.py +14 -10
- plugins/bot.py +172 -102
- plugins/broadcast.py +14 -14
- plugins/button.py +11 -11
- plugins/calculator.py +2 -2
- plugins/carbon.py +8 -19
- plugins/channelhacks.py +15 -15
- plugins/{chat_bot.py → chatbot.py} +26 -20
- plugins/chats.py +37 -56
- plugins/{clean_action.py → cleanaction.py} +19 -13
.github/ISSUE_TEMPLATE/bug-reports.yml
CHANGED
@@ -30,6 +30,7 @@ body:
|
|
30 |
label: Version
|
31 |
description: What version of Ultroid are you running?
|
32 |
options:
|
|
|
33 |
- 0.2
|
34 |
- 0.1
|
35 |
- 0.0.9
|
@@ -64,4 +65,4 @@ body:
|
|
64 |
description: By submitting this issue, you agree that you have read the [docs](https://ultroid.tech) and gone through the [deploy tutorial](https://www.youtube.com/watch?v=9wF7k9qA0Q4) at first.
|
65 |
options:
|
66 |
- label: I have followed all of the above steps.
|
67 |
-
required: true
|
|
|
30 |
label: Version
|
31 |
description: What version of Ultroid are you running?
|
32 |
options:
|
33 |
+
- 0.3
|
34 |
- 0.2
|
35 |
- 0.1
|
36 |
- 0.0.9
|
|
|
65 |
description: By submitting this issue, you agree that you have read the [docs](https://ultroid.tech) and gone through the [deploy tutorial](https://www.youtube.com/watch?v=9wF7k9qA0Q4) at first.
|
66 |
options:
|
67 |
- label: I have followed all of the above steps.
|
68 |
+
required: true
|
.github/ISSUE_TEMPLATE/config.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
blank_issues_enabled:
|
2 |
contact_links:
|
3 |
- name: Ultroid Support
|
4 |
url: https://t.me/UltroidSupport
|
|
|
1 |
+
blank_issues_enabled: true
|
2 |
contact_links:
|
3 |
- name: Ultroid Support
|
4 |
url: https://t.me/UltroidSupport
|
.github/PULL_REQUEST_TEMPLATE/pull_request_template.md
CHANGED
@@ -6,7 +6,4 @@ detailed_description_here
|
|
6 |
### Issue Number [Optional] :
|
7 |
Issue Number here if your pull request close any issue or is linked to.
|
8 |
|
9 |
-
----
|
10 |
-
### What defines you?
|
11 |
-
- [ ] Hacktoberfest Participant.
|
12 |
-
- [ ] Contributor
|
|
|
6 |
### Issue Number [Optional] :
|
7 |
Issue Number here if your pull request close any issue or is linked to.
|
8 |
|
9 |
+
----
|
|
|
|
|
|
.github/stalebot.yml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Number of days of inactivity before an issue becomes stale
|
2 |
+
daysUntilStale: 50
|
3 |
+
# Number of days of inactivity before a stale issue is closed
|
4 |
+
daysUntilClose: 7
|
5 |
+
# Label to use when marking an issue as stale
|
6 |
+
staleLabel: inactive
|
7 |
+
# Comment to post when marking an issue as stale. Set to `false` to disable
|
8 |
+
markComment: >
|
9 |
+
This issue has been automatically marked as stale because it has not had
|
10 |
+
recent activity. It will be closed if no further activity occurs. Thank you
|
11 |
+
for your contributions.
|
12 |
+
# Comment to post when closing a stale issue. Set to `false` to disable
|
13 |
+
closeComment: false
|
.github/workflows/codeql-analysis.yml
CHANGED
@@ -24,6 +24,4 @@ jobs:
|
|
24 |
languages: python
|
25 |
|
26 |
- name: Perform CodeQL Analysis
|
27 |
-
uses: github/codeql-action/analyze@v1
|
28 |
-
|
29 |
-
# Built with ❤ by [Pipeline Foundation](https://pipeline.foundation)
|
|
|
24 |
languages: python
|
25 |
|
26 |
- name: Perform CodeQL Analysis
|
27 |
+
uses: github/codeql-action/analyze@v1
|
|
|
|
CONTRIBUTING.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1 |
# Welcome To Contributing Guide
|
2 |
Any contribution done to this repository will be appreciated! 🎉
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
### Issues
|
5 |
- Search for existing Similar issues.
|
6 |
- You can open a issue first before contributing, If it contain some major changes like `bug fixes` or `feature addition`.
|
|
|
1 |
# Welcome To Contributing Guide
|
2 |
Any contribution done to this repository will be appreciated! 🎉
|
3 |
|
4 |
+
### About Ultroid
|
5 |
+
- **Ultroid** is Telegram Userbot, which allow you to perform many task easily.
|
6 |
+
- It's base core is a pip package named [`pyUltroid`](https://GitHub.com/TeamUltroid/pyUltroid).
|
7 |
+
- This repository, contains Ultroid's official plugin files.
|
8 |
+
- moreover, Ultroid User also have an option to get more plugins available at [`UltroidAddons`](https://github.com/TeamUltroid/UltroidAddons)
|
9 |
+
|
10 |
### Issues
|
11 |
- Search for existing Similar issues.
|
12 |
- You can open a issue first before contributing, If it contain some major changes like `bug fixes` or `feature addition`.
|
Dockerfile
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
# Ultroid - UserBot
|
2 |
-
# Copyright (C) 2021 TeamUltroid
|
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 |
|
@@ -9,14 +9,13 @@ FROM theteamultroid/ultroid:main
|
|
9 |
ENV TZ=Asia/Kolkata
|
10 |
|
11 |
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
|
12 |
-
|
13 |
# cloning the repo and installing requirements.
|
14 |
&& git clone https://github.com/TeamUltroid/Ultroid.git /root/TeamUltroid/ \
|
15 |
&& pip3 install --no-cache-dir -r root/TeamUltroid/requirements.txt \
|
16 |
-
&& pip3
|
17 |
|
18 |
# changing workdir
|
19 |
WORKDIR /root/TeamUltroid/
|
20 |
|
21 |
# start the bot
|
22 |
-
CMD ["bash", "
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
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 |
|
|
|
9 |
ENV TZ=Asia/Kolkata
|
10 |
|
11 |
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
|
|
|
12 |
# cloning the repo and installing requirements.
|
13 |
&& git clone https://github.com/TeamUltroid/Ultroid.git /root/TeamUltroid/ \
|
14 |
&& pip3 install --no-cache-dir -r root/TeamUltroid/requirements.txt \
|
15 |
+
&& pip3 install av --no-binary av
|
16 |
|
17 |
# changing workdir
|
18 |
WORKDIR /root/TeamUltroid/
|
19 |
|
20 |
# start the bot
|
21 |
+
CMD ["bash", "startup"]
|
README.md
CHANGED
@@ -5,19 +5,20 @@
|
|
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.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 |
|
@@ -29,7 +30,7 @@
|
|
29 |
[](http://ultroid.tech/)
|
30 |
|
31 |
# Tutorial
|
32 |
-
- Full Tutorial - [](https://www.youtube.com/watch?v=
|
33 |
|
34 |
- Tutorial to get Redis URL and password - [here.](./resources/extras/redistut.md)
|
35 |
---
|
@@ -42,16 +43,7 @@ Get the [Necessary Variables](#Necessary-Variables) and then click the button be
|
|
42 |
## Deploy Locally
|
43 |
- [Traditional Method](#local-deploy---traditional-method)
|
44 |
- [Easy Method](#local-deploy---easy-method)
|
45 |
-
- [
|
46 |
-
|
47 |
-
|
48 |
-
### Local Deploy - Latest Method
|
49 |
-
This is the latest and most fastest method currently.<br>
|
50 |
-
First, go to [UltroidCli](https://github.com/BLUE-DEVIL1134/UltroidCli) and install the latest release from the Github Releases.<br>
|
51 |
-
Then, do as it's given in the `README.md` to add the executable to your system path.
|
52 |
-
|
53 |
-
Further, take a look at the [`docs`](https://blue-devil1134.github.io/UltroidCli/) to get more information.
|
54 |
-
|
55 |
|
56 |
### Local Deploy - Easy Method
|
57 |
- Linux - `bash -c "$(curl -fsSL https://git.io/JY9UM)"`
|
@@ -60,14 +52,14 @@ Further, take a look at the [`docs`](https://blue-devil1134.github.io/UltroidCli
|
|
60 |
|
61 |
### Local Deploy - Traditional Method
|
62 |
- Get your [Necessary Variables](#Necessary-Variables)
|
63 |
-
- Clone the repository:
|
64 |
`git clone https://github.com/TeamUltroid/Ultroid.git`
|
65 |
-
- Go to the cloned folder:
|
66 |
`cd Ultroid`
|
67 |
-
- Create a virtual env:
|
68 |
`virtualenv -p /usr/bin/python3 venv`
|
69 |
`. ./venv/bin/activate`
|
70 |
-
- Install the requirements:
|
71 |
`pip(3) install -U -r re*/st*/optional-requirements.txt`
|
72 |
`pip(3) install -U -r requirements.txt`
|
73 |
- Generate your `SESSION`:
|
@@ -83,10 +75,23 @@ Further, take a look at the [`docs`](https://blue-devil1134.github.io/UltroidCli
|
|
83 |
(You can either edit and rename the file or make a new file named `.env`.)
|
84 |
- Run the bot:
|
85 |
- Linux Users:
|
86 |
-
`bash
|
87 |
- Windows Users:
|
88 |
`python(3) -m pyUltroid`
|
89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
## Necessary Variables
|
91 |
- `SESSION` - SessionString for your accounts login session. Get it from [here](#Session-String)
|
92 |
- `REDIS_URI` - Redis endpoint URL, from [redislabs](http://redislabs.com/), tutorial [here.](./resources/extras/redistut.md)
|
@@ -100,14 +105,17 @@ Different ways to get your `SESSION`:
|
|
100 |
* Termux : `sh -c "$(curl -fsSL https://da.gd/termux-tel)"`
|
101 |
* TelegramBot : [@SessionGeneratorBot](https://t.me/SessionGeneratorBot)
|
102 |
|
103 |
-
|
104 |
|
105 |
# License
|
|
|
106 |
Ultroid is licensed under [GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html) v3 or later.
|
107 |
|
108 |
-
|
109 |
|
110 |
# Credits
|
111 |
* [](https://t.me/UltroidDevs)
|
112 |
* [Lonami](https://github.com/LonamiWebs/) for [Telethon.](https://github.com/LonamiWebs/Telethon)
|
113 |
* [MarshalX](https://github.com/MarshalX) for [PyTgCalls.](https://github.com/MarshalX/tgcalls)
|
|
|
|
|
|
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 |
+
[](#)
|
11 |
[](https://github.com/TeamUltroid/Ultroid/stargazers)
|
12 |
[](https://github.com/TeamUltroid/Ultroid/fork)
|
13 |
[](https://github.com/TeamUltroid/Ultroid/)
|
14 |
+
[](https://www.python.org/)
|
15 |
[](https://www.codefactor.io/repository/github/teamultroid/ultroid/overview/main)
|
16 |
[](https://github.com/TeamUltroid/Ultroid/graphs/commit-activity)
|
17 |
+
[](https://img.shields.io/docker/pulls/theteamultroid/ultroid?style=flat-square)
|
18 |
+
[](https://github.com/TeamUltroid/Ultroid)
|
19 |
[](https://github.com/TeamUltroid/Ultroid/graphs/contributors)
|
20 |
[](https://makeapullrequest.com)
|
21 |
+
[](https://github.com/TeamUltroid/Ultroid/blob/main/LICENSE)
|
22 |
[](https://stars.medv.io/TeamUltroid/Ultroid)
|
23 |
----
|
24 |
|
|
|
30 |
[](http://ultroid.tech/)
|
31 |
|
32 |
# Tutorial
|
33 |
+
- Full Tutorial - [](https://www.youtube.com/watch?v=0wAV7pUzhDQ)
|
34 |
|
35 |
- Tutorial to get Redis URL and password - [here.](./resources/extras/redistut.md)
|
36 |
---
|
|
|
43 |
## Deploy Locally
|
44 |
- [Traditional Method](#local-deploy---traditional-method)
|
45 |
- [Easy Method](#local-deploy---easy-method)
|
46 |
+
- [Ultroid CLI](#Ultroid-CLI)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
### Local Deploy - Easy Method
|
49 |
- Linux - `bash -c "$(curl -fsSL https://git.io/JY9UM)"`
|
|
|
52 |
|
53 |
### Local Deploy - Traditional Method
|
54 |
- Get your [Necessary Variables](#Necessary-Variables)
|
55 |
+
- Clone the repository:
|
56 |
`git clone https://github.com/TeamUltroid/Ultroid.git`
|
57 |
+
- Go to the cloned folder:
|
58 |
`cd Ultroid`
|
59 |
+
- Create a virtual env:
|
60 |
`virtualenv -p /usr/bin/python3 venv`
|
61 |
`. ./venv/bin/activate`
|
62 |
+
- Install the requirements:
|
63 |
`pip(3) install -U -r re*/st*/optional-requirements.txt`
|
64 |
`pip(3) install -U -r requirements.txt`
|
65 |
- Generate your `SESSION`:
|
|
|
75 |
(You can either edit and rename the file or make a new file named `.env`.)
|
76 |
- Run the bot:
|
77 |
- Linux Users:
|
78 |
+
`bash startup`
|
79 |
- Windows Users:
|
80 |
`python(3) -m pyUltroid`
|
81 |
|
82 |
+
### Ultroid CLI
|
83 |
+
[Ultroid CLI](https://github.com/BLUE-DEVIL1134/UltroidCli) is a command-line interface for deploying Ultroid.
|
84 |
+
|
85 |
+
- **Installing** -
|
86 |
+
Run the following code on a terminal, with curl installed.
|
87 |
+
`ver=$(curl https://raw.githubusercontent.com/BLUE-DEVIL1134/UltroidCli/main/version.txt) && curl -L -o ultroid https://github.com/BLUE-DEVIL1134/UltroidCli/releases/download/$ver/ultroid.exe`
|
88 |
+
OR
|
89 |
+
Go to [UltroidCli](https://github.com/BLUE-DEVIL1134/UltroidCli) and install the version release from the Github Releases. Add the executable to your system path as specified in the [Readme](https://github.com/BLUE-DEVIL1134/UltroidCli#how-to-use-ultroidcli-).
|
90 |
+
|
91 |
+
- **Documentation** -
|
92 |
+
Take a look at the [`docs`](https://blue-devil1134.github.io/UltroidCli/) for more detailed information.
|
93 |
+
|
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)
|
|
|
105 |
* Termux : `sh -c "$(curl -fsSL https://da.gd/termux-tel)"`
|
106 |
* TelegramBot : [@SessionGeneratorBot](https://t.me/SessionGeneratorBot)
|
107 |
|
108 |
+
---
|
109 |
|
110 |
# License
|
111 |
+
[](LICENSE)
|
112 |
Ultroid is licensed under [GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html) v3 or later.
|
113 |
|
114 |
+
---
|
115 |
|
116 |
# Credits
|
117 |
* [](https://t.me/UltroidDevs)
|
118 |
* [Lonami](https://github.com/LonamiWebs/) for [Telethon.](https://github.com/LonamiWebs/Telethon)
|
119 |
* [MarshalX](https://github.com/MarshalX) for [PyTgCalls.](https://github.com/MarshalX/tgcalls)
|
120 |
+
|
121 |
+
> Made with 💕 by [@TeamUltroid](https://t.me/TeamUltroid).
|
assistant/__init__.py
CHANGED
@@ -1,12 +1,14 @@
|
|
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 pyUltroid import *
|
|
|
9 |
from pyUltroid.functions.helper import *
|
|
|
10 |
from pyUltroid.misc import owner_and_sudos
|
11 |
from pyUltroid.misc._assistant import asst_cmd, callback, in_pattern
|
12 |
from telethon import Button, custom
|
@@ -14,15 +16,15 @@ from telethon import Button, custom
|
|
14 |
from plugins import ATRA_COL
|
15 |
from strings import get_languages, get_string, language
|
16 |
|
17 |
-
OWNER_NAME = ultroid_bot.
|
18 |
-
OWNER_ID = ultroid_bot.
|
19 |
|
20 |
AST_PLUGINS = {}
|
21 |
|
22 |
|
23 |
async def setit(event, name, value):
|
24 |
try:
|
25 |
-
udB.
|
26 |
except BaseException:
|
27 |
return await event.edit("`Something Went Wrong`")
|
28 |
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 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 pyUltroid import *
|
9 |
+
from pyUltroid import _ult_cache
|
10 |
from pyUltroid.functions.helper import *
|
11 |
+
from pyUltroid.functions.tools import get_stored_file
|
12 |
from pyUltroid.misc import owner_and_sudos
|
13 |
from pyUltroid.misc._assistant import asst_cmd, callback, in_pattern
|
14 |
from telethon import Button, custom
|
|
|
16 |
from plugins import ATRA_COL
|
17 |
from strings import get_languages, get_string, language
|
18 |
|
19 |
+
OWNER_NAME = ultroid_bot.full_name
|
20 |
+
OWNER_ID = ultroid_bot.uid
|
21 |
|
22 |
AST_PLUGINS = {}
|
23 |
|
24 |
|
25 |
async def setit(event, name, value):
|
26 |
try:
|
27 |
+
udB.set_key(name, value)
|
28 |
except BaseException:
|
29 |
return await event.edit("`Something Went Wrong`")
|
30 |
|
assistant/api_setter.py
DELETED
@@ -1,94 +0,0 @@
|
|
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 telethon import events
|
9 |
-
|
10 |
-
from . import *
|
11 |
-
|
12 |
-
# main menu for api setting
|
13 |
-
|
14 |
-
|
15 |
-
@callback("apiset", owner=True)
|
16 |
-
async def apiset(event: events.CallbackQuery):
|
17 |
-
await event.edit(
|
18 |
-
get_string("ast_1"),
|
19 |
-
buttons=[
|
20 |
-
[Button.inline("Remove.bg API", data="rmbg")],
|
21 |
-
[Button.inline("DEEP API", data="dapi")],
|
22 |
-
[Button.inline("OCR API", data="oapi")],
|
23 |
-
[Button.inline("« Back", data="setter")],
|
24 |
-
],
|
25 |
-
)
|
26 |
-
|
27 |
-
|
28 |
-
@callback("rmbg", owner=True)
|
29 |
-
async def rmbgapi(event: events.CallbackQuery):
|
30 |
-
await event.delete()
|
31 |
-
pru = event.sender_id
|
32 |
-
var = "RMBG_API"
|
33 |
-
name = "Remove.bg API Key"
|
34 |
-
async with event.client.conversation(pru) as conv:
|
35 |
-
await conv.send_message(get_string("ast_2"))
|
36 |
-
response = conv.wait_event(events.NewMessage(chats=pru))
|
37 |
-
response = await response
|
38 |
-
themssg = response.message.message
|
39 |
-
if themssg == "/cancel":
|
40 |
-
return await conv.send_message(
|
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", owner=True)
|
52 |
-
async def rmbgapi(event: events.CallbackQuery):
|
53 |
-
await event.delete()
|
54 |
-
pru = event.sender_id
|
55 |
-
var = "DEEP_API"
|
56 |
-
name = "DEEP AI API Key"
|
57 |
-
async with event.client.conversation(pru) as conv:
|
58 |
-
await conv.send_message("Get Your Deep Api from deepai.org and send here.")
|
59 |
-
response = conv.wait_event(events.NewMessage(chats=pru))
|
60 |
-
response = await response
|
61 |
-
themssg = response.message.message
|
62 |
-
if themssg == "/cancel":
|
63 |
-
return await conv.send_message(
|
64 |
-
"Cancelled!!",
|
65 |
-
buttons=get_back_button("apiset"),
|
66 |
-
)
|
67 |
-
await setit(event, var, themssg)
|
68 |
-
await conv.send_message(
|
69 |
-
f"{name} changed to {themssg}",
|
70 |
-
buttons=get_back_button("apiset"),
|
71 |
-
)
|
72 |
-
|
73 |
-
|
74 |
-
@callback("oapi", owner=True)
|
75 |
-
async def rmbgapi(event: events.CallbackQuery):
|
76 |
-
await event.delete()
|
77 |
-
pru = event.sender_id
|
78 |
-
var = "OCR_API"
|
79 |
-
name = "OCR API Key"
|
80 |
-
async with event.client.conversation(pru) as conv:
|
81 |
-
await conv.send_message("Get Your OCR api from ocr.space Send Send Here.")
|
82 |
-
response = conv.wait_event(events.NewMessage(chats=pru))
|
83 |
-
response = await response
|
84 |
-
themssg = response.message.message
|
85 |
-
if themssg == "/cancel":
|
86 |
-
return await conv.send_message(
|
87 |
-
"Cancelled!!",
|
88 |
-
buttons=get_back_button("apiset"),
|
89 |
-
)
|
90 |
-
await setit(event, var, themssg)
|
91 |
-
await conv.send_message(
|
92 |
-
f"{name} changed to {themssg}",
|
93 |
-
buttons=get_back_button("apiset"),
|
94 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assistant/callbackstuffs.py
CHANGED
@@ -1,32 +1,39 @@
|
|
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 |
import sys
|
|
|
10 |
from asyncio.exceptions import TimeoutError as AsyncTimeOut
|
11 |
from os import execl, remove
|
12 |
from random import choice
|
13 |
|
14 |
-
from
|
15 |
-
from pyUltroid.functions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
from pyUltroid.startup.loader import Loader
|
17 |
from telegraph import upload_file as upl
|
18 |
-
from telethon import events
|
19 |
from telethon.tl.types import MessageMediaWebPage
|
20 |
from telethon.utils import get_peer_id
|
21 |
|
22 |
-
try:
|
23 |
-
from carbonnow import Carbon
|
24 |
-
except ImportError:
|
25 |
-
Carbon = None
|
26 |
from . import *
|
27 |
|
28 |
# --------------------------------------------------------------------#
|
29 |
telegraph = telegraph_client()
|
|
|
30 |
# --------------------------------------------------------------------#
|
31 |
|
32 |
|
@@ -34,13 +41,198 @@ def text_to_url(event):
|
|
34 |
"""function to get media url (with|without) Webpage"""
|
35 |
if isinstance(event.media, MessageMediaWebPage):
|
36 |
webpage = event.media.webpage
|
37 |
-
if webpage and webpage.type in ["photo"]:
|
38 |
return webpage.display_url
|
39 |
return event.text
|
40 |
|
41 |
|
42 |
# --------------------------------------------------------------------#
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
TOKEN_FILE = "resources/auths/auth_token.txt"
|
46 |
|
@@ -52,33 +244,34 @@ TOKEN_FILE = "resources/auths/auth_token.txt"
|
|
52 |
owner=True,
|
53 |
)
|
54 |
async def send(eve):
|
55 |
-
name = (eve.data_match.group(1)).decode("UTF-8")
|
56 |
thumb = "resources/extras/inline.jpg"
|
57 |
await eve.answer("■ Sending ■")
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
plugin = f"vcbot/{plug_name}.py"
|
69 |
-
data = "vc_helper"
|
70 |
buttons = [
|
71 |
[
|
72 |
Button.inline(
|
73 |
"« Pᴀsᴛᴇ »",
|
74 |
-
data=
|
75 |
)
|
76 |
],
|
77 |
[
|
78 |
Button.inline("« Bᴀᴄᴋ", data=data),
|
79 |
],
|
80 |
]
|
81 |
-
|
|
|
|
|
|
|
82 |
|
83 |
|
84 |
heroku_api, app_name = Var.HEROKU_API, Var.HEROKU_APP_NAME
|
@@ -130,24 +323,28 @@ async def update(eve):
|
|
130 |
execl(sys.executable, sys.executable, "-m", "pyUltroid")
|
131 |
|
132 |
|
133 |
-
@callback("changes", owner=True)
|
134 |
async def changes(okk):
|
|
|
135 |
await okk.answer(get_string("clst_3"))
|
136 |
repo = Repo.init()
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
140 |
cli = "\n\nClick the below button to update!"
|
141 |
-
if
|
142 |
try:
|
|
|
|
|
|
|
143 |
await okk.edit("• Writing Changelogs 📝 •")
|
144 |
-
|
145 |
-
|
146 |
code=tl_chnglog,
|
147 |
-
|
148 |
language="md",
|
149 |
)
|
150 |
-
img = await carbon.memorize("changelog")
|
151 |
return await okk.edit(
|
152 |
f"**• Ultroid Userbot •**{cli}", file=img, buttons=button
|
153 |
)
|
@@ -162,7 +359,7 @@ async def changes(okk):
|
|
162 |
await okk.edit(
|
163 |
get_string("upd_5"),
|
164 |
file="ultroid_updates.txt",
|
165 |
-
buttons=
|
166 |
)
|
167 |
remove("ultroid_updates.txt")
|
168 |
return
|
@@ -181,39 +378,83 @@ async def changes(okk):
|
|
181 |
)
|
182 |
async def _(e):
|
183 |
ok = (e.data_match.group(1)).decode("UTF-8")
|
|
|
|
|
|
|
184 |
with open(ok, "r") as hmm:
|
185 |
_, key = await get_paste(hmm.read())
|
186 |
link = "https://spaceb.in/" + key
|
187 |
raw = f"https://spaceb.in/api/v1/documents/{key}/raw"
|
188 |
if not _:
|
189 |
return await e.answer(key[:30], alert=True)
|
190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
await e.edit(
|
192 |
-
|
193 |
-
buttons=
|
194 |
-
|
195 |
-
|
|
|
196 |
)
|
197 |
|
198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
@callback("authorise", owner=True)
|
200 |
async def _(e):
|
201 |
if not e.is_private:
|
202 |
return
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
)
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
buttons=Button.inline("Main Menu", data="setter"),
|
216 |
-
)
|
217 |
|
218 |
|
219 |
@callback("folderid", owner=True, func=lambda x: x.is_private)
|
@@ -226,47 +467,17 @@ async def _(e):
|
|
226 |
+ "1. Open Google Drive App.\n"
|
227 |
+ "2. Create Folder.\n"
|
228 |
+ "3. Make that folder public.\n"
|
229 |
-
+ "4.
|
230 |
-
+ "5. Send all characters which is after id= .",
|
231 |
)
|
232 |
async with asst.conversation(e.sender_id) as conv:
|
233 |
reply = conv.wait_event(events.NewMessage(from_users=e.sender_id))
|
234 |
repl = await reply
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
)
|
240 |
-
|
241 |
-
|
242 |
-
@callback("clientsec", owner=True)
|
243 |
-
async def _(e):
|
244 |
-
if not e.is_private:
|
245 |
-
return
|
246 |
-
await e.edit("Send your CLIENT SECRET")
|
247 |
-
async with asst.conversation(e.sender_id) as conv:
|
248 |
-
reply = conv.wait_event(events.NewMessage(from_users=e.sender_id))
|
249 |
-
repl = await reply
|
250 |
-
udB.set("GDRIVE_CLIENT_SECRET", repl.text)
|
251 |
await repl.reply(
|
252 |
-
"Success
|
253 |
-
buttons=get_back_button("gdrive"),
|
254 |
-
)
|
255 |
-
|
256 |
-
|
257 |
-
@callback("clientid", owner=True)
|
258 |
-
async def _(e):
|
259 |
-
if not e.is_private:
|
260 |
-
return
|
261 |
-
await e.edit("Send your CLIENT ID ending with .com")
|
262 |
-
async with asst.conversation(e.sender_id) as conv:
|
263 |
-
reply = conv.wait_event(events.NewMessage(from_users=e.sender_id))
|
264 |
-
repl = await reply
|
265 |
-
if not repl.text.endswith(".com"):
|
266 |
-
return await repl.reply("`Wrong CLIENT ID`")
|
267 |
-
udB.set("GDRIVE_CLIENT_ID", repl.text)
|
268 |
-
await repl.reply(
|
269 |
-
"Success now set CLIENT SECRET",
|
270 |
buttons=get_back_button("gdrive"),
|
271 |
)
|
272 |
|
@@ -276,77 +487,28 @@ async def _(e):
|
|
276 |
if not e.is_private:
|
277 |
return
|
278 |
await e.edit(
|
279 |
-
"
|
280 |
buttons=[
|
281 |
[
|
282 |
-
Button.inline("
|
283 |
-
Button.inline("
|
284 |
],
|
285 |
-
[
|
286 |
-
Button.inline("Fᴏʟᴅᴇʀ Iᴅ", data="folderid"),
|
287 |
-
Button.inline("Aᴜᴛʜᴏʀɪsᴇ", data="authorise"),
|
288 |
-
],
|
289 |
-
[Button.inline("« Bᴀᴄᴋ", data="otvars")],
|
290 |
],
|
291 |
link_preview=False,
|
292 |
)
|
293 |
|
294 |
|
295 |
-
@callback("otvars", owner=True)
|
296 |
-
async def otvaar(event):
|
297 |
-
await event.edit(
|
298 |
-
"Other Variables to set for @TheUltroid:",
|
299 |
-
buttons=[
|
300 |
-
[
|
301 |
-
Button.inline("Tᴀɢ Lᴏɢɢᴇʀ", data="taglog"),
|
302 |
-
Button.inline("SᴜᴘᴇʀFʙᴀɴ", data="sfban"),
|
303 |
-
],
|
304 |
-
[
|
305 |
-
Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ", data="sudo"),
|
306 |
-
Button.inline("Hᴀɴᴅʟᴇʀ", data="hhndlr"),
|
307 |
-
],
|
308 |
-
[
|
309 |
-
Button.inline("Exᴛʀᴀ Pʟᴜɢɪɴs", data="plg"),
|
310 |
-
Button.inline("Aᴅᴅᴏɴs", data="eaddon"),
|
311 |
-
],
|
312 |
-
[
|
313 |
-
Button.inline("Eᴍᴏᴊɪ ɪɴ Hᴇʟᴘ", data="emoj"),
|
314 |
-
Button.inline("Sᴇᴛ ɢDʀɪᴠᴇ", data="gdrive"),
|
315 |
-
],
|
316 |
-
[
|
317 |
-
Button.inline("Iɴʟɪɴᴇ Pɪᴄ", data="inli_pic"),
|
318 |
-
Button.inline("Sᴜᴅᴏ HNDLR", data="shndlr"),
|
319 |
-
],
|
320 |
-
[Button.inline("Dᴜᴀʟ Mᴏᴅᴇ", "oofdm")],
|
321 |
-
[Button.inline("« Bᴀᴄᴋ", data="setter")],
|
322 |
-
],
|
323 |
-
)
|
324 |
-
|
325 |
-
|
326 |
-
@callback("oofdm", owner=True)
|
327 |
-
async def euwhe(event):
|
328 |
-
BT = [
|
329 |
-
[Button.inline("Dᴜᴀʟ Mᴏᴅᴇ Oɴ", "dmof")],
|
330 |
-
[Button.inline("Dᴜᴀʟ Mᴏᴅᴇ Oғғ", "dmof")],
|
331 |
-
[Button.inline("Dᴜᴀʟ Mᴏᴅᴇ Hɴᴅʟʀ", "dmhn")],
|
332 |
-
]
|
333 |
-
await event.edit(
|
334 |
-
"About [Dual Mode](https://t.me/UltroidUpdates/18)",
|
335 |
-
buttons=BT,
|
336 |
-
link_preview=False,
|
337 |
-
)
|
338 |
-
|
339 |
-
|
340 |
@callback("dmof", owner=True)
|
341 |
async def rhwhe(e):
|
342 |
-
if udB.
|
343 |
-
udB.
|
344 |
key = "Off"
|
345 |
else:
|
346 |
-
udB.
|
347 |
key = "On"
|
348 |
Msg = "Dual Mode : " + key
|
349 |
-
await e.edit(Msg, buttons=get_back_button("
|
350 |
|
351 |
|
352 |
@callback("dmhn", owner=True)
|
@@ -355,7 +517,7 @@ async def hndlrr(event):
|
|
355 |
pru = event.sender_id
|
356 |
var = "DUAL_HNDLR"
|
357 |
name = "Dual Handler"
|
358 |
-
CH = udB.
|
359 |
async with event.client.conversation(pru) as conv:
|
360 |
await conv.send_message(
|
361 |
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.",
|
@@ -366,18 +528,18 @@ async def hndlrr(event):
|
|
366 |
if themssg == "/cancel":
|
367 |
await conv.send_message(
|
368 |
"Cancelled!!",
|
369 |
-
buttons=get_back_button("
|
370 |
)
|
371 |
elif len(themssg) > 1:
|
372 |
await conv.send_message(
|
373 |
"Incorrect Handler",
|
374 |
-
buttons=get_back_button("
|
375 |
)
|
376 |
else:
|
377 |
await setit(event, var, themssg)
|
378 |
await conv.send_message(
|
379 |
f"{name} changed to {themssg}",
|
380 |
-
buttons=get_back_button("
|
381 |
)
|
382 |
|
383 |
|
@@ -395,18 +557,18 @@ async def emoji(event):
|
|
395 |
if themssg == "/cancel":
|
396 |
await conv.send_message(
|
397 |
"Cancelled!!",
|
398 |
-
buttons=get_back_button("
|
399 |
)
|
400 |
elif themssg.startswith(("/", HNDLR)):
|
401 |
await conv.send_message(
|
402 |
"Incorrect Emoji",
|
403 |
-
buttons=get_back_button("
|
404 |
)
|
405 |
else:
|
406 |
await setit(event, var, themssg)
|
407 |
await conv.send_message(
|
408 |
f"{name} changed to {themssg}\n",
|
409 |
-
buttons=get_back_button("
|
410 |
)
|
411 |
|
412 |
|
@@ -426,12 +588,12 @@ async def pluginch(event):
|
|
426 |
if themssg == "/cancel":
|
427 |
await conv.send_message(
|
428 |
"Cancelled!!",
|
429 |
-
buttons=get_back_button("
|
430 |
)
|
431 |
elif themssg.startswith(("/", HNDLR)):
|
432 |
await conv.send_message(
|
433 |
"Incorrect channel",
|
434 |
-
buttons=get_back_button("
|
435 |
)
|
436 |
else:
|
437 |
await setit(event, var, themssg)
|
@@ -440,7 +602,7 @@ async def pluginch(event):
|
|
440 |
name,
|
441 |
themssg,
|
442 |
),
|
443 |
-
buttons=get_back_button("
|
444 |
)
|
445 |
|
446 |
|
@@ -460,23 +622,23 @@ async def hndlrr(event):
|
|
460 |
if themssg == "/cancel":
|
461 |
await conv.send_message(
|
462 |
"Cancelled!!",
|
463 |
-
buttons=get_back_button("
|
464 |
)
|
465 |
elif len(themssg) > 1:
|
466 |
await conv.send_message(
|
467 |
"Incorrect Handler",
|
468 |
-
buttons=get_back_button("
|
469 |
)
|
470 |
elif themssg.startswith(("/", "#", "@")):
|
471 |
await conv.send_message(
|
472 |
"This cannot be used as handler",
|
473 |
-
buttons=get_back_button("
|
474 |
)
|
475 |
else:
|
476 |
await setit(event, var, themssg)
|
477 |
await conv.send_message(
|
478 |
f"{name} changed to {themssg}",
|
479 |
-
buttons=get_back_button("
|
480 |
)
|
481 |
|
482 |
|
@@ -497,72 +659,48 @@ async def hndlrr(event):
|
|
497 |
if themssg == "/cancel":
|
498 |
await conv.send_message(
|
499 |
"Cancelled!!",
|
500 |
-
buttons=get_back_button("
|
501 |
)
|
502 |
elif len(themssg) > 1:
|
503 |
await conv.send_message(
|
504 |
"Incorrect Handler",
|
505 |
-
buttons=get_back_button("
|
506 |
)
|
507 |
elif themssg.startswith(("/", "#", "@")):
|
508 |
await conv.send_message(
|
509 |
"This cannot be used as handler",
|
510 |
-
buttons=get_back_button("
|
511 |
)
|
512 |
else:
|
513 |
await setit(event, var, themssg)
|
514 |
await conv.send_message(
|
515 |
f"{name} changed to {themssg}",
|
516 |
-
buttons=get_back_button("
|
517 |
)
|
518 |
|
519 |
|
520 |
@callback("taglog", owner=True)
|
521 |
async def tagloggrr(e):
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
|
|
526 |
await e.edit(
|
527 |
"Choose Options",
|
528 |
-
buttons=
|
529 |
)
|
530 |
|
531 |
|
532 |
@callback("deltag", owner=True)
|
533 |
async def _(e):
|
534 |
-
udB.
|
535 |
-
await e.answer("Done!!!
|
536 |
-
|
537 |
-
|
538 |
-
@callback("settag", owner=True)
|
539 |
-
async def taglogerr(event):
|
540 |
-
await event.delete()
|
541 |
-
pru = event.sender_id
|
542 |
-
var = "TAG_LOG"
|
543 |
-
name = "Tag Log Group"
|
544 |
-
async with event.client.conversation(pru) as conv:
|
545 |
-
await conv.send_message(
|
546 |
-
f"Make a group, add your assistant and make it admin.\nGet the `{HNDLR}id` of that group and send it here for tag logs.\n\nUse /cancel to cancel.",
|
547 |
-
)
|
548 |
-
response = conv.wait_event(events.NewMessage(chats=pru))
|
549 |
-
response = await response
|
550 |
-
themssg = response.message.message
|
551 |
-
if themssg == "/cancel":
|
552 |
-
return await conv.send_message(
|
553 |
-
"Cancelled!!",
|
554 |
-
buttons=get_back_button("taglog"),
|
555 |
-
)
|
556 |
-
await setit(event, var, themssg)
|
557 |
-
await conv.send_message(
|
558 |
-
f"{name} changed to {themssg}",
|
559 |
-
buttons=get_back_button("taglog"),
|
560 |
-
)
|
561 |
|
562 |
|
563 |
@callback("eaddon", owner=True)
|
564 |
async def pmset(event):
|
565 |
-
if not udB.
|
566 |
BT = [Button.inline("Aᴅᴅᴏɴs Oɴ", data="edon")]
|
567 |
else:
|
568 |
BT = [Button.inline("Aᴅᴅᴏɴs Oғғ", data="edof")]
|
@@ -570,7 +708,7 @@ async def pmset(event):
|
|
570 |
"ADDONS~ Extra Plugins:",
|
571 |
buttons=[
|
572 |
BT,
|
573 |
-
[Button.inline("« Bᴀᴄᴋ", data="
|
574 |
],
|
575 |
)
|
576 |
|
@@ -587,7 +725,7 @@ async def eddon(event):
|
|
587 |
|
588 |
@callback("edof", owner=True)
|
589 |
async def eddof(event):
|
590 |
-
udB.
|
591 |
await event.edit(
|
592 |
"Done! ADDONS has been turned off!! After Setting All Things Do Restart",
|
593 |
buttons=get_back_button("eaddon"),
|
@@ -596,7 +734,7 @@ async def eddof(event):
|
|
596 |
|
597 |
@callback("sudo", owner=True)
|
598 |
async def pmset(event):
|
599 |
-
if not udB.
|
600 |
BT = [Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ Oɴ", data="onsudo")]
|
601 |
else:
|
602 |
BT = [Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ Oғғ", data="ofsudo")]
|
@@ -604,7 +742,7 @@ async def pmset(event):
|
|
604 |
f"SUDO MODE ~ Some peoples can use ur Bot which u selected. To know More use `{HNDLR}help sudo`",
|
605 |
buttons=[
|
606 |
BT,
|
607 |
-
[Button.inline("« Bᴀᴄᴋ", data="
|
608 |
],
|
609 |
)
|
610 |
|
@@ -629,18 +767,6 @@ async def eddof(event):
|
|
629 |
)
|
630 |
|
631 |
|
632 |
-
@callback("sfban", owner=True)
|
633 |
-
async def sfban(event):
|
634 |
-
await event.edit(
|
635 |
-
"SuperFban Settings:",
|
636 |
-
buttons=[
|
637 |
-
[Button.inline("FBᴀɴ Gʀᴏᴜᴘ", data="sfgrp")],
|
638 |
-
[Button.inline("Exᴄʟᴜᴅᴇ Fᴇᴅs", data="sfexf")],
|
639 |
-
[Button.inline("« Bᴀᴄᴋ", data="otvars")],
|
640 |
-
],
|
641 |
-
)
|
642 |
-
|
643 |
-
|
644 |
@callback("sfgrp", owner=True)
|
645 |
async def sfgrp(event):
|
646 |
await event.delete()
|
@@ -657,79 +783,12 @@ async def sfgrp(event):
|
|
657 |
if themssg == "/cancel":
|
658 |
return await conv.send_message(
|
659 |
"Cancelled!!",
|
660 |
-
buttons=get_back_button("
|
661 |
)
|
662 |
await setit(event, var, themssg)
|
663 |
await conv.send_message(
|
664 |
f"{name} changed to {themssg}",
|
665 |
-
buttons=get_back_button("
|
666 |
-
)
|
667 |
-
|
668 |
-
|
669 |
-
@callback("sfexf", owner=True)
|
670 |
-
async def sfexf(event):
|
671 |
-
await event.delete()
|
672 |
-
name = "Excluded Feds"
|
673 |
-
var = "EXCLUDE_FED"
|
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
|
683 |
-
if themssg == "/cancel":
|
684 |
-
return await conv.send_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", owner=True)
|
696 |
-
async def alvcs(event):
|
697 |
-
await event.edit(
|
698 |
-
f"Customise your {HNDLR}alive. Choose from the below options -",
|
699 |
-
buttons=[
|
700 |
-
[Button.inline("Aʟɪᴠᴇ Tᴇxᴛ", data="alvtx")],
|
701 |
-
[Button.inline("Aʟɪᴠᴇ ᴍᴇᴅɪᴀ", data="alvmed")],
|
702 |
-
[Button.inline("Dᴇʟᴇᴛᴇ Aʟɪᴠᴇ Mᴇᴅɪᴀ", data="delmed")],
|
703 |
-
[Button.inline("« Bᴀᴄᴋ", data="setter")],
|
704 |
-
],
|
705 |
-
)
|
706 |
-
|
707 |
-
|
708 |
-
@callback("alvtx", owner=True)
|
709 |
-
async def name(event):
|
710 |
-
await event.delete()
|
711 |
-
pru = event.sender_id
|
712 |
-
var = "ALIVE_TEXT"
|
713 |
-
name = "Alive Text"
|
714 |
-
async with event.client.conversation(pru) as conv:
|
715 |
-
await conv.send_message(
|
716 |
-
"**Alive Text**\nEnter the new alive text.\n\nUse /cancel to terminate the operation.",
|
717 |
-
)
|
718 |
-
response = conv.wait_event(events.NewMessage(chats=pru))
|
719 |
-
response = await response
|
720 |
-
themssg = response.message.message
|
721 |
-
if themssg == "/cancel":
|
722 |
-
return await conv.send_message(
|
723 |
-
"Cancelled!!",
|
724 |
-
buttons=get_back_button("alvcstm"),
|
725 |
-
)
|
726 |
-
await setit(event, var, themssg)
|
727 |
-
await conv.send_message(
|
728 |
-
"{} changed to {}\n\nAfter Setting All Things Do restart".format(
|
729 |
-
name,
|
730 |
-
themssg,
|
731 |
-
),
|
732 |
-
buttons=get_back_button("alvcstm"),
|
733 |
)
|
734 |
|
735 |
|
@@ -749,7 +808,7 @@ async def media(event):
|
|
749 |
if themssg == "/cancel":
|
750 |
return await conv.send_message(
|
751 |
"Operation cancelled!!",
|
752 |
-
buttons=get_back_button("
|
753 |
)
|
754 |
except BaseException:
|
755 |
pass
|
@@ -770,71 +829,36 @@ async def media(event):
|
|
770 |
except BaseException:
|
771 |
return await conv.send_message(
|
772 |
"Terminated.",
|
773 |
-
buttons=get_back_button("
|
774 |
)
|
775 |
await setit(event, var, url)
|
776 |
await conv.send_message(
|
777 |
f"{name} has been set.",
|
778 |
-
buttons=get_back_button("
|
779 |
)
|
780 |
|
781 |
|
782 |
@callback("delmed", owner=True)
|
783 |
async def dell(event):
|
784 |
try:
|
785 |
-
udB.
|
786 |
return await event.edit(
|
787 |
-
get_string("clst_5"), buttons=get_back_button("
|
788 |
)
|
789 |
except BaseException:
|
790 |
return await event.edit(
|
791 |
get_string("clst_4"),
|
792 |
-
buttons=get_back_button("
|
793 |
)
|
794 |
|
795 |
|
796 |
-
@callback("pmcstm", owner=True)
|
797 |
-
async def alvcs(event):
|
798 |
-
await event.edit(
|
799 |
-
"Customise your PMPERMIT Settings -",
|
800 |
-
buttons=[
|
801 |
-
[
|
802 |
-
Button.inline("Pᴍ Tᴇxᴛ", data="pmtxt"),
|
803 |
-
Button.inline("Pᴍ Mᴇᴅɪᴀ", data="pmmed"),
|
804 |
-
],
|
805 |
-
[
|
806 |
-
Button.inline("Aᴜᴛᴏ Aᴘᴘʀᴏᴠᴇ", data="apauto"),
|
807 |
-
Button.inline("PMLOGGER", data="pml"),
|
808 |
-
],
|
809 |
-
[
|
810 |
-
Button.inline("Sᴇᴛ Wᴀʀɴs", data="swarn"),
|
811 |
-
Button.inline("Dᴇʟᴇᴛᴇ Pᴍ Mᴇᴅɪᴀ", data="delpmmed"),
|
812 |
-
],
|
813 |
-
[Button.inline("PMPermit Type", data="pmtype")],
|
814 |
-
[Button.inline("« Bᴀᴄᴋ", data="ppmset")],
|
815 |
-
],
|
816 |
-
)
|
817 |
-
|
818 |
-
|
819 |
-
@callback("pmtype", owner=True)
|
820 |
-
async def pmtyp(event):
|
821 |
-
await event.edit(
|
822 |
-
"Select the type of PMPermit needed.",
|
823 |
-
buttons=[
|
824 |
-
[Button.inline("Inline", data="inpm_in")],
|
825 |
-
[Button.inline("Normal", data="inpm_no")],
|
826 |
-
[Button.inline("« Bᴀᴄᴋ", data="pmcstm")],
|
827 |
-
],
|
828 |
-
)
|
829 |
-
|
830 |
-
|
831 |
@callback("inpm_in", owner=True)
|
832 |
async def inl_on(event):
|
833 |
var = "INLINE_PM"
|
834 |
await setit(event, var, "True")
|
835 |
await event.edit(
|
836 |
"Done!! PMPermit type has been set to inline!",
|
837 |
-
buttons=[[Button.inline("« Bᴀᴄᴋ", data="
|
838 |
)
|
839 |
|
840 |
|
@@ -844,7 +868,7 @@ async def inl_on(event):
|
|
844 |
await setit(event, var, "False")
|
845 |
await event.edit(
|
846 |
"Done!! PMPermit type has been set to normal!",
|
847 |
-
buttons=[[Button.inline("« Bᴀᴄᴋ", data="
|
848 |
)
|
849 |
|
850 |
|
@@ -864,12 +888,12 @@ async def name(event):
|
|
864 |
if themssg == "/cancel":
|
865 |
return await conv.send_message(
|
866 |
"Cancelled!!",
|
867 |
-
buttons=get_back_button("
|
868 |
)
|
869 |
if len(themssg) > 4090:
|
870 |
return await conv.send_message(
|
871 |
"Message too long!\nGive a shorter message please!!",
|
872 |
-
buttons=get_back_button("
|
873 |
)
|
874 |
await setit(event, var, themssg)
|
875 |
await conv.send_message(
|
@@ -877,7 +901,7 @@ async def name(event):
|
|
877 |
name,
|
878 |
themssg,
|
879 |
),
|
880 |
-
buttons=get_back_button("
|
881 |
)
|
882 |
|
883 |
|
@@ -886,7 +910,7 @@ async def name(event):
|
|
886 |
m = range(1, 10)
|
887 |
tultd = [Button.inline(f"{x}", data=f"wrns_{x}") for x in m]
|
888 |
lst = list(zip(tultd[::3], tultd[1::3], tultd[2::3]))
|
889 |
-
lst.append([Button.inline("« Bᴀᴄᴋ", data="
|
890 |
await event.edit(
|
891 |
"Select the number of warnings for a user before getting blocked in PMs.",
|
892 |
buttons=lst,
|
@@ -896,16 +920,16 @@ async def name(event):
|
|
896 |
@callback(re.compile(b"wrns_(.*)"), owner=True)
|
897 |
async def set_wrns(event):
|
898 |
value = int(event.data_match.group(1).decode("UTF-8"))
|
899 |
-
dn = udB.
|
900 |
if dn:
|
901 |
await event.edit(
|
902 |
f"PM Warns Set to {value}.\nNew users will have {value} chances in PMs before getting banned.",
|
903 |
-
buttons=get_back_button("
|
904 |
)
|
905 |
else:
|
906 |
await event.edit(
|
907 |
f"Something went wrong, please check your {HNDLR}logs!",
|
908 |
-
buttons=get_back_button("
|
909 |
)
|
910 |
|
911 |
|
@@ -925,7 +949,7 @@ async def media(event):
|
|
925 |
if themssg == "/cancel":
|
926 |
return await conv.send_message(
|
927 |
"Operation cancelled!!",
|
928 |
-
buttons=get_back_button("
|
929 |
)
|
930 |
except BaseException:
|
931 |
pass
|
@@ -946,20 +970,22 @@ async def media(event):
|
|
946 |
except BaseException:
|
947 |
return await conv.send_message(
|
948 |
"Terminated.",
|
949 |
-
buttons=get_back_button("
|
950 |
)
|
951 |
await setit(event, var, url)
|
952 |
await conv.send_message(
|
953 |
f"{name} has been set.",
|
954 |
-
buttons=get_back_button("
|
955 |
)
|
956 |
|
957 |
|
958 |
@callback("delpmmed", owner=True)
|
959 |
async def dell(event):
|
960 |
try:
|
961 |
-
udB.
|
962 |
-
return await event.edit(
|
|
|
|
|
963 |
except BaseException:
|
964 |
return await event.edit(
|
965 |
get_string("clst_4"),
|
@@ -967,35 +993,23 @@ async def dell(event):
|
|
967 |
)
|
968 |
|
969 |
|
970 |
-
@callback("apauto", owner=True)
|
971 |
-
async def apauto(event):
|
972 |
-
await event.edit(
|
973 |
-
"This'll auto approve on outgoing messages",
|
974 |
-
buttons=[
|
975 |
-
[Button.inline("Aᴜᴛᴏ Aᴘᴘʀᴏᴠᴇ ON", data="apon")],
|
976 |
-
[Button.inline("Aᴜᴛᴏ Aᴘᴘʀᴏᴠᴇ OFF", data="apof")],
|
977 |
-
[Button.inline("« Bᴀᴄᴋ", data="pmcstm")],
|
978 |
-
],
|
979 |
-
)
|
980 |
-
|
981 |
-
|
982 |
@callback("apon", owner=True)
|
983 |
async def apon(event):
|
984 |
var = "AUTOAPPROVE"
|
985 |
await setit(event, var, "True")
|
986 |
await event.edit(
|
987 |
"Done!! AUTOAPPROVE Started!!",
|
988 |
-
buttons=[[Button.inline("« Bᴀᴄᴋ", data="
|
989 |
)
|
990 |
|
991 |
|
992 |
@callback("apof", owner=True)
|
993 |
async def apof(event):
|
994 |
try:
|
995 |
-
udB.
|
996 |
return await event.edit(
|
997 |
"Done! AUTOAPPROVE Stopped!!",
|
998 |
-
buttons=[[Button.inline("« Bᴀᴄᴋ", data="
|
999 |
)
|
1000 |
except BaseException:
|
1001 |
return await event.edit(
|
@@ -1005,8 +1019,8 @@ async def apof(event):
|
|
1005 |
|
1006 |
|
1007 |
@callback("pml", owner=True)
|
1008 |
-
async def
|
1009 |
-
if not udB.
|
1010 |
BT = [Button.inline("PMLOGGER ON", data="pmlog")]
|
1011 |
else:
|
1012 |
BT = [Button.inline("PMLOGGER OFF", data="pmlogof")]
|
@@ -1014,38 +1028,12 @@ async def alvcs(event):
|
|
1014 |
"PMLOGGER This Will Forward Ur Pm to Ur Private Group -",
|
1015 |
buttons=[
|
1016 |
BT,
|
1017 |
-
[Button.inline("PᴍLᴏɢɢᴇʀ Gʀᴏᴜᴘ", "
|
1018 |
-
[Button.inline("« Bᴀᴄᴋ", data="
|
1019 |
],
|
1020 |
)
|
1021 |
|
1022 |
|
1023 |
-
@callback("pmlgg", owner=True)
|
1024 |
-
async def disus(event):
|
1025 |
-
await event.delete()
|
1026 |
-
pru = event.sender_id
|
1027 |
-
var = "PMLOGGROUP"
|
1028 |
-
name = "Pm Logger Group"
|
1029 |
-
async with event.client.conversation(pru) as conv:
|
1030 |
-
await conv.send_message(
|
1031 |
-
f"Send The Chat Id of group Which u want as your {name}\n\n use /cancel to cancel.",
|
1032 |
-
)
|
1033 |
-
response = conv.wait_event(events.NewMessage(chats=pru))
|
1034 |
-
response = await response
|
1035 |
-
themssg = response.message.message
|
1036 |
-
if themssg == "/cancel":
|
1037 |
-
await conv.send_message(
|
1038 |
-
"Cancelled!!",
|
1039 |
-
buttons=get_back_button("pml"),
|
1040 |
-
)
|
1041 |
-
else:
|
1042 |
-
await setit(event, var, themssg)
|
1043 |
-
await conv.send_message(
|
1044 |
-
f"{name} changed to `{themssg}`",
|
1045 |
-
buttons=get_back_button("pml"),
|
1046 |
-
)
|
1047 |
-
|
1048 |
-
|
1049 |
@callback("pmlog", owner=True)
|
1050 |
async def pmlog(event):
|
1051 |
await setit(event, "PMLOG", "True")
|
@@ -1058,7 +1046,7 @@ async def pmlog(event):
|
|
1058 |
@callback("pmlogof", owner=True)
|
1059 |
async def pmlogof(event):
|
1060 |
try:
|
1061 |
-
udB.
|
1062 |
return await event.edit(
|
1063 |
"Done! PMLOGGER Stopped!!",
|
1064 |
buttons=[[Button.inline("« Bᴀᴄᴋ", data="pml")]],
|
@@ -1070,26 +1058,13 @@ async def pmlogof(event):
|
|
1070 |
)
|
1071 |
|
1072 |
|
1073 |
-
@callback("ppmset", owner=True)
|
1074 |
-
async def pmset(event):
|
1075 |
-
await event.edit(
|
1076 |
-
"PMPermit Settings:",
|
1077 |
-
buttons=[
|
1078 |
-
[Button.inline("Tᴜʀɴ PMPᴇʀᴍɪᴛ Oɴ", data="pmon")],
|
1079 |
-
[Button.inline("Tᴜʀɴ PMPᴇʀᴍɪᴛ Oғғ", data="pmoff")],
|
1080 |
-
[Button.inline("Cᴜsᴛᴏᴍɪᴢᴇ PMPᴇʀᴍɪᴛ", data="pmcstm")],
|
1081 |
-
[Button.inline("« Bᴀᴄᴋ", data="setter")],
|
1082 |
-
],
|
1083 |
-
)
|
1084 |
-
|
1085 |
-
|
1086 |
@callback("pmon", owner=True)
|
1087 |
async def pmonn(event):
|
1088 |
var = "PMSETTING"
|
1089 |
await setit(event, var, "True")
|
1090 |
await event.edit(
|
1091 |
"Done! PMPermit has been turned on!!",
|
1092 |
-
buttons=[[Button.inline("« Bᴀᴄᴋ", data="
|
1093 |
)
|
1094 |
|
1095 |
|
@@ -1099,7 +1074,7 @@ async def pmofff(event):
|
|
1099 |
await setit(event, var, "False")
|
1100 |
await event.edit(
|
1101 |
"Done! PMPermit has been turned off!!",
|
1102 |
-
buttons=[[Button.inline("« Bᴀᴄᴋ", data="
|
1103 |
)
|
1104 |
|
1105 |
|
@@ -1110,27 +1085,10 @@ async def hhh(e):
|
|
1110 |
msg = await conv.get_response()
|
1111 |
if not msg.media or msg.text.startswith("/"):
|
1112 |
return await conv.send_message(
|
1113 |
-
"Terminated!", buttons=get_back_button("
|
1114 |
)
|
1115 |
-
udB.
|
1116 |
-
await conv.send_message("Done!", buttons=get_back_button("
|
1117 |
-
|
1118 |
-
|
1119 |
-
@callback("chatbot", owner=True)
|
1120 |
-
async def chbot(event):
|
1121 |
-
await event.edit(
|
1122 |
-
"From This Feature U can chat with ppls Via ur Assistant Bot.\n[More info](https://t.me/UltroidUpdates/2)",
|
1123 |
-
buttons=[
|
1124 |
-
[Button.inline("Cʜᴀᴛ Bᴏᴛ Oɴ", data="onchbot")],
|
1125 |
-
[Button.inline("Cʜᴀᴛ Bᴏᴛ Oғғ", data="ofchbot")],
|
1126 |
-
[Button.inline("Bᴏᴛ Wᴇʟᴄᴏᴍᴇ", data="bwel")],
|
1127 |
-
[Button.inline("Bᴏᴛ Wᴇʟᴄᴏᴍᴇ Mᴇᴅɪᴀ", data="botmew")],
|
1128 |
-
[Button.inline("Bᴏᴛ Iɴғᴏ Tᴇxᴛ", data="botinfe")],
|
1129 |
-
[Button.inline("Fᴏʀᴄᴇ Sᴜʙsᴄʀɪʙᴇ", data="pmfs")],
|
1130 |
-
[Button.inline("« Bᴀᴄᴋ", data="setter")],
|
1131 |
-
],
|
1132 |
-
link_preview=False,
|
1133 |
-
)
|
1134 |
|
1135 |
|
1136 |
@callback("botinfe", owner=True)
|
@@ -1142,10 +1100,10 @@ async def hhh(e):
|
|
1142 |
msg = await conv.get_response()
|
1143 |
if msg.media or msg.text.startswith("/"):
|
1144 |
return await conv.send_message(
|
1145 |
-
"Terminated!", buttons=get_back_button("
|
1146 |
)
|
1147 |
-
udB.
|
1148 |
-
await conv.send_message("Done!", buttons=get_back_button("
|
1149 |
|
1150 |
|
1151 |
@callback("pmfs", owner=True)
|
@@ -1154,7 +1112,7 @@ async def heheh(event):
|
|
1154 |
err = ""
|
1155 |
async with event.client.conversation(event.chat_id) as conv:
|
1156 |
await conv.send_message(
|
1157 |
-
"• Send The Chat Id(s), which you want user to Join Before using Chat/Pm Bot"
|
1158 |
)
|
1159 |
await conv.send_message(
|
1160 |
"Example : \n`-1001234567\n-100778888`\n\nFor Multiple Chat(s)."
|
@@ -1162,10 +1120,14 @@ async def heheh(event):
|
|
1162 |
try:
|
1163 |
msg = await conv.get_response()
|
1164 |
except AsyncTimeOut:
|
1165 |
-
return await conv.send_message("TimeUp
|
1166 |
if not msg.text or msg.text.startswith("/"):
|
|
|
|
|
|
|
|
|
1167 |
return await conv.send_message(
|
1168 |
-
"Cancelled!", buttons=get_back_button("
|
1169 |
)
|
1170 |
for chat in msg.message.split("\n"):
|
1171 |
if chat.startswith("-") or chat.isdigit():
|
@@ -1177,9 +1139,9 @@ async def heheh(event):
|
|
1177 |
err += f"**{chat}** : {er}\n"
|
1178 |
if err:
|
1179 |
return await conv.send_message(err)
|
1180 |
-
udB.
|
1181 |
await conv.send_message(
|
1182 |
-
"Done!\nRestart Your Bot.", buttons=get_back_button("
|
1183 |
)
|
1184 |
|
1185 |
|
@@ -1199,7 +1161,7 @@ async def name(event):
|
|
1199 |
if themssg == "/cancel":
|
1200 |
return await conv.send_message(
|
1201 |
"Cancelled!!",
|
1202 |
-
buttons=get_back_button("
|
1203 |
)
|
1204 |
await setit(event, var, themssg)
|
1205 |
await conv.send_message(
|
@@ -1207,7 +1169,7 @@ async def name(event):
|
|
1207 |
name,
|
1208 |
themssg,
|
1209 |
),
|
1210 |
-
buttons=get_back_button("
|
1211 |
)
|
1212 |
|
1213 |
|
@@ -1223,7 +1185,7 @@ async def chon(event):
|
|
1223 |
event.client.add_event_handler(i, events.NewMessage(**e))
|
1224 |
await event.edit(
|
1225 |
"Done! Now u Can Chat With People Via This Bot",
|
1226 |
-
buttons=[Button.inline("« Bᴀᴄᴋ", data="
|
1227 |
)
|
1228 |
|
1229 |
|
@@ -1236,50 +1198,10 @@ async def chon(event):
|
|
1236 |
event.client.remove_event_handler(i)
|
1237 |
await event.edit(
|
1238 |
"Done! Chat People Via This Bot Stopped.",
|
1239 |
-
buttons=[Button.inline("« Bᴀᴄᴋ", data="
|
1240 |
)
|
1241 |
|
1242 |
|
1243 |
-
@callback("vcb", owner=True)
|
1244 |
-
async def vcb(event):
|
1245 |
-
await event.edit(
|
1246 |
-
"From This Feature U can play songs in group voice chat\n\n[moreinfo](https://t.me/UltroidUpdates/4)",
|
1247 |
-
buttons=[
|
1248 |
-
[Button.inline("VC Sᴇssɪᴏɴ", data="vcs")],
|
1249 |
-
[Button.inline("« Bᴀᴄᴋ", data="setter")],
|
1250 |
-
],
|
1251 |
-
link_preview=False,
|
1252 |
-
)
|
1253 |
-
|
1254 |
-
|
1255 |
-
@callback("vcs", owner=True)
|
1256 |
-
async def name(event):
|
1257 |
-
await event.delete()
|
1258 |
-
pru = event.sender_id
|
1259 |
-
var = "VC_SESSION"
|
1260 |
-
name = "VC SESSION"
|
1261 |
-
async with event.client.conversation(pru) as conv:
|
1262 |
-
await conv.send_message(
|
1263 |
-
"**Vc session**\nEnter the New session u generated for vc bot.\n\nUse /cancel to terminate the operation.",
|
1264 |
-
)
|
1265 |
-
response = conv.wait_event(events.NewMessage(chats=pru))
|
1266 |
-
response = await response
|
1267 |
-
themssg = response.message.message
|
1268 |
-
if themssg == "/cancel":
|
1269 |
-
return await conv.send_message(
|
1270 |
-
"Cancelled!!",
|
1271 |
-
buttons=get_back_button("vcb"),
|
1272 |
-
)
|
1273 |
-
await setit(event, var, themssg)
|
1274 |
-
await conv.send_message(
|
1275 |
-
"{} changed to {}\n\nAfter Setting All Things Do restart".format(
|
1276 |
-
name,
|
1277 |
-
themssg,
|
1278 |
-
),
|
1279 |
-
buttons=get_back_button("vcb"),
|
1280 |
-
)
|
1281 |
-
|
1282 |
-
|
1283 |
@callback("inli_pic", owner=True)
|
1284 |
async def media(event):
|
1285 |
await event.delete()
|
@@ -1322,3 +1244,65 @@ async def media(event):
|
|
1322 |
f"{name} has been set.",
|
1323 |
buttons=get_back_button("setter"),
|
1324 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 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 asyncio
|
10 |
import re
|
11 |
import sys
|
12 |
+
import time
|
13 |
from asyncio.exceptions import TimeoutError as AsyncTimeOut
|
14 |
from os import execl, remove
|
15 |
from random import choice
|
16 |
|
17 |
+
from bs4 import BeautifulSoup as bs
|
18 |
+
from pyUltroid.functions.gDrive import GDriveManager
|
19 |
+
from pyUltroid.functions.helper import fast_download, progress, uploader
|
20 |
+
from pyUltroid.functions.tools import (
|
21 |
+
Carbon,
|
22 |
+
async_searcher,
|
23 |
+
get_paste,
|
24 |
+
telegraph_client,
|
25 |
+
)
|
26 |
from pyUltroid.startup.loader import Loader
|
27 |
from telegraph import upload_file as upl
|
28 |
+
from telethon import Button, events
|
29 |
from telethon.tl.types import MessageMediaWebPage
|
30 |
from telethon.utils import get_peer_id
|
31 |
|
|
|
|
|
|
|
|
|
32 |
from . import *
|
33 |
|
34 |
# --------------------------------------------------------------------#
|
35 |
telegraph = telegraph_client()
|
36 |
+
GDrive = GDriveManager()
|
37 |
# --------------------------------------------------------------------#
|
38 |
|
39 |
|
|
|
41 |
"""function to get media url (with|without) Webpage"""
|
42 |
if isinstance(event.media, MessageMediaWebPage):
|
43 |
webpage = event.media.webpage
|
44 |
+
if not isinstance(webpage, types.WebPageEmpty) and webpage.type in ["photo"]:
|
45 |
return webpage.display_url
|
46 |
return event.text
|
47 |
|
48 |
|
49 |
# --------------------------------------------------------------------#
|
50 |
|
51 |
+
_buttons = {
|
52 |
+
"otvars": {
|
53 |
+
"text": "Other Variables to set for @TheUltroid:",
|
54 |
+
"buttons": [
|
55 |
+
[
|
56 |
+
Button.inline("Tᴀɢ Lᴏɢɢᴇʀ", data="taglog"),
|
57 |
+
Button.inline("SᴜᴘᴇʀFʙᴀɴ", data="cbs_sfban"),
|
58 |
+
],
|
59 |
+
[
|
60 |
+
Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ", data="sudo"),
|
61 |
+
Button.inline("Hᴀɴᴅʟᴇʀ", data="hhndlr"),
|
62 |
+
],
|
63 |
+
[
|
64 |
+
Button.inline("Exᴛʀᴀ Pʟᴜɢɪɴs", data="plg"),
|
65 |
+
Button.inline("Aᴅᴅᴏɴs", data="eaddon"),
|
66 |
+
],
|
67 |
+
[
|
68 |
+
Button.inline("Eᴍᴏᴊɪ ɪɴ Hᴇʟᴘ", data="emoj"),
|
69 |
+
Button.inline("Sᴇᴛ ɢDʀɪᴠᴇ", data="gdrive"),
|
70 |
+
],
|
71 |
+
[
|
72 |
+
Button.inline("Iɴʟɪɴᴇ Pɪᴄ", data="inli_pic"),
|
73 |
+
Button.inline("Sᴜᴅᴏ HNDLR", data="shndlr"),
|
74 |
+
],
|
75 |
+
[Button.inline("Dᴜᴀʟ Mᴏᴅᴇ", "cbs_oofdm")],
|
76 |
+
[Button.inline("« Bᴀᴄᴋ", data="setter")],
|
77 |
+
],
|
78 |
+
},
|
79 |
+
"sfban": {
|
80 |
+
"text": "SuperFban Settings:",
|
81 |
+
"buttons": [
|
82 |
+
[Button.inline("FBᴀɴ Gʀᴏᴜᴘ", data="sfgrp")],
|
83 |
+
[Button.inline("Exᴄʟᴜᴅᴇ Fᴇᴅs", data="abs_sfexf")],
|
84 |
+
[Button.inline("« Bᴀᴄᴋ", data="cbs_otvars")],
|
85 |
+
],
|
86 |
+
},
|
87 |
+
"apauto": {
|
88 |
+
"text": "This'll auto approve on outgoing messages",
|
89 |
+
"buttons": [
|
90 |
+
[Button.inline("Aᴜᴛᴏ Aᴘᴘʀᴏᴠᴇ ON", data="apon")],
|
91 |
+
[Button.inline("Aᴜᴛᴏ Aᴘᴘʀᴏᴠᴇ OFF", data="apof")],
|
92 |
+
[Button.inline("« Bᴀᴄᴋ", data="cbs_pmcstm")],
|
93 |
+
],
|
94 |
+
},
|
95 |
+
"alabs_vcstm": {
|
96 |
+
"text": f"Customise your {HNDLR}alive. Choose from the below options -",
|
97 |
+
"buttons": [
|
98 |
+
[Button.inline("Aʟɪᴠᴇ Tᴇxᴛ", data="abs_alvtx")],
|
99 |
+
[Button.inline("Aʟɪᴠᴇ ᴍᴇᴅɪᴀ", data="alvmed")],
|
100 |
+
[Button.inline("Dᴇʟᴇᴛᴇ Aʟɪᴠᴇ Mᴇᴅɪᴀ", data="delmed")],
|
101 |
+
[Button.inline("« Bᴀᴄᴋ", data="setter")],
|
102 |
+
],
|
103 |
+
},
|
104 |
+
"pmcstm": {
|
105 |
+
"text": "Customise your PMPERMIT Settings -",
|
106 |
+
"buttons": [
|
107 |
+
[
|
108 |
+
Button.inline("Pᴍ Tᴇxᴛ", data="pmtxt"),
|
109 |
+
Button.inline("Pᴍ Mᴇᴅɪᴀ", data="pmmed"),
|
110 |
+
],
|
111 |
+
[
|
112 |
+
Button.inline("Aᴜᴛᴏ Aᴘᴘʀᴏᴠᴇ", data="cbs_apauto"),
|
113 |
+
Button.inline("PMLOGGER", data="pml"),
|
114 |
+
],
|
115 |
+
[
|
116 |
+
Button.inline("Sᴇᴛ Wᴀʀɴs", data="swarn"),
|
117 |
+
Button.inline("Dᴇʟᴇᴛᴇ Pᴍ Mᴇᴅɪᴀ", data="delpmmed"),
|
118 |
+
],
|
119 |
+
[Button.inline("PMPermit Type", data="cbs_pmtype")],
|
120 |
+
[Button.inline("« Bᴀᴄᴋ", data="cbs_ppmset")],
|
121 |
+
],
|
122 |
+
},
|
123 |
+
"pmtype": {
|
124 |
+
"text": "Select the type of PMPermit needed.",
|
125 |
+
"buttons": [
|
126 |
+
[Button.inline("Inline", data="inpm_in")],
|
127 |
+
[Button.inline("Normal", data="inpm_no")],
|
128 |
+
[Button.inline("« Bᴀᴄᴋ", data="cbs_pmcstm")],
|
129 |
+
],
|
130 |
+
},
|
131 |
+
"ppmset": {
|
132 |
+
"text": "PMPermit Settings:",
|
133 |
+
"buttons": [
|
134 |
+
[Button.inline("Tᴜʀɴ PMPᴇʀᴍɪᴛ Oɴ", data="pmon")],
|
135 |
+
[Button.inline("Tᴜʀɴ PMPᴇʀᴍɪᴛ Oғғ", data="pmoff")],
|
136 |
+
[Button.inline("Cᴜsᴛᴏᴍɪᴢᴇ PMPᴇʀᴍɪᴛ", data="cbs_pmcstm")],
|
137 |
+
[Button.inline("« Bᴀᴄᴋ", data="setter")],
|
138 |
+
],
|
139 |
+
},
|
140 |
+
"chatbot": {
|
141 |
+
"text": "From This Feature U can chat with ppls Via ur Assistant Bot.\n[More info](https://t.me/UltroidUpdates/2)",
|
142 |
+
"buttons": [
|
143 |
+
[
|
144 |
+
Button.inline("Cʜᴀᴛ Bᴏᴛ Oɴ", data="onchbot"),
|
145 |
+
Button.inline("Cʜᴀᴛ Bᴏᴛ Oғғ", data="ofchbot"),
|
146 |
+
],
|
147 |
+
[
|
148 |
+
Button.inline("Bᴏᴛ Wᴇʟᴄᴏᴍᴇ", data="bwel"),
|
149 |
+
Button.inline("Bᴏᴛ Wᴇʟᴄᴏᴍᴇ Mᴇᴅɪᴀ", data="botmew"),
|
150 |
+
],
|
151 |
+
[Button.inline("Bᴏᴛ Iɴғᴏ Tᴇxᴛ", data="botinfe")],
|
152 |
+
[Button.inline("Fᴏʀᴄᴇ Sᴜʙsᴄʀɪʙᴇ", data="pmfs")],
|
153 |
+
[Button.inline("« Bᴀᴄᴋ", data="setter")],
|
154 |
+
],
|
155 |
+
},
|
156 |
+
"vcb": {
|
157 |
+
"text": "From This Feature U can play songs in group voice chat\n\n[moreinfo](https://t.me/UltroidUpdates/4)",
|
158 |
+
"buttons": [
|
159 |
+
[Button.inline("VC Sᴇssɪᴏɴ", data="abs_vcs")],
|
160 |
+
[Button.inline("« Bᴀᴄᴋ", data="setter")],
|
161 |
+
],
|
162 |
+
},
|
163 |
+
"oofdm": {
|
164 |
+
"text": "About [Dual Mode](https://t.me/UltroidUpdates/18)",
|
165 |
+
"buttons": [
|
166 |
+
[
|
167 |
+
Button.inline("Dᴜᴀʟ Mᴏᴅᴇ Oɴ", "dmof"),
|
168 |
+
Button.inline("Dᴜᴀʟ Mᴏᴅᴇ Oғғ", "dmof"),
|
169 |
+
],
|
170 |
+
[Button.inline("Dᴜᴀʟ Mᴏᴅᴇ Hɴᴅʟʀ", "dmhn")],
|
171 |
+
[Button.inline("« Back", data="cbs_otvars")],
|
172 |
+
],
|
173 |
+
},
|
174 |
+
"apiset": {
|
175 |
+
"text": get_string("ast_1"),
|
176 |
+
"buttons": [
|
177 |
+
[Button.inline("Remove.bg API", data="abs_rmbg")],
|
178 |
+
[Button.inline("DEEP API", data="abs_dapi")],
|
179 |
+
[Button.inline("OCR API", data="abs_oapi")],
|
180 |
+
[Button.inline("« Back", data="setter")],
|
181 |
+
],
|
182 |
+
},
|
183 |
+
}
|
184 |
+
|
185 |
+
_convo = {
|
186 |
+
"rmbg": {
|
187 |
+
"var": "RMBG_API",
|
188 |
+
"name": "Remove.bg API Key",
|
189 |
+
"text": get_string("ast_2"),
|
190 |
+
"back": "cbs_apiset",
|
191 |
+
},
|
192 |
+
"dapi": {
|
193 |
+
"var": "DEEP_AI",
|
194 |
+
"name": "Deep AI Api Key",
|
195 |
+
"text": "Get Your Deep Api from deepai.org and send here.",
|
196 |
+
"back": "cbs_apiset",
|
197 |
+
},
|
198 |
+
"oapi": {
|
199 |
+
"var": "OCR_API",
|
200 |
+
"name": "Ocr Api Key",
|
201 |
+
"text": "Get Your OCR api from ocr.space and send that Here.",
|
202 |
+
"back": "cbs_apiset",
|
203 |
+
},
|
204 |
+
"pmlgg": {
|
205 |
+
"var": "PMLOGGROUP",
|
206 |
+
"name": "Pm Log Group",
|
207 |
+
"text": "Send chat id of chat which you want to save as Pm log Group.",
|
208 |
+
"back": "pml",
|
209 |
+
},
|
210 |
+
"vcs": {
|
211 |
+
"var": "VC_SESSION",
|
212 |
+
"name": "Vc Session",
|
213 |
+
"text": "**Vc session**\nEnter the New session u generated for vc bot.\n\nUse /cancel to terminate the operation.",
|
214 |
+
"back": "cbs_vcb",
|
215 |
+
},
|
216 |
+
"settag": {
|
217 |
+
"var": "TAG_LOG",
|
218 |
+
"name": "Tag Log Group",
|
219 |
+
"text": f"Make a group, add your assistant and make it admin.\nGet the `{HNDLR}id` of that group and send it here for tag logs.\n\nUse /cancel to cancel.",
|
220 |
+
"back": "taglog",
|
221 |
+
},
|
222 |
+
"alvtx": {
|
223 |
+
"var": "ALIVE_TEXT",
|
224 |
+
"name": "Alive Text",
|
225 |
+
"text": "**Alive Text**\nEnter the new alive text.\n\nUse /cancel to terminate the operation.",
|
226 |
+
"back": "cbs_alvcstm",
|
227 |
+
},
|
228 |
+
"sfexf": {
|
229 |
+
"var": "EXCLUDE_FED",
|
230 |
+
"name": "Excluded Fed",
|
231 |
+
"text": "Send the Fed IDs you want to exclude in the ban. Split by a space.\neg`id1 id2 id3`\nSet is as `None` if you dont want any.\nUse /cancel to go back.",
|
232 |
+
"back": "cbs_sfban",
|
233 |
+
},
|
234 |
+
}
|
235 |
+
|
236 |
|
237 |
TOKEN_FILE = "resources/auths/auth_token.txt"
|
238 |
|
|
|
244 |
owner=True,
|
245 |
)
|
246 |
async def send(eve):
|
247 |
+
key, name = (eve.data_match.group(1)).decode("UTF-8").split("_")
|
248 |
thumb = "resources/extras/inline.jpg"
|
249 |
await eve.answer("■ Sending ■")
|
250 |
+
data = f"uh_{key}_"
|
251 |
+
index = None
|
252 |
+
if "|" in name:
|
253 |
+
name, index = name.split("|")
|
254 |
+
key = "plugins" if key == "Official" else key.lower()
|
255 |
+
plugin = f"{key}/{name}.py"
|
256 |
+
_ = f"pasta-{plugin}"
|
257 |
+
if index is not None:
|
258 |
+
data += f"|{index}"
|
259 |
+
_ += f"|{index}"
|
|
|
|
|
260 |
buttons = [
|
261 |
[
|
262 |
Button.inline(
|
263 |
"« Pᴀsᴛᴇ »",
|
264 |
+
data=_,
|
265 |
)
|
266 |
],
|
267 |
[
|
268 |
Button.inline("« Bᴀᴄᴋ", data=data),
|
269 |
],
|
270 |
]
|
271 |
+
try:
|
272 |
+
await eve.edit(file=plugin, thumb=thumb, buttons=buttons)
|
273 |
+
except Exception as er:
|
274 |
+
await eve.answer(str(er), alert=True)
|
275 |
|
276 |
|
277 |
heroku_api, app_name = Var.HEROKU_API, Var.HEROKU_APP_NAME
|
|
|
323 |
execl(sys.executable, sys.executable, "-m", "pyUltroid")
|
324 |
|
325 |
|
326 |
+
@callback(re.compile("changes(.*)"), owner=True)
|
327 |
async def changes(okk):
|
328 |
+
match = okk.data_match.group(1).decode("utf-8")
|
329 |
await okk.answer(get_string("clst_3"))
|
330 |
repo = Repo.init()
|
331 |
+
button = [[Button.inline("Update Now", data="updatenow")]]
|
332 |
+
changelog, tl_chnglog = await gen_chlog(
|
333 |
+
repo, f"HEAD..upstream/{repo.active_branch}"
|
334 |
+
)
|
335 |
cli = "\n\nClick the below button to update!"
|
336 |
+
if not match:
|
337 |
try:
|
338 |
+
if len(tl_chnglog) > 700:
|
339 |
+
tl_chnglog = tl_chnglog[:700] + "..."
|
340 |
+
button.append([Button.inline("View Complete", "changesall")])
|
341 |
await okk.edit("• Writing Changelogs 📝 •")
|
342 |
+
img = await Carbon(
|
343 |
+
file_name="changelog",
|
344 |
code=tl_chnglog,
|
345 |
+
backgroundColor=choice(ATRA_COL),
|
346 |
language="md",
|
347 |
)
|
|
|
348 |
return await okk.edit(
|
349 |
f"**• Ultroid Userbot •**{cli}", file=img, buttons=button
|
350 |
)
|
|
|
359 |
await okk.edit(
|
360 |
get_string("upd_5"),
|
361 |
file="ultroid_updates.txt",
|
362 |
+
buttons=button,
|
363 |
)
|
364 |
remove("ultroid_updates.txt")
|
365 |
return
|
|
|
378 |
)
|
379 |
async def _(e):
|
380 |
ok = (e.data_match.group(1)).decode("UTF-8")
|
381 |
+
index = None
|
382 |
+
if "|" in ok:
|
383 |
+
ok, index = ok.split("|")
|
384 |
with open(ok, "r") as hmm:
|
385 |
_, key = await get_paste(hmm.read())
|
386 |
link = "https://spaceb.in/" + key
|
387 |
raw = f"https://spaceb.in/api/v1/documents/{key}/raw"
|
388 |
if not _:
|
389 |
return await e.answer(key[:30], alert=True)
|
390 |
+
if ok.startswith("addons"):
|
391 |
+
key = "Addons"
|
392 |
+
elif ok.startswith("vcbot"):
|
393 |
+
key = "VCBot"
|
394 |
+
else:
|
395 |
+
key = "Official"
|
396 |
+
data = f"uh_{key}_"
|
397 |
+
if index is not None:
|
398 |
+
data += f"|{index}"
|
399 |
await e.edit(
|
400 |
+
"",
|
401 |
+
buttons=[
|
402 |
+
[Button.url("Lɪɴᴋ", link), Button.url("Rᴀᴡ", raw)],
|
403 |
+
[Button.inline("« Bᴀᴄᴋ", data=data)],
|
404 |
+
],
|
405 |
)
|
406 |
|
407 |
|
408 |
+
@callback(re.compile("cbs_(.*)"), owner=True)
|
409 |
+
async def _edit_to(event):
|
410 |
+
match = event.data_match.group(1).decode("utf-8")
|
411 |
+
data = _buttons.get(match)
|
412 |
+
if not data:
|
413 |
+
return
|
414 |
+
await event.edit(data["text"], buttons=data["buttons"], link_preview=False)
|
415 |
+
|
416 |
+
|
417 |
+
@callback(re.compile("abs_(.*)"), owner=True)
|
418 |
+
async def convo_handler(event: events.CallbackQuery):
|
419 |
+
match = event.data_match.group(1).decode("utf-8")
|
420 |
+
if not _convo.get(match):
|
421 |
+
return
|
422 |
+
await event.delete()
|
423 |
+
get_ = _convo[match]
|
424 |
+
back = get_["back"]
|
425 |
+
async with event.client.conversation(event.sender_id) as conv:
|
426 |
+
await conv.send_message(get_["text"])
|
427 |
+
response = conv.wait_event(events.NewMessage(chats=event.sender_id))
|
428 |
+
response = await response
|
429 |
+
themssg = response.message.message
|
430 |
+
if themssg == "/cancel":
|
431 |
+
return await conv.send_message(
|
432 |
+
"Cancelled!!",
|
433 |
+
buttons=get_back_button(back),
|
434 |
+
)
|
435 |
+
await setit(event, get_["var"], themssg)
|
436 |
+
await conv.send_message(
|
437 |
+
f"{get_['name']} changed to `{themssg}`",
|
438 |
+
buttons=get_back_button(back),
|
439 |
+
)
|
440 |
+
|
441 |
+
|
442 |
@callback("authorise", owner=True)
|
443 |
async def _(e):
|
444 |
if not e.is_private:
|
445 |
return
|
446 |
+
url = GDrive._create_token_file()
|
447 |
+
await e.edit("Go to the below link and send the code!")
|
448 |
+
async with asst.conversation(e.sender_id) as conv:
|
449 |
+
await conv.send_message(url)
|
450 |
+
code = await conv.get_response()
|
451 |
+
if GDrive._create_token_file(code=code.text):
|
452 |
+
await conv.send_message(
|
453 |
+
"`Success!\nYou are all set to use Google Drive with Ultroid Userbot.`",
|
454 |
+
buttons=Button.inline("Main Menu", data="setter"),
|
455 |
+
)
|
456 |
+
else:
|
457 |
+
await conv.send_message("Wrong code! Click authorise again.")
|
|
|
|
|
458 |
|
459 |
|
460 |
@callback("folderid", owner=True, func=lambda x: x.is_private)
|
|
|
467 |
+ "1. Open Google Drive App.\n"
|
468 |
+ "2. Create Folder.\n"
|
469 |
+ "3. Make that folder public.\n"
|
470 |
+
+ "4. Send link of that folder."
|
|
|
471 |
)
|
472 |
async with asst.conversation(e.sender_id) as conv:
|
473 |
reply = conv.wait_event(events.NewMessage(from_users=e.sender_id))
|
474 |
repl = await reply
|
475 |
+
id = repl.text
|
476 |
+
if id.startswith("https"):
|
477 |
+
id = id.split("?id=")[-1]
|
478 |
+
udB.set_key("GDRIVE_FOLDER_ID", id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
479 |
await repl.reply(
|
480 |
+
"`Success.`",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
481 |
buttons=get_back_button("gdrive"),
|
482 |
)
|
483 |
|
|
|
487 |
if not e.is_private:
|
488 |
return
|
489 |
await e.edit(
|
490 |
+
"Click Authorise and send the code.\n\nYou can use your own CLIENT ID and SECRET by [this](https://t.me/UltroidUpdates/37)",
|
491 |
buttons=[
|
492 |
[
|
493 |
+
Button.inline("Folder ID", data="folderid"),
|
494 |
+
Button.inline("Authorise", data="authorise"),
|
495 |
],
|
496 |
+
[Button.inline("« Back", data="cbs_otvars")],
|
|
|
|
|
|
|
|
|
497 |
],
|
498 |
link_preview=False,
|
499 |
)
|
500 |
|
501 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
502 |
@callback("dmof", owner=True)
|
503 |
async def rhwhe(e):
|
504 |
+
if udB.get_key("DUAL_MODE"):
|
505 |
+
udB.del_key("DUAL_MODE")
|
506 |
key = "Off"
|
507 |
else:
|
508 |
+
udB.set_key("DUAL_MODE", "True")
|
509 |
key = "On"
|
510 |
Msg = "Dual Mode : " + key
|
511 |
+
await e.edit(Msg, buttons=get_back_button("cbs_otvars"))
|
512 |
|
513 |
|
514 |
@callback("dmhn", owner=True)
|
|
|
517 |
pru = event.sender_id
|
518 |
var = "DUAL_HNDLR"
|
519 |
name = "Dual Handler"
|
520 |
+
CH = udB.get_key(var) or "/"
|
521 |
async with event.client.conversation(pru) as conv:
|
522 |
await conv.send_message(
|
523 |
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.",
|
|
|
528 |
if themssg == "/cancel":
|
529 |
await conv.send_message(
|
530 |
"Cancelled!!",
|
531 |
+
buttons=get_back_button("cbs_otvars"),
|
532 |
)
|
533 |
elif len(themssg) > 1:
|
534 |
await conv.send_message(
|
535 |
"Incorrect Handler",
|
536 |
+
buttons=get_back_button("cbs_otvars"),
|
537 |
)
|
538 |
else:
|
539 |
await setit(event, var, themssg)
|
540 |
await conv.send_message(
|
541 |
f"{name} changed to {themssg}",
|
542 |
+
buttons=get_back_button("cbs_otvars"),
|
543 |
)
|
544 |
|
545 |
|
|
|
557 |
if themssg == "/cancel":
|
558 |
await conv.send_message(
|
559 |
"Cancelled!!",
|
560 |
+
buttons=get_back_button("cbs_otvars"),
|
561 |
)
|
562 |
elif themssg.startswith(("/", HNDLR)):
|
563 |
await conv.send_message(
|
564 |
"Incorrect Emoji",
|
565 |
+
buttons=get_back_button("cbs_otvars"),
|
566 |
)
|
567 |
else:
|
568 |
await setit(event, var, themssg)
|
569 |
await conv.send_message(
|
570 |
f"{name} changed to {themssg}\n",
|
571 |
+
buttons=get_back_button("cbs_otvars"),
|
572 |
)
|
573 |
|
574 |
|
|
|
588 |
if themssg == "/cancel":
|
589 |
await conv.send_message(
|
590 |
"Cancelled!!",
|
591 |
+
buttons=get_back_button("cbs_otvars"),
|
592 |
)
|
593 |
elif themssg.startswith(("/", HNDLR)):
|
594 |
await conv.send_message(
|
595 |
"Incorrect channel",
|
596 |
+
buttons=get_back_button("cbs_otvars"),
|
597 |
)
|
598 |
else:
|
599 |
await setit(event, var, themssg)
|
|
|
602 |
name,
|
603 |
themssg,
|
604 |
),
|
605 |
+
buttons=get_back_button("cbs_otvars"),
|
606 |
)
|
607 |
|
608 |
|
|
|
622 |
if themssg == "/cancel":
|
623 |
await conv.send_message(
|
624 |
"Cancelled!!",
|
625 |
+
buttons=get_back_button("cbs_otvars"),
|
626 |
)
|
627 |
elif len(themssg) > 1:
|
628 |
await conv.send_message(
|
629 |
"Incorrect Handler",
|
630 |
+
buttons=get_back_button("cbs_otvars"),
|
631 |
)
|
632 |
elif themssg.startswith(("/", "#", "@")):
|
633 |
await conv.send_message(
|
634 |
"This cannot be used as handler",
|
635 |
+
buttons=get_back_button("cbs_otvars"),
|
636 |
)
|
637 |
else:
|
638 |
await setit(event, var, themssg)
|
639 |
await conv.send_message(
|
640 |
f"{name} changed to {themssg}",
|
641 |
+
buttons=get_back_button("cbs_otvars"),
|
642 |
)
|
643 |
|
644 |
|
|
|
659 |
if themssg == "/cancel":
|
660 |
await conv.send_message(
|
661 |
"Cancelled!!",
|
662 |
+
buttons=get_back_button("cbs_otvars"),
|
663 |
)
|
664 |
elif len(themssg) > 1:
|
665 |
await conv.send_message(
|
666 |
"Incorrect Handler",
|
667 |
+
buttons=get_back_button("cbs_otvars"),
|
668 |
)
|
669 |
elif themssg.startswith(("/", "#", "@")):
|
670 |
await conv.send_message(
|
671 |
"This cannot be used as handler",
|
672 |
+
buttons=get_back_button("cbs_otvars"),
|
673 |
)
|
674 |
else:
|
675 |
await setit(event, var, themssg)
|
676 |
await conv.send_message(
|
677 |
f"{name} changed to {themssg}",
|
678 |
+
buttons=get_back_button("cbs_otvars"),
|
679 |
)
|
680 |
|
681 |
|
682 |
@callback("taglog", owner=True)
|
683 |
async def tagloggrr(e):
|
684 |
+
BUTTON = [
|
685 |
+
[Button.inline("SET TAG LOG", data="abs_settag")],
|
686 |
+
[Button.inline("DELETE TAG LOG", data="deltag")],
|
687 |
+
get_back_button("cbs_otvars"),
|
688 |
+
]
|
689 |
await e.edit(
|
690 |
"Choose Options",
|
691 |
+
buttons=BUTTON,
|
692 |
)
|
693 |
|
694 |
|
695 |
@callback("deltag", owner=True)
|
696 |
async def _(e):
|
697 |
+
udB.del_key("TAG_LOG")
|
698 |
+
await e.answer("Done!!! Tag Logger has been turned Off")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
699 |
|
700 |
|
701 |
@callback("eaddon", owner=True)
|
702 |
async def pmset(event):
|
703 |
+
if not udB.get_key("ADDONS"):
|
704 |
BT = [Button.inline("Aᴅᴅᴏɴs Oɴ", data="edon")]
|
705 |
else:
|
706 |
BT = [Button.inline("Aᴅᴅᴏɴs Oғғ", data="edof")]
|
|
|
708 |
"ADDONS~ Extra Plugins:",
|
709 |
buttons=[
|
710 |
BT,
|
711 |
+
[Button.inline("« Bᴀᴄᴋ", data="cbs_otvars")],
|
712 |
],
|
713 |
)
|
714 |
|
|
|
725 |
|
726 |
@callback("edof", owner=True)
|
727 |
async def eddof(event):
|
728 |
+
udB.set_key("ADDONS", "False")
|
729 |
await event.edit(
|
730 |
"Done! ADDONS has been turned off!! After Setting All Things Do Restart",
|
731 |
buttons=get_back_button("eaddon"),
|
|
|
734 |
|
735 |
@callback("sudo", owner=True)
|
736 |
async def pmset(event):
|
737 |
+
if not udB.get_key("SUDO"):
|
738 |
BT = [Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ Oɴ", data="onsudo")]
|
739 |
else:
|
740 |
BT = [Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ Oғғ", data="ofsudo")]
|
|
|
742 |
f"SUDO MODE ~ Some peoples can use ur Bot which u selected. To know More use `{HNDLR}help sudo`",
|
743 |
buttons=[
|
744 |
BT,
|
745 |
+
[Button.inline("« Bᴀᴄᴋ", data="cbs_otvars")],
|
746 |
],
|
747 |
)
|
748 |
|
|
|
767 |
)
|
768 |
|
769 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
770 |
@callback("sfgrp", owner=True)
|
771 |
async def sfgrp(event):
|
772 |
await event.delete()
|
|
|
783 |
if themssg == "/cancel":
|
784 |
return await conv.send_message(
|
785 |
"Cancelled!!",
|
786 |
+
buttons=get_back_button("cbs_sfban"),
|
787 |
)
|
788 |
await setit(event, var, themssg)
|
789 |
await conv.send_message(
|
790 |
f"{name} changed to {themssg}",
|
791 |
+
buttons=get_back_button("cbs_sfban"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
792 |
)
|
793 |
|
794 |
|
|
|
808 |
if themssg == "/cancel":
|
809 |
return await conv.send_message(
|
810 |
"Operation cancelled!!",
|
811 |
+
buttons=get_back_button("cbs_alvcstm"),
|
812 |
)
|
813 |
except BaseException:
|
814 |
pass
|
|
|
829 |
except BaseException:
|
830 |
return await conv.send_message(
|
831 |
"Terminated.",
|
832 |
+
buttons=get_back_button("cbs_alvcstm"),
|
833 |
)
|
834 |
await setit(event, var, url)
|
835 |
await conv.send_message(
|
836 |
f"{name} has been set.",
|
837 |
+
buttons=get_back_button("cbs_alvcstm"),
|
838 |
)
|
839 |
|
840 |
|
841 |
@callback("delmed", owner=True)
|
842 |
async def dell(event):
|
843 |
try:
|
844 |
+
udB.del_key("ALIVE_PIC")
|
845 |
return await event.edit(
|
846 |
+
get_string("clst_5"), buttons=get_back_button("cbs_alabs_vcstm")
|
847 |
)
|
848 |
except BaseException:
|
849 |
return await event.edit(
|
850 |
get_string("clst_4"),
|
851 |
+
buttons=get_back_button("cbs_alabs_vcstm"),
|
852 |
)
|
853 |
|
854 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
855 |
@callback("inpm_in", owner=True)
|
856 |
async def inl_on(event):
|
857 |
var = "INLINE_PM"
|
858 |
await setit(event, var, "True")
|
859 |
await event.edit(
|
860 |
"Done!! PMPermit type has been set to inline!",
|
861 |
+
buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_pmtype")]],
|
862 |
)
|
863 |
|
864 |
|
|
|
868 |
await setit(event, var, "False")
|
869 |
await event.edit(
|
870 |
"Done!! PMPermit type has been set to normal!",
|
871 |
+
buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_pmtype")]],
|
872 |
)
|
873 |
|
874 |
|
|
|
888 |
if themssg == "/cancel":
|
889 |
return await conv.send_message(
|
890 |
"Cancelled!!",
|
891 |
+
buttons=get_back_button("cbs_pmcstm"),
|
892 |
)
|
893 |
if len(themssg) > 4090:
|
894 |
return await conv.send_message(
|
895 |
"Message too long!\nGive a shorter message please!!",
|
896 |
+
buttons=get_back_button("cbs_pmcstm"),
|
897 |
)
|
898 |
await setit(event, var, themssg)
|
899 |
await conv.send_message(
|
|
|
901 |
name,
|
902 |
themssg,
|
903 |
),
|
904 |
+
buttons=get_back_button("cbs_pmcstm"),
|
905 |
)
|
906 |
|
907 |
|
|
|
910 |
m = range(1, 10)
|
911 |
tultd = [Button.inline(f"{x}", data=f"wrns_{x}") for x in m]
|
912 |
lst = list(zip(tultd[::3], tultd[1::3], tultd[2::3]))
|
913 |
+
lst.append([Button.inline("« Bᴀᴄᴋ", data="cbs_pmcstm")])
|
914 |
await event.edit(
|
915 |
"Select the number of warnings for a user before getting blocked in PMs.",
|
916 |
buttons=lst,
|
|
|
920 |
@callback(re.compile(b"wrns_(.*)"), owner=True)
|
921 |
async def set_wrns(event):
|
922 |
value = int(event.data_match.group(1).decode("UTF-8"))
|
923 |
+
dn = udB.set_key("PMWARNS", value)
|
924 |
if dn:
|
925 |
await event.edit(
|
926 |
f"PM Warns Set to {value}.\nNew users will have {value} chances in PMs before getting banned.",
|
927 |
+
buttons=get_back_button("cbs_pmcstm"),
|
928 |
)
|
929 |
else:
|
930 |
await event.edit(
|
931 |
f"Something went wrong, please check your {HNDLR}logs!",
|
932 |
+
buttons=get_back_button("cbs_pmcstm"),
|
933 |
)
|
934 |
|
935 |
|
|
|
949 |
if themssg == "/cancel":
|
950 |
return await conv.send_message(
|
951 |
"Operation cancelled!!",
|
952 |
+
buttons=get_back_button("cbs_pmcstm"),
|
953 |
)
|
954 |
except BaseException:
|
955 |
pass
|
|
|
970 |
except BaseException:
|
971 |
return await conv.send_message(
|
972 |
"Terminated.",
|
973 |
+
buttons=get_back_button("cbs_pmcstm"),
|
974 |
)
|
975 |
await setit(event, var, url)
|
976 |
await conv.send_message(
|
977 |
f"{name} has been set.",
|
978 |
+
buttons=get_back_button("cbs_pmcstm"),
|
979 |
)
|
980 |
|
981 |
|
982 |
@callback("delpmmed", owner=True)
|
983 |
async def dell(event):
|
984 |
try:
|
985 |
+
udB.del_key("PMPIC")
|
986 |
+
return await event.edit(
|
987 |
+
get_string("clst_5"), buttons=get_back_button("cbs_pmcstm")
|
988 |
+
)
|
989 |
except BaseException:
|
990 |
return await event.edit(
|
991 |
get_string("clst_4"),
|
|
|
993 |
)
|
994 |
|
995 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
996 |
@callback("apon", owner=True)
|
997 |
async def apon(event):
|
998 |
var = "AUTOAPPROVE"
|
999 |
await setit(event, var, "True")
|
1000 |
await event.edit(
|
1001 |
"Done!! AUTOAPPROVE Started!!",
|
1002 |
+
buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_apauto")]],
|
1003 |
)
|
1004 |
|
1005 |
|
1006 |
@callback("apof", owner=True)
|
1007 |
async def apof(event):
|
1008 |
try:
|
1009 |
+
udB.del_key("AUTOAPPROVE")
|
1010 |
return await event.edit(
|
1011 |
"Done! AUTOAPPROVE Stopped!!",
|
1012 |
+
buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_apauto")]],
|
1013 |
)
|
1014 |
except BaseException:
|
1015 |
return await event.edit(
|
|
|
1019 |
|
1020 |
|
1021 |
@callback("pml", owner=True)
|
1022 |
+
async def l_vcs(event):
|
1023 |
+
if not udB.get_key("PMLOG"):
|
1024 |
BT = [Button.inline("PMLOGGER ON", data="pmlog")]
|
1025 |
else:
|
1026 |
BT = [Button.inline("PMLOGGER OFF", data="pmlogof")]
|
|
|
1028 |
"PMLOGGER This Will Forward Ur Pm to Ur Private Group -",
|
1029 |
buttons=[
|
1030 |
BT,
|
1031 |
+
[Button.inline("PᴍLᴏɢɢᴇʀ Gʀᴏᴜᴘ", "abs_pmlgg")],
|
1032 |
+
[Button.inline("« Bᴀᴄᴋ", data="cbs_pmcstm")],
|
1033 |
],
|
1034 |
)
|
1035 |
|
1036 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1037 |
@callback("pmlog", owner=True)
|
1038 |
async def pmlog(event):
|
1039 |
await setit(event, "PMLOG", "True")
|
|
|
1046 |
@callback("pmlogof", owner=True)
|
1047 |
async def pmlogof(event):
|
1048 |
try:
|
1049 |
+
udB.del_key("PMLOG")
|
1050 |
return await event.edit(
|
1051 |
"Done! PMLOGGER Stopped!!",
|
1052 |
buttons=[[Button.inline("« Bᴀᴄᴋ", data="pml")]],
|
|
|
1058 |
)
|
1059 |
|
1060 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1061 |
@callback("pmon", owner=True)
|
1062 |
async def pmonn(event):
|
1063 |
var = "PMSETTING"
|
1064 |
await setit(event, var, "True")
|
1065 |
await event.edit(
|
1066 |
"Done! PMPermit has been turned on!!",
|
1067 |
+
buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_ppmset")]],
|
1068 |
)
|
1069 |
|
1070 |
|
|
|
1074 |
await setit(event, var, "False")
|
1075 |
await event.edit(
|
1076 |
"Done! PMPermit has been turned off!!",
|
1077 |
+
buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_ppmset")]],
|
1078 |
)
|
1079 |
|
1080 |
|
|
|
1085 |
msg = await conv.get_response()
|
1086 |
if not msg.media or msg.text.startswith("/"):
|
1087 |
return await conv.send_message(
|
1088 |
+
"Terminated!", buttons=get_back_button("cbs_chatbot")
|
1089 |
)
|
1090 |
+
udB.set_key("STARTMEDIA", msg.file.id)
|
1091 |
+
await conv.send_message("Done!", buttons=get_back_button("cbs_chatbot"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1092 |
|
1093 |
|
1094 |
@callback("botinfe", owner=True)
|
|
|
1100 |
msg = await conv.get_response()
|
1101 |
if msg.media or msg.text.startswith("/"):
|
1102 |
return await conv.send_message(
|
1103 |
+
"Terminated!", buttons=get_back_button("cbs_chatbot")
|
1104 |
)
|
1105 |
+
udB.set_key("BOT_INFO_START", msg.text)
|
1106 |
+
await conv.send_message("Done!", buttons=get_back_button("cbs_chatbot"))
|
1107 |
|
1108 |
|
1109 |
@callback("pmfs", owner=True)
|
|
|
1112 |
err = ""
|
1113 |
async with event.client.conversation(event.chat_id) as conv:
|
1114 |
await conv.send_message(
|
1115 |
+
"• Send The Chat Id(s), which you want user to Join Before using Chat/Pm Bot\n\n• Send /clear to disable PmBot Force sub..\n• • Send /cancel to stop this process.."
|
1116 |
)
|
1117 |
await conv.send_message(
|
1118 |
"Example : \n`-1001234567\n-100778888`\n\nFor Multiple Chat(s)."
|
|
|
1120 |
try:
|
1121 |
msg = await conv.get_response()
|
1122 |
except AsyncTimeOut:
|
1123 |
+
return await conv.send_message("**• TimeUp!**\nStart from /start back.")
|
1124 |
if not msg.text or msg.text.startswith("/"):
|
1125 |
+
timyork = "Cancelled!"
|
1126 |
+
if msg.text == "/clear":
|
1127 |
+
udB.del_key("PMBOT_FSUB")
|
1128 |
+
timyork = "Done! Force Subscribe Stopped\nRestart your Bot!"
|
1129 |
return await conv.send_message(
|
1130 |
+
"Cancelled!", buttons=get_back_button("cbs_chatbot")
|
1131 |
)
|
1132 |
for chat in msg.message.split("\n"):
|
1133 |
if chat.startswith("-") or chat.isdigit():
|
|
|
1139 |
err += f"**{chat}** : {er}\n"
|
1140 |
if err:
|
1141 |
return await conv.send_message(err)
|
1142 |
+
udB.set_key("PMBOT_FSUB", str(Ll))
|
1143 |
await conv.send_message(
|
1144 |
+
"Done!\nRestart Your Bot.", buttons=get_back_button("cbs_chatbot")
|
1145 |
)
|
1146 |
|
1147 |
|
|
|
1161 |
if themssg == "/cancel":
|
1162 |
return await conv.send_message(
|
1163 |
"Cancelled!!",
|
1164 |
+
buttons=get_back_button("cbs_chatbot"),
|
1165 |
)
|
1166 |
await setit(event, var, themssg)
|
1167 |
await conv.send_message(
|
|
|
1169 |
name,
|
1170 |
themssg,
|
1171 |
),
|
1172 |
+
buttons=get_back_button("cbs_chatbot"),
|
1173 |
)
|
1174 |
|
1175 |
|
|
|
1185 |
event.client.add_event_handler(i, events.NewMessage(**e))
|
1186 |
await event.edit(
|
1187 |
"Done! Now u Can Chat With People Via This Bot",
|
1188 |
+
buttons=[Button.inline("« Bᴀᴄᴋ", data="cbs_chatbot")],
|
1189 |
)
|
1190 |
|
1191 |
|
|
|
1198 |
event.client.remove_event_handler(i)
|
1199 |
await event.edit(
|
1200 |
"Done! Chat People Via This Bot Stopped.",
|
1201 |
+
buttons=[Button.inline("« Bᴀᴄᴋ", data="cbs_chatbot")],
|
1202 |
)
|
1203 |
|
1204 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1205 |
@callback("inli_pic", owner=True)
|
1206 |
async def media(event):
|
1207 |
await event.delete()
|
|
|
1244 |
f"{name} has been set.",
|
1245 |
buttons=get_back_button("setter"),
|
1246 |
)
|
1247 |
+
|
1248 |
+
|
1249 |
+
FD_MEDIA = {}
|
1250 |
+
|
1251 |
+
|
1252 |
+
@callback(re.compile("fd(.*)"), owner=True)
|
1253 |
+
async def fdroid_dler(event):
|
1254 |
+
uri = event.data_match.group(1).decode("utf-8")
|
1255 |
+
if FD_MEDIA.get(uri):
|
1256 |
+
return await event.edit(file=FD_MEDIA[uri])
|
1257 |
+
await event.answer("• Starting Download •", alert=True)
|
1258 |
+
await event.edit("• Downloading.. •")
|
1259 |
+
URL = f"https://f-droid.org/packages/{uri}"
|
1260 |
+
conte = await async_searcher(URL, re_content=True)
|
1261 |
+
BSC = bs(conte, "html.parser", from_encoding="utf-8")
|
1262 |
+
dl_ = BSC.find("p", "package-version-download").find("a")["href"]
|
1263 |
+
title = BSC.find("h3", "package-name").text.strip()
|
1264 |
+
thumb = BSC.find("img", "package-icon")["src"]
|
1265 |
+
if thumb.startswith("/"):
|
1266 |
+
thumb = "https://f-droid.org" + thumb
|
1267 |
+
thumb, _ = await fast_download(thumb, filename=uri + ".png")
|
1268 |
+
s_time = time.time()
|
1269 |
+
file, _ = await fast_download(
|
1270 |
+
dl_,
|
1271 |
+
filename=title + ".apk",
|
1272 |
+
progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
|
1273 |
+
progress(
|
1274 |
+
d,
|
1275 |
+
t,
|
1276 |
+
event,
|
1277 |
+
s_time,
|
1278 |
+
"Downloading...",
|
1279 |
+
)
|
1280 |
+
),
|
1281 |
+
)
|
1282 |
+
tt = time.time()
|
1283 |
+
n_file = await uploader(file, file, tt, event, "Uploading...")
|
1284 |
+
buttons = Button.switch_inline("Search Back", query="fdroid", same_peer=True)
|
1285 |
+
try:
|
1286 |
+
msg = await event.edit(
|
1287 |
+
f"**• [{title}]({URL}) •**", file=n_file, thumb=thumb, buttons=buttons
|
1288 |
+
)
|
1289 |
+
except Exception as er:
|
1290 |
+
LOGS.exception(er)
|
1291 |
+
try:
|
1292 |
+
msg = await event.client.edit_message(
|
1293 |
+
await event.get_input_chat(),
|
1294 |
+
event.message_id,
|
1295 |
+
f"**• [{title}]({URL}) •**",
|
1296 |
+
buttons=buttons,
|
1297 |
+
thumb=thumb,
|
1298 |
+
file=n_file,
|
1299 |
+
)
|
1300 |
+
except Exception as er:
|
1301 |
+
os.remove(thumb)
|
1302 |
+
os.remove(file)
|
1303 |
+
LOGS.exception(er)
|
1304 |
+
return await event.edit(f"**ERROR**: `{er}`", buttons=buttons)
|
1305 |
+
if msg and hasattr(msg, "media"):
|
1306 |
+
FD_MEDIA.update({uri: msg.media})
|
1307 |
+
os.remove(thumb)
|
1308 |
+
os.remove(file)
|
assistant/games.py
ADDED
@@ -0,0 +1,308 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 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 |
+
• `{i}akinator` | `/akinator`
|
10 |
+
Start akinator game from Userbot/Assistant
|
11 |
+
|
12 |
+
• `/startgame`
|
13 |
+
Open Portal for Games
|
14 |
+
"""
|
15 |
+
|
16 |
+
import asyncio
|
17 |
+
import operator
|
18 |
+
import re
|
19 |
+
import uuid
|
20 |
+
from html import unescape
|
21 |
+
from random import choice, shuffle
|
22 |
+
|
23 |
+
import akinator
|
24 |
+
from pyUltroid.functions.helper import inline_mention
|
25 |
+
from pyUltroid.functions.tools import async_searcher
|
26 |
+
from pyUltroid.misc._decorators import ultroid_cmd
|
27 |
+
from telethon.errors.rpcerrorlist import (
|
28 |
+
BotMethodInvalidError,
|
29 |
+
ChatSendStickersForbiddenError,
|
30 |
+
)
|
31 |
+
from telethon.events import Raw
|
32 |
+
from telethon.tl.types import InputMediaPoll, Poll, PollAnswer, UpdateMessagePollVote
|
33 |
+
|
34 |
+
from . import *
|
35 |
+
|
36 |
+
# -------------------------- Akinator ----------------------- #
|
37 |
+
|
38 |
+
games = {}
|
39 |
+
aki_photo = "https://telegra.ph/file/3cc8825c029fd0cab9edc.jpg"
|
40 |
+
|
41 |
+
|
42 |
+
@ultroid_cmd(pattern="akinator")
|
43 |
+
async def akina(e):
|
44 |
+
sta = akinator.Akinator()
|
45 |
+
games.update({e.chat_id: {e.id: sta}})
|
46 |
+
try:
|
47 |
+
m = await e.client.inline_query(asst.me.username, f"aki_{e.chat_id}_{e.id}")
|
48 |
+
await m[0].click(e.chat_id)
|
49 |
+
except BotMethodInvalidError:
|
50 |
+
await asst.send_file(
|
51 |
+
e.chat_id,
|
52 |
+
aki_photo,
|
53 |
+
buttons=Button.inline(get_string("aki_2"), data=f"aki_{e.chat_id}_{e.id}"),
|
54 |
+
)
|
55 |
+
except Exception as er:
|
56 |
+
return await e.eor(f"**ERROR :** `{er}`")
|
57 |
+
if e.out:
|
58 |
+
await e.delete()
|
59 |
+
|
60 |
+
|
61 |
+
@asst_cmd(pattern="akinator", owner=True)
|
62 |
+
async def _akokk(e):
|
63 |
+
await akina(e)
|
64 |
+
|
65 |
+
|
66 |
+
@callback(re.compile("aki_(.*)"), owner=True)
|
67 |
+
async def doai(e):
|
68 |
+
adt = e.pattern_match.group(1).decode("utf-8")
|
69 |
+
dt = adt.split("_")
|
70 |
+
ch = int(dt[0])
|
71 |
+
mid = int(dt[1])
|
72 |
+
await e.edit(get_string("com_1"))
|
73 |
+
try:
|
74 |
+
qu = games[ch][mid].start_game(child_mode=True)
|
75 |
+
# child mode should be promoted
|
76 |
+
except KeyError:
|
77 |
+
return await e.answer(get_string("aki_1"), alert=True)
|
78 |
+
bts = [Button.inline(o, f"aka_{adt}_{o}") for o in ["Yes", "No", "Idk"]]
|
79 |
+
cts = [Button.inline(o, f"aka_{adt}_{o}") for o in ["Probably", "Probably Not"]]
|
80 |
+
|
81 |
+
bts = [bts, cts]
|
82 |
+
# ignored Back Button since it makes the Pagination looks Bad
|
83 |
+
await e.edit("Q. " + qu, buttons=bts)
|
84 |
+
|
85 |
+
|
86 |
+
@callback(re.compile("aka_(.*)"), owner=True)
|
87 |
+
async def okah(e):
|
88 |
+
mk = e.pattern_match.group(1).decode("utf-8").split("_")
|
89 |
+
ch = int(mk[0])
|
90 |
+
mid = int(mk[1])
|
91 |
+
ans = mk[2]
|
92 |
+
try:
|
93 |
+
gm = games[ch][mid]
|
94 |
+
except KeyError:
|
95 |
+
await e.answer(get_string("aki_3"))
|
96 |
+
return
|
97 |
+
text = gm.answer(ans)
|
98 |
+
if gm.progression >= 80:
|
99 |
+
gm.win()
|
100 |
+
gs = gm.first_guess
|
101 |
+
text = "It's " + gs["name"] + "\n " + gs["description"]
|
102 |
+
return await e.edit(text, file=gs["absolute_picture_path"])
|
103 |
+
bts = [Button.inline(o, f"aka_{ch}_{mid}_{o}") for o in ["Yes", "No", "Idk"]]
|
104 |
+
cts = [
|
105 |
+
Button.inline(o, f"aka_{ch}_{mid}_{o}") for o in ["Probably", "Probably Not"]
|
106 |
+
]
|
107 |
+
|
108 |
+
bts = [bts, cts]
|
109 |
+
await e.edit(text, buttons=bts)
|
110 |
+
|
111 |
+
|
112 |
+
@in_pattern(re.compile("aki_?(.*)"), owner=True)
|
113 |
+
async def eiagx(e):
|
114 |
+
bts = Button.inline(get_string("aki_2"), data=e.text)
|
115 |
+
ci = types.InputWebDocument(aki_photo, 0, "image/jpeg", [])
|
116 |
+
ans = [
|
117 |
+
await e.builder.article(
|
118 |
+
"Akinator",
|
119 |
+
type="photo",
|
120 |
+
content=ci,
|
121 |
+
text="Akinator",
|
122 |
+
thumb=ci,
|
123 |
+
buttons=bts,
|
124 |
+
include_media=True,
|
125 |
+
)
|
126 |
+
]
|
127 |
+
await e.answer(ans)
|
128 |
+
|
129 |
+
|
130 |
+
# ----------------------- Main Command ------------------- #
|
131 |
+
|
132 |
+
|
133 |
+
@asst_cmd(pattern="startgame", owner=True)
|
134 |
+
async def magic(event):
|
135 |
+
buttons = [
|
136 |
+
[Button.inline("Trivia Quiz", "trzia")],
|
137 |
+
[Button.inline("Cancel ❌", "delit")],
|
138 |
+
]
|
139 |
+
await event.reply(
|
140 |
+
get_string("games_1"),
|
141 |
+
file="https://telegra.ph/file/1c51015bae5205a65fd69.jpg",
|
142 |
+
buttons=buttons,
|
143 |
+
)
|
144 |
+
|
145 |
+
|
146 |
+
# -------------------------- Trivia ----------------------- #
|
147 |
+
|
148 |
+
TR_BTS = {}
|
149 |
+
DIFI_KEYS = ["Easy", "Medium", "Hard"]
|
150 |
+
TRIVIA_CHATS = {}
|
151 |
+
POLLS = {}
|
152 |
+
CONGO_STICKER = [
|
153 |
+
"CAADAgADSgIAAladvQrJasZoYBh68AI",
|
154 |
+
"CAADAgADXhIAAuyZKUl879mlR_dkOwI",
|
155 |
+
"CAADAgADpQAD9wLID-xfZCDwOI5LAg",
|
156 |
+
"CAADAgADjAADECECEFZM-SrKO9GgAg",
|
157 |
+
"CAADAgADSwIAAj-VzArAzNCDiGWAHAI",
|
158 |
+
"CAADAgADhQADwZxgDIuMHR9IU10iAg",
|
159 |
+
]
|
160 |
+
|
161 |
+
|
162 |
+
@callback("delit")
|
163 |
+
async def delete_it(event):
|
164 |
+
await event.delete()
|
165 |
+
|
166 |
+
|
167 |
+
@callback(re.compile("ctdown(.*)"), owner=True)
|
168 |
+
async def ct_spam(e):
|
169 |
+
n = e.data_match.group(1).decode("utf-8")
|
170 |
+
await e.answer(f"Wait {n} seconds..", alert=True)
|
171 |
+
|
172 |
+
|
173 |
+
@callback(re.compile("trzia(.*)"), owner=True)
|
174 |
+
async def choose_cata(event):
|
175 |
+
match = event.data_match.group(1).decode("utf-8")
|
176 |
+
if not match:
|
177 |
+
if TR_BTS.get("category"):
|
178 |
+
buttons = TR_BTS["category"]
|
179 |
+
else:
|
180 |
+
req = (
|
181 |
+
await async_searcher(
|
182 |
+
"https://opentdb.com/api_category.php", re_json=True
|
183 |
+
)
|
184 |
+
)["trivia_categories"]
|
185 |
+
btt = []
|
186 |
+
for i in req:
|
187 |
+
name = i["name"]
|
188 |
+
if ":" in name:
|
189 |
+
name = name.split(":")[1]
|
190 |
+
btt.append(Button.inline(name, f"trziad_{i['id']}"))
|
191 |
+
buttons = list(zip(btt[::2], btt[1::2]))
|
192 |
+
if len(btt) % 2 == 1:
|
193 |
+
buttons.append((btt[-1],))
|
194 |
+
buttons.append([Button.inline("Cancel ❌", "delit")])
|
195 |
+
TR_BTS.update({"category": buttons})
|
196 |
+
text = get_string("games_2")
|
197 |
+
elif match[0] == "d":
|
198 |
+
cat = match[1:]
|
199 |
+
buttons = [[Button.inline(i, f"trziac{cat}_{i}") for i in DIFI_KEYS]]
|
200 |
+
buttons.append(get_back_button("trzia"))
|
201 |
+
text = get_string("games_3")
|
202 |
+
elif match[0] == "c":
|
203 |
+
m = match[1:]
|
204 |
+
buttons = [[Button.inline(str(i), f"trziat{m}_{i}") for i in range(10, 70, 20)]]
|
205 |
+
text = get_string("games_4")
|
206 |
+
elif match[0] == "t":
|
207 |
+
m_ = match[1:]
|
208 |
+
buttons = [
|
209 |
+
[Button.inline(str(i), f"trzias{m_}_{i}") for i in [10, 30, 60, 120]]
|
210 |
+
]
|
211 |
+
text = get_string("games_5")
|
212 |
+
elif match[0] == "s":
|
213 |
+
chat = event.chat_id
|
214 |
+
cat, le, nu, in_ = match[2:].split("_")
|
215 |
+
msg = await event.edit(get_string("games_6").format(le, nu))
|
216 |
+
for i in reversed(range(5)):
|
217 |
+
msg = await msg.edit(buttons=Button.inline(f"{i} ⏰", f"ctdown{i}"))
|
218 |
+
await asyncio.sleep(1)
|
219 |
+
await msg.edit(
|
220 |
+
msg.text + "\n\n• Send /cancel to stop the Quiz...", buttons=None
|
221 |
+
)
|
222 |
+
qsss = await async_searcher(
|
223 |
+
f"https://opentdb.com/api.php?amount={nu}&category={cat}&difficulty={le.lower()}",
|
224 |
+
re_json=True,
|
225 |
+
)
|
226 |
+
qs = qsss["results"]
|
227 |
+
if not qs:
|
228 |
+
await event.respond("Sorry, No Question Found for the given Criteria..")
|
229 |
+
await event.delete()
|
230 |
+
return
|
231 |
+
TRIVIA_CHATS.update({chat: {}})
|
232 |
+
for copper, q in enumerate(qs):
|
233 |
+
if TRIVIA_CHATS[chat].get("cancel") is not None:
|
234 |
+
break
|
235 |
+
ansi = str(uuid.uuid1()).split("-")[0].encode()
|
236 |
+
opts = [PollAnswer(unescape(q["correct_answer"]), ansi)]
|
237 |
+
[
|
238 |
+
opts.append(
|
239 |
+
PollAnswer(unescape(a), str(uuid.uuid1()).split("-")[0].encode())
|
240 |
+
)
|
241 |
+
for a in q["incorrect_answers"]
|
242 |
+
]
|
243 |
+
shuffle(opts)
|
244 |
+
poll = InputMediaPoll(
|
245 |
+
Poll(
|
246 |
+
0,
|
247 |
+
f"[{copper+1}]. " + unescape(q["question"]),
|
248 |
+
answers=opts,
|
249 |
+
public_voters=True,
|
250 |
+
quiz=True,
|
251 |
+
close_period=int(in_),
|
252 |
+
),
|
253 |
+
correct_answers=[ansi],
|
254 |
+
solution="Join @TheUltroid",
|
255 |
+
solution_entities=[],
|
256 |
+
)
|
257 |
+
m_ = await event.client.send_message(chat, file=poll)
|
258 |
+
POLLS.update({m_.poll.poll.id: {"chat": m_.chat_id, "answer": ansi}})
|
259 |
+
await asyncio.sleep(int(in_))
|
260 |
+
if not TRIVIA_CHATS[chat]:
|
261 |
+
await event.respond(
|
262 |
+
"No-One Got Any Score in the Quiz!\nBetter Luck Next Time!"
|
263 |
+
)
|
264 |
+
else:
|
265 |
+
try:
|
266 |
+
await event.respond(file=choice(CONGO_STICKER))
|
267 |
+
except ChatSendStickersForbiddenError:
|
268 |
+
pass
|
269 |
+
LBD = "🎯 **Scoreboard of the Quiz.**\n\n"
|
270 |
+
TRC = TRIVIA_CHATS[chat]
|
271 |
+
if "cancel" in TRC.keys():
|
272 |
+
del TRC["cancel"]
|
273 |
+
for userid, user_score in dict(
|
274 |
+
sorted(TRC.items(), key=operator.itemgetter(1), reverse=True)
|
275 |
+
).items():
|
276 |
+
user = inline_mention(await event.client.get_entity(userid))
|
277 |
+
LBD += f"••• {user} - {user_score}\n"
|
278 |
+
await event.respond(LBD)
|
279 |
+
del TRIVIA_CHATS[chat]
|
280 |
+
list_ = list(POLLS.copy().keys())
|
281 |
+
for key in list_:
|
282 |
+
if POLLS[key]["chat"] == chat:
|
283 |
+
del POLLS[key]
|
284 |
+
return
|
285 |
+
await event.edit(text, buttons=buttons)
|
286 |
+
|
287 |
+
|
288 |
+
@asst.on(
|
289 |
+
Raw(UpdateMessagePollVote, func=lambda x: TRIVIA_CHATS and POLLS.get(x.poll_id))
|
290 |
+
)
|
291 |
+
async def pollish(eve):
|
292 |
+
if POLLS.get(eve.poll_id)["chat"] not in TRIVIA_CHATS.keys():
|
293 |
+
return
|
294 |
+
if POLLS[eve.poll_id]["answer"] != eve.options[0]:
|
295 |
+
return
|
296 |
+
chat = POLLS.get(eve.poll_id)["chat"]
|
297 |
+
user = eve.user_id
|
298 |
+
if not TRIVIA_CHATS.get(chat, {}).get(user):
|
299 |
+
TRIVIA_CHATS[chat][user] = 1
|
300 |
+
else:
|
301 |
+
TRIVIA_CHATS[chat][user] += 1
|
302 |
+
|
303 |
+
|
304 |
+
@asst_cmd("cancel", owner=True, func=lambda x: TRIVIA_CHATS.get(x.chat_id))
|
305 |
+
async def cancelish(event):
|
306 |
+
chat = TRIVIA_CHATS.get(event.chat_id)
|
307 |
+
chat.update({"cancel": True})
|
308 |
+
await event.respond("Cancelled!")
|
assistant/initial.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
assistant/inlinestuff.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -10,14 +10,21 @@ from datetime import datetime
|
|
10 |
from random import choice
|
11 |
from re import compile as re_compile
|
12 |
|
13 |
-
import requests
|
14 |
from bs4 import BeautifulSoup as bs
|
15 |
from pyUltroid.functions.misc import google_search
|
16 |
-
from pyUltroid.functions.tools import
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
from telethon import Button
|
|
|
18 |
from telethon.tl.types import InputWebDocument as wb
|
19 |
|
20 |
from . import *
|
|
|
21 |
|
22 |
SUP_BUTTONS = [
|
23 |
[
|
@@ -30,20 +37,15 @@ ofox = "https://telegra.ph/file/231f0049fcd722824f13b.jpg"
|
|
30 |
gugirl = "https://telegra.ph/file/0df54ae4541abca96aa11.jpg"
|
31 |
ultpic = "https://telegra.ph/file/4136aa1650bc9d4109cc5.jpg"
|
32 |
|
33 |
-
|
34 |
-
"
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
)
|
39 |
-
api3 = base64.b64decode("QUl6YVN5RGRPS253blB3VklRX2xiSDVzWUU0Rm9YakFLSVFWMERR").decode(
|
40 |
-
"ascii"
|
41 |
-
)
|
42 |
|
43 |
|
44 |
@in_pattern("ofox", owner=True)
|
45 |
async def _(e):
|
46 |
-
match = None
|
47 |
try:
|
48 |
match = e.text.split(" ", maxsplit=1)[1]
|
49 |
except IndexError:
|
@@ -101,27 +103,31 @@ async def _(e):
|
|
101 |
|
102 |
@in_pattern("fl2lnk ?(.*)", owner=True)
|
103 |
async def _(e):
|
104 |
-
|
105 |
-
|
106 |
-
|
|
|
|
|
|
|
|
|
107 |
[
|
108 |
-
Button.inline("anonfiles", data=f"flanonfiles//{
|
109 |
-
Button.inline("transfer", data=f"fltransfer//{
|
110 |
],
|
111 |
[
|
112 |
-
Button.inline("bayfiles", data=f"flbayfiles//{
|
113 |
-
Button.inline("x0", data=f"flx0//{
|
114 |
],
|
115 |
[
|
116 |
-
Button.inline("file.io", data=f"flfile.io//{
|
117 |
-
Button.inline("siasky", data=f"flsiasky//{
|
118 |
],
|
119 |
]
|
120 |
try:
|
121 |
lnk = e.builder.article(
|
122 |
-
title="
|
123 |
-
text=f"**File:**\n{
|
124 |
-
buttons=
|
125 |
)
|
126 |
except BaseException:
|
127 |
lnk = e.builder.article(
|
@@ -141,10 +147,13 @@ async def _(e):
|
|
141 |
t = (e.data).decode("UTF-8")
|
142 |
data = t[2:]
|
143 |
host = data.split("//")[0]
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
|
|
|
|
|
|
148 |
|
149 |
|
150 |
@in_pattern("repo", owner=True)
|
@@ -210,16 +219,15 @@ async def _(e):
|
|
210 |
try:
|
211 |
quer = e.text.split(" ", maxsplit=1)[1]
|
212 |
except IndexError:
|
213 |
-
await e.answer(
|
214 |
[], switch_pm="Mod Apps Search. Enter app name!", switch_pm_param="start"
|
215 |
)
|
216 |
page = 1
|
217 |
start = (page - 1) * 3 + 1
|
218 |
-
da = choice(
|
219 |
url = f"https://www.googleapis.com/customsearch/v1?key={da}&cx=25b3b50edb928435b&q={quer}&start={start}"
|
220 |
-
data =
|
221 |
search_items = data.get("items")
|
222 |
-
search(quer)
|
223 |
modss = []
|
224 |
for a in search_items:
|
225 |
title = a.get("title")
|
@@ -288,19 +296,23 @@ async def xda_dev(event):
|
|
288 |
|
289 |
|
290 |
APP_CACHE = {}
|
|
|
291 |
|
292 |
|
293 |
@in_pattern("app", owner=True)
|
294 |
async def _(e):
|
295 |
try:
|
296 |
-
f = e.text.split(" ", maxsplit=1)[1]
|
297 |
except IndexError:
|
298 |
-
|
299 |
res = []
|
300 |
-
if APP_CACHE:
|
301 |
-
|
302 |
-
|
303 |
-
|
|
|
|
|
|
|
304 |
try:
|
305 |
return await e.answer(
|
306 |
APP_CACHE[f], switch_pm="Application Searcher.", switch_pm_param="start"
|
@@ -355,6 +367,10 @@ async def _(e):
|
|
355 |
),
|
356 |
)
|
357 |
APP_CACHE.update({f: foles})
|
|
|
|
|
|
|
|
|
358 |
await e.answer(foles, switch_pm="Application Searcher.", switch_pm_param="start")
|
359 |
|
360 |
|
@@ -371,6 +387,9 @@ async def piston_run(event):
|
|
371 |
result = await event.builder.article(
|
372 |
title="Bad Query",
|
373 |
description="Usage: [Language] [code]",
|
|
|
|
|
|
|
374 |
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)',
|
375 |
)
|
376 |
return await event.answer([result])
|
@@ -383,23 +402,284 @@ async def piston_run(event):
|
|
383 |
result = await event.builder.article(
|
384 |
title="Unsupported Language",
|
385 |
description="Usage: [Language] [code]",
|
|
|
|
|
|
|
386 |
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)',
|
387 |
)
|
388 |
return await event.answer([result])
|
389 |
-
output = (
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
)["run"]["output"] or get_string("instu_4")
|
397 |
if len(output) > 3000:
|
398 |
output = output[:3000] + "..."
|
399 |
result = await event.builder.article(
|
400 |
title="Result",
|
401 |
description=output,
|
402 |
text=f"• **Language:**\n`{lang}`\n\n• **Code:**\n`{code}`\n\n• **Result:**\n`{output}`",
|
|
|
|
|
|
|
403 |
buttons=Button.switch_inline("Fork", query=event.text, same_peer=True),
|
404 |
)
|
405 |
await event.answer([result], switch_pm="• Piston •", switch_pm_param="start")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
10 |
from random import choice
|
11 |
from re import compile as re_compile
|
12 |
|
|
|
13 |
from bs4 import BeautifulSoup as bs
|
14 |
from pyUltroid.functions.misc import google_search
|
15 |
+
from pyUltroid.functions.tools import (
|
16 |
+
_webupload_cache,
|
17 |
+
async_searcher,
|
18 |
+
get_ofox,
|
19 |
+
saavn_search,
|
20 |
+
webuploader,
|
21 |
+
)
|
22 |
from telethon import Button
|
23 |
+
from telethon.tl.types import DocumentAttributeAudio as Audio
|
24 |
from telethon.tl.types import InputWebDocument as wb
|
25 |
|
26 |
from . import *
|
27 |
+
from . import _ult_cache
|
28 |
|
29 |
SUP_BUTTONS = [
|
30 |
[
|
|
|
37 |
gugirl = "https://telegra.ph/file/0df54ae4541abca96aa11.jpg"
|
38 |
ultpic = "https://telegra.ph/file/4136aa1650bc9d4109cc5.jpg"
|
39 |
|
40 |
+
apis = [
|
41 |
+
"QUl6YVN5QXlEQnNZM1dSdEI1WVBDNmFCX3c4SkF5NlpkWE5jNkZV",
|
42 |
+
"QUl6YVN5QkYwenhMbFlsUE1wOXh3TVFxVktDUVJxOERnZHJMWHNn",
|
43 |
+
"QUl6YVN5RGRPS253blB3VklRX2xiSDVzWUU0Rm9YakFLSVFWMERR",
|
44 |
+
]
|
|
|
|
|
|
|
|
|
45 |
|
46 |
|
47 |
@in_pattern("ofox", owner=True)
|
48 |
async def _(e):
|
|
|
49 |
try:
|
50 |
match = e.text.split(" ", maxsplit=1)[1]
|
51 |
except IndexError:
|
|
|
103 |
|
104 |
@in_pattern("fl2lnk ?(.*)", owner=True)
|
105 |
async def _(e):
|
106 |
+
match = e.pattern_match.group(1)
|
107 |
+
chat_id, msg_id = match.split(":")
|
108 |
+
filename = _webupload_cache[int(chat_id)][int(msg_id)]
|
109 |
+
if "/" in filename:
|
110 |
+
filename = filename.split("/")[-1]
|
111 |
+
__cache = f"{chat_id}:{msg_id}"
|
112 |
+
buttons = [
|
113 |
[
|
114 |
+
Button.inline("anonfiles", data=f"flanonfiles//{__cache}"),
|
115 |
+
Button.inline("transfer", data=f"fltransfer//{__cache}"),
|
116 |
],
|
117 |
[
|
118 |
+
Button.inline("bayfiles", data=f"flbayfiles//{__cache}"),
|
119 |
+
Button.inline("x0.at", data=f"flx0.at//{__cache}"),
|
120 |
],
|
121 |
[
|
122 |
+
Button.inline("file.io", data=f"flfile.io//{__cache}"),
|
123 |
+
Button.inline("siasky", data=f"flsiasky//{__cache}"),
|
124 |
],
|
125 |
]
|
126 |
try:
|
127 |
lnk = e.builder.article(
|
128 |
+
title=f"Upload {filename}",
|
129 |
+
text=f"**File:**\n{filename}",
|
130 |
+
buttons=buttons,
|
131 |
)
|
132 |
except BaseException:
|
133 |
lnk = e.builder.article(
|
|
|
147 |
t = (e.data).decode("UTF-8")
|
148 |
data = t[2:]
|
149 |
host = data.split("//")[0]
|
150 |
+
chat_id, msg_id = data.split("//")[1].split(":")
|
151 |
+
filename = _webupload_cache[int(chat_id)][int(msg_id)]
|
152 |
+
if "/" in filename:
|
153 |
+
filename = filename.split("/")[-1]
|
154 |
+
await e.edit(f"Uploading `{filename}` on {host}")
|
155 |
+
link = (await webuploader(chat_id, msg_id, host)).strip().replace("\n", "")
|
156 |
+
await e.edit(f"Uploaded [{filename}]({link}) on {host}.")
|
157 |
|
158 |
|
159 |
@in_pattern("repo", owner=True)
|
|
|
219 |
try:
|
220 |
quer = e.text.split(" ", maxsplit=1)[1]
|
221 |
except IndexError:
|
222 |
+
return await e.answer(
|
223 |
[], switch_pm="Mod Apps Search. Enter app name!", switch_pm_param="start"
|
224 |
)
|
225 |
page = 1
|
226 |
start = (page - 1) * 3 + 1
|
227 |
+
da = base64.b64decode(choice(apis)).decode("ascii")
|
228 |
url = f"https://www.googleapis.com/customsearch/v1?key={da}&cx=25b3b50edb928435b&q={quer}&start={start}"
|
229 |
+
data = await async_searcher(url, re_json=True)
|
230 |
search_items = data.get("items")
|
|
|
231 |
modss = []
|
232 |
for a in search_items:
|
233 |
title = a.get("title")
|
|
|
296 |
|
297 |
|
298 |
APP_CACHE = {}
|
299 |
+
RECENTS = {}
|
300 |
|
301 |
|
302 |
@in_pattern("app", owner=True)
|
303 |
async def _(e):
|
304 |
try:
|
305 |
+
f = e.text.split(" ", maxsplit=1)[1].lower()
|
306 |
except IndexError:
|
307 |
+
get_string("instu_1")
|
308 |
res = []
|
309 |
+
if APP_CACHE and RECENTS.get(e.sender_id):
|
310 |
+
for a in RECENTS[e.sender_id]:
|
311 |
+
if APP_CACHE.get(a):
|
312 |
+
res.append(APP_CACHE[a][0])
|
313 |
+
return await e.answer(
|
314 |
+
res, switch_pm=get_string("instu_2"), switch_pm_param="start"
|
315 |
+
)
|
316 |
try:
|
317 |
return await e.answer(
|
318 |
APP_CACHE[f], switch_pm="Application Searcher.", switch_pm_param="start"
|
|
|
367 |
),
|
368 |
)
|
369 |
APP_CACHE.update({f: foles})
|
370 |
+
if RECENTS.get(e.sender_id):
|
371 |
+
RECENTS[e.sender_id].append(f)
|
372 |
+
else:
|
373 |
+
RECENTS.update({e.sender_id: [f]})
|
374 |
await e.answer(foles, switch_pm="Application Searcher.", switch_pm_param="start")
|
375 |
|
376 |
|
|
|
387 |
result = await event.builder.article(
|
388 |
title="Bad Query",
|
389 |
description="Usage: [Language] [code]",
|
390 |
+
thumb=wb(
|
391 |
+
"https://telegra.ph/file/e33c57fc5f1044547e4d8.jpg", 0, "image/jpeg", []
|
392 |
+
),
|
393 |
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)',
|
394 |
)
|
395 |
return await event.answer([result])
|
|
|
402 |
result = await event.builder.article(
|
403 |
title="Unsupported Language",
|
404 |
description="Usage: [Language] [code]",
|
405 |
+
thumb=wb(
|
406 |
+
"https://telegra.ph/file/e33c57fc5f1044547e4d8.jpg", 0, "image/jpeg", []
|
407 |
+
),
|
408 |
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)',
|
409 |
)
|
410 |
return await event.answer([result])
|
411 |
+
output = await async_searcher(
|
412 |
+
PISTON_URI + "execute",
|
413 |
+
post=True,
|
414 |
+
json={"language": lang, "version": version, "files": [{"content": code}]},
|
415 |
+
re_json=True,
|
416 |
+
)
|
417 |
+
output = output["run"]["output"] or get_string("instu_4")
|
|
|
418 |
if len(output) > 3000:
|
419 |
output = output[:3000] + "..."
|
420 |
result = await event.builder.article(
|
421 |
title="Result",
|
422 |
description=output,
|
423 |
text=f"• **Language:**\n`{lang}`\n\n• **Code:**\n`{code}`\n\n• **Result:**\n`{output}`",
|
424 |
+
thumb=wb(
|
425 |
+
"https://telegra.ph/file/871ee4a481f58117dccc4.jpg", 0, "image/jpeg", []
|
426 |
+
),
|
427 |
buttons=Button.switch_inline("Fork", query=event.text, same_peer=True),
|
428 |
)
|
429 |
await event.answer([result], switch_pm="• Piston •", switch_pm_param="start")
|
430 |
+
|
431 |
+
|
432 |
+
FDROID_ = {}
|
433 |
+
|
434 |
+
|
435 |
+
@in_pattern("fdroid", owner=True)
|
436 |
+
async def do_magic(event):
|
437 |
+
try:
|
438 |
+
match = event.text.split(" ", maxsplit=1)[1].lower()
|
439 |
+
except IndexError:
|
440 |
+
return await event.answer(
|
441 |
+
[], switch_pm="Enter Query to Search", switch_pm_param="start"
|
442 |
+
)
|
443 |
+
if FDROID_.get(match):
|
444 |
+
return await event.answer(
|
445 |
+
FDROID_[match], switch_pm=f"• Results for {match}", switch_pm_param="start"
|
446 |
+
)
|
447 |
+
link = "https://search.f-droid.org/?q=" + match.replace(" ", "+")
|
448 |
+
content = await async_searcher(link, re_content=True)
|
449 |
+
BSC = bs(content, "html.parser", from_encoding="utf-8")
|
450 |
+
ress = []
|
451 |
+
for dat in BSC.find_all("a", "package-header")[:10]:
|
452 |
+
image = dat.find("img", "package-icon")["src"]
|
453 |
+
if image.endswith("/"):
|
454 |
+
image = "https://telegra.ph/file/a8dd4a92c5a53a89d0eff.jpg"
|
455 |
+
title = dat.find("h4", "package-name").text.strip()
|
456 |
+
desc = dat.find("span", "package-summary").text.strip()
|
457 |
+
text = f"• **Name :** `{title}`\n\n"
|
458 |
+
text += f"• **Description :** `{desc}`\n"
|
459 |
+
text += f"• **License :** `{dat.find('span', 'package-license').text.strip()}`"
|
460 |
+
imga = wb(image, 0, "image/jpeg", [])
|
461 |
+
ress.append(
|
462 |
+
await event.builder.article(
|
463 |
+
title=title,
|
464 |
+
type="photo",
|
465 |
+
description=desc,
|
466 |
+
text=text,
|
467 |
+
content=imga,
|
468 |
+
thumb=imga,
|
469 |
+
include_media=True,
|
470 |
+
buttons=[
|
471 |
+
Button.inline(
|
472 |
+
"• Download •", "fd" + dat["href"].split("packages/")[-1]
|
473 |
+
),
|
474 |
+
Button.switch_inline("• Share •", query=event.text),
|
475 |
+
],
|
476 |
+
)
|
477 |
+
)
|
478 |
+
msg = f"Showing {len(ress)} Results!" if ress else "No Results Found"
|
479 |
+
FDROID_.update({match: ress})
|
480 |
+
await event.answer(ress, switch_pm=msg, switch_pm_param="start")
|
481 |
+
|
482 |
+
|
483 |
+
_koo_ = {}
|
484 |
+
|
485 |
+
|
486 |
+
@in_pattern("koo", owner=True)
|
487 |
+
async def koo_search(ult):
|
488 |
+
"""Search Users on koo with API"""
|
489 |
+
try:
|
490 |
+
match = ult.text.split(maxsplit=1)[1].lower()
|
491 |
+
match_ = match
|
492 |
+
except IndexError:
|
493 |
+
return await ult.answer(
|
494 |
+
[], switch_pm="Enter Query to Search..", switch_pm_param="start"
|
495 |
+
)
|
496 |
+
if _koo_.get(match):
|
497 |
+
return await ult.answer(
|
498 |
+
_koo_[match], switch_pm="• Koo Search •", switch_pm_param="start"
|
499 |
+
)
|
500 |
+
res = []
|
501 |
+
se_ = None
|
502 |
+
key_count = None
|
503 |
+
if " | " in match:
|
504 |
+
match = match.split(" | ", maxsplit=1)
|
505 |
+
try:
|
506 |
+
key_count = int(match[1])
|
507 |
+
except ValueError:
|
508 |
+
pass
|
509 |
+
match = match[0]
|
510 |
+
match = match.replace(" ", "+")
|
511 |
+
req = await async_searcher(
|
512 |
+
f"https://www.kooapp.com/apiV1/search?query={match}&searchType=EXPLORE",
|
513 |
+
re_json=True,
|
514 |
+
)
|
515 |
+
if key_count:
|
516 |
+
try:
|
517 |
+
se_ = [req["feed"][key_count - 1]]
|
518 |
+
except KeyError:
|
519 |
+
pass
|
520 |
+
if not se_:
|
521 |
+
se_ = req["feed"]
|
522 |
+
for count, feed in enumerate(se_[:10]):
|
523 |
+
if feed["uiItemType"] == "search_profile":
|
524 |
+
count += 1
|
525 |
+
item = feed["items"][0]
|
526 |
+
profileImage = (
|
527 |
+
item["profileImageBaseUrl"]
|
528 |
+
if item.get("profileImageBaseUrl")
|
529 |
+
else "https://telegra.ph/file/dc28e69bd7ea2c0f25329.jpg"
|
530 |
+
)
|
531 |
+
extra = await async_searcher(
|
532 |
+
"https://www.kooapp.com/apiV1/users/handle/" + item["userHandle"],
|
533 |
+
re_json=True,
|
534 |
+
)
|
535 |
+
img = wb(profileImage, 0, "image/jpeg", [])
|
536 |
+
text = f"‣ **Name :** `{item['name']}`"
|
537 |
+
if extra.get("title"):
|
538 |
+
text += f"\n‣ **Title :** `{extra['title']}`"
|
539 |
+
text += f"\n‣ **Username :** `@{item['userHandle']}`"
|
540 |
+
if extra.get("description"):
|
541 |
+
text += f"\n‣ **Description :** `{extra['description']}`"
|
542 |
+
text += f"\n‣ **Followers :** `{extra['followerCount']}` ‣ **Following :** {extra['followingCount']}"
|
543 |
+
if extra.get("socialProfile") and extra["socialProfile"].get("website"):
|
544 |
+
text += f"\n‣ **Website :** {extra['socialProfile']['website']}"
|
545 |
+
res.append(
|
546 |
+
await ult.builder.article(
|
547 |
+
title=item["name"],
|
548 |
+
description=item.get("title") or f"@{item['userHandle']}",
|
549 |
+
type="photo",
|
550 |
+
content=img,
|
551 |
+
thumb=img,
|
552 |
+
include_media=True,
|
553 |
+
text=text,
|
554 |
+
buttons=[
|
555 |
+
Button.url(
|
556 |
+
"View", "https://kooapp.com/profile/" + item["userHandle"]
|
557 |
+
),
|
558 |
+
Button.switch_inline(
|
559 |
+
"• Share •",
|
560 |
+
query=ult.text if key_count else ult.text + f" | {count}",
|
561 |
+
),
|
562 |
+
],
|
563 |
+
)
|
564 |
+
)
|
565 |
+
if not res:
|
566 |
+
switch = "No Results Found :("
|
567 |
+
else:
|
568 |
+
_koo_.update({match_: res})
|
569 |
+
switch = f"Showing {len(res)} Results!"
|
570 |
+
await ult.answer(res, switch_pm=switch, switch_pm_param="start")
|
571 |
+
|
572 |
+
|
573 |
+
# Thanks to OpenSource
|
574 |
+
_bearer_collected = [
|
575 |
+
"AAAAAAAAAAAAAAAAAAAAALIKKgEAAAAA1DRuS%2BI7ZRKiagD6KHYmreaXomo%3DP5Vaje4UTtEkODg0fX7nCh5laSrchhtLxeyEqxXpv0w9ZKspLD",
|
576 |
+
"AAAAAAAAAAAAAAAAAAAAAL5iUAEAAAAAmo6FYRjqdKlI3cNziIm%2BHUQB9Xs%3DS31pj0mxARMTOk2g9dvQ1yP9wknvY4FPBPUlE00smJcncw4dPR",
|
577 |
+
"AAAAAAAAAAAAAAAAAAAAAN6sVgEAAAAAMMjMMWrwgGyv7YQOWN%2FSAsO5SGM%3Dg8MG9Jq93Rlllaok6eht7HvRCruN4Vpzp4NaVsZaaHHWSTzKI8",
|
578 |
+
]
|
579 |
+
|
580 |
+
|
581 |
+
@in_pattern("twitter", owner=True)
|
582 |
+
async def twitter_search(event):
|
583 |
+
try:
|
584 |
+
match = event.text.split(maxsplit=1)[1].lower()
|
585 |
+
except IndexError:
|
586 |
+
return await event.answer(
|
587 |
+
[], switch_pm="Enter Query to Search", switch_pm_param="start"
|
588 |
+
)
|
589 |
+
try:
|
590 |
+
return await event.answer(
|
591 |
+
_ult_cache["twitter"][match],
|
592 |
+
switch_pm="• Twitter Search •",
|
593 |
+
switch_pm_param="start",
|
594 |
+
)
|
595 |
+
except KeyError:
|
596 |
+
pass
|
597 |
+
headers = {"Authorization": "bearer " + choice(_bearer_collected)}
|
598 |
+
res = await async_searcher(
|
599 |
+
f"https://api.twitter.com/1.1/users/search.json?q={match}",
|
600 |
+
headers=headers,
|
601 |
+
re_json=True,
|
602 |
+
)
|
603 |
+
reso = []
|
604 |
+
for user in res:
|
605 |
+
thumb = wb(user["profile_image_url_https"], 0, "image/jpeg", [])
|
606 |
+
if user.get("profile_banner_url"):
|
607 |
+
url = user["profile_banner_url"]
|
608 |
+
text = f"[\xad]({url})• **Name :** `{user['name']}`\n"
|
609 |
+
else:
|
610 |
+
text = f"• **Name :** `{user['name']}`\n"
|
611 |
+
text += f"• **Description :** `{user['description']}`\n"
|
612 |
+
text += f"• **Username :** `@{user['screen_name']}`\n"
|
613 |
+
text += f"• **Followers :** `{user['followers_count']}` • **Following :** `{user['friends_count']}`\n"
|
614 |
+
pro_ = "https://twitter.com/" + user["screen_name"]
|
615 |
+
text += f"• **Link :** [Click Here]({pro_})\n_"
|
616 |
+
reso.append(
|
617 |
+
await event.builder.article(
|
618 |
+
title=user["name"],
|
619 |
+
description=user["description"],
|
620 |
+
url=pro_,
|
621 |
+
text=text,
|
622 |
+
thumb=thumb,
|
623 |
+
)
|
624 |
+
)
|
625 |
+
swi_ = "No User Found :(" if not reso else f"🐦 Showing {len(reso)} Results!"
|
626 |
+
await event.answer(reso, switch_pm=swi_, switch_pm_param="start")
|
627 |
+
if _ult_cache.get("twitter"):
|
628 |
+
_ult_cache["twitter"].update({match: reso})
|
629 |
+
else:
|
630 |
+
_ult_cache.update({"twitter": {match: reso}})
|
631 |
+
|
632 |
+
|
633 |
+
_savn_cache = {}
|
634 |
+
|
635 |
+
|
636 |
+
@in_pattern("saavn", owner=True)
|
637 |
+
async def savn_s(event):
|
638 |
+
try:
|
639 |
+
query = event.text.split(maxsplit=1)[1].lower()
|
640 |
+
except IndexError:
|
641 |
+
return await event.answer(
|
642 |
+
[], switch_pm="Enter Query to search 🔍", switch_pm_param="start"
|
643 |
+
)
|
644 |
+
if query in _savn_cache:
|
645 |
+
return await event.answer(
|
646 |
+
_savn_cache[query],
|
647 |
+
switch_pm=f"Showing Results for {query}",
|
648 |
+
switch_pm_param="start",
|
649 |
+
)
|
650 |
+
results = await saavn_search(query)
|
651 |
+
swi = "No Results Found!" if not results else "🎵 Saavn Search"
|
652 |
+
res = []
|
653 |
+
for song in results:
|
654 |
+
thumb = wb(song["image"], 0, "image/jpeg", [])
|
655 |
+
text = f"• **Title :** {song['song']}"
|
656 |
+
text += f"\n• **Year :** {song['year']}"
|
657 |
+
text += f"\n• **Lang :** {song['language']}"
|
658 |
+
text += f"\n• **Artist :** {song['primary_artists']}"
|
659 |
+
text += f"\n• **Release Date :** {song['release_date']}"
|
660 |
+
res.append(
|
661 |
+
await event.builder.article(
|
662 |
+
title=song["song"],
|
663 |
+
type="audio",
|
664 |
+
text=text,
|
665 |
+
include_media=True,
|
666 |
+
buttons=Button.switch_inline(
|
667 |
+
"Search Again 🔍", query="saavn", same_peer=True
|
668 |
+
),
|
669 |
+
thumb=thumb,
|
670 |
+
content=wb(
|
671 |
+
song["media_url"],
|
672 |
+
0,
|
673 |
+
"audio/mp4",
|
674 |
+
[
|
675 |
+
Audio(
|
676 |
+
title=song["song"],
|
677 |
+
duration=int(song["duration"]),
|
678 |
+
performer=song["primary_artists"],
|
679 |
+
)
|
680 |
+
],
|
681 |
+
),
|
682 |
+
)
|
683 |
+
)
|
684 |
+
await event.answer(res, switch_pm=swi, switch_pm_param="start")
|
685 |
+
_savn_cache.update({query: res})
|
assistant/localization.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -32,7 +32,7 @@ async def settt(event):
|
|
32 |
lang = event.data_match.group(1).decode("UTF-8")
|
33 |
languages = get_languages()
|
34 |
language[0] = lang
|
35 |
-
udB.
|
36 |
await event.edit(
|
37 |
f"Your language has been set to {languages[lang]['natively']} [{lang}].",
|
38 |
buttons=get_back_button("lang"),
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
32 |
lang = event.data_match.group(1).decode("UTF-8")
|
33 |
languages = get_languages()
|
34 |
language[0] = lang
|
35 |
+
udB.del_key("language") if lang == "en" else udB.set_key("language", lang)
|
36 |
await event.edit(
|
37 |
f"Your language has been set to {languages[lang]['natively']} [{lang}].",
|
38 |
buttons=get_back_button("lang"),
|
assistant/manager/__init__.py
CHANGED
@@ -1,10 +1,11 @@
|
|
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 |
-
from pyUltroid.misc._decorators import ultroid_cmd
|
10 |
from pyUltroid.functions.helper import inline_mention
|
|
|
|
|
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 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 pyUltroid.functions.helper import inline_mention
|
9 |
+
from pyUltroid.misc._decorators import ultroid_cmd
|
10 |
+
|
11 |
+
from .. import *
|
assistant/manager/_help.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -44,6 +44,7 @@ UTILITIES = """
|
|
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.
|
@@ -75,11 +76,15 @@ MISC = """
|
|
75 |
|
76 |
• /joke : Get Random Jokes.
|
77 |
• /decide : Decide Something..
|
|
|
|
|
|
|
|
|
78 |
"""
|
79 |
|
80 |
STRINGS = {"Admintools": ADMINTOOLS, "locks": LOCKS, "Utils": UTILITIES, "Misc": MISC}
|
81 |
|
82 |
-
MNGE = udB.
|
83 |
|
84 |
|
85 |
def get_buttons():
|
@@ -105,11 +110,10 @@ async def helpish(event):
|
|
105 |
"Contact me in PM for help!", buttons=Button.url("Click me for Help", url)
|
106 |
)
|
107 |
if str(event.sender_id) in owner_and_sudos() and (
|
108 |
-
udB.
|
109 |
):
|
110 |
return
|
111 |
-
|
112 |
-
await event.reply(START, buttons=BTTS)
|
113 |
|
114 |
|
115 |
@callback("mngbtn", owner=True)
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
44 |
• /info (reply/username/id) : get detailed info of user.
|
45 |
• /id : get chat/user id.
|
46 |
• /tr : Translate Languages..
|
47 |
+
• /q : Create Quotes.
|
48 |
|
49 |
• /paste (reply file/text) : paste content on Spaceb.in
|
50 |
• /meaning (text) : Get Meaning of that Word.
|
|
|
76 |
|
77 |
• /joke : Get Random Jokes.
|
78 |
• /decide : Decide Something..
|
79 |
+
|
80 |
+
**✘ Stickertools ✘**
|
81 |
+
• /kang : add sticker to your pack.
|
82 |
+
• /listpack : get all of yours pack..
|
83 |
"""
|
84 |
|
85 |
STRINGS = {"Admintools": ADMINTOOLS, "locks": LOCKS, "Utils": UTILITIES, "Misc": MISC}
|
86 |
|
87 |
+
MNGE = udB.get_key("MNGR_EMOJI") or "•"
|
88 |
|
89 |
|
90 |
def get_buttons():
|
|
|
110 |
"Contact me in PM for help!", buttons=Button.url("Click me for Help", url)
|
111 |
)
|
112 |
if str(event.sender_id) in owner_and_sudos() and (
|
113 |
+
udB.get_key("DUAL_MODE") and (udB.get_key("DUAL_HNDLR") == "/")
|
114 |
):
|
115 |
return
|
116 |
+
await event.reply(START, buttons=get_buttons())
|
|
|
117 |
|
118 |
|
119 |
@callback("mngbtn", owner=True)
|
assistant/manager/_on_adds.py
CHANGED
@@ -1,20 +1,21 @@
|
|
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 |
from telethon import events
|
10 |
|
|
|
|
|
11 |
|
12 |
-
@asst.on(events.ChatAction(func=
|
13 |
async def dueha(e):
|
14 |
user = await e.get_user()
|
15 |
if not user.is_self:
|
16 |
return
|
17 |
-
sm = udB.
|
18 |
if sm == "OFF":
|
19 |
return
|
20 |
if not sm:
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
6 |
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
7 |
|
|
|
8 |
from telethon import events
|
9 |
|
10 |
+
from . import *
|
11 |
+
|
12 |
|
13 |
+
@asst.on(events.ChatAction(func=lambda x: x.user_added))
|
14 |
async def dueha(e):
|
15 |
user = await e.get_user()
|
16 |
if not user.is_self:
|
17 |
return
|
18 |
+
sm = udB.get_key("ON_MNGR_ADD")
|
19 |
if sm == "OFF":
|
20 |
return
|
21 |
if not sm:
|
assistant/manager/admins.py
CHANGED
@@ -1,38 +1,49 @@
|
|
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="
|
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(
|
18 |
try:
|
19 |
await replied.delete()
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
22 |
except Exception as E:
|
23 |
-
await eor(
|
24 |
|
25 |
|
26 |
-
@
|
27 |
-
async def
|
28 |
-
|
29 |
-
if
|
30 |
-
|
31 |
-
else:
|
32 |
-
return await eor(e, "Reply to a message...")
|
33 |
try:
|
34 |
-
await
|
35 |
-
|
36 |
-
await
|
37 |
-
|
38 |
-
await
|
|
|
|
|
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 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 pyUltroid import _ult_cache
|
11 |
+
from telethon.errors.rpcerrorlist import UserNotParticipantError
|
12 |
+
|
13 |
from . import *
|
14 |
|
15 |
|
16 |
+
@ultroid_cmd(pattern="d(kick|ban)", manager=True, require="ban_users")
|
17 |
async def dowj(e):
|
18 |
replied = await e.get_reply_message()
|
19 |
if replied:
|
20 |
user = replied.sender_id
|
21 |
else:
|
22 |
+
return await e.eor("Reply to a message...")
|
23 |
try:
|
24 |
await replied.delete()
|
25 |
+
if e.pattern_match.group(1) == "kick":
|
26 |
+
await e.client.kick_participant(e.chat_id, user)
|
27 |
+
te = "Kicked"
|
28 |
+
else:
|
29 |
+
await e.client.edit_permissions(e.chat_id, user, view_messages=False)
|
30 |
+
te = "Banned"
|
31 |
+
await e.eor(f"{te} Successfully!")
|
32 |
except Exception as E:
|
33 |
+
await e.eor(str(E))
|
34 |
|
35 |
|
36 |
+
@callback(re.compile("cc_(.*)"), func=_ult_cache.get("admin_callback"))
|
37 |
+
async def callback_(event):
|
38 |
+
data = event.data_match.group(1).decode("utf-8")
|
39 |
+
if data not in _ult_cache.get("admin_callback", {}):
|
40 |
+
return
|
|
|
|
|
41 |
try:
|
42 |
+
perm = await event.client.get_permissions(event.chat_id, event.sender_id)
|
43 |
+
except UserNotParticipantError:
|
44 |
+
return await event.answer("Join the Group First!", alert=True)
|
45 |
+
if not perm.is_admin:
|
46 |
+
return await event.answer("You are not an Admin!", alert=True)
|
47 |
+
_ult_cache["admin_callback"].update({data: (event.sender, perm)})
|
48 |
+
await event.answer("Verification Done!")
|
49 |
+
await event.delete()
|
assistant/manager/afk.py
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
+
#
|
4 |
+
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
+
# PLease read the GNU Affero General Public License in
|
6 |
+
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
7 |
+
|
8 |
+
from datetime import datetime as dt
|
9 |
+
|
10 |
+
from pyUltroid.functions.helper import inline_mention, time_formatter
|
11 |
+
from telethon.events import NewMessage
|
12 |
+
from telethon.tl.types import (
|
13 |
+
Message,
|
14 |
+
MessageEntityMention,
|
15 |
+
MessageEntityMentionName,
|
16 |
+
User,
|
17 |
+
)
|
18 |
+
from telethon.utils import get_display_name
|
19 |
+
|
20 |
+
from . import asst, asst_cmd
|
21 |
+
|
22 |
+
AFK = {}
|
23 |
+
|
24 |
+
|
25 |
+
@asst_cmd(pattern="afk", func=lambda x: not x.is_private)
|
26 |
+
async def go_afk(event):
|
27 |
+
sender = await event.get_sender()
|
28 |
+
if (not isinstance(sender, User)) or sender.bot:
|
29 |
+
return
|
30 |
+
try:
|
31 |
+
reason = event.text.split(" ", maxsplit=1)[1]
|
32 |
+
except IndexError:
|
33 |
+
reason = None
|
34 |
+
if event.is_reply and not reason:
|
35 |
+
replied = await event.get_reply_message()
|
36 |
+
if not reason and replied.text and not replied.media:
|
37 |
+
reason = replied.text
|
38 |
+
else:
|
39 |
+
reason = replied
|
40 |
+
time_ = dt.now()
|
41 |
+
if AFK.get(event.chat_id):
|
42 |
+
AFK[event.chat_id].update({event.sender_id: {"reason": reason, "time": time_}})
|
43 |
+
else:
|
44 |
+
AFK.update(
|
45 |
+
{event.chat_id: {event.sender_id: {"reason": reason, "time": time_}}}
|
46 |
+
)
|
47 |
+
mention = inline_mention(sender)
|
48 |
+
msg = f"**{mention} went AFK Now!**"
|
49 |
+
if reason and not isinstance(reason, str):
|
50 |
+
await event.reply(reason)
|
51 |
+
else:
|
52 |
+
msg += f"\n\n**Reason : ** `{reason}`"
|
53 |
+
await event.reply(msg)
|
54 |
+
|
55 |
+
|
56 |
+
@asst.on(NewMessage(func=lambda x: AFK.get(x.chat_id) and not x.is_private))
|
57 |
+
async def make_change(event):
|
58 |
+
if event.text.startswith("/afk"):
|
59 |
+
return
|
60 |
+
sender = await event.get_sender()
|
61 |
+
if (not isinstance(sender, User)) or sender.bot:
|
62 |
+
return
|
63 |
+
chat_ = AFK[event.chat_id]
|
64 |
+
if event.sender_id in chat_.keys():
|
65 |
+
name = get_display_name(event.sender)
|
66 |
+
cha_send = chat_[event.sender_id]
|
67 |
+
time_ = time_formatter((dt.now() - cha_send["time"]).seconds * 1000)
|
68 |
+
msg = f"**{name}** is No Longer AFK!\n**Was AFK for** {time_}"
|
69 |
+
await event.reply(msg)
|
70 |
+
del chat_[event.sender_id]
|
71 |
+
if not chat_:
|
72 |
+
del AFK[event.chat_id]
|
73 |
+
ST_SPAM = []
|
74 |
+
replied = await event.get_reply_message()
|
75 |
+
if replied:
|
76 |
+
name = get_display_name(replied.sender)
|
77 |
+
if replied.sender_id in chat_.keys():
|
78 |
+
s_der = chat_[replied.sender_id]
|
79 |
+
res_ = s_der["reason"]
|
80 |
+
time_ = time_formatter((dt.now() - s_der["time"]).seconds * 1000)
|
81 |
+
msg = f"**{name}** is AFK Currently!\n**From :** {time_}"
|
82 |
+
if res_ and isinstance(res_, str):
|
83 |
+
msg += f"\n**Reason :** {res_}"
|
84 |
+
elif res_ and isinstance(res_, Message):
|
85 |
+
await event.reply(res_)
|
86 |
+
await event.reply(msg)
|
87 |
+
ST_SPAM.append(replied.sender_id)
|
88 |
+
for ent, text in event.get_entities_text():
|
89 |
+
dont_send, entity = None, None
|
90 |
+
if isinstance(ent, MessageEntityMentionName):
|
91 |
+
c_id = ent.user_id
|
92 |
+
elif isinstance(ent, MessageEntityMention):
|
93 |
+
c_id = text
|
94 |
+
else:
|
95 |
+
c_id = None
|
96 |
+
if c_id:
|
97 |
+
entity = await event.client.get_entity(c_id)
|
98 |
+
if entity and entity.id in chat_.keys() and entity.id not in ST_SPAM:
|
99 |
+
ST_SPAM.append(entity.id)
|
100 |
+
s_der = chat_[entity.id]
|
101 |
+
name = get_display_name(entity)
|
102 |
+
res_ = s_der["reason"]
|
103 |
+
time_ = time_formatter((dt.now() - s_der["time"]).seconds * 1000)
|
104 |
+
msg = f"**{name}** is AFK Currently!\n**From :** {time_}"
|
105 |
+
if res_ and isinstance(res_, str):
|
106 |
+
msg += f"\n**Reason :** {res_}"
|
107 |
+
elif res_ and isinstance(res_, Message):
|
108 |
+
await event.reply(res_)
|
109 |
+
await event.reply(msg)
|
assistant/manager/misc.py
CHANGED
@@ -1,27 +1,28 @@
|
|
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 |
import random
|
|
|
|
|
11 |
from pyUltroid.dB import DEVLIST
|
|
|
12 |
from . import *
|
13 |
|
14 |
|
15 |
-
@
|
16 |
async def dheh(e):
|
17 |
text = ["Yes", "NoU", "Maybe", "IDK"]
|
18 |
text = random.choice(text)
|
19 |
-
ri = e.id
|
20 |
-
if e.is_reply:
|
21 |
-
ri = e.reply_to_msg_id
|
22 |
await e.client.send_message(e.chat_id, text, reply_to=ri)
|
23 |
|
24 |
-
|
|
|
25 |
async def oqha(e):
|
26 |
match = e.pattern_match.group(1)
|
27 |
if match:
|
@@ -31,22 +32,26 @@ async def oqha(e):
|
|
31 |
text = (await e.get_reply_message()).text
|
32 |
reply_to = e.reply_to_msg_id
|
33 |
else:
|
34 |
-
return await eor(
|
|
|
|
|
|
|
|
|
35 |
await e.client.send_message(e.chat_id, text, reply_to=reply_to)
|
36 |
|
37 |
|
38 |
-
@
|
39 |
async def doit(e):
|
40 |
if e.sender_id in DEVLIST:
|
41 |
return await eod(e, "`I will Not Kick You, my Developer..`")
|
42 |
try:
|
43 |
await e.client.kick_participant(e.chat_id, e.sender_id)
|
44 |
except Exception as Fe:
|
45 |
-
return await eor(
|
46 |
-
await eor(
|
47 |
|
48 |
|
49 |
-
@
|
50 |
async def do_joke(e):
|
51 |
e = await e.get_reply_message() if e.is_reply else e
|
52 |
link = "https://v2.jokeapi.dev/joke/Any?blacklistFlags=nsfw,religious,political,racist,sexist,explicit&type=single"
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 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 random
|
10 |
+
|
11 |
+
import aiohttp
|
12 |
from pyUltroid.dB import DEVLIST
|
13 |
+
|
14 |
from . import *
|
15 |
|
16 |
|
17 |
+
@asst_cmd(pattern="decide")
|
18 |
async def dheh(e):
|
19 |
text = ["Yes", "NoU", "Maybe", "IDK"]
|
20 |
text = random.choice(text)
|
21 |
+
ri = e.reply_to_msg_id or e.id
|
|
|
|
|
22 |
await e.client.send_message(e.chat_id, text, reply_to=ri)
|
23 |
|
24 |
+
|
25 |
+
@asst_cmd(pattern="echo ?(.*)")
|
26 |
async def oqha(e):
|
27 |
match = e.pattern_match.group(1)
|
28 |
if match:
|
|
|
32 |
text = (await e.get_reply_message()).text
|
33 |
reply_to = e.reply_to_msg_id
|
34 |
else:
|
35 |
+
return await e.eor("What to Echo?", time=5)
|
36 |
+
try:
|
37 |
+
await e.delete()
|
38 |
+
except BaseException as ex:
|
39 |
+
LOGS.error(ex)
|
40 |
await e.client.send_message(e.chat_id, text, reply_to=reply_to)
|
41 |
|
42 |
|
43 |
+
@asst_cmd(pattern="kickme$")
|
44 |
async def doit(e):
|
45 |
if e.sender_id in DEVLIST:
|
46 |
return await eod(e, "`I will Not Kick You, my Developer..`")
|
47 |
try:
|
48 |
await e.client.kick_participant(e.chat_id, e.sender_id)
|
49 |
except Exception as Fe:
|
50 |
+
return await e.eor(str(Fe), time=5)
|
51 |
+
await e.eor("Yes, You are right, get out.", time=5)
|
52 |
|
53 |
|
54 |
+
@asst_cmd(pattern="joke$")
|
55 |
async def do_joke(e):
|
56 |
e = await e.get_reply_message() if e.is_reply else e
|
57 |
link = "https://v2.jokeapi.dev/joke/Any?blacklistFlags=nsfw,religious,political,racist,sexist,explicit&type=single"
|
assistant/manager/stickermanager.py
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 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 random
|
9 |
+
|
10 |
+
from pyUltroid.functions.misc import create_quotly
|
11 |
+
from pyUltroid.functions.tools import resize_photo
|
12 |
+
from telethon import errors
|
13 |
+
from telethon.errors.rpcerrorlist import StickersetInvalidError
|
14 |
+
from telethon.tl.functions.messages import GetStickerSetRequest as GetSticker
|
15 |
+
from telethon.tl.functions.messages import UploadMediaRequest
|
16 |
+
from telethon.tl.functions.stickers import AddStickerToSetRequest as AddSticker
|
17 |
+
from telethon.tl.functions.stickers import CreateStickerSetRequest
|
18 |
+
from telethon.tl.types import InputPeerSelf
|
19 |
+
from telethon.tl.types import InputStickerSetItem as SetItem
|
20 |
+
from telethon.tl.types import InputStickerSetShortName, User
|
21 |
+
from telethon.utils import get_display_name, get_input_document
|
22 |
+
|
23 |
+
from . import LOGS, asst, asst_cmd, udB
|
24 |
+
|
25 |
+
|
26 |
+
@asst_cmd(
|
27 |
+
pattern="kang",
|
28 |
+
)
|
29 |
+
async def kang_cmd(ult):
|
30 |
+
sender = await ult.get_sender()
|
31 |
+
if not isinstance(sender, User):
|
32 |
+
return
|
33 |
+
if not ult.is_reply:
|
34 |
+
return await ult.eor("`Reply to a sticker/photo..`", time=5)
|
35 |
+
reply = await ult.get_reply_message()
|
36 |
+
if sender.username:
|
37 |
+
pre = sender.username[:4]
|
38 |
+
else:
|
39 |
+
pre = random.random_string(length=3)
|
40 |
+
animated, dl = None, None
|
41 |
+
try:
|
42 |
+
emoji = ult.text.split(maxsplit=1)[1]
|
43 |
+
except IndexError:
|
44 |
+
emoji = None
|
45 |
+
if reply.sticker:
|
46 |
+
file = get_input_document(reply.sticker)
|
47 |
+
emoji = emoji or reply.file.emoji
|
48 |
+
if reply.file.name.endswith(".tgs"):
|
49 |
+
animated = True
|
50 |
+
dl = await reply.download_media()
|
51 |
+
elif reply.photo:
|
52 |
+
dl = await reply.download_media()
|
53 |
+
name = "sticker.webp"
|
54 |
+
image = resize_photo(dl)
|
55 |
+
image.save(name, "WEBP")
|
56 |
+
elif reply.text:
|
57 |
+
dl = await create_quotly(reply)
|
58 |
+
else:
|
59 |
+
return await ult.eor("`Reply to sticker or text to add it in your pack...`")
|
60 |
+
if not emoji:
|
61 |
+
emoji = "🏵"
|
62 |
+
if dl:
|
63 |
+
upl = await ult.client.upload_file(dl)
|
64 |
+
file = get_input_document(
|
65 |
+
await ult.client(UploadMediaRequest(InputPeerSelf(), upl))
|
66 |
+
)
|
67 |
+
get_ = udB.get_key("STICKERS") or {}
|
68 |
+
type_ = "static" if not animated else "anim"
|
69 |
+
if not get_.get(ult.sender_id) or not get_.get(ult.sender_id, {}).get(type_):
|
70 |
+
sn = f"{pre}_{ult.sender_id}"
|
71 |
+
title = f"{get_display_name(sender)}'s Kang Pack"
|
72 |
+
if animated:
|
73 |
+
type_ = "anim"
|
74 |
+
sn += "_anim"
|
75 |
+
title += " (Animated)"
|
76 |
+
sn += f"_by_{asst.me.username}"
|
77 |
+
try:
|
78 |
+
await asst(GetSticker(InputStickerSetShortName(sn), hash=0))
|
79 |
+
sn = sn.replace(str(ult.sender_id), f"{ult.sender_id}_{ult.id}")
|
80 |
+
except StickersetInvalidError:
|
81 |
+
pass
|
82 |
+
try:
|
83 |
+
pack = await ult.client(
|
84 |
+
CreateStickerSetRequest(
|
85 |
+
user_id=sender.id,
|
86 |
+
title=title,
|
87 |
+
short_name=sn,
|
88 |
+
stickers=[SetItem(file, emoji=emoji)],
|
89 |
+
animated=animated,
|
90 |
+
)
|
91 |
+
)
|
92 |
+
except Exception as er:
|
93 |
+
return await ult.eor(str(er))
|
94 |
+
sn = pack.set.short_name
|
95 |
+
if not get_.get(ult.sender_id):
|
96 |
+
get_.update({ult.sender_id: {type_: [sn]}})
|
97 |
+
else:
|
98 |
+
get_[ult.sender_id].update({type_: [sn]})
|
99 |
+
udB.set_key("STICKERS", get_)
|
100 |
+
return await ult.reply(
|
101 |
+
f"**Kanged Successfully!\nEmoji :** {emoji}\n**Link :** [Click Here](https://t.me/addstickers/{sn})"
|
102 |
+
)
|
103 |
+
name = get_[ult.sender_id][type_][-1]
|
104 |
+
try:
|
105 |
+
await asst(GetSticker(InputStickerSetShortName(name), hash=0))
|
106 |
+
except StickersetInvalidError:
|
107 |
+
get_[ult.sender_id][type_].remove(name)
|
108 |
+
try:
|
109 |
+
await asst(
|
110 |
+
AddSticker(InputStickerSetShortName(name), SetItem(file, emoji=emoji))
|
111 |
+
)
|
112 |
+
except (errors.StickerpackStickersTooMuchError, errors.StickersTooMuchError):
|
113 |
+
sn = f"{pre}{ult.sender_id}_{ult.id}"
|
114 |
+
title = f"{get_display_name(sender)}'s Kang Pack"
|
115 |
+
if animated:
|
116 |
+
sn += "_anim"
|
117 |
+
title += " (Animated)"
|
118 |
+
sn += f"_by_{asst.me.username}"
|
119 |
+
try:
|
120 |
+
pack = await ult.client(
|
121 |
+
CreateStickerSetRequest(
|
122 |
+
user_id=sender.id,
|
123 |
+
title=title,
|
124 |
+
short_name=sn,
|
125 |
+
stickers=[SetItem(file, emoji=emoji)],
|
126 |
+
animated=animated,
|
127 |
+
)
|
128 |
+
)
|
129 |
+
except Exception as er:
|
130 |
+
return await ult.eor(str(er))
|
131 |
+
get_[ult.sender_id][type_].append(pack.set.short_name)
|
132 |
+
udB.set_key("STICKERS", get_)
|
133 |
+
return await ult.reply(
|
134 |
+
f"**Created New Kang Pack!\nEmoji :** {emoji}\n**Link :** [Click Here](https://t.me/addstickers/{sn})"
|
135 |
+
)
|
136 |
+
except Exception as er:
|
137 |
+
LOGS.exception(er)
|
138 |
+
return await ult.reply(str(er))
|
139 |
+
await ult.reply(
|
140 |
+
f"Sticker Added to Pack Successfully\n**Link :** [Click Here](https://t.me/addstickers/{name})"
|
141 |
+
)
|
142 |
+
|
143 |
+
|
144 |
+
@asst_cmd(pattern="listpack")
|
145 |
+
async def do_magic(ult):
|
146 |
+
ko = udB.get_key("STICKERS") or {}
|
147 |
+
if not ko.get(ult.sender_id):
|
148 |
+
return await ult.reply("No Sticker Pack Found!")
|
149 |
+
al_ = []
|
150 |
+
ul = ko[ult.sender_id]
|
151 |
+
if ul.get("static"):
|
152 |
+
al_.extend(ul["static"])
|
153 |
+
if ul.get("anim"):
|
154 |
+
al_.extend(ul["anim"])
|
155 |
+
msg = "• **Stickers Owned by You!**\n\n"
|
156 |
+
for _ in al_:
|
157 |
+
try:
|
158 |
+
pack = await ult.client(GetSticker(InputStickerSetShortName(_), hash=0))
|
159 |
+
msg += f"• [{pack.set.title}](https://t.me/addstickers/{_})\n"
|
160 |
+
except StickerSetInvalidError:
|
161 |
+
if ul.get("anim") and _ in ul["anim"]:
|
162 |
+
ul["anim"].remove(_)
|
163 |
+
else:
|
164 |
+
ul["static"].remove(_)
|
165 |
+
udB.set_key("STICKERS", ko)
|
166 |
+
await ult.reply(msg)
|
assistant/pmbot.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -9,10 +9,11 @@
|
|
9 |
|
10 |
# --------------------------------------- Imports -------------------------------------------- #
|
11 |
|
|
|
|
|
12 |
from pyUltroid.dB.asst_fns import *
|
13 |
from pyUltroid.dB.botchat_db import *
|
14 |
from pyUltroid.functions.helper import inline_mention
|
15 |
-
from pyUltroid.misc import owner_and_sudos
|
16 |
from telethon.errors.rpcerrorlist import UserNotParticipantError
|
17 |
from telethon.tl.custom import Button
|
18 |
from telethon.tl.functions.channels import GetFullChannelRequest
|
@@ -22,16 +23,18 @@ from telethon.utils import get_display_name
|
|
22 |
|
23 |
from . import *
|
24 |
|
25 |
-
FSUB = udB.
|
26 |
CACHE = {}
|
27 |
# --------------------------------------- Incoming -------------------------------------------- #
|
28 |
|
29 |
|
30 |
-
@asst_cmd(
|
|
|
|
|
|
|
|
|
31 |
async def on_new_mssg(event):
|
32 |
who = event.sender_id
|
33 |
-
if is_blacklisted(who):
|
34 |
-
return
|
35 |
# doesn't reply to that user anymore
|
36 |
if event.text.startswith("/") or who == OWNER_ID:
|
37 |
return
|
@@ -43,7 +46,7 @@ async def on_new_mssg(event):
|
|
43 |
await event.client.get_permissions(chat, event.sender_id)
|
44 |
except UserNotParticipantError:
|
45 |
if not MSG:
|
46 |
-
MSG += "
|
47 |
try:
|
48 |
TAHC_ = await event.client.get_entity(chat)
|
49 |
if hasattr(TAHC_, "username") and TAHC_.username:
|
@@ -81,16 +84,21 @@ async def on_new_mssg(event):
|
|
81 |
func=lambda e: e.is_private and e.is_reply,
|
82 |
)
|
83 |
async def on_out_mssg(event):
|
84 |
-
x =
|
85 |
-
to_user = get_who(x
|
86 |
if event.text.startswith("/who"):
|
87 |
try:
|
88 |
k = await asst.get_entity(to_user)
|
89 |
-
|
90 |
-
|
|
|
|
|
91 |
)
|
92 |
-
|
|
|
93 |
return
|
|
|
|
|
94 |
elif event.text.startswith("/"):
|
95 |
return
|
96 |
if to_user:
|
@@ -103,42 +111,37 @@ async def on_out_mssg(event):
|
|
103 |
@asst_cmd(
|
104 |
pattern="ban",
|
105 |
load=AST_PLUGINS,
|
106 |
-
from_users=
|
107 |
func=lambda x: x.is_private,
|
108 |
)
|
109 |
async def banhammer(event):
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
target = get_who(x.id)
|
114 |
if is_blacklisted(target):
|
115 |
-
return await event.reply("
|
116 |
|
117 |
blacklist_user(target)
|
118 |
await event.reply(f"#BAN\nUser : {target}")
|
119 |
-
await asst.send_message(
|
120 |
-
target,
|
121 |
-
"`GoodBye! You have been banned.`\n**Further messages you send will not be forwarded.**",
|
122 |
-
)
|
123 |
|
124 |
|
125 |
@asst_cmd(
|
126 |
pattern="unban",
|
127 |
load=AST_PLUGINS,
|
128 |
-
from_users=
|
129 |
func=lambda x: x.is_private,
|
130 |
)
|
131 |
async def unbanhammer(event):
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
target = get_who(x.id)
|
136 |
if not is_blacklisted(target):
|
137 |
-
return await event.reply("
|
138 |
|
139 |
rem_blacklist(target)
|
140 |
await event.reply(f"#UNBAN\nUser : {target}")
|
141 |
-
await asst.send_message(target, "
|
142 |
|
143 |
|
144 |
# --------------------------------------- END -------------------------------------------- #
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
9 |
|
10 |
# --------------------------------------- Imports -------------------------------------------- #
|
11 |
|
12 |
+
import os
|
13 |
+
|
14 |
from pyUltroid.dB.asst_fns import *
|
15 |
from pyUltroid.dB.botchat_db import *
|
16 |
from pyUltroid.functions.helper import inline_mention
|
|
|
17 |
from telethon.errors.rpcerrorlist import UserNotParticipantError
|
18 |
from telethon.tl.custom import Button
|
19 |
from telethon.tl.functions.channels import GetFullChannelRequest
|
|
|
23 |
|
24 |
from . import *
|
25 |
|
26 |
+
FSUB = udB.get_key("PMBOT_FSUB")
|
27 |
CACHE = {}
|
28 |
# --------------------------------------- Incoming -------------------------------------------- #
|
29 |
|
30 |
|
31 |
+
@asst_cmd(
|
32 |
+
load=AST_PLUGINS,
|
33 |
+
incoming=True,
|
34 |
+
func=lambda e: e.is_private and not is_blacklisted(e.sender_id),
|
35 |
+
)
|
36 |
async def on_new_mssg(event):
|
37 |
who = event.sender_id
|
|
|
|
|
38 |
# doesn't reply to that user anymore
|
39 |
if event.text.startswith("/") or who == OWNER_ID:
|
40 |
return
|
|
|
46 |
await event.client.get_permissions(chat, event.sender_id)
|
47 |
except UserNotParticipantError:
|
48 |
if not MSG:
|
49 |
+
MSG += get_string("pmbot_1")
|
50 |
try:
|
51 |
TAHC_ = await event.client.get_entity(chat)
|
52 |
if hasattr(TAHC_, "username") and TAHC_.username:
|
|
|
84 |
func=lambda e: e.is_private and e.is_reply,
|
85 |
)
|
86 |
async def on_out_mssg(event):
|
87 |
+
x = event.reply_to_msg_id
|
88 |
+
to_user = get_who(x)
|
89 |
if event.text.startswith("/who"):
|
90 |
try:
|
91 |
k = await asst.get_entity(to_user)
|
92 |
+
photu = await event.client.download_profile_photo(k.id)
|
93 |
+
await event.reply(
|
94 |
+
f"• **Name :** {get_display_name(k)}\n• **ID :** `{k.id}`\n• **Link :** {inline_mention(k)}",
|
95 |
+
file=photu,
|
96 |
)
|
97 |
+
if photu:
|
98 |
+
os.remove(photu)
|
99 |
return
|
100 |
+
except BaseException as er:
|
101 |
+
return await event.reply("**ERROR : **" + str(er))
|
102 |
elif event.text.startswith("/"):
|
103 |
return
|
104 |
if to_user:
|
|
|
111 |
@asst_cmd(
|
112 |
pattern="ban",
|
113 |
load=AST_PLUGINS,
|
114 |
+
from_users=[OWNER_ID],
|
115 |
func=lambda x: x.is_private,
|
116 |
)
|
117 |
async def banhammer(event):
|
118 |
+
if not event.is_reply:
|
119 |
+
return await event.reply(get_string("pmbot_2"))
|
120 |
+
target = get_who(event.reply_to_msg_id)
|
|
|
121 |
if is_blacklisted(target):
|
122 |
+
return await event.reply(get_string("pmbot_3"))
|
123 |
|
124 |
blacklist_user(target)
|
125 |
await event.reply(f"#BAN\nUser : {target}")
|
126 |
+
await asst.send_message(target, get_string("pmbot_4"))
|
|
|
|
|
|
|
127 |
|
128 |
|
129 |
@asst_cmd(
|
130 |
pattern="unban",
|
131 |
load=AST_PLUGINS,
|
132 |
+
from_users=[OWNER_ID],
|
133 |
func=lambda x: x.is_private,
|
134 |
)
|
135 |
async def unbanhammer(event):
|
136 |
+
if not event.is_reply:
|
137 |
+
return await event.reply(get_string("pmbot_5"))
|
138 |
+
target = get_who(event.reply_to_msg_id)
|
|
|
139 |
if not is_blacklisted(target):
|
140 |
+
return await event.reply(get_string("pmbot_6"))
|
141 |
|
142 |
rem_blacklist(target)
|
143 |
await event.reply(f"#UNBAN\nUser : {target}")
|
144 |
+
await asst.send_message(target, get_string("pmbot_7"))
|
145 |
|
146 |
|
147 |
# --------------------------------------- END -------------------------------------------- #
|
assistant/start.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -9,9 +9,8 @@ from datetime import datetime
|
|
9 |
|
10 |
from pytz import timezone as tz
|
11 |
from pyUltroid.dB.asst_fns import *
|
12 |
-
from pyUltroid.dB.sudos import is_fullsudo
|
13 |
from pyUltroid.functions.helper import inline_mention
|
14 |
-
from pyUltroid.misc import owner_and_sudos
|
15 |
from telethon import Button, events
|
16 |
from telethon.utils import get_display_name
|
17 |
|
@@ -19,30 +18,32 @@ from strings.strings import get_string
|
|
19 |
|
20 |
from . import *
|
21 |
|
22 |
-
Owner_info_msg = (
|
23 |
-
|
24 |
-
|
|
|
|
|
25 |
**Owner** - {OWNER_NAME}
|
26 |
**OwnerID** - `{OWNER_ID}`
|
27 |
|
28 |
-
**Message Forwards** - {udB.
|
29 |
|
30 |
**Ultroid [v{ultroid_version}](https://github.com/TeamUltroid/Ultroid), powered by @TeamUltroid**
|
31 |
"""
|
32 |
-
|
33 |
|
34 |
_settings = [
|
35 |
[
|
36 |
-
Button.inline("API Kᴇʏs", data="
|
37 |
-
Button.inline("Pᴍ Bᴏᴛ", data="
|
38 |
],
|
39 |
[
|
40 |
-
Button.inline("Aʟɪᴠᴇ", data="
|
41 |
-
Button.inline("PᴍPᴇʀᴍɪᴛ", data="
|
42 |
],
|
43 |
[
|
44 |
-
Button.inline("Fᴇᴀᴛᴜʀᴇs", data="
|
45 |
-
Button.inline("VC Sᴏɴɢ Bᴏᴛ", data="
|
46 |
],
|
47 |
[Button.inline("« Bᴀᴄᴋ", data="mainmenu")],
|
48 |
]
|
@@ -62,8 +63,13 @@ _start = [
|
|
62 |
|
63 |
@callback("ownerinfo")
|
64 |
async def own(event):
|
|
|
|
|
|
|
|
|
|
|
65 |
await event.edit(
|
66 |
-
|
67 |
buttons=[Button.inline("Close", data="closeit")],
|
68 |
link_preview=False,
|
69 |
)
|
@@ -76,45 +82,55 @@ async def closet(lol):
|
|
76 |
|
77 |
@asst_cmd(pattern="start ?(.*)", forwards=False, func=lambda x: not x.is_group)
|
78 |
async def ultroid(event):
|
79 |
-
|
|
|
80 |
add_user(event.sender_id)
|
81 |
-
kak_uiw = udB.
|
82 |
-
if not kak_uiw or kak_uiw !=
|
83 |
msg = f"{inline_mention(event.sender)} `[{event.sender_id}]` started your [Assistant bot](@{asst.me.username})."
|
84 |
buttons = [[Button.inline("Info", "itkkstyo")]]
|
85 |
if event.sender.username:
|
86 |
-
buttons[0].append(
|
|
|
|
|
|
|
|
|
87 |
await event.client.send_message(
|
88 |
-
|
89 |
)
|
90 |
-
if
|
91 |
ok = ""
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
95 |
ok = "You can contact my master using this bot!!\n\nSend your Message, I will Deliver it To Master."
|
96 |
await event.reply(
|
97 |
-
f"Hey there
|
98 |
-
file=udB.
|
99 |
buttons=[Button.inline("Info.", data="ownerinfo")]
|
100 |
-
if Owner_info_msg
|
101 |
else None,
|
102 |
)
|
103 |
else:
|
104 |
-
me = f"[{ultroid_bot.me.first_name}](tg://user?id={ultroid_bot.uid})"
|
105 |
-
mention = f"[{get_display_name(u)}](tg://user?id={u.id})"
|
106 |
await event.reply(
|
107 |
-
udB.
|
108 |
-
file=udB.
|
109 |
-
buttons=[Button.inline("Info.", data="ownerinfo")]
|
|
|
|
|
110 |
)
|
111 |
else:
|
112 |
-
name = get_display_name(event.
|
113 |
-
if
|
114 |
await event.reply(
|
115 |
"Choose from the below options -",
|
116 |
buttons=_settings,
|
117 |
)
|
|
|
|
|
118 |
else:
|
119 |
await event.reply(
|
120 |
get_string("ast_3").format(name),
|
@@ -124,7 +140,7 @@ async def ultroid(event):
|
|
124 |
|
125 |
@callback("itkkstyo", owner=True)
|
126 |
async def ekekdhdb(e):
|
127 |
-
text = f"When New Visitor will visit your Assistant Bot. You will get this log message!\n\nTo Disable : {HNDLR}
|
128 |
await e.answer(text, alert=True)
|
129 |
|
130 |
|
@@ -138,7 +154,7 @@ async def ultroid(event):
|
|
138 |
|
139 |
@callback("stat", owner=True)
|
140 |
async def botstat(event):
|
141 |
-
ok = len(get_all_users())
|
142 |
msg = """Ultroid Assistant - Stats
|
143 |
Total Users - {}""".format(
|
144 |
ok,
|
@@ -148,7 +164,7 @@ Total Users - {}""".format(
|
|
148 |
|
149 |
@callback("bcast", owner=True)
|
150 |
async def bdcast(event):
|
151 |
-
ok = get_all_users()
|
152 |
await event.edit(f"• Broadcast to {len(ok)} users.")
|
153 |
async with event.client.conversation(OWNER_ID) as conv:
|
154 |
await conv.send_message(
|
@@ -163,7 +179,7 @@ async def bdcast(event):
|
|
163 |
start = datetime.now()
|
164 |
for i in ok:
|
165 |
try:
|
166 |
-
await asst.send_message(int(i), response
|
167 |
success += 1
|
168 |
except BaseException:
|
169 |
fail += 1
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
9 |
|
10 |
from pytz import timezone as tz
|
11 |
from pyUltroid.dB.asst_fns import *
|
|
|
12 |
from pyUltroid.functions.helper import inline_mention
|
13 |
+
from pyUltroid.misc import SUDO_M, owner_and_sudos
|
14 |
from telethon import Button, events
|
15 |
from telethon.utils import get_display_name
|
16 |
|
|
|
18 |
|
19 |
from . import *
|
20 |
|
21 |
+
Owner_info_msg = udB.get_key("BOT_INFO_START")
|
22 |
+
custom_info = True
|
23 |
+
if Owner_info_msg is None:
|
24 |
+
custom_info = False
|
25 |
+
Owner_info_msg = f"""
|
26 |
**Owner** - {OWNER_NAME}
|
27 |
**OwnerID** - `{OWNER_ID}`
|
28 |
|
29 |
+
**Message Forwards** - {udB.get_key("PMBOT")}
|
30 |
|
31 |
**Ultroid [v{ultroid_version}](https://github.com/TeamUltroid/Ultroid), powered by @TeamUltroid**
|
32 |
"""
|
33 |
+
|
34 |
|
35 |
_settings = [
|
36 |
[
|
37 |
+
Button.inline("API Kᴇʏs", data="cbs_apiset"),
|
38 |
+
Button.inline("Pᴍ Bᴏᴛ", data="cbs_chatbot"),
|
39 |
],
|
40 |
[
|
41 |
+
Button.inline("Aʟɪᴠᴇ", data="cbs_alvcstm"),
|
42 |
+
Button.inline("PᴍPᴇʀᴍɪᴛ", data="cbs_ppmset"),
|
43 |
],
|
44 |
[
|
45 |
+
Button.inline("Fᴇᴀᴛᴜʀᴇs", data="cbs_otvars"),
|
46 |
+
Button.inline("VC Sᴏɴɢ Bᴏᴛ", data="cbs_vcb"),
|
47 |
],
|
48 |
[Button.inline("« Bᴀᴄᴋ", data="mainmenu")],
|
49 |
]
|
|
|
63 |
|
64 |
@callback("ownerinfo")
|
65 |
async def own(event):
|
66 |
+
msg = Owner_info_msg.format(
|
67 |
+
mention=event.sender.mention, me=inline_mention(ultroid_bot.me)
|
68 |
+
)
|
69 |
+
if custom_info:
|
70 |
+
msg += "\n\n• Powered by **@TheUltroid**"
|
71 |
await event.edit(
|
72 |
+
msg,
|
73 |
buttons=[Button.inline("Close", data="closeit")],
|
74 |
link_preview=False,
|
75 |
)
|
|
|
82 |
|
83 |
@asst_cmd(pattern="start ?(.*)", forwards=False, func=lambda x: not x.is_group)
|
84 |
async def ultroid(event):
|
85 |
+
args = event.pattern_match.group(1)
|
86 |
+
if not is_added(event.sender_id) and event.sender_id not in owner_and_sudos():
|
87 |
add_user(event.sender_id)
|
88 |
+
kak_uiw = udB.get_key("OFF_START_LOG")
|
89 |
+
if not kak_uiw or kak_uiw != True:
|
90 |
msg = f"{inline_mention(event.sender)} `[{event.sender_id}]` started your [Assistant bot](@{asst.me.username})."
|
91 |
buttons = [[Button.inline("Info", "itkkstyo")]]
|
92 |
if event.sender.username:
|
93 |
+
buttons[0].append(
|
94 |
+
Button.mention(
|
95 |
+
"User", await event.client.get_input_entity(event.sender_id)
|
96 |
+
)
|
97 |
+
)
|
98 |
await event.client.send_message(
|
99 |
+
udB.get_key("LOG_CHANNEL"), msg, buttons=buttons
|
100 |
)
|
101 |
+
if event.sender_id not in SUDO_M.fullsudos:
|
102 |
ok = ""
|
103 |
+
me = inline_mention(ultroid_bot.me)
|
104 |
+
mention = inline_mention(event.sender)
|
105 |
+
if args and args != "set":
|
106 |
+
await get_stored_file(event, args)
|
107 |
+
if not udB.get_key("STARTMSG"):
|
108 |
+
if udB.get_key("PMBOT"):
|
109 |
ok = "You can contact my master using this bot!!\n\nSend your Message, I will Deliver it To Master."
|
110 |
await event.reply(
|
111 |
+
f"Hey there {mention}, this is Ultroid Assistant of {me}!\n\n{ok}",
|
112 |
+
file=udB.get_key("STARTMEDIA"),
|
113 |
buttons=[Button.inline("Info.", data="ownerinfo")]
|
114 |
+
if Owner_info_msg
|
115 |
else None,
|
116 |
)
|
117 |
else:
|
|
|
|
|
118 |
await event.reply(
|
119 |
+
udB.get_key("STARTMSG").format(me=me, mention=mention),
|
120 |
+
file=udB.get_key("STARTMEDIA"),
|
121 |
+
buttons=[Button.inline("Info.", data="ownerinfo")]
|
122 |
+
if Owner_info_msg
|
123 |
+
else None,
|
124 |
)
|
125 |
else:
|
126 |
+
name = get_display_name(event.sender)
|
127 |
+
if args == "set":
|
128 |
await event.reply(
|
129 |
"Choose from the below options -",
|
130 |
buttons=_settings,
|
131 |
)
|
132 |
+
elif args:
|
133 |
+
await get_stored_file(event, args)
|
134 |
else:
|
135 |
await event.reply(
|
136 |
get_string("ast_3").format(name),
|
|
|
140 |
|
141 |
@callback("itkkstyo", owner=True)
|
142 |
async def ekekdhdb(e):
|
143 |
+
text = f"When New Visitor will visit your Assistant Bot. You will get this log message!\n\nTo Disable : {HNDLR}setdb OFF_START_LOG True"
|
144 |
await e.answer(text, alert=True)
|
145 |
|
146 |
|
|
|
154 |
|
155 |
@callback("stat", owner=True)
|
156 |
async def botstat(event):
|
157 |
+
ok = len(get_all_users("BOT_USERS"))
|
158 |
msg = """Ultroid Assistant - Stats
|
159 |
Total Users - {}""".format(
|
160 |
ok,
|
|
|
164 |
|
165 |
@callback("bcast", owner=True)
|
166 |
async def bdcast(event):
|
167 |
+
ok = get_all_users("BOT_USERS")
|
168 |
await event.edit(f"• Broadcast to {len(ok)} users.")
|
169 |
async with event.client.conversation(OWNER_ID) as conv:
|
170 |
await conv.send_message(
|
|
|
179 |
start = datetime.now()
|
180 |
for i in ok:
|
181 |
try:
|
182 |
+
await asst.send_message(int(i), response)
|
183 |
success += 1
|
184 |
except BaseException:
|
185 |
fail += 1
|
assistant/ytdl.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
# Ultroid - UserBot
|
2 |
-
# Copyright (C)
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
@@ -8,26 +8,30 @@
|
|
8 |
|
9 |
import os
|
10 |
import re
|
11 |
-
import time
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
uploader,
|
20 |
-
)
|
21 |
-
from pyUltroid.functions.ytdl import dler, get_buttons, get_data
|
22 |
from telethon import Button
|
|
|
23 |
from telethon.tl.types import DocumentAttributeAudio, DocumentAttributeVideo
|
24 |
from telethon.tl.types import InputWebDocument as wb
|
25 |
-
from youtubesearchpython import VideosSearch
|
26 |
|
27 |
-
from . import callback, in_pattern
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
ytt = "https://telegra.ph/file/afd04510c13914a06dd03.jpg"
|
30 |
_yt_base_url = "https://www.youtube.com/watch?v="
|
|
|
31 |
|
32 |
|
33 |
@in_pattern("yt", owner=True)
|
@@ -67,13 +71,34 @@ async def _(event):
|
|
67 |
)
|
68 |
thumb = f"https://i.ytimg.com/vi/{ids}/hqdefault.jpg"
|
69 |
text = f"<strong>Title:- <a href={link}>{title}</a></strong>\n"
|
70 |
-
text += f"<strong
|
71 |
-
text += f"<strong
|
72 |
-
text += f"<strong
|
73 |
-
text += f"<strong
|
74 |
-
text += f"<strong
|
75 |
desc = f"{title}\n{duration}"
|
76 |
file = wb(thumb, 0, "image/jpeg", [])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
results.append(
|
78 |
await event.builder.article(
|
79 |
type="photo",
|
@@ -84,24 +109,7 @@ async def _(event):
|
|
84 |
text=text,
|
85 |
include_media=True,
|
86 |
parse_mode="html",
|
87 |
-
buttons=
|
88 |
-
[
|
89 |
-
Button.inline("Audio", data=f"ytdl_audio_{ids}"),
|
90 |
-
Button.inline("Video", data=f"ytdl_video_{ids}"),
|
91 |
-
],
|
92 |
-
[
|
93 |
-
Button.switch_inline(
|
94 |
-
"Sᴇᴀʀᴄʜ Aɢᴀɪɴ",
|
95 |
-
query="yt ",
|
96 |
-
same_peer=True,
|
97 |
-
),
|
98 |
-
Button.switch_inline(
|
99 |
-
"Sʜᴀʀᴇ",
|
100 |
-
query=f"yt {string}",
|
101 |
-
same_peer=False,
|
102 |
-
),
|
103 |
-
],
|
104 |
-
],
|
105 |
),
|
106 |
)
|
107 |
await event.answer(results[:50])
|
@@ -109,18 +117,16 @@ async def _(event):
|
|
109 |
|
110 |
@callback(
|
111 |
re.compile(
|
112 |
-
"
|
113 |
),
|
114 |
owner=True,
|
115 |
)
|
116 |
async def _(e):
|
117 |
_e = e.pattern_match.group(1).decode("UTF-8")
|
118 |
-
_lets_split = _e.split("
|
119 |
_ytdl_data = await dler(e, _yt_base_url + _lets_split[1])
|
120 |
-
_data =
|
121 |
-
_buttons = get_buttons(
|
122 |
-
"ytdownload_" + _lets_split[0] + "_" + _lets_split[1] + ":", _data
|
123 |
-
)
|
124 |
_text = "`Select Your Format.`"
|
125 |
if not _buttons:
|
126 |
_text = "`Error downloading from YouTube.\nTry Restarting your bot.`"
|
@@ -129,26 +135,36 @@ async def _(e):
|
|
129 |
|
130 |
@callback(
|
131 |
re.compile(
|
132 |
-
"
|
133 |
),
|
134 |
owner=True,
|
135 |
)
|
136 |
async def _(event):
|
137 |
url = event.pattern_match.group(1).decode("UTF-8")
|
138 |
-
lets_split = url.split("
|
139 |
-
vid_id = lets_split[
|
140 |
link = _yt_base_url + vid_id
|
141 |
-
format =
|
|
|
|
|
|
|
|
|
142 |
if lets_split[0] == "audio":
|
143 |
opts = {
|
144 |
-
"format": str(format),
|
145 |
"addmetadata": True,
|
146 |
"key": "FFmpegMetadata",
|
147 |
"prefer_ffmpeg": True,
|
148 |
"geo_bypass": True,
|
149 |
-
"outtmpl": "%(id)s.
|
150 |
-
"quiet": True,
|
151 |
"logtostderr": False,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
}
|
153 |
ytdl_data = await dler(event, link, opts, True)
|
154 |
title = ytdl_data["title"]
|
@@ -158,16 +174,22 @@ async def _(event):
|
|
158 |
artist = ytdl_data["creator"]
|
159 |
elif ytdl_data.get("channel"):
|
160 |
artist = ytdl_data["channel"]
|
161 |
-
views = numerize(ytdl_data
|
162 |
-
await
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
164 |
)
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
|
|
171 |
)
|
172 |
attributes = [
|
173 |
DocumentAttributeAudio(
|
@@ -183,9 +205,9 @@ async def _(event):
|
|
183 |
"key": "FFmpegMetadata",
|
184 |
"prefer_ffmpeg": True,
|
185 |
"geo_bypass": True,
|
186 |
-
"outtmpl": "%(id)s.
|
187 |
"logtostderr": False,
|
188 |
-
"
|
189 |
}
|
190 |
ytdl_data = await dler(event, link, opts, True)
|
191 |
title = ytdl_data["title"]
|
@@ -195,24 +217,30 @@ async def _(event):
|
|
195 |
artist = ytdl_data["creator"]
|
196 |
elif ytdl_data.get("channel"):
|
197 |
artist = ytdl_data["channel"]
|
198 |
-
views = numerize(ytdl_data
|
199 |
-
thumb = await fast_download(
|
200 |
-
f"https://i.ytimg.com/vi/{vid_id}/hqdefault.jpg", filename=f"{title}.jpg"
|
201 |
-
)
|
202 |
-
hi, wi = ytdl_data["height"], ytdl_data["width"]
|
203 |
-
duration = ytdl_data["duration"]
|
204 |
try:
|
205 |
-
|
206 |
-
except
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
)
|
217 |
attributes = [
|
218 |
DocumentAttributeVideo(
|
@@ -222,15 +250,37 @@ async def _(event):
|
|
222 |
supports_streaming=True,
|
223 |
),
|
224 |
]
|
225 |
-
text = f"**Title:** `{title}`\n"
|
226 |
-
text += f"
|
227 |
-
text += f"
|
228 |
-
text += f"
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
8 |
|
9 |
import os
|
10 |
import re
|
|
|
11 |
|
12 |
+
try:
|
13 |
+
from PIL import Image
|
14 |
+
except ImportError:
|
15 |
+
Image = None
|
16 |
+
from pyUltroid.functions.helper import bash, fast_download, numerize, time_formatter
|
17 |
+
from pyUltroid.functions.ytdl import dler, get_buttons, get_formats
|
|
|
|
|
|
|
18 |
from telethon import Button
|
19 |
+
from telethon.errors.rpcerrorlist import FilePartLengthInvalidError, MediaEmptyError
|
20 |
from telethon.tl.types import DocumentAttributeAudio, DocumentAttributeVideo
|
21 |
from telethon.tl.types import InputWebDocument as wb
|
|
|
22 |
|
23 |
+
from . import LOGS, asst, callback, in_pattern, udB
|
24 |
+
|
25 |
+
try:
|
26 |
+
from youtubesearchpython import VideosSearch
|
27 |
+
except ImportError:
|
28 |
+
LOGS.info("'youtubesearchpython' not installed!")
|
29 |
+
VideosSearch = None
|
30 |
+
|
31 |
|
32 |
ytt = "https://telegra.ph/file/afd04510c13914a06dd03.jpg"
|
33 |
_yt_base_url = "https://www.youtube.com/watch?v="
|
34 |
+
BACK_BUTTON = {}
|
35 |
|
36 |
|
37 |
@in_pattern("yt", owner=True)
|
|
|
71 |
)
|
72 |
thumb = f"https://i.ytimg.com/vi/{ids}/hqdefault.jpg"
|
73 |
text = f"<strong>Title:- <a href={link}>{title}</a></strong>\n"
|
74 |
+
text += f"<strong>⏳ Duration:-</strong> <code>{duration}</code>\n"
|
75 |
+
text += f"<strong>👀 Views:- </strong> <code>{views}</code>\n"
|
76 |
+
text += f"<strong>🎙️ Publisher:- </strong> <code>{publisher}</code>\n"
|
77 |
+
text += f"<strong>🗓️ Published on:- </strong> <code>{published_on}</code>\n"
|
78 |
+
text += f"<strong>📝 Description:- </strong> <code>{description}</code>"
|
79 |
desc = f"{title}\n{duration}"
|
80 |
file = wb(thumb, 0, "image/jpeg", [])
|
81 |
+
buttons = [
|
82 |
+
[
|
83 |
+
Button.inline("Audio", data=f"ytdl:audio:{ids}"),
|
84 |
+
Button.inline("Video", data=f"ytdl:video:{ids}"),
|
85 |
+
],
|
86 |
+
[
|
87 |
+
Button.switch_inline(
|
88 |
+
"Sᴇᴀʀᴄʜ Aɢᴀɪɴ",
|
89 |
+
query="yt ",
|
90 |
+
same_peer=True,
|
91 |
+
),
|
92 |
+
Button.switch_inline(
|
93 |
+
"Sʜᴀʀᴇ",
|
94 |
+
query=f"yt {string}",
|
95 |
+
same_peer=False,
|
96 |
+
),
|
97 |
+
],
|
98 |
+
]
|
99 |
+
BACK_BUTTON.update(
|
100 |
+
{ids: {"text": text, "buttons": buttons, "parse_mode": "html"}}
|
101 |
+
)
|
102 |
results.append(
|
103 |
await event.builder.article(
|
104 |
type="photo",
|
|
|
109 |
text=text,
|
110 |
include_media=True,
|
111 |
parse_mode="html",
|
112 |
+
buttons=buttons,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
),
|
114 |
)
|
115 |
await event.answer(results[:50])
|
|
|
117 |
|
118 |
@callback(
|
119 |
re.compile(
|
120 |
+
"ytdl:(.*)",
|
121 |
),
|
122 |
owner=True,
|
123 |
)
|
124 |
async def _(e):
|
125 |
_e = e.pattern_match.group(1).decode("UTF-8")
|
126 |
+
_lets_split = _e.split(":")
|
127 |
_ytdl_data = await dler(e, _yt_base_url + _lets_split[1])
|
128 |
+
_data = get_formats(_lets_split[0], _lets_split[1], _ytdl_data)
|
129 |
+
_buttons = get_buttons(_data)
|
|
|
|
|
130 |
_text = "`Select Your Format.`"
|
131 |
if not _buttons:
|
132 |
_text = "`Error downloading from YouTube.\nTry Restarting your bot.`"
|
|
|
135 |
|
136 |
@callback(
|
137 |
re.compile(
|
138 |
+
"ytdownload:(.*)",
|
139 |
),
|
140 |
owner=True,
|
141 |
)
|
142 |
async def _(event):
|
143 |
url = event.pattern_match.group(1).decode("UTF-8")
|
144 |
+
lets_split = url.split(":")
|
145 |
+
vid_id = lets_split[2]
|
146 |
link = _yt_base_url + vid_id
|
147 |
+
format = lets_split[1]
|
148 |
+
try:
|
149 |
+
ext = lets_split[3]
|
150 |
+
except IndexError:
|
151 |
+
ext = "mp3"
|
152 |
if lets_split[0] == "audio":
|
153 |
opts = {
|
|
|
154 |
"addmetadata": True,
|
155 |
"key": "FFmpegMetadata",
|
156 |
"prefer_ffmpeg": True,
|
157 |
"geo_bypass": True,
|
158 |
+
"outtmpl": "%(id)s." + ext,
|
|
|
159 |
"logtostderr": False,
|
160 |
+
"postprocessors": [
|
161 |
+
{
|
162 |
+
"key": "FFmpegExtractAudio",
|
163 |
+
"preferredcodec": ext,
|
164 |
+
"preferredquality": format,
|
165 |
+
},
|
166 |
+
{"key": "FFmpegMetadata"},
|
167 |
+
],
|
168 |
}
|
169 |
ytdl_data = await dler(event, link, opts, True)
|
170 |
title = ytdl_data["title"]
|
|
|
174 |
artist = ytdl_data["creator"]
|
175 |
elif ytdl_data.get("channel"):
|
176 |
artist = ytdl_data["channel"]
|
177 |
+
views = numerize(ytdl_data.get("view_count")) or 0
|
178 |
+
thumb, _ = await fast_download(ytdl_data["thumbnail"], filename=vid_id + ".jpg")
|
179 |
+
likes = numerize(ytdl_data.get("like_count")) or 0
|
180 |
+
duration = ytdl_data.get("duration") or 0
|
181 |
+
description = (
|
182 |
+
ytdl_data["description"]
|
183 |
+
if len(ytdl_data["description"]) < 100
|
184 |
+
else ytdl_data["description"][:100]
|
185 |
)
|
186 |
+
description = description or "None"
|
187 |
+
file, _ = await event.client.fast_uploader(
|
188 |
+
vid_id + f".{ext}" * 2,
|
189 |
+
filename=title + "." + ext,
|
190 |
+
show_progress=True,
|
191 |
+
event=event,
|
192 |
+
to_delete=True,
|
193 |
)
|
194 |
attributes = [
|
195 |
DocumentAttributeAudio(
|
|
|
205 |
"key": "FFmpegMetadata",
|
206 |
"prefer_ffmpeg": True,
|
207 |
"geo_bypass": True,
|
208 |
+
"outtmpl": "%(id)s." + ext,
|
209 |
"logtostderr": False,
|
210 |
+
"postprocessors": [{"key": "FFmpegMetadata"}],
|
211 |
}
|
212 |
ytdl_data = await dler(event, link, opts, True)
|
213 |
title = ytdl_data["title"]
|
|
|
217 |
artist = ytdl_data["creator"]
|
218 |
elif ytdl_data.get("channel"):
|
219 |
artist = ytdl_data["channel"]
|
220 |
+
views = numerize(ytdl_data.get("view_count")) or 0
|
221 |
+
thumb, _ = await fast_download(ytdl_data["thumbnail"], filename=vid_id + ".jpg")
|
|
|
|
|
|
|
|
|
222 |
try:
|
223 |
+
Image.open(thumb).save(thumb, "JPEG")
|
224 |
+
except Exception as er:
|
225 |
+
LOGS.exception(er)
|
226 |
+
thumb = None
|
227 |
+
description = (
|
228 |
+
ytdl_data["description"]
|
229 |
+
if len(ytdl_data["description"]) < 100
|
230 |
+
else ytdl_data["description"][:100]
|
231 |
+
)
|
232 |
+
likes = numerize(ytdl_data.get("like_count")) or 0
|
233 |
+
hi, wi = ytdl_data.get("height") or 720, ytdl_data.get("width") or 1280
|
234 |
+
duration = ytdl_data.get("duration") or 0
|
235 |
+
filepath = vid_id + ".mkv"
|
236 |
+
if not os.path.exists(filepath):
|
237 |
+
filepath = filepath + ".webm"
|
238 |
+
file, _ = await event.client.fast_uploader(
|
239 |
+
filepath,
|
240 |
+
filename=title + ".mkv",
|
241 |
+
show_progress=True,
|
242 |
+
event=event,
|
243 |
+
to_delete=True,
|
244 |
)
|
245 |
attributes = [
|
246 |
DocumentAttributeVideo(
|
|
|
250 |
supports_streaming=True,
|
251 |
),
|
252 |
]
|
253 |
+
text = f"**Title:** `{title}`\n\n"
|
254 |
+
text += f"`📝 Description:` `{description}`\n\n"
|
255 |
+
text += f"`⏳ Duration:` `{time_formatter(int(duration)*1000)}`\n"
|
256 |
+
text += f"`🎤 Artist:` `{artist}`\n"
|
257 |
+
text += f"`👀 Views`: `{views}`\n"
|
258 |
+
text += f"`👍 Likes`: `{likes}`\n"
|
259 |
+
button = Button.switch_inline("Search More", query="yt ", same_peer=True)
|
260 |
+
try:
|
261 |
+
await event.edit(
|
262 |
+
text,
|
263 |
+
file=file,
|
264 |
+
buttons=button,
|
265 |
+
attributes=attributes,
|
266 |
+
thumb=thumb,
|
267 |
+
)
|
268 |
+
except (FilePartLengthInvalidError, MediaEmptyError):
|
269 |
+
file = await asst.send_message(
|
270 |
+
udB.get_key("LOG_CHANNEL"),
|
271 |
+
text,
|
272 |
+
file=file,
|
273 |
+
buttons=button,
|
274 |
+
attributes=attributes,
|
275 |
+
thumb=thumb,
|
276 |
+
)
|
277 |
+
await event.edit(text, file=file.media, buttons=button)
|
278 |
+
await bash(f"rm {vid_id}.jpg")
|
279 |
+
|
280 |
+
|
281 |
+
@callback(re.compile("ytdl_back:(.*)"), owner=True)
|
282 |
+
async def ytdl_back(event):
|
283 |
+
id_ = event.data_match.group(1).decode("utf-8")
|
284 |
+
if not BACK_BUTTON.get(id_):
|
285 |
+
return await event.answer("Query Expired! Search again 🔍")
|
286 |
+
await event.edit(**BACK_BUTTON[id_])
|
plugins/__init__.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -11,7 +11,7 @@ import time
|
|
11 |
from random import choice
|
12 |
|
13 |
from pyUltroid import *
|
14 |
-
from pyUltroid.dB import ULTROID_IMAGES
|
15 |
from pyUltroid.functions.helper import *
|
16 |
from pyUltroid.functions.info import *
|
17 |
from pyUltroid.functions.misc import *
|
@@ -25,15 +25,20 @@ from telethon.tl import functions, types
|
|
25 |
|
26 |
from strings import get_string
|
27 |
|
28 |
-
Redis = udB.
|
29 |
-
client = bot = ultroid_bot
|
30 |
|
31 |
-
OWNER_NAME = ultroid_bot.
|
32 |
-
OWNER_ID = ultroid_bot.
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
36 |
INLINE_PIC = None
|
|
|
37 |
Telegraph = telegraph_client()
|
38 |
|
39 |
List = []
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
11 |
from random import choice
|
12 |
|
13 |
from pyUltroid import *
|
14 |
+
from pyUltroid.dB import DEVLIST, ULTROID_IMAGES
|
15 |
from pyUltroid.functions.helper import *
|
16 |
from pyUltroid.functions.info import *
|
17 |
from pyUltroid.functions.misc import *
|
|
|
25 |
|
26 |
from strings import get_string
|
27 |
|
28 |
+
Redis = udB.get_key
|
|
|
29 |
|
30 |
+
OWNER_NAME = ultroid_bot.full_name
|
31 |
+
OWNER_ID = ultroid_bot.uid
|
32 |
+
|
33 |
+
LOG_CHANNEL = udB.get_key("LOG_CHANNEL")
|
34 |
+
|
35 |
+
INLINE_PIC = udB.get_key("INLINE_PIC")
|
36 |
+
|
37 |
+
if INLINE_PIC is None:
|
38 |
+
INLINE_PIC = choice(ULTROID_IMAGES)
|
39 |
+
elif INLINE_PIC == False:
|
40 |
INLINE_PIC = None
|
41 |
+
|
42 |
Telegraph = telegraph_client()
|
43 |
|
44 |
List = []
|
plugins/_chatactions.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -8,12 +8,10 @@
|
|
8 |
import asyncio
|
9 |
|
10 |
from pyUltroid.dB import stickers
|
11 |
-
from pyUltroid.dB.chatBot_db import chatbot_stats
|
12 |
-
from pyUltroid.dB.clean_db import is_clean_added
|
13 |
from pyUltroid.dB.forcesub_db import get_forcesetting
|
14 |
from pyUltroid.dB.gban_mute_db import is_gbanned
|
15 |
from pyUltroid.dB.greetings_db import get_goodbye, get_welcome, must_thank
|
16 |
-
from pyUltroid.dB.
|
17 |
from pyUltroid.functions.helper import inline_mention
|
18 |
from pyUltroid.functions.tools import create_tl_btn, get_chatbot_reply
|
19 |
from telethon import events
|
@@ -21,6 +19,10 @@ from telethon.errors.rpcerrorlist import UserNotParticipantError
|
|
21 |
from telethon.tl.functions.channels import GetParticipantRequest
|
22 |
from telethon.utils import get_display_name
|
23 |
|
|
|
|
|
|
|
|
|
24 |
from . import LOG_CHANNEL, LOGS, asst, get_string, types, udB, ultroid_bot
|
25 |
from ._inline import something
|
26 |
|
@@ -28,7 +30,8 @@ from ._inline import something
|
|
28 |
@ultroid_bot.on(events.ChatAction())
|
29 |
async def ChatActionsHandler(ult): # sourcery no-metrics
|
30 |
# clean chat actions
|
31 |
-
|
|
|
32 |
try:
|
33 |
await ult.delete()
|
34 |
except BaseException:
|
@@ -43,7 +46,7 @@ async def ChatActionsHandler(ult): # sourcery no-metrics
|
|
43 |
await ult.respond(file=sticker)
|
44 |
# force subscribe
|
45 |
if (
|
46 |
-
udB.
|
47 |
and ((ult.user_joined or ult.user_added))
|
48 |
and get_forcesetting(ult.chat_id)
|
49 |
):
|
@@ -83,7 +86,10 @@ async def ChatActionsHandler(ult): # sourcery no-metrics
|
|
83 |
user = await ult.get_user()
|
84 |
chat = await ult.get_chat()
|
85 |
title = chat.title or "this chat"
|
86 |
-
count = (
|
|
|
|
|
|
|
87 |
mention = inline_mention(user)
|
88 |
name = user.first_name
|
89 |
fullname = get_display_name(user)
|
@@ -120,7 +126,10 @@ async def ChatActionsHandler(ult): # sourcery no-metrics
|
|
120 |
user = await ult.get_user()
|
121 |
chat = await ult.get_chat()
|
122 |
title = chat.title or "this chat"
|
123 |
-
count = (
|
|
|
|
|
|
|
124 |
mention = inline_mention(user)
|
125 |
name = user.first_name
|
126 |
fullname = get_display_name(user)
|
@@ -160,9 +169,12 @@ async def chatBot_replies(e):
|
|
160 |
sender = await e.get_sender()
|
161 |
if not isinstance(sender, types.User):
|
162 |
return
|
163 |
-
|
|
|
164 |
msg = await get_chatbot_reply(e.message.message)
|
165 |
if msg:
|
|
|
|
|
166 |
await e.reply(msg)
|
167 |
chat = await e.get_chat()
|
168 |
if e.is_group and not sender.bot:
|
@@ -171,6 +183,10 @@ async def chatBot_replies(e):
|
|
171 |
elif e.is_private and not sender.bot:
|
172 |
if chat.username:
|
173 |
await uname_stuff(e.sender_id, chat.username, chat.first_name)
|
|
|
|
|
|
|
|
|
174 |
|
175 |
|
176 |
@ultroid_bot.on(events.Raw(types.UpdateUserName))
|
@@ -179,8 +195,9 @@ async def uname_change(e):
|
|
179 |
|
180 |
|
181 |
async def uname_stuff(id, uname, name):
|
182 |
-
if udB.
|
183 |
-
|
|
|
184 |
# Ignore Name Logs
|
185 |
if old and old == uname:
|
186 |
return
|
@@ -199,4 +216,6 @@ async def uname_stuff(id, uname, name):
|
|
199 |
LOG_CHANNEL,
|
200 |
get_string("can_4").format(f"[{name}](tg://user?id={id})", uname),
|
201 |
)
|
202 |
-
|
|
|
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
8 |
import asyncio
|
9 |
|
10 |
from pyUltroid.dB import stickers
|
|
|
|
|
11 |
from pyUltroid.dB.forcesub_db import get_forcesetting
|
12 |
from pyUltroid.dB.gban_mute_db import is_gbanned
|
13 |
from pyUltroid.dB.greetings_db import get_goodbye, get_welcome, must_thank
|
14 |
+
from pyUltroid.dB.nsfw_db import is_profan
|
15 |
from pyUltroid.functions.helper import inline_mention
|
16 |
from pyUltroid.functions.tools import create_tl_btn, get_chatbot_reply
|
17 |
from telethon import events
|
|
|
19 |
from telethon.tl.functions.channels import GetParticipantRequest
|
20 |
from telethon.utils import get_display_name
|
21 |
|
22 |
+
try:
|
23 |
+
from ProfanityDetector import detector
|
24 |
+
except ImportError:
|
25 |
+
detector = None
|
26 |
from . import LOG_CHANNEL, LOGS, asst, get_string, types, udB, ultroid_bot
|
27 |
from ._inline import something
|
28 |
|
|
|
30 |
@ultroid_bot.on(events.ChatAction())
|
31 |
async def ChatActionsHandler(ult): # sourcery no-metrics
|
32 |
# clean chat actions
|
33 |
+
key = udB.get_key("CLEANCHAT") or []
|
34 |
+
if ult.chat_id in key:
|
35 |
try:
|
36 |
await ult.delete()
|
37 |
except BaseException:
|
|
|
46 |
await ult.respond(file=sticker)
|
47 |
# force subscribe
|
48 |
if (
|
49 |
+
udB.get_key("FORCESUB")
|
50 |
and ((ult.user_joined or ult.user_added))
|
51 |
and get_forcesetting(ult.chat_id)
|
52 |
):
|
|
|
86 |
user = await ult.get_user()
|
87 |
chat = await ult.get_chat()
|
88 |
title = chat.title or "this chat"
|
89 |
+
count = (
|
90 |
+
chat.participants_count
|
91 |
+
or (await ult.client.get_participants(chat, limit=0)).total
|
92 |
+
)
|
93 |
mention = inline_mention(user)
|
94 |
name = user.first_name
|
95 |
fullname = get_display_name(user)
|
|
|
126 |
user = await ult.get_user()
|
127 |
chat = await ult.get_chat()
|
128 |
title = chat.title or "this chat"
|
129 |
+
count = (
|
130 |
+
chat.participants_count
|
131 |
+
or (await ult.client.get_participants(chat, limit=0)).total
|
132 |
+
)
|
133 |
mention = inline_mention(user)
|
134 |
name = user.first_name
|
135 |
fullname = get_display_name(user)
|
|
|
169 |
sender = await e.get_sender()
|
170 |
if not isinstance(sender, types.User):
|
171 |
return
|
172 |
+
key = udB.get_key("CHATBOT_USERS") or {}
|
173 |
+
if e.text and key.get(e.chat_id) and sender.id in key[e.chat_id]:
|
174 |
msg = await get_chatbot_reply(e.message.message)
|
175 |
if msg:
|
176 |
+
sleep = udB.get_key("CHATBOT_SLEEP") or 1.5
|
177 |
+
await asyncio.sleep(sleep)
|
178 |
await e.reply(msg)
|
179 |
chat = await e.get_chat()
|
180 |
if e.is_group and not sender.bot:
|
|
|
183 |
elif e.is_private and not sender.bot:
|
184 |
if chat.username:
|
185 |
await uname_stuff(e.sender_id, chat.username, chat.first_name)
|
186 |
+
if detector and is_profan(e.chat_id) and e.text:
|
187 |
+
x, y = detector(e.text)
|
188 |
+
if y:
|
189 |
+
await e.delete()
|
190 |
|
191 |
|
192 |
@ultroid_bot.on(events.Raw(types.UpdateUserName))
|
|
|
195 |
|
196 |
|
197 |
async def uname_stuff(id, uname, name):
|
198 |
+
if udB.get_key("USERNAME_LOG") == "True":
|
199 |
+
old_ = udB.get_key("USERNAME_DB") or {}
|
200 |
+
old = old_.get(id)
|
201 |
# Ignore Name Logs
|
202 |
if old and old == uname:
|
203 |
return
|
|
|
216 |
LOG_CHANNEL,
|
217 |
get_string("can_4").format(f"[{name}](tg://user?id={id})", uname),
|
218 |
)
|
219 |
+
|
220 |
+
old_[id] = uname
|
221 |
+
udB.set_key("USERNAME_DB", str(old_))
|
plugins/_help.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -14,15 +14,15 @@ from telethon.errors.rpcerrorlist import (
|
|
14 |
)
|
15 |
from telethon.tl.custom import Button
|
16 |
|
17 |
-
from . import
|
18 |
|
19 |
_main_help_menu = [
|
20 |
[
|
21 |
-
Button.inline(get_string("help_4"), data="
|
22 |
-
Button.inline(get_string("help_5"), data="
|
23 |
],
|
24 |
[
|
25 |
-
Button.inline(get_string("help_6"), data="
|
26 |
Button.inline(get_string("help_7"), data="inlone"),
|
27 |
],
|
28 |
[
|
@@ -38,6 +38,7 @@ _main_help_menu = [
|
|
38 |
@ultroid_cmd(pattern="help ?(.*)")
|
39 |
async def _help(ult):
|
40 |
plug = ult.pattern_match.group(1)
|
|
|
41 |
if plug:
|
42 |
try:
|
43 |
if plug in HELP["Official"]:
|
@@ -45,19 +46,19 @@ async def _help(ult):
|
|
45 |
for i in HELP["Official"][plug]:
|
46 |
output += i
|
47 |
output += "\n© @TeamUltroid"
|
48 |
-
await eor(
|
49 |
elif HELP.get("Addons") and plug in HELP["Addons"]:
|
50 |
output = f"**Plugin** - `{plug}`\n"
|
51 |
for i in HELP["Addons"][plug]:
|
52 |
output += i
|
53 |
output += "\n© @TeamUltroid"
|
54 |
-
await eor(
|
55 |
elif HELP.get("VCBot") and plug in HELP["VCBot"]:
|
56 |
output = f"**Plugin** - `{plug}`\n"
|
57 |
for i in HELP["VCBot"][plug]:
|
58 |
output += i
|
59 |
output += "\n© @TeamUltroid"
|
60 |
-
await eor(
|
61 |
else:
|
62 |
try:
|
63 |
x = get_string("help_11").format(plug)
|
@@ -65,12 +66,12 @@ async def _help(ult):
|
|
65 |
x += HNDLR + d
|
66 |
x += "\n"
|
67 |
x += "\n© @TeamUltroid"
|
68 |
-
await eor(
|
69 |
except BaseException:
|
70 |
-
await eor(
|
71 |
except BaseException as er:
|
72 |
LOGS.exception(er)
|
73 |
-
await eor(
|
74 |
else:
|
75 |
try:
|
76 |
results = await ult.client.inline_query(asst.me.username, "ultd")
|
@@ -80,12 +81,12 @@ async def _help(ult):
|
|
80 |
for y in x:
|
81 |
z.append(y)
|
82 |
cmd = len(z) + 10
|
83 |
-
if udB.
|
84 |
_main_help_menu[2:3] = [[Button.inline("• Manager Help •", "mngbtn")]]
|
85 |
return await ult.reply(
|
86 |
get_string("inline_4").format(
|
87 |
OWNER_NAME,
|
88 |
-
len(HELP["Official"])
|
89 |
len(HELP["Addons"] if "Addons" in HELP else []),
|
90 |
cmd,
|
91 |
),
|
@@ -93,11 +94,10 @@ async def _help(ult):
|
|
93 |
buttons=_main_help_menu,
|
94 |
)
|
95 |
except BotResponseTimeoutError:
|
96 |
-
return await eor(
|
97 |
-
ult,
|
98 |
get_string("help_2").format(HNDLR),
|
99 |
)
|
100 |
except BotInlineDisabledError:
|
101 |
-
return await eor(
|
102 |
-
await results[0].click(
|
103 |
await ult.delete()
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
14 |
)
|
15 |
from telethon.tl.custom import Button
|
16 |
|
17 |
+
from . import HNDLR, INLINE_PIC, LOGS, OWNER_NAME, asst, get_string, udB, ultroid_cmd
|
18 |
|
19 |
_main_help_menu = [
|
20 |
[
|
21 |
+
Button.inline(get_string("help_4"), data="uh_Official_"),
|
22 |
+
Button.inline(get_string("help_5"), data="uh_Addons_"),
|
23 |
],
|
24 |
[
|
25 |
+
Button.inline(get_string("help_6"), data="uh_VCBot_"),
|
26 |
Button.inline(get_string("help_7"), data="inlone"),
|
27 |
],
|
28 |
[
|
|
|
38 |
@ultroid_cmd(pattern="help ?(.*)")
|
39 |
async def _help(ult):
|
40 |
plug = ult.pattern_match.group(1)
|
41 |
+
chat = await ult.get_chat()
|
42 |
if plug:
|
43 |
try:
|
44 |
if plug in HELP["Official"]:
|
|
|
46 |
for i in HELP["Official"][plug]:
|
47 |
output += i
|
48 |
output += "\n© @TeamUltroid"
|
49 |
+
await ult.eor(output)
|
50 |
elif HELP.get("Addons") and plug in HELP["Addons"]:
|
51 |
output = f"**Plugin** - `{plug}`\n"
|
52 |
for i in HELP["Addons"][plug]:
|
53 |
output += i
|
54 |
output += "\n© @TeamUltroid"
|
55 |
+
await ult.eor(output)
|
56 |
elif HELP.get("VCBot") and plug in HELP["VCBot"]:
|
57 |
output = f"**Plugin** - `{plug}`\n"
|
58 |
for i in HELP["VCBot"][plug]:
|
59 |
output += i
|
60 |
output += "\n© @TeamUltroid"
|
61 |
+
await ult.eor(output)
|
62 |
else:
|
63 |
try:
|
64 |
x = get_string("help_11").format(plug)
|
|
|
66 |
x += HNDLR + d
|
67 |
x += "\n"
|
68 |
x += "\n© @TeamUltroid"
|
69 |
+
await ult.eor(x)
|
70 |
except BaseException:
|
71 |
+
await ult.eor(get_string("help_1").format(plug), time=5)
|
72 |
except BaseException as er:
|
73 |
LOGS.exception(er)
|
74 |
+
await ult.eor("Error 🤔 occured.")
|
75 |
else:
|
76 |
try:
|
77 |
results = await ult.client.inline_query(asst.me.username, "ultd")
|
|
|
81 |
for y in x:
|
82 |
z.append(y)
|
83 |
cmd = len(z) + 10
|
84 |
+
if udB.get_key("MANAGER") and udB.get_key("DUAL_HNDLR") == "/":
|
85 |
_main_help_menu[2:3] = [[Button.inline("• Manager Help •", "mngbtn")]]
|
86 |
return await ult.reply(
|
87 |
get_string("inline_4").format(
|
88 |
OWNER_NAME,
|
89 |
+
len(HELP["Official"]),
|
90 |
len(HELP["Addons"] if "Addons" in HELP else []),
|
91 |
cmd,
|
92 |
),
|
|
|
94 |
buttons=_main_help_menu,
|
95 |
)
|
96 |
except BotResponseTimeoutError:
|
97 |
+
return await ult.eor(
|
|
|
98 |
get_string("help_2").format(HNDLR),
|
99 |
)
|
100 |
except BotInlineDisabledError:
|
101 |
+
return await ult.eor(get_string("help_3"))
|
102 |
+
await results[0].click(chat.id, reply_to=ult.reply_to_msg_id, hide_via=True)
|
103 |
await ult.delete()
|
plugins/_inline.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -8,13 +8,12 @@
|
|
8 |
import re
|
9 |
import time
|
10 |
from datetime import datetime
|
11 |
-
from math import ceil
|
12 |
from os import remove
|
13 |
|
14 |
from git import Repo
|
15 |
from pyUltroid.dB._core import HELP, LIST
|
16 |
from pyUltroid.functions.helper import gen_chlog, time_formatter, updater
|
17 |
-
from pyUltroid.misc import
|
18 |
from pyUltroid.misc._assistant import callback, in_pattern
|
19 |
from telethon import Button
|
20 |
from telethon.tl.types import InputWebDocument, Message
|
@@ -24,18 +23,19 @@ from . import HNDLR, INLINE_PIC, LOGS, OWNER_NAME, asst, get_string, start_time,
|
|
24 |
from ._help import _main_help_menu
|
25 |
|
26 |
# ================================================#
|
27 |
-
notmine = f"This bot is for {OWNER_NAME}"
|
28 |
|
29 |
-
TLINK = INLINE_PIC or "https://telegra.ph/file/
|
30 |
helps = get_string("inline_1")
|
31 |
|
32 |
-
add_ons = udB.
|
33 |
-
|
|
|
34 |
zhelps = get_string("inline_2")
|
35 |
else:
|
36 |
zhelps = get_string("inline_3")
|
37 |
|
38 |
-
|
|
|
39 |
upage = 0
|
40 |
# ============================================#
|
41 |
|
@@ -55,7 +55,7 @@ SUP_BUTTONS = [
|
|
55 |
async def inline_alive(o):
|
56 |
MSG = "• **Ultroid Userbot •**"
|
57 |
WEB0 = InputWebDocument(
|
58 |
-
"https://telegra.ph/file/
|
59 |
)
|
60 |
RES = [
|
61 |
await o.builder.article(
|
@@ -76,15 +76,12 @@ async def inline_alive(o):
|
|
76 |
@in_pattern("ultd", owner=True)
|
77 |
async def inline_handler(event):
|
78 |
z = []
|
79 |
-
PLUGINS = HELP["Official"] if "Official" in HELP.keys() else []
|
80 |
-
ADDONS = HELP["Addons"] if "Addons" in HELP.keys() else []
|
81 |
for x in LIST.values():
|
82 |
-
|
83 |
-
z.append(y)
|
84 |
text = get_string("inline_4").format(
|
85 |
OWNER_NAME,
|
86 |
-
len(
|
87 |
-
len(
|
88 |
len(z),
|
89 |
)
|
90 |
if INLINE_PIC:
|
@@ -122,16 +119,13 @@ async def _(event):
|
|
122 |
@callback("ownr", owner=True)
|
123 |
async def setting(event):
|
124 |
z = []
|
125 |
-
PLUGINS = HELP["Official"] if "Official" in HELP.keys() else []
|
126 |
-
ADDONS = HELP["Addons"] if "Addons" in HELP.keys() else []
|
127 |
for x in LIST.values():
|
128 |
-
|
129 |
-
z.append(y)
|
130 |
await event.edit(
|
131 |
get_string("inline_4").format(
|
132 |
OWNER_NAME,
|
133 |
-
len(
|
134 |
-
len(
|
135 |
len(z),
|
136 |
),
|
137 |
file=INLINE_PIC,
|
@@ -150,14 +144,73 @@ async def setting(event):
|
|
150 |
)
|
151 |
|
152 |
|
153 |
-
|
154 |
-
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
try:
|
157 |
-
|
158 |
-
except
|
159 |
-
|
160 |
-
|
|
|
161 |
|
162 |
|
163 |
@callback(data="doupdate", owner=True)
|
@@ -165,10 +218,11 @@ async def _(event):
|
|
165 |
if not updater():
|
166 |
return await event.answer(get_string("inline_9"), cache_time=0, alert=True)
|
167 |
if not INLINE_PIC:
|
168 |
-
return await event.answer(f"Do {HNDLR}update")
|
169 |
repo = Repo.init()
|
170 |
-
|
171 |
-
|
|
|
172 |
changelog_str = changelog + "\n\n" + get_string("inline_8")
|
173 |
if len(changelog_str) > 1024:
|
174 |
await event.edit(get_string("upd_4"))
|
@@ -261,6 +315,19 @@ async def _(e):
|
|
261 |
same_peer=True,
|
262 |
),
|
263 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
264 |
[
|
265 |
Button.inline(
|
266 |
"« Bᴀᴄᴋ",
|
@@ -271,124 +338,16 @@ async def _(e):
|
|
271 |
await e.edit(buttons=button, link_preview=False)
|
272 |
|
273 |
|
274 |
-
@callback(data="hrrrr", owner=True)
|
275 |
-
async def on_plug_in_callback_query_handler(event):
|
276 |
-
xhelps = helps.format(OWNER_NAME, len(HELP["Official"]))
|
277 |
-
buttons = page_num(0, HELP["Official"].keys(), "helpme", "def")
|
278 |
-
await event.edit(f"{xhelps}", buttons=buttons, link_preview=False)
|
279 |
-
|
280 |
-
|
281 |
-
@callback(data="frrr", owner=True)
|
282 |
-
async def addon(event):
|
283 |
-
if HELP.get("Addons"):
|
284 |
-
halp = zhelps.format(OWNER_NAME, len(HELP["Addons"]))
|
285 |
-
buttons = page_num(0, HELP["Addons"].keys(), "addon", "add")
|
286 |
-
await event.edit(halp, buttons=buttons, link_preview=False)
|
287 |
-
else:
|
288 |
-
await event.answer(
|
289 |
-
f"• Tʏᴘᴇ {HNDLR}setredis ADDONS True\n Tᴏ ɢᴇᴛ ᴀᴅᴅᴏɴs ᴘʟᴜɢɪɴs",
|
290 |
-
cache_time=0,
|
291 |
-
alert=True,
|
292 |
-
)
|
293 |
-
|
294 |
-
|
295 |
-
@callback(
|
296 |
-
data=re.compile(
|
297 |
-
rb"helpme_next\((.+?)\)",
|
298 |
-
),
|
299 |
-
owner=True,
|
300 |
-
)
|
301 |
-
async def on_plug_in_callback_query_handler(event):
|
302 |
-
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
|
303 |
-
buttons = page_num(
|
304 |
-
current_page_number + 1, HELP["Official"].keys(), "helpme", "def"
|
305 |
-
)
|
306 |
-
await event.edit(buttons=buttons, link_preview=False)
|
307 |
-
|
308 |
-
|
309 |
-
@callback(
|
310 |
-
data=re.compile(
|
311 |
-
rb"helpme_prev\((.+?)\)",
|
312 |
-
),
|
313 |
-
owner=True,
|
314 |
-
)
|
315 |
-
async def on_plug_in_callback_query_handler(event):
|
316 |
-
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
|
317 |
-
buttons = page_num(
|
318 |
-
current_page_number - 1, list(HELP["Official"].keys()), "helpme", "def"
|
319 |
-
)
|
320 |
-
await event.edit(buttons=buttons, link_preview=False)
|
321 |
-
|
322 |
-
|
323 |
-
@callback(
|
324 |
-
data=re.compile(
|
325 |
-
rb"addon_next\((.+?)\)",
|
326 |
-
),
|
327 |
-
owner=True,
|
328 |
-
)
|
329 |
-
async def on_plug_in_callback_query_handler(event):
|
330 |
-
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
|
331 |
-
buttons = page_num(
|
332 |
-
current_page_number + 1, list(HELP["Addons"].keys()), "addon", "add"
|
333 |
-
)
|
334 |
-
await event.edit(buttons=buttons, link_preview=False)
|
335 |
-
|
336 |
-
|
337 |
-
@callback(
|
338 |
-
data=re.compile(
|
339 |
-
rb"addon_prev\((.+?)\)",
|
340 |
-
),
|
341 |
-
owner=True,
|
342 |
-
)
|
343 |
-
async def on_plug_in_callback_query_handler(event):
|
344 |
-
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
|
345 |
-
buttons = page_num(
|
346 |
-
current_page_number - 1, list(HELP["Addons"].keys()), "addon", "add"
|
347 |
-
)
|
348 |
-
await event.edit(buttons=buttons, link_preview=False)
|
349 |
-
|
350 |
-
|
351 |
-
@callback(data="back", owner=True)
|
352 |
-
async def backr(event):
|
353 |
-
xhelps = helps.format(OWNER_NAME, len(HELP["Official"]))
|
354 |
-
current_page_number = int(upage)
|
355 |
-
buttons = page_num(
|
356 |
-
current_page_number, list(HELP["Official"].keys()), "helpme", "def"
|
357 |
-
)
|
358 |
-
await event.edit(
|
359 |
-
xhelps,
|
360 |
-
file=INLINE_PIC,
|
361 |
-
buttons=buttons,
|
362 |
-
link_preview=False,
|
363 |
-
)
|
364 |
-
|
365 |
-
|
366 |
-
@callback(data="buck", owner=True)
|
367 |
-
async def backr(event):
|
368 |
-
xhelps = zhelps.format(OWNER_NAME, len(HELP["Addons"]))
|
369 |
-
current_page_number = int(upage)
|
370 |
-
buttons = page_num(current_page_number, list(HELP["Addons"].keys()), "addon", "add")
|
371 |
-
await event.edit(
|
372 |
-
xhelps,
|
373 |
-
file=INLINE_PIC,
|
374 |
-
buttons=buttons,
|
375 |
-
link_preview=False,
|
376 |
-
)
|
377 |
-
|
378 |
-
|
379 |
@callback(data="open", owner=True)
|
380 |
async def opner(event):
|
381 |
z = []
|
382 |
-
PLUGINS = HELP["Official"] if "Official" in HELP.keys() else []
|
383 |
-
ADDONS = HELP["Addons"] if "Addons" in HELP.keys() else []
|
384 |
for x in LIST.values():
|
385 |
-
|
386 |
-
z.append(y)
|
387 |
await event.edit(
|
388 |
get_string("inline_4").format(
|
389 |
OWNER_NAME,
|
390 |
-
len(
|
391 |
-
len(
|
392 |
len(z),
|
393 |
),
|
394 |
buttons=_main_help_menu,
|
@@ -404,211 +363,44 @@ async def on_plug_in_callback_query_handler(event):
|
|
404 |
)
|
405 |
|
406 |
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
)
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
help_string += i
|
419 |
-
except BaseException:
|
420 |
-
pass
|
421 |
-
if help_string == "":
|
422 |
-
reply_pop_up_alert = f"{plugin_name} has no detailed help..."
|
423 |
-
else:
|
424 |
-
reply_pop_up_alert = help_string
|
425 |
-
reply_pop_up_alert += "\n© @TeamUltroid"
|
426 |
-
buttons = []
|
427 |
-
if INLINE_PIC:
|
428 |
-
buttons.append(
|
429 |
-
[
|
430 |
-
Button.inline(
|
431 |
-
"« Sᴇɴᴅ Pʟᴜɢɪɴ »",
|
432 |
-
data=f"sndplug_{(event.data).decode('UTF-8')}",
|
433 |
-
)
|
434 |
-
]
|
435 |
-
)
|
436 |
-
buttons.append(
|
437 |
-
[
|
438 |
-
Button.inline("« Bᴀᴄᴋ", data="back"),
|
439 |
-
]
|
440 |
-
)
|
441 |
-
try:
|
442 |
-
if str(event.query.user_id) in owner_and_sudos():
|
443 |
-
await event.edit(
|
444 |
-
reply_pop_up_alert,
|
445 |
-
buttons=buttons,
|
446 |
-
)
|
447 |
-
else:
|
448 |
-
reply_pop_up_alert = notmine
|
449 |
-
await event.answer(reply_pop_up_alert, cache_time=0)
|
450 |
-
except BaseException:
|
451 |
-
await event.edit(get_string("inline_7").format(plugin_name), buttons=buttons)
|
452 |
-
|
453 |
-
|
454 |
-
@callback(
|
455 |
-
data=re.compile(
|
456 |
-
b"vc_plugin_(.*)",
|
457 |
-
),
|
458 |
-
owner=True,
|
459 |
-
)
|
460 |
-
async def on_vc_plg_callback_query_handler(event):
|
461 |
-
plugin_name = event.data_match.group(1).decode("UTF-8")
|
462 |
-
help_string = f"Plugin Name - `{plugin_name}`\n"
|
463 |
-
try:
|
464 |
-
for i in HELP["VCBot"][plugin_name]:
|
465 |
-
help_string += i
|
466 |
-
except BaseException:
|
467 |
-
pass
|
468 |
-
if help_string == "**Commands Available:**\n\n":
|
469 |
-
reply_pop_up_alert = f"{plugin_name} has no detailed help..."
|
470 |
-
else:
|
471 |
-
reply_pop_up_alert = help_string
|
472 |
-
reply_pop_up_alert += "\n© @TeamUltroid"
|
473 |
-
buttons = []
|
474 |
-
if INLINE_PIC:
|
475 |
-
buttons.append(
|
476 |
-
[
|
477 |
-
Button.inline(
|
478 |
-
"« Sᴇɴᴅ Pʟᴜɢɪɴ »",
|
479 |
-
data=f"sndplug_{(event.data).decode('UTF-8')}",
|
480 |
-
)
|
481 |
-
]
|
482 |
-
)
|
483 |
-
buttons.append(
|
484 |
-
[
|
485 |
-
Button.inline("« Bᴀᴄᴋ", data="vc_helper"),
|
486 |
-
]
|
487 |
-
)
|
488 |
-
try:
|
489 |
-
if str(event.query.user_id) in owner_and_sudos():
|
490 |
-
await event.edit(
|
491 |
-
reply_pop_up_alert,
|
492 |
-
buttons=buttons,
|
493 |
-
)
|
494 |
-
else:
|
495 |
-
reply_pop_up_alert = notmine
|
496 |
-
await event.answer(reply_pop_up_alert, cache_time=0)
|
497 |
-
except BaseException:
|
498 |
-
halps = f"Do .help {plugin_name} to get the list of commands."
|
499 |
-
await event.edit(halps, buttons=buttons)
|
500 |
-
|
501 |
-
|
502 |
-
@callback(
|
503 |
-
data=re.compile(
|
504 |
-
b"add_plugin_(.*)",
|
505 |
-
),
|
506 |
-
owner=True,
|
507 |
-
)
|
508 |
-
async def on_plug_in_callback_query_handler(event):
|
509 |
-
plugin_name = event.data_match.group(1).decode("UTF-8")
|
510 |
-
help_string = ""
|
511 |
try:
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
help_string += str(CMD_HELP[plugin_name])
|
519 |
-
except BaseException:
|
520 |
-
try:
|
521 |
-
if plugin_name in LIST:
|
522 |
-
help_string = get_string("help_11").format(plugin_name)
|
523 |
-
for d in LIST[plugin_name]:
|
524 |
-
help_string += HNDLR + d
|
525 |
-
help_string += "\n"
|
526 |
-
except BaseException:
|
527 |
-
pass
|
528 |
-
if help_string == "":
|
529 |
-
reply_pop_up_alert = f"{plugin_name} has no detailed help..."
|
530 |
else:
|
531 |
-
|
532 |
-
reply_pop_up_alert += "\n© @TeamUltroid"
|
533 |
-
buttons = []
|
534 |
-
if INLINE_PIC:
|
535 |
-
buttons.append(
|
536 |
[
|
537 |
-
Button.inline(
|
538 |
-
"« Sᴇɴᴅ Pʟᴜɢɪɴ »",
|
539 |
-
data=f"sndplug_{(event.data).decode('UTF-8')}",
|
540 |
-
)
|
541 |
-
]
|
542 |
-
)
|
543 |
-
buttons.append(
|
544 |
-
[
|
545 |
-
Button.inline("« Bᴀᴄᴋ", data="buck"),
|
546 |
-
]
|
547 |
-
)
|
548 |
-
try:
|
549 |
-
if str(event.query.user_id) in owner_and_sudos():
|
550 |
-
await event.edit(
|
551 |
-
reply_pop_up_alert,
|
552 |
-
buttons=buttons,
|
553 |
-
)
|
554 |
-
else:
|
555 |
-
reply_pop_up_alert = notmine
|
556 |
-
await event.answer(reply_pop_up_alert, cache_time=0)
|
557 |
-
except BaseException:
|
558 |
-
halps = get_string("inline_7").format(plugin_name)
|
559 |
-
await event.edit(halps, buttons=buttons)
|
560 |
-
|
561 |
-
|
562 |
-
def page_num(page_number, loaded_plugins, prefix, type_):
|
563 |
-
number_of_rows = 5
|
564 |
-
number_of_cols = 2
|
565 |
-
emoji = udB.get("EMOJI_IN_HELP")
|
566 |
-
multi = emoji or "✘"
|
567 |
-
global upage
|
568 |
-
upage = page_number
|
569 |
-
helpable_plugins = [p for p in loaded_plugins]
|
570 |
-
helpable_plugins = sorted(helpable_plugins)
|
571 |
-
modules = [
|
572 |
-
Button.inline(
|
573 |
-
"{} {} {}".format(
|
574 |
-
multi,
|
575 |
-
x,
|
576 |
-
multi,
|
577 |
-
),
|
578 |
-
data=f"{type_}_plugin_{x}",
|
579 |
-
)
|
580 |
-
for x in helpable_plugins
|
581 |
-
]
|
582 |
-
pairs = list(zip(modules[::number_of_cols], modules[1::number_of_cols]))
|
583 |
-
if len(modules) % number_of_cols == 1:
|
584 |
-
pairs.append((modules[-1],))
|
585 |
-
max_num_pages = ceil(len(pairs) / number_of_rows)
|
586 |
-
modulo_page = page_number % max_num_pages
|
587 |
-
if len(pairs) > number_of_rows:
|
588 |
-
pairs = pairs[
|
589 |
-
modulo_page * number_of_rows : number_of_rows * (modulo_page + 1)
|
590 |
-
] + [
|
591 |
-
(
|
592 |
Button.inline(
|
593 |
"« Pʀᴇᴠɪᴏᴜs",
|
594 |
-
data=f"{
|
595 |
),
|
596 |
Button.inline("« Bᴀᴄᴋ »", data="open"),
|
597 |
Button.inline(
|
598 |
"Nᴇxᴛ »",
|
599 |
-
data=f"{
|
600 |
),
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
pairs = pairs[
|
605 |
-
modulo_page * number_of_rows : number_of_rows * (modulo_page + 1)
|
606 |
-
] + [(Button.inline("« Bᴀᴄᴋ »", data="open"),)]
|
607 |
-
return pairs
|
608 |
|
609 |
|
610 |
# --------------------------------------------------------------------------------- #
|
611 |
|
|
|
612 |
STUFF = {}
|
613 |
|
614 |
|
@@ -619,9 +411,9 @@ async def ibuild(e):
|
|
619 |
if not (n and n.isdigit()):
|
620 |
return
|
621 |
ok = STUFF.get(int(n))
|
622 |
-
txt = ok.get("msg")
|
623 |
-
pic = ok.get("media")
|
624 |
-
btn = ok.get("button")
|
625 |
if not (pic or txt):
|
626 |
txt = "Hey!"
|
627 |
if pic:
|
@@ -701,4 +493,4 @@ async def something(e, msg, media, button, reply=True, chat=None):
|
|
701 |
)
|
702 |
|
703 |
except Exception as er:
|
704 |
-
LOGS.
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
8 |
import re
|
9 |
import time
|
10 |
from datetime import datetime
|
|
|
11 |
from os import remove
|
12 |
|
13 |
from git import Repo
|
14 |
from pyUltroid.dB._core import HELP, LIST
|
15 |
from pyUltroid.functions.helper import gen_chlog, time_formatter, updater
|
16 |
+
from pyUltroid.functions.misc import split_list
|
17 |
from pyUltroid.misc._assistant import callback, in_pattern
|
18 |
from telethon import Button
|
19 |
from telethon.tl.types import InputWebDocument, Message
|
|
|
23 |
from ._help import _main_help_menu
|
24 |
|
25 |
# ================================================#
|
|
|
26 |
|
27 |
+
TLINK = INLINE_PIC or "https://telegra.ph/file/74d6259983e0642923fdb.jpg"
|
28 |
helps = get_string("inline_1")
|
29 |
|
30 |
+
add_ons = udB.get_key("ADDONS")
|
31 |
+
|
32 |
+
if add_ons is not False:
|
33 |
zhelps = get_string("inline_2")
|
34 |
else:
|
35 |
zhelps = get_string("inline_3")
|
36 |
|
37 |
+
PLUGINS = HELP.get("Official", [])
|
38 |
+
ADDONS = HELP.get("Addons", [])
|
39 |
upage = 0
|
40 |
# ============================================#
|
41 |
|
|
|
55 |
async def inline_alive(o):
|
56 |
MSG = "• **Ultroid Userbot •**"
|
57 |
WEB0 = InputWebDocument(
|
58 |
+
"https://telegra.ph/file/acd4f5d61369f74c5e7a7.jpg", 0, "image/jpg", []
|
59 |
)
|
60 |
RES = [
|
61 |
await o.builder.article(
|
|
|
76 |
@in_pattern("ultd", owner=True)
|
77 |
async def inline_handler(event):
|
78 |
z = []
|
|
|
|
|
79 |
for x in LIST.values():
|
80 |
+
z.extend(x)
|
|
|
81 |
text = get_string("inline_4").format(
|
82 |
OWNER_NAME,
|
83 |
+
len(HELP.get("Official", [])),
|
84 |
+
len(HELP.get("Addons", [])),
|
85 |
len(z),
|
86 |
)
|
87 |
if INLINE_PIC:
|
|
|
119 |
@callback("ownr", owner=True)
|
120 |
async def setting(event):
|
121 |
z = []
|
|
|
|
|
122 |
for x in LIST.values():
|
123 |
+
z.extend(x)
|
|
|
124 |
await event.edit(
|
125 |
get_string("inline_4").format(
|
126 |
OWNER_NAME,
|
127 |
+
len(HELP.get("Official", [])),
|
128 |
+
len(HELP.get("Addons", [])),
|
129 |
len(z),
|
130 |
),
|
131 |
file=INLINE_PIC,
|
|
|
144 |
)
|
145 |
|
146 |
|
147 |
+
_strings = {"Official": helps, "Addons": zhelps, "VCBot": get_string("inline_6")}
|
148 |
+
|
149 |
+
|
150 |
+
@callback(re.compile("uh_(.*)"), owner=True)
|
151 |
+
async def help_func(ult):
|
152 |
+
key, count = ult.data_match.group(1).decode("utf-8").split("_")
|
153 |
+
if key == "VCBot" and HELP.get("VCBot") is None:
|
154 |
+
return await ult.answer(get_string("help_12"), alert=True)
|
155 |
+
elif key == "Addons" and HELP.get("Addons") is None:
|
156 |
+
return await ult.answer(get_string("help_13").format(HNDLR), alert=True)
|
157 |
+
if "|" in count:
|
158 |
+
_, count = count.split("|")
|
159 |
+
count = 0 if not count else int(count)
|
160 |
+
text = _strings.get(key, "").format(OWNER_NAME, len(HELP.get(key)))
|
161 |
+
await ult.edit(
|
162 |
+
text, file=INLINE_PIC, buttons=page_num(count, key), link_preview=False
|
163 |
+
)
|
164 |
+
|
165 |
+
|
166 |
+
@callback(re.compile("uplugin_(.*)"), owner=True)
|
167 |
+
async def uptd_plugin(event):
|
168 |
+
key, file = event.data_match.group(1).decode("utf-8").split("_")
|
169 |
+
index = None
|
170 |
+
if "|" in file:
|
171 |
+
file, index = file.split("|")
|
172 |
+
key_ = HELP.get(key, [])
|
173 |
+
hel_p = f"Plugin Name - `{file}`\n"
|
174 |
+
help_ = ""
|
175 |
+
try:
|
176 |
+
for i in key_[file]:
|
177 |
+
help_ += i
|
178 |
+
except BaseException:
|
179 |
+
if file in LIST:
|
180 |
+
help_ = get_string("help_11").format(file)
|
181 |
+
for d in LIST[file]:
|
182 |
+
help_ += HNDLR + d
|
183 |
+
help_ += "\n"
|
184 |
+
if not help_:
|
185 |
+
help_ = f"{file} has no Detailed Help!"
|
186 |
+
help_ += "\n© Join @TeamUltroid"
|
187 |
+
buttons = []
|
188 |
+
if INLINE_PIC:
|
189 |
+
data = f"sndplug_{key}_{file}"
|
190 |
+
if index is not None:
|
191 |
+
data += f"|{index}"
|
192 |
+
buttons.append(
|
193 |
+
[
|
194 |
+
Button.inline(
|
195 |
+
"« Sᴇɴᴅ Pʟᴜɢɪɴ »",
|
196 |
+
data=data,
|
197 |
+
)
|
198 |
+
]
|
199 |
+
)
|
200 |
+
data = f"uh_{key}_"
|
201 |
+
if index is not None:
|
202 |
+
data += f"|{index}"
|
203 |
+
buttons.append(
|
204 |
+
[
|
205 |
+
Button.inline("« Bᴀᴄᴋ", data=data),
|
206 |
+
]
|
207 |
+
)
|
208 |
try:
|
209 |
+
await event.edit(help_, buttons=buttons)
|
210 |
+
except Exception as er:
|
211 |
+
LOGS.exception(er)
|
212 |
+
help = f"Do `{HNDLR}help {key}` to get list of commands."
|
213 |
+
await event.edit(help, buttons=buttons)
|
214 |
|
215 |
|
216 |
@callback(data="doupdate", owner=True)
|
|
|
218 |
if not updater():
|
219 |
return await event.answer(get_string("inline_9"), cache_time=0, alert=True)
|
220 |
if not INLINE_PIC:
|
221 |
+
return await event.answer(f"Do '{HNDLR}update' to update..")
|
222 |
repo = Repo.init()
|
223 |
+
changelog, tl_chnglog = await gen_chlog(
|
224 |
+
repo, f"HEAD..upstream/{repo.active_branch}"
|
225 |
+
)
|
226 |
changelog_str = changelog + "\n\n" + get_string("inline_8")
|
227 |
if len(changelog_str) > 1024:
|
228 |
await event.edit(get_string("upd_4"))
|
|
|
315 |
same_peer=True,
|
316 |
),
|
317 |
],
|
318 |
+
[
|
319 |
+
Button.switch_inline(
|
320 |
+
"Tᴡɪᴛᴛᴇʀ Usᴇʀ", query="twitter theultroid", same_peer=True
|
321 |
+
),
|
322 |
+
Button.switch_inline(
|
323 |
+
"Kᴏᴏ Sᴇᴀʀᴄʜ", query="koo @__kumar__amit", same_peer=True
|
324 |
+
),
|
325 |
+
],
|
326 |
+
[
|
327 |
+
Button.switch_inline(
|
328 |
+
"Fᴅʀᴏɪᴅ Sᴇᴀʀᴄʜ", query="fdroid telegram", same_peer=True
|
329 |
+
)
|
330 |
+
],
|
331 |
[
|
332 |
Button.inline(
|
333 |
"« Bᴀᴄᴋ",
|
|
|
338 |
await e.edit(buttons=button, link_preview=False)
|
339 |
|
340 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
341 |
@callback(data="open", owner=True)
|
342 |
async def opner(event):
|
343 |
z = []
|
|
|
|
|
344 |
for x in LIST.values():
|
345 |
+
z.extend(x)
|
|
|
346 |
await event.edit(
|
347 |
get_string("inline_4").format(
|
348 |
OWNER_NAME,
|
349 |
+
len(HELP.get("Official", [])),
|
350 |
+
len(HELP.get("Addons", [])),
|
351 |
len(z),
|
352 |
),
|
353 |
buttons=_main_help_menu,
|
|
|
363 |
)
|
364 |
|
365 |
|
366 |
+
def page_num(index, key):
|
367 |
+
rows = udB.get_key("HELP_ROWS") or 5
|
368 |
+
cols = udB.get_key("HELP_COLUMNS") or 2
|
369 |
+
loaded = HELP.get(key, [])
|
370 |
+
emoji = udB.get_key("EMOJI_IN_HELP") or "✘"
|
371 |
+
List = [
|
372 |
+
Button.inline(f"{emoji} {x} {emoji}", data=f"uplugin_{key}_{x}|{index}")
|
373 |
+
for x in sorted(loaded)
|
374 |
+
]
|
375 |
+
all_ = split_list(List, cols)
|
376 |
+
fl_ = split_list(all_, rows)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
377 |
try:
|
378 |
+
new_ = fl_[index]
|
379 |
+
except IndexError:
|
380 |
+
new_ = fl_[0] if fl_ else []
|
381 |
+
index = 0
|
382 |
+
if index == 0 and len(fl_) == 1:
|
383 |
+
new_.append([Button.inline("« Bᴀᴄᴋ »", data="open")])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
384 |
else:
|
385 |
+
new_.append(
|
|
|
|
|
|
|
|
|
386 |
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
387 |
Button.inline(
|
388 |
"« Pʀᴇᴠɪᴏᴜs",
|
389 |
+
data=f"uh_{key}_{index-1}",
|
390 |
),
|
391 |
Button.inline("« Bᴀᴄᴋ »", data="open"),
|
392 |
Button.inline(
|
393 |
"Nᴇxᴛ »",
|
394 |
+
data=f"uh_{key}_{index+1}",
|
395 |
),
|
396 |
+
]
|
397 |
+
)
|
398 |
+
return new_
|
|
|
|
|
|
|
|
|
399 |
|
400 |
|
401 |
# --------------------------------------------------------------------------------- #
|
402 |
|
403 |
+
|
404 |
STUFF = {}
|
405 |
|
406 |
|
|
|
411 |
if not (n and n.isdigit()):
|
412 |
return
|
413 |
ok = STUFF.get(int(n))
|
414 |
+
txt = ok.get("msg")
|
415 |
+
pic = ok.get("media")
|
416 |
+
btn = ok.get("button")
|
417 |
if not (pic or txt):
|
418 |
txt = "Hey!"
|
419 |
if pic:
|
|
|
493 |
)
|
494 |
|
495 |
except Exception as er:
|
496 |
+
LOGS.exception(er)
|
plugins/_ultroid.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -35,7 +35,7 @@ ULTSTRING = """🎇 **Thanks for Deploying Ultroid Userbot!**
|
|
35 |
|
36 |
@ultroid_cmd(
|
37 |
pattern="repo$",
|
38 |
-
|
39 |
)
|
40 |
async def repify(e):
|
41 |
try:
|
@@ -50,7 +50,7 @@ async def repify(e):
|
|
50 |
pass
|
51 |
except Exception as er:
|
52 |
LOGS.info("Error while repo command : " + str(er))
|
53 |
-
await eor(
|
54 |
|
55 |
|
56 |
@ultroid_cmd(pattern="ultroid$")
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
35 |
|
36 |
@ultroid_cmd(
|
37 |
pattern="repo$",
|
38 |
+
manager=True,
|
39 |
)
|
40 |
async def repify(e):
|
41 |
try:
|
|
|
50 |
pass
|
51 |
except Exception as er:
|
52 |
LOGS.info("Error while repo command : " + str(er))
|
53 |
+
await e.eor(REPOMSG)
|
54 |
|
55 |
|
56 |
@ultroid_cmd(pattern="ultroid$")
|
plugins/_userlogs.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -11,15 +11,19 @@ import re
|
|
11 |
from pyUltroid.dB.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(
|
@@ -29,51 +33,55 @@ CACHE_SPAM = {}
|
|
29 |
),
|
30 |
)
|
31 |
async def all_messages_catcher(e):
|
32 |
-
|
|
|
|
|
|
|
33 |
return
|
34 |
try:
|
35 |
-
NEEDTOLOG = int(udB.
|
36 |
except Exception:
|
37 |
return LOGS.info(get_string("userlogs_1"))
|
38 |
-
|
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 hasattr(x, "username") and 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 |
-
|
|
|
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.
|
70 |
await asst.send_message(NEEDTOLOG, get_string("com_4"), buttons=buttons)
|
71 |
except (PeerIdInvalidError, ValueError):
|
72 |
try:
|
73 |
CACHE_SPAM[NEEDTOLOG]
|
74 |
except KeyError:
|
75 |
await asst.send_message(
|
76 |
-
|
77 |
)
|
78 |
CACHE_SPAM.update({NEEDTOLOG: True})
|
79 |
except ChatWriteForbiddenError:
|
@@ -88,14 +96,83 @@ async def all_messages_catcher(e):
|
|
88 |
await asst.send_message(LOG_CHANNEL, MSG)
|
89 |
CACHE_SPAM.update({NEEDTOLOG: True})
|
90 |
except Exception as er:
|
91 |
-
LOGS.
|
|
|
92 |
|
|
|
93 |
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
@ultroid_bot.on(
|
97 |
events.NewMessage(
|
98 |
-
outgoing=True,
|
|
|
|
|
99 |
)
|
100 |
)
|
101 |
async def idk(e):
|
@@ -104,85 +181,92 @@ if udB.get("TAG_LOG"):
|
|
104 |
if chat and msg:
|
105 |
try:
|
106 |
await ultroid_bot.send_message(chat, e.message, reply_to=msg)
|
107 |
-
except BaseException:
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
@callback(re.compile("who(.*)"))
|
112 |
-
async def _(e):
|
113 |
-
wah = e.pattern_match.group(1).decode("UTF-8")
|
114 |
-
y = await ultroid_bot.get_entity(int(wah))
|
115 |
-
who = f"[{get_display_name(y)}](tg://user?id={y.id})"
|
116 |
-
x = await e.reply(f"Mention By user : {who}")
|
117 |
-
await asyncio.sleep(6)
|
118 |
-
await x.delete()
|
119 |
-
|
120 |
-
|
121 |
-
# log for assistant
|
122 |
-
@asst.on(events.ChatAction)
|
123 |
-
async def when_asst_added_to_chat(event):
|
124 |
-
if not event.user_added:
|
125 |
-
return
|
126 |
-
user = await event.get_user()
|
127 |
-
chat = await event.get_chat()
|
128 |
-
if hasattr(chat, "username") and chat.username:
|
129 |
-
chat = f"[{chat.title}](https://t.me/{chat.username}/{event.action_message.id})"
|
130 |
-
else:
|
131 |
-
chat = f"[{chat.title}](https://t.me/c/{chat.id}/{event.action_message.id})"
|
132 |
-
if not (user and user.is_self):
|
133 |
-
return
|
134 |
-
tmp = event.added_by
|
135 |
-
buttons = Button.inline(
|
136 |
-
get_string("userlogs_3"), data=f"leave_ch_{event.chat_id}|bot"
|
137 |
-
)
|
138 |
-
await asst.send_message(
|
139 |
-
int(udB.get("LOG_CHANNEL")),
|
140 |
-
f"#ADD_LOG\n\n[{tmp.first_name}](tg://user?id={tmp.id}) added [{user.first_name}](tg://user?id={user.id}) to {chat}.",
|
141 |
-
buttons=buttons,
|
142 |
-
)
|
143 |
|
144 |
|
145 |
-
# log for user
|
146 |
|
147 |
|
148 |
-
|
149 |
-
async def when_ultd_added_to_chat(event):
|
150 |
user = await event.get_user()
|
151 |
chat = await event.get_chat()
|
152 |
if not (user and user.is_self):
|
153 |
return
|
154 |
-
if
|
155 |
chat = f"[{chat.title}](https://t.me/{chat.username}/{event.action_message.id})"
|
156 |
else:
|
157 |
chat = f"[{chat.title}](https://t.me/c/{chat.id}/{event.action_message.id})"
|
|
|
158 |
buttons = Button.inline(
|
159 |
-
get_string("userlogs_3"), data=f"leave_ch_{event.chat_id}|
|
160 |
)
|
161 |
if event.user_added:
|
162 |
tmp = event.added_by
|
163 |
text = f"#ADD_LOG\n\n{inline_mention(tmp)} just added {inline_mention(user)} to {chat}."
|
164 |
-
elif event.
|
165 |
-
text = f"#
|
166 |
else:
|
167 |
-
|
168 |
-
await asst.send_message(int(udB
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
|
170 |
|
171 |
@callback(
|
172 |
re.compile(
|
173 |
"leave_ch_(.*)",
|
174 |
),
|
175 |
-
|
176 |
)
|
177 |
async def leave_ch_at(event):
|
178 |
cht = event.data_match.group(1).decode("UTF-8")
|
179 |
ch_id, client = cht.split("|")
|
180 |
-
|
181 |
-
client =
|
182 |
-
|
183 |
-
client = ultroid_bot
|
184 |
-
else:
|
185 |
return
|
186 |
name = (await client.get_entity(int(ch_id))).title
|
187 |
await client.delete_dialog(int(ch_id))
|
188 |
await event.edit(get_string("userlogs_5").format(name))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
11 |
from pyUltroid.dB.botchat_db import tag_add, who_tag
|
12 |
from telethon.errors.rpcerrorlist import (
|
13 |
ChatWriteForbiddenError,
|
14 |
+
MediaCaptionTooLongError,
|
15 |
MediaEmptyError,
|
16 |
+
MessageTooLongError,
|
17 |
PeerIdInvalidError,
|
18 |
UserNotParticipantError,
|
19 |
)
|
20 |
+
from telethon.tl.types import MessageEntityMention, MessageEntityMentionName
|
21 |
from telethon.utils import get_display_name
|
22 |
|
23 |
from . import *
|
24 |
|
25 |
CACHE_SPAM = {}
|
26 |
+
TAG_EDITS = {}
|
27 |
|
28 |
|
29 |
@ultroid_bot.on(
|
|
|
33 |
),
|
34 |
)
|
35 |
async def all_messages_catcher(e):
|
36 |
+
x = await e.get_sender()
|
37 |
+
if isinstance(x, types.User) and (x.bot or x.verified):
|
38 |
+
return
|
39 |
+
if not udB.get_key("TAG_LOG"):
|
40 |
return
|
41 |
try:
|
42 |
+
NEEDTOLOG = int(udB.get_key("TAG_LOG"))
|
43 |
except Exception:
|
44 |
return LOGS.info(get_string("userlogs_1"))
|
45 |
+
buttons = await parse_buttons(e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
try:
|
47 |
sent = await asst.send_message(NEEDTOLOG, e.message, buttons=buttons)
|
48 |
+
if TAG_EDITS.get(e.chat_id):
|
49 |
+
TAG_EDITS[e.chat_id].update({e.id: {"id": sent.id}})
|
50 |
+
else:
|
51 |
+
TAG_EDITS.update({e.chat_id: {e.id: {"id": sent.id}}})
|
52 |
tag_add(sent.id, e.chat_id, e.id)
|
53 |
except MediaEmptyError:
|
54 |
try:
|
55 |
msg = await asst.get_messages(e.chat_id, ids=e.id)
|
56 |
sent = await asst.send_message(NEEDTOLOG, msg, buttons=buttons)
|
57 |
+
if TAG_EDITS.get(e.chat_id):
|
58 |
+
TAG_EDITS[e.chat_id].update({e.id: {"id": sent.id}})
|
59 |
+
else:
|
60 |
+
TAG_EDITS.update({e.chat_id: {e.id: {"id": sent.id}}})
|
61 |
tag_add(sent.id, e.chat_id, e.id)
|
62 |
except Exception as me:
|
63 |
+
if not isinstance(me, (PeerIdInvalidError, ValueError)):
|
64 |
+
LOGS.exception(me)
|
65 |
if e.photo or e.sticker or e.gif:
|
66 |
try:
|
67 |
media = await e.download_media()
|
68 |
+
sent = await asst.send_message(
|
69 |
NEEDTOLOG, e.message.text, file=media, buttons=buttons
|
70 |
)
|
71 |
+
if TAG_EDITS.get(e.chat_id):
|
72 |
+
TAG_EDITS[e.chat_id].update({e.id: {"id": sent.id}})
|
73 |
+
else:
|
74 |
+
TAG_EDITS.update({e.chat_id: {e.id: {"id": sent.id}}})
|
75 |
return os.remove(media)
|
76 |
except Exception as er:
|
77 |
+
LOGS.exception(er)
|
78 |
await asst.send_message(NEEDTOLOG, get_string("com_4"), buttons=buttons)
|
79 |
except (PeerIdInvalidError, ValueError):
|
80 |
try:
|
81 |
CACHE_SPAM[NEEDTOLOG]
|
82 |
except KeyError:
|
83 |
await asst.send_message(
|
84 |
+
udB.get_key("LOG_CHANNEL"), get_string("userlogs_1")
|
85 |
)
|
86 |
CACHE_SPAM.update({NEEDTOLOG: True})
|
87 |
except ChatWriteForbiddenError:
|
|
|
96 |
await asst.send_message(LOG_CHANNEL, MSG)
|
97 |
CACHE_SPAM.update({NEEDTOLOG: True})
|
98 |
except Exception as er:
|
99 |
+
LOGS.exception(er)
|
100 |
+
|
101 |
|
102 |
+
if udB.get_key("TAG_LOG"):
|
103 |
|
104 |
+
@ultroid_bot.on(events.MessageEdited(func=lambda x: not x.out))
|
105 |
+
async def upd_edits(event):
|
106 |
+
x = event.sender
|
107 |
+
if isinstance(x, types.User) and (x.bot or x.verified):
|
108 |
+
return
|
109 |
+
if event.chat_id not in TAG_EDITS:
|
110 |
+
if event.sender_id == udB.get_key("TAG_LOG"):
|
111 |
+
return
|
112 |
+
entities = event.get_entities_text()
|
113 |
+
if entities:
|
114 |
+
is_self = False
|
115 |
+
username = event.client.me.username
|
116 |
+
if username:
|
117 |
+
username = username.lower()
|
118 |
+
for ent, text in entities:
|
119 |
+
if isinstance(ent, MessageEntityMention):
|
120 |
+
is_self = text[1:].lower() == username
|
121 |
+
elif isinstance(ent, MessageEntityMentionName):
|
122 |
+
is_self = ent.user_id == event.client.me.id
|
123 |
+
if is_self:
|
124 |
+
text = f"**#Edited & #Mentioned**\n\n{event.text}"
|
125 |
+
try:
|
126 |
+
sent = await asst.send_message(
|
127 |
+
udB.get_key("TAG_LOG"),
|
128 |
+
text,
|
129 |
+
buttons=await parse_buttons(event),
|
130 |
+
)
|
131 |
+
except Exception as er:
|
132 |
+
return LOGS.exception(er)
|
133 |
+
if TAG_EDITS.get(event.chat_id):
|
134 |
+
TAG_EDITS[event.chat_id].update({event.id: {"id": sent.id}})
|
135 |
+
else:
|
136 |
+
TAG_EDITS.update({event.chat_id: {event.id: {"id": sent.id}}})
|
137 |
+
return
|
138 |
+
d_ = TAG_EDITS[event.chat_id]
|
139 |
+
if not d_.get(event.id):
|
140 |
+
return
|
141 |
+
d_ = d_[event.id]
|
142 |
+
msg = None
|
143 |
+
if d_.get("count"):
|
144 |
+
d_["count"] += 1
|
145 |
+
else:
|
146 |
+
msg = True
|
147 |
+
d_.update({"count": 1})
|
148 |
+
if d_["count"] > 10:
|
149 |
+
return # some limit to take edits
|
150 |
+
try:
|
151 |
+
MSG = await asst.get_messages(udB.get_key("TAG_LOG"), ids=d_["id"])
|
152 |
+
except Exception as er:
|
153 |
+
return LOGS.exception(er)
|
154 |
+
TEXT = MSG.text
|
155 |
+
if msg:
|
156 |
+
TEXT += "\n\n🖋 **Later Edited to !**"
|
157 |
+
strf = event.edit_date.strftime("%H:%M:%S")
|
158 |
+
if "\n" not in event.text:
|
159 |
+
TEXT += f"\n• `{strf}` : {event.text}"
|
160 |
+
else:
|
161 |
+
TEXT += f"\n• `{strf}` :\n-> {event.text}"
|
162 |
+
if d_["count"] == 10:
|
163 |
+
TEXT += "\n\n• __Only the first 10 Edits are shown.__"
|
164 |
+
try:
|
165 |
+
await MSG.edit(TEXT, buttons=await parse_buttons(event))
|
166 |
+
except (MessageTooLongError, MediaCaptionTooLongError):
|
167 |
+
del TAG_EDITS[event.chat_id][event.id]
|
168 |
+
except Exception as er:
|
169 |
+
LOGS.exception(er)
|
170 |
|
171 |
@ultroid_bot.on(
|
172 |
events.NewMessage(
|
173 |
+
outgoing=True,
|
174 |
+
chats=[udB.get_key("TAG_LOG")],
|
175 |
+
func=lambda e: e.reply_to,
|
176 |
)
|
177 |
)
|
178 |
async def idk(e):
|
|
|
181 |
if chat and msg:
|
182 |
try:
|
183 |
await ultroid_bot.send_message(chat, e.message, reply_to=msg)
|
184 |
+
except BaseException as er:
|
185 |
+
LOGS.exception(er)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
|
187 |
|
188 |
+
# log for assistant/user joins/add
|
189 |
|
190 |
|
191 |
+
async def when_added_or_joined(event):
|
|
|
192 |
user = await event.get_user()
|
193 |
chat = await event.get_chat()
|
194 |
if not (user and user.is_self):
|
195 |
return
|
196 |
+
if getattr(chat, "username", None):
|
197 |
chat = f"[{chat.title}](https://t.me/{chat.username}/{event.action_message.id})"
|
198 |
else:
|
199 |
chat = f"[{chat.title}](https://t.me/c/{chat.id}/{event.action_message.id})"
|
200 |
+
key = "bot" if event.client._bot else "user"
|
201 |
buttons = Button.inline(
|
202 |
+
get_string("userlogs_3"), data=f"leave_ch_{event.chat_id}|{key}"
|
203 |
)
|
204 |
if event.user_added:
|
205 |
tmp = event.added_by
|
206 |
text = f"#ADD_LOG\n\n{inline_mention(tmp)} just added {inline_mention(user)} to {chat}."
|
207 |
+
elif event.from_request:
|
208 |
+
text = f"#APPROVAL_LOG\n\n{inline_mention(user)} just got Chat Join Approval to {chat}."
|
209 |
else:
|
210 |
+
text = f"#JOIN_LOG\n\n{inline_mention(user)} just joined {chat}."
|
211 |
+
await asst.send_message(int(udB.get_key("LOG_CHANNEL")), text, buttons=buttons)
|
212 |
+
|
213 |
+
|
214 |
+
asst.add_event_handler(
|
215 |
+
when_added_or_joined, events.ChatAction(func=lambda x: x.user_added)
|
216 |
+
)
|
217 |
+
ultroid_bot.add_event_handler(
|
218 |
+
when_added_or_joined,
|
219 |
+
events.ChatAction(func=lambda x: x.user_added or x.user_joined),
|
220 |
+
)
|
221 |
+
|
222 |
+
_client = {"bot": asst, "user": ultroid_bot}
|
223 |
|
224 |
|
225 |
@callback(
|
226 |
re.compile(
|
227 |
"leave_ch_(.*)",
|
228 |
),
|
229 |
+
from_users=[ultroid_bot.uid],
|
230 |
)
|
231 |
async def leave_ch_at(event):
|
232 |
cht = event.data_match.group(1).decode("UTF-8")
|
233 |
ch_id, client = cht.split("|")
|
234 |
+
try:
|
235 |
+
client = _client[client]
|
236 |
+
except KeyError:
|
|
|
|
|
237 |
return
|
238 |
name = (await client.get_entity(int(ch_id))).title
|
239 |
await client.delete_dialog(int(ch_id))
|
240 |
await event.edit(get_string("userlogs_5").format(name))
|
241 |
+
|
242 |
+
|
243 |
+
@callback("do_nothing")
|
244 |
+
async def _(event):
|
245 |
+
await event.answer()
|
246 |
+
|
247 |
+
|
248 |
+
async def parse_buttons(event):
|
249 |
+
y, x = event.chat, event.sender
|
250 |
+
where_n, who_n = get_display_name(y), get_display_name(x)
|
251 |
+
where_l = event.message_link
|
252 |
+
buttons = [[Button.url(where_n, where_l)]]
|
253 |
+
if isinstance(x, types.User) and x.username:
|
254 |
+
try:
|
255 |
+
buttons.append(
|
256 |
+
[Button.mention(who_n, await asst.get_input_entity(x.username))]
|
257 |
+
)
|
258 |
+
except Exception as er:
|
259 |
+
LOGS.exception(er)
|
260 |
+
buttons.append([Button.url(who_n, f"t.me/{x.username}")])
|
261 |
+
elif getattr(x, "username"):
|
262 |
+
buttons.append([Button.url(who_n, f"t.me/{x.username}")])
|
263 |
+
else:
|
264 |
+
buttons.append([Button.url(who_n, where_l)])
|
265 |
+
replied = await event.get_reply_message()
|
266 |
+
if replied and replied.out:
|
267 |
+
button = Button.url("Replied to", replied.message_link)
|
268 |
+
if len(who_n) > 7:
|
269 |
+
buttons.append([button])
|
270 |
+
else:
|
271 |
+
buttons[-1].append(button)
|
272 |
+
return buttons
|
plugins/_wspr.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -8,18 +8,25 @@
|
|
8 |
import re
|
9 |
|
10 |
from telethon import Button
|
11 |
-
from telethon.errors.rpcerrorlist import
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
14 |
from telethon.tl.functions.users import GetFullUserRequest as gu
|
15 |
-
from telethon.tl.types import UserStatusEmpty as mt
|
16 |
-
from telethon.tl.types import UserStatusLastMonth as lm
|
17 |
-
from telethon.tl.types import UserStatusLastWeek as lw
|
18 |
-
from telethon.tl.types import UserStatusOffline as off
|
19 |
-
from telethon.tl.types import UserStatusOnline as on
|
20 |
-
from telethon.tl.types import UserStatusRecently as rec
|
21 |
|
22 |
-
from . import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
buddhhu = {}
|
25 |
|
@@ -38,16 +45,15 @@ async def _(e):
|
|
38 |
if put:
|
39 |
try:
|
40 |
results = await e.client.inline_query(asst.me.username, f"msg {put}")
|
41 |
-
except
|
42 |
-
return await eor(
|
43 |
-
e,
|
44 |
get_string("help_2").format(HNDLR),
|
45 |
)
|
46 |
-
except
|
47 |
-
return await eor(
|
48 |
await results[0].click(e.chat_id, reply_to=e.reply_to_msg_id, hide_via=True)
|
49 |
return await e.delete()
|
50 |
-
await eor(
|
51 |
|
52 |
|
53 |
@in_pattern("wspr", owner=True)
|
@@ -102,34 +108,31 @@ async def _(e):
|
|
102 |
if query.isdigit():
|
103 |
query = int(query)
|
104 |
logi = await ultroid_bot(gu(id=query))
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
x = logi.user.status
|
110 |
-
bio = logi.about
|
111 |
-
if isinstance(x, on):
|
112 |
status = "Online"
|
113 |
-
|
114 |
status = "Offline"
|
115 |
-
|
116 |
status = "Last Seen Recently"
|
117 |
-
|
118 |
status = "Last seen months ago"
|
119 |
-
|
120 |
status = "Last seen weeks ago"
|
121 |
-
|
122 |
status = "Can't Tell"
|
123 |
-
text = f"**Name:** `{
|
124 |
-
text += f"**Id:** `{
|
125 |
-
if username:
|
126 |
-
text += f"**Username:** `{username}`\n"
|
127 |
-
url = f"https://t.me/{username}"
|
128 |
else:
|
129 |
text += f"**Mention:** `{mention}`\n"
|
130 |
-
url = f"tg://user?id={
|
131 |
text += f"**Status:** `{status}`\n"
|
132 |
-
text += f"**About:** `{
|
133 |
button = [
|
134 |
Button.url("Private", url=url),
|
135 |
Button.switch_inline(
|
@@ -139,7 +142,7 @@ async def _(e):
|
|
139 |
),
|
140 |
]
|
141 |
sur = e.builder.article(
|
142 |
-
title=
|
143 |
description=desc,
|
144 |
text=text,
|
145 |
buttons=button,
|
@@ -150,7 +153,8 @@ async def _(e):
|
|
150 |
description="You Didn't Type Username or id.",
|
151 |
text="You Didn't Type Username or id.",
|
152 |
)
|
153 |
-
except BaseException:
|
|
|
154 |
name = get_string("wspr_4").format(query)
|
155 |
sur = e.builder.article(
|
156 |
title=name,
|
@@ -184,7 +188,7 @@ async def _(e):
|
|
184 |
buddhhu.pop(ids)
|
185 |
try:
|
186 |
await e.edit(get_string("wspr_2"))
|
187 |
-
except
|
188 |
pass
|
189 |
else:
|
190 |
await e.answer(get_string("wspr_5"), alert=True)
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
8 |
import re
|
9 |
|
10 |
from telethon import Button
|
11 |
+
from telethon.errors.rpcerrorlist import (
|
12 |
+
BotInlineDisabledError,
|
13 |
+
BotResponseTimeoutError,
|
14 |
+
MessageNotModifiedError,
|
15 |
+
)
|
16 |
+
from telethon.tl import types
|
17 |
from telethon.tl.functions.users import GetFullUserRequest as gu
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
from . import (
|
20 |
+
HNDLR,
|
21 |
+
LOGS,
|
22 |
+
asst,
|
23 |
+
callback,
|
24 |
+
get_string,
|
25 |
+
in_pattern,
|
26 |
+
inline_mention,
|
27 |
+
ultroid_bot,
|
28 |
+
ultroid_cmd,
|
29 |
+
)
|
30 |
|
31 |
buddhhu = {}
|
32 |
|
|
|
45 |
if put:
|
46 |
try:
|
47 |
results = await e.client.inline_query(asst.me.username, f"msg {put}")
|
48 |
+
except BotResponseTimeoutError:
|
49 |
+
return await e.eor(
|
|
|
50 |
get_string("help_2").format(HNDLR),
|
51 |
)
|
52 |
+
except BotInlineDisabledError:
|
53 |
+
return await e.eor(get_string("help_3"))
|
54 |
await results[0].click(e.chat_id, reply_to=e.reply_to_msg_id, hide_via=True)
|
55 |
return await e.delete()
|
56 |
+
await e.eor(get_string("wspr_3"))
|
57 |
|
58 |
|
59 |
@in_pattern("wspr", owner=True)
|
|
|
108 |
if query.isdigit():
|
109 |
query = int(query)
|
110 |
logi = await ultroid_bot(gu(id=query))
|
111 |
+
user = logi.users[0]
|
112 |
+
mention = inline_mention(user)
|
113 |
+
x = user.status
|
114 |
+
if isinstance(x, types.UserStatusOnline):
|
|
|
|
|
|
|
115 |
status = "Online"
|
116 |
+
elif isinstance(x, types.UserStatusOffline):
|
117 |
status = "Offline"
|
118 |
+
elif isinstance(x, types.UserStatusRecently):
|
119 |
status = "Last Seen Recently"
|
120 |
+
elif isinstance(x, types.UserStatusLastMonth):
|
121 |
status = "Last seen months ago"
|
122 |
+
elif isinstance(x, types.UserStatusLastWeek):
|
123 |
status = "Last seen weeks ago"
|
124 |
+
else:
|
125 |
status = "Can't Tell"
|
126 |
+
text = f"**Name:** `{user.first_name}`\n"
|
127 |
+
text += f"**Id:** `{user.id}`\n"
|
128 |
+
if user.username:
|
129 |
+
text += f"**Username:** `{user.username}`\n"
|
130 |
+
url = f"https://t.me/{user.username}"
|
131 |
else:
|
132 |
text += f"**Mention:** `{mention}`\n"
|
133 |
+
url = f"tg://user?id={user.id}"
|
134 |
text += f"**Status:** `{status}`\n"
|
135 |
+
text += f"**About:** `{logi.full_user.about}`"
|
136 |
button = [
|
137 |
Button.url("Private", url=url),
|
138 |
Button.switch_inline(
|
|
|
142 |
),
|
143 |
]
|
144 |
sur = e.builder.article(
|
145 |
+
title=user.first_name,
|
146 |
description=desc,
|
147 |
text=text,
|
148 |
buttons=button,
|
|
|
153 |
description="You Didn't Type Username or id.",
|
154 |
text="You Didn't Type Username or id.",
|
155 |
)
|
156 |
+
except BaseException as er:
|
157 |
+
LOGS.exception(er)
|
158 |
name = get_string("wspr_4").format(query)
|
159 |
sur = e.builder.article(
|
160 |
title=name,
|
|
|
188 |
buddhhu.pop(ids)
|
189 |
try:
|
190 |
await e.edit(get_string("wspr_2"))
|
191 |
+
except MessageNotModifiedError:
|
192 |
pass
|
193 |
else:
|
194 |
await e.answer(get_string("wspr_5"), alert=True)
|
plugins/admintools.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -45,10 +45,7 @@ from pyUltroid.dB import DEVLIST
|
|
45 |
from pyUltroid.functions.admins import ban_time
|
46 |
from telethon.errors import BadRequestError
|
47 |
from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidError
|
48 |
-
from telethon.tl.functions.channels import
|
49 |
-
DeleteUserHistoryRequest,
|
50 |
-
GetFullChannelRequest,
|
51 |
-
)
|
52 |
from telethon.tl.functions.messages import GetFullChatRequest, SetHistoryTTLRequest
|
53 |
from telethon.tl.types import InputMessagesFilterPinned
|
54 |
|
@@ -59,7 +56,6 @@ from . import (
|
|
59 |
eor,
|
60 |
get_string,
|
61 |
get_uinfo,
|
62 |
-
get_user_id,
|
63 |
inline_mention,
|
64 |
types,
|
65 |
ultroid_bot,
|
@@ -67,9 +63,11 @@ from . import (
|
|
67 |
)
|
68 |
|
69 |
|
70 |
-
@ultroid_cmd(
|
|
|
|
|
71 |
async def prmte(ult):
|
72 |
-
xx = await eor(
|
73 |
await ult.get_chat()
|
74 |
user, rank = await get_uinfo(ult)
|
75 |
rank = rank or "Admin"
|
@@ -94,12 +92,10 @@ async def prmte(ult):
|
|
94 |
|
95 |
|
96 |
@ultroid_cmd(
|
97 |
-
pattern="demote ?(.*)",
|
98 |
-
admins_only=True,
|
99 |
-
type=["official", "manager"],
|
100 |
)
|
101 |
async def dmote(ult):
|
102 |
-
xx = await eor(
|
103 |
await ult.get_chat()
|
104 |
user, rank = await get_uinfo(ult)
|
105 |
if not rank:
|
@@ -125,10 +121,14 @@ async def dmote(ult):
|
|
125 |
@ultroid_cmd(
|
126 |
pattern="ban ?(.*)",
|
127 |
admins_only=True,
|
128 |
-
|
|
|
129 |
)
|
130 |
async def bban(ult):
|
131 |
-
|
|
|
|
|
|
|
132 |
if not user:
|
133 |
return await eod(ult, get_string("ban_1"))
|
134 |
if user.id in DEVLIST:
|
@@ -147,16 +147,15 @@ async def bban(ult):
|
|
147 |
await eod(ult, text)
|
148 |
|
149 |
|
150 |
-
@ultroid_cmd(
|
151 |
-
pattern="unban ?(.*)",
|
152 |
-
admins_only=True,
|
153 |
-
type=["official", "manager"],
|
154 |
-
)
|
155 |
async def uunban(ult):
|
156 |
-
xx = await eor(
|
157 |
if ult.text[1:].startswith("unbanall"):
|
158 |
return
|
159 |
-
|
|
|
|
|
|
|
160 |
if not user:
|
161 |
return await xx.edit(get_string("unban_1"))
|
162 |
try:
|
@@ -166,7 +165,7 @@ async def uunban(ult):
|
|
166 |
except UserIdInvalidError:
|
167 |
await xx.edit(get_string("adm_1"))
|
168 |
sender = inline_mention(await ult.get_sender())
|
169 |
-
text = get_string("unban_3").format(user, sender, ult.chat.title)
|
170 |
if reason:
|
171 |
text += get_string("ban_5").format(reason)
|
172 |
await xx.edit(text)
|
@@ -174,20 +173,23 @@ async def uunban(ult):
|
|
174 |
|
175 |
@ultroid_cmd(
|
176 |
pattern="kick ?(.*)",
|
177 |
-
|
178 |
-
|
179 |
)
|
180 |
async def kck(ult):
|
181 |
if "kickme" in ult.text:
|
182 |
return
|
183 |
ml = ult.text.split(" ", maxsplit=1)[0]
|
184 |
-
xx = await eor(
|
185 |
-
|
|
|
|
|
|
|
186 |
if not user:
|
187 |
return await xx.edit(get_string("adm_1"))
|
188 |
if user.id in DEVLIST:
|
189 |
return await xx.edit(get_string("kick_2"))
|
190 |
-
if user
|
191 |
return await xx.edit(get_string("kick_3"))
|
192 |
try:
|
193 |
await ult.client.kick_participant(ult.chat_id, user.id)
|
@@ -204,42 +206,41 @@ async def kck(ult):
|
|
204 |
await xx.edit(text)
|
205 |
|
206 |
|
207 |
-
@ultroid_cmd(pattern="tban ?(.*)",
|
208 |
async def tkicki(e):
|
209 |
huh = e.text.split(" ")
|
|
|
210 |
try:
|
211 |
tme = huh[1]
|
212 |
except IndexError:
|
213 |
-
return await eor(
|
214 |
try:
|
215 |
inputt = huh[2]
|
216 |
except IndexError:
|
217 |
-
|
218 |
-
|
219 |
-
if
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
else:
|
227 |
-
return await eor(e, get_string("tban_1"), time=3)
|
228 |
try:
|
229 |
bun = await ban_time(e, tme)
|
230 |
await e.client.edit_permissions(
|
231 |
-
e.chat_id,
|
232 |
)
|
233 |
await eod(
|
234 |
e,
|
235 |
-
get_string("tban_2").format(
|
236 |
time=15,
|
237 |
)
|
238 |
except Exception as m:
|
239 |
-
return await eor(
|
240 |
|
241 |
|
242 |
-
@ultroid_cmd(pattern="pin$",
|
243 |
async def pin(msg):
|
244 |
if not msg.is_reply:
|
245 |
return await eor(msg, get_string("pin_1"))
|
@@ -259,10 +260,11 @@ async def pin(msg):
|
|
259 |
|
260 |
@ultroid_cmd(
|
261 |
pattern="unpin($| (.*))",
|
262 |
-
|
|
|
263 |
)
|
264 |
async def unp(ult):
|
265 |
-
xx = await eor(
|
266 |
ch = (ult.pattern_match.group(1)).strip()
|
267 |
msg = None
|
268 |
if ult.is_reply:
|
@@ -278,10 +280,7 @@ async def unp(ult):
|
|
278 |
await xx.edit("`Unpinned!`")
|
279 |
|
280 |
|
281 |
-
@ultroid_cmd(
|
282 |
-
pattern="purge ?(.*)",
|
283 |
-
type=["official", "manager"],
|
284 |
-
)
|
285 |
async def fastpurger(purg):
|
286 |
match = purg.pattern_match.group(1)
|
287 |
try:
|
@@ -290,7 +289,10 @@ async def fastpurger(purg):
|
|
290 |
ABC = None
|
291 |
if ABC and purg.text[6] in ["m", "a"]:
|
292 |
return
|
293 |
-
if not purg._client._bot and (
|
|
|
|
|
|
|
294 |
p = 0
|
295 |
async for msg in purg.client.iter_messages(
|
296 |
purg.chat_id,
|
@@ -304,8 +306,9 @@ async def fastpurger(purg):
|
|
304 |
return await eor(purg, get_string("purge_1"), time=10)
|
305 |
try:
|
306 |
await purg.client.delete_messages(
|
307 |
-
purg.chat_id,
|
308 |
)
|
|
|
309 |
except Exception as er:
|
310 |
LOGS.info(er)
|
311 |
await purg.respond(
|
@@ -371,15 +374,16 @@ async def _(e):
|
|
371 |
get_string("purgeall_1"),
|
372 |
)
|
373 |
|
374 |
-
|
|
|
375 |
try:
|
376 |
-
await e.client(
|
377 |
-
await eor(
|
378 |
except Exception as er:
|
379 |
-
return await eor(
|
380 |
|
381 |
|
382 |
-
@ultroid_cmd(pattern="pinned",
|
383 |
async def djshsh(event):
|
384 |
chat = await event.get_chat()
|
385 |
if isinstance(chat, types.Chat):
|
@@ -390,19 +394,17 @@ async def djshsh(event):
|
|
390 |
return
|
391 |
msg_id = FChat.full_chat.pinned_msg_id
|
392 |
if not msg_id:
|
393 |
-
return await eor(
|
394 |
msg = await event.client.get_messages(chat.id, ids=msg_id)
|
395 |
if msg:
|
396 |
-
await eor(
|
397 |
-
event, f"Pinned Message in Current chat is [here]({msg.message_link})."
|
398 |
-
)
|
399 |
|
400 |
|
401 |
@ultroid_cmd(
|
402 |
pattern="listpinned$",
|
403 |
)
|
404 |
async def get_all_pinned(event):
|
405 |
-
x = await eor(
|
406 |
chat_id = (str(event.chat_id)).replace("-100", "")
|
407 |
chat_name = (await event.get_chat()).title
|
408 |
a = ""
|
@@ -411,7 +413,7 @@ async def get_all_pinned(event):
|
|
411 |
event.chat_id, filter=InputMessagesFilterPinned
|
412 |
):
|
413 |
if i.message:
|
414 |
-
t = " ".join(i.message.split()[
|
415 |
txt = "{}....".format(t)
|
416 |
else:
|
417 |
txt = "Go to message."
|
@@ -436,7 +438,7 @@ async def get_all_pinned(event):
|
|
436 |
async def autodelte(ult):
|
437 |
match = ult.pattern_match.group(1)
|
438 |
if not match or match not in ["24h", "7d", "1m", "off"]:
|
439 |
-
return await eor(
|
440 |
if match == "24h":
|
441 |
tt = 3600 * 24
|
442 |
elif match == "7d":
|
@@ -451,4 +453,4 @@ async def autodelte(ult):
|
|
451 |
return await eor(
|
452 |
ult, f"Auto Delete Setting is Already same to `{match}`", time=5
|
453 |
)
|
454 |
-
await eor(
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
45 |
from pyUltroid.functions.admins import ban_time
|
46 |
from telethon.errors import BadRequestError
|
47 |
from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidError
|
48 |
+
from telethon.tl.functions.channels import GetFullChannelRequest
|
|
|
|
|
|
|
49 |
from telethon.tl.functions.messages import GetFullChatRequest, SetHistoryTTLRequest
|
50 |
from telethon.tl.types import InputMessagesFilterPinned
|
51 |
|
|
|
56 |
eor,
|
57 |
get_string,
|
58 |
get_uinfo,
|
|
|
59 |
inline_mention,
|
60 |
types,
|
61 |
ultroid_bot,
|
|
|
63 |
)
|
64 |
|
65 |
|
66 |
+
@ultroid_cmd(
|
67 |
+
pattern="promote ?(.*)", admins_only=True, manager=True, require="add_admins"
|
68 |
+
)
|
69 |
async def prmte(ult):
|
70 |
+
xx = await ult.eor(get_string("com_1"))
|
71 |
await ult.get_chat()
|
72 |
user, rank = await get_uinfo(ult)
|
73 |
rank = rank or "Admin"
|
|
|
92 |
|
93 |
|
94 |
@ultroid_cmd(
|
95 |
+
pattern="demote ?(.*)", admins_only=True, manager=True, require="add_admins"
|
|
|
|
|
96 |
)
|
97 |
async def dmote(ult):
|
98 |
+
xx = await ult.eor(get_string("com_1"))
|
99 |
await ult.get_chat()
|
100 |
user, rank = await get_uinfo(ult)
|
101 |
if not rank:
|
|
|
121 |
@ultroid_cmd(
|
122 |
pattern="ban ?(.*)",
|
123 |
admins_only=True,
|
124 |
+
manager=True,
|
125 |
+
require="ban_users",
|
126 |
)
|
127 |
async def bban(ult):
|
128 |
+
something = await get_uinfo(ult)
|
129 |
+
if not something:
|
130 |
+
return
|
131 |
+
user, reason = something
|
132 |
if not user:
|
133 |
return await eod(ult, get_string("ban_1"))
|
134 |
if user.id in DEVLIST:
|
|
|
147 |
await eod(ult, text)
|
148 |
|
149 |
|
150 |
+
@ultroid_cmd(pattern="unban ?(.*)", admins_only=True, manager=True, require="ban_users")
|
|
|
|
|
|
|
|
|
151 |
async def uunban(ult):
|
152 |
+
xx = await ult.eor(get_string("com_1"))
|
153 |
if ult.text[1:].startswith("unbanall"):
|
154 |
return
|
155 |
+
something = await get_uinfo(ult)
|
156 |
+
if not something:
|
157 |
+
return
|
158 |
+
user, reason = something
|
159 |
if not user:
|
160 |
return await xx.edit(get_string("unban_1"))
|
161 |
try:
|
|
|
165 |
except UserIdInvalidError:
|
166 |
await xx.edit(get_string("adm_1"))
|
167 |
sender = inline_mention(await ult.get_sender())
|
168 |
+
text = get_string("unban_3").format(inline_mention(user), sender, ult.chat.title)
|
169 |
if reason:
|
170 |
text += get_string("ban_5").format(reason)
|
171 |
await xx.edit(text)
|
|
|
173 |
|
174 |
@ultroid_cmd(
|
175 |
pattern="kick ?(.*)",
|
176 |
+
manager=True,
|
177 |
+
require="ban_users",
|
178 |
)
|
179 |
async def kck(ult):
|
180 |
if "kickme" in ult.text:
|
181 |
return
|
182 |
ml = ult.text.split(" ", maxsplit=1)[0]
|
183 |
+
xx = await ult.eor(get_string("com_1"))
|
184 |
+
something = await get_uinfo(ult)
|
185 |
+
if not something:
|
186 |
+
return
|
187 |
+
user, reason = something
|
188 |
if not user:
|
189 |
return await xx.edit(get_string("adm_1"))
|
190 |
if user.id in DEVLIST:
|
191 |
return await xx.edit(get_string("kick_2"))
|
192 |
+
if getattr(user, "is_self", False):
|
193 |
return await xx.edit(get_string("kick_3"))
|
194 |
try:
|
195 |
await ult.client.kick_participant(ult.chat_id, user.id)
|
|
|
206 |
await xx.edit(text)
|
207 |
|
208 |
|
209 |
+
@ultroid_cmd(pattern="tban ?(.*)", manager=True, require="ban_users")
|
210 |
async def tkicki(e):
|
211 |
huh = e.text.split(" ")
|
212 |
+
inputt = None
|
213 |
try:
|
214 |
tme = huh[1]
|
215 |
except IndexError:
|
216 |
+
return await e.eor(get_string("adm_3"), time=15)
|
217 |
try:
|
218 |
inputt = huh[2]
|
219 |
except IndexError:
|
220 |
+
if e.reply_to_msg_id:
|
221 |
+
inputt = (await e.get_reply_message()).sender_id
|
222 |
+
if not inputt:
|
223 |
+
return await e.eor(get_string("tban_1"))
|
224 |
+
userid = await e.client.parse_id(inputt)
|
225 |
+
try:
|
226 |
+
user = await e.client.get_entity(userid)
|
227 |
+
except Exception as ex:
|
228 |
+
return await eor(d, f"`{ex}`")
|
|
|
|
|
229 |
try:
|
230 |
bun = await ban_time(e, tme)
|
231 |
await e.client.edit_permissions(
|
232 |
+
e.chat_id, user.id, until_date=bun, view_messages=False
|
233 |
)
|
234 |
await eod(
|
235 |
e,
|
236 |
+
get_string("tban_2").format(inline_mention(user), e.chat.title, tme),
|
237 |
time=15,
|
238 |
)
|
239 |
except Exception as m:
|
240 |
+
return await e.eor(str(m))
|
241 |
|
242 |
|
243 |
+
@ultroid_cmd(pattern="pin$", manager=True, require="pin_messages")
|
244 |
async def pin(msg):
|
245 |
if not msg.is_reply:
|
246 |
return await eor(msg, get_string("pin_1"))
|
|
|
260 |
|
261 |
@ultroid_cmd(
|
262 |
pattern="unpin($| (.*))",
|
263 |
+
manager=True,
|
264 |
+
require="pin_messages",
|
265 |
)
|
266 |
async def unp(ult):
|
267 |
+
xx = await ult.eor(get_string("com_1"))
|
268 |
ch = (ult.pattern_match.group(1)).strip()
|
269 |
msg = None
|
270 |
if ult.is_reply:
|
|
|
280 |
await xx.edit("`Unpinned!`")
|
281 |
|
282 |
|
283 |
+
@ultroid_cmd(pattern="purge ?(.*)", manager=True, require="delete_messages")
|
|
|
|
|
|
|
284 |
async def fastpurger(purg):
|
285 |
match = purg.pattern_match.group(1)
|
286 |
try:
|
|
|
289 |
ABC = None
|
290 |
if ABC and purg.text[6] in ["m", "a"]:
|
291 |
return
|
292 |
+
if not purg._client._bot and (
|
293 |
+
(match)
|
294 |
+
or (purg.is_reply and (purg.is_private or isinstance(purg.chat, types.Chat)))
|
295 |
+
):
|
296 |
p = 0
|
297 |
async for msg in purg.client.iter_messages(
|
298 |
purg.chat_id,
|
|
|
306 |
return await eor(purg, get_string("purge_1"), time=10)
|
307 |
try:
|
308 |
await purg.client.delete_messages(
|
309 |
+
purg.chat_id, list(range(purg.reply_to_msg_id, purg.id + 1))
|
310 |
)
|
311 |
+
|
312 |
except Exception as er:
|
313 |
LOGS.info(er)
|
314 |
await purg.respond(
|
|
|
374 |
get_string("purgeall_1"),
|
375 |
)
|
376 |
|
377 |
+
msg = await e.get_reply_message()
|
378 |
+
name = msg.sender
|
379 |
try:
|
380 |
+
await e.client.delete_messages(e.chat_id, from_user=msg.sender_id)
|
381 |
+
await e.eor(get_string("purgeall_2").format(name.first_name), time=5)
|
382 |
except Exception as er:
|
383 |
+
return await e.eor(str(er), time=5)
|
384 |
|
385 |
|
386 |
+
@ultroid_cmd(pattern="pinned", manager=True, groups_only=True)
|
387 |
async def djshsh(event):
|
388 |
chat = await event.get_chat()
|
389 |
if isinstance(chat, types.Chat):
|
|
|
394 |
return
|
395 |
msg_id = FChat.full_chat.pinned_msg_id
|
396 |
if not msg_id:
|
397 |
+
return await event.eor(get_string("pinned_1"))
|
398 |
msg = await event.client.get_messages(chat.id, ids=msg_id)
|
399 |
if msg:
|
400 |
+
await event.eor(get_string("pinned_2").format(msg.message_link))
|
|
|
|
|
401 |
|
402 |
|
403 |
@ultroid_cmd(
|
404 |
pattern="listpinned$",
|
405 |
)
|
406 |
async def get_all_pinned(event):
|
407 |
+
x = await event.eor(get_string("com_1"))
|
408 |
chat_id = (str(event.chat_id)).replace("-100", "")
|
409 |
chat_name = (await event.get_chat()).title
|
410 |
a = ""
|
|
|
413 |
event.chat_id, filter=InputMessagesFilterPinned
|
414 |
):
|
415 |
if i.message:
|
416 |
+
t = " ".join(i.message.split()[:4])
|
417 |
txt = "{}....".format(t)
|
418 |
else:
|
419 |
txt = "Go to message."
|
|
|
438 |
async def autodelte(ult):
|
439 |
match = ult.pattern_match.group(1)
|
440 |
if not match or match not in ["24h", "7d", "1m", "off"]:
|
441 |
+
return await ult.eor("`Please Use in Proper Format..`", time=5)
|
442 |
if match == "24h":
|
443 |
tt = 3600 * 24
|
444 |
elif match == "7d":
|
|
|
453 |
return await eor(
|
454 |
ult, f"Auto Delete Setting is Already same to `{match}`", time=5
|
455 |
)
|
456 |
+
await ult.eor(f"Auto Delete Status Changed to `{match}` !")
|
plugins/afk.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -27,9 +27,9 @@ from . import (
|
|
27 |
NOSPAM_CHAT,
|
28 |
Redis,
|
29 |
asst,
|
30 |
-
eor,
|
31 |
get_string,
|
32 |
mediainfo,
|
|
|
33 |
ultroid_bot,
|
34 |
ultroid_cmd,
|
35 |
)
|
@@ -39,9 +39,7 @@ old_afk_msg = []
|
|
39 |
|
40 |
@ultroid_cmd(pattern="afk ?(.*)", fullsudo=True)
|
41 |
async def set_afk(event):
|
42 |
-
if event.client._bot:
|
43 |
-
await eor(event, "Master, I am a Bot, I cant go AFK..")
|
44 |
-
elif is_afk():
|
45 |
return
|
46 |
text, media, media_type = None, None, None
|
47 |
if event.pattern_match.group(1):
|
@@ -56,12 +54,17 @@ async def set_afk(event):
|
|
56 |
file = await event.client.download_media(reply.media)
|
57 |
iurl = uf(file)
|
58 |
media = f"https://telegra.ph{iurl[0]}"
|
59 |
-
elif "sticker" or "audio" in media_type:
|
60 |
-
media = reply.file.id
|
61 |
else:
|
62 |
-
|
63 |
-
await eor(
|
64 |
add_afk(text, media_type, media)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
msg1, msg2 = None, None
|
66 |
if text and media:
|
67 |
if "sticker" in media_type:
|
@@ -92,16 +95,13 @@ async def set_afk(event):
|
|
92 |
await asst.send_message(LOG_CHANNEL, msg1.text)
|
93 |
|
94 |
|
95 |
-
@ultroid_bot.on(events.NewMessage(outgoing=True))
|
96 |
async def remove_afk(event):
|
97 |
-
if (
|
98 |
-
event.is_private
|
99 |
-
and Redis("PMSETTING") == "True"
|
100 |
-
and not is_approved(event.chat_id)
|
101 |
-
):
|
102 |
return
|
103 |
elif "afk" in event.text.lower():
|
104 |
return
|
|
|
|
|
105 |
if is_afk():
|
106 |
_, _, _, afk_time = is_afk()
|
107 |
del_afk()
|
@@ -116,15 +116,8 @@ async def remove_afk(event):
|
|
116 |
await off.delete()
|
117 |
|
118 |
|
119 |
-
@ultroid_bot.on(
|
120 |
-
events.NewMessage(incoming=True, func=lambda e: bool(e.mentioned or e.is_private)),
|
121 |
-
)
|
122 |
async def on_afk(event):
|
123 |
-
if (
|
124 |
-
event.is_private
|
125 |
-
and Redis("PMSETTING") == "True"
|
126 |
-
and not is_approved(event.chat_id)
|
127 |
-
):
|
128 |
return
|
129 |
elif "afk" in event.text.lower():
|
130 |
return
|
@@ -163,3 +156,13 @@ async def on_afk(event):
|
|
163 |
old_afk_msg.append(msg1)
|
164 |
if msg2:
|
165 |
old_afk_msg.append(msg2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
27 |
NOSPAM_CHAT,
|
28 |
Redis,
|
29 |
asst,
|
|
|
30 |
get_string,
|
31 |
mediainfo,
|
32 |
+
udB,
|
33 |
ultroid_bot,
|
34 |
ultroid_cmd,
|
35 |
)
|
|
|
39 |
|
40 |
@ultroid_cmd(pattern="afk ?(.*)", fullsudo=True)
|
41 |
async def set_afk(event):
|
42 |
+
if event.client._bot or is_afk():
|
|
|
|
|
43 |
return
|
44 |
text, media, media_type = None, None, None
|
45 |
if event.pattern_match.group(1):
|
|
|
54 |
file = await event.client.download_media(reply.media)
|
55 |
iurl = uf(file)
|
56 |
media = f"https://telegra.ph{iurl[0]}"
|
|
|
|
|
57 |
else:
|
58 |
+
media = reply.file.id
|
59 |
+
await event.eor("`Done`", time=2)
|
60 |
add_afk(text, media_type, media)
|
61 |
+
ultroid_bot.add_handler(remove_afk, events.NewMessage(outgoing=True))
|
62 |
+
ultroid_bot.add_handler(
|
63 |
+
on_afk,
|
64 |
+
events.NewMessage(
|
65 |
+
incoming=True, func=lambda e: bool(e.mentioned or e.is_private)
|
66 |
+
),
|
67 |
+
)
|
68 |
msg1, msg2 = None, None
|
69 |
if text and media:
|
70 |
if "sticker" in media_type:
|
|
|
95 |
await asst.send_message(LOG_CHANNEL, msg1.text)
|
96 |
|
97 |
|
|
|
98 |
async def remove_afk(event):
|
99 |
+
if event.is_private and udB.get_key("PMSETTING") and not is_approved(event.chat_id):
|
|
|
|
|
|
|
|
|
100 |
return
|
101 |
elif "afk" in event.text.lower():
|
102 |
return
|
103 |
+
elif event.chat_id in NOSPAM_CHAT:
|
104 |
+
return
|
105 |
if is_afk():
|
106 |
_, _, _, afk_time = is_afk()
|
107 |
del_afk()
|
|
|
116 |
await off.delete()
|
117 |
|
118 |
|
|
|
|
|
|
|
119 |
async def on_afk(event):
|
120 |
+
if event.is_private and Redis("PMSETTING") and not is_approved(event.chat_id):
|
|
|
|
|
|
|
|
|
121 |
return
|
122 |
elif "afk" in event.text.lower():
|
123 |
return
|
|
|
156 |
old_afk_msg.append(msg1)
|
157 |
if msg2:
|
158 |
old_afk_msg.append(msg2)
|
159 |
+
|
160 |
+
|
161 |
+
if udB.get_key("AFK_DB"):
|
162 |
+
ultroid_bot.add_handler(remove_afk, events.NewMessage(outgoing=True))
|
163 |
+
ultroid_bot.add_handler(
|
164 |
+
on_afk,
|
165 |
+
events.NewMessage(
|
166 |
+
incoming=True, func=lambda e: bool(e.mentioned or e.is_private)
|
167 |
+
),
|
168 |
+
)
|
plugins/akinator.py
DELETED
@@ -1,104 +0,0 @@
|
|
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 |
-
✘ Commands Available -
|
9 |
-
|
10 |
-
• `{i}akinator`
|
11 |
-
`Start Akinator Game`.
|
12 |
-
|
13 |
-
"""
|
14 |
-
|
15 |
-
import re
|
16 |
-
|
17 |
-
import akinator
|
18 |
-
from telethon.errors import BotMethodInvalidError
|
19 |
-
|
20 |
-
from . import Button, asst, callback, get_string, in_pattern, types, ultroid_cmd
|
21 |
-
|
22 |
-
games = {}
|
23 |
-
aki_photo = "https://telegra.ph/file/b0ff07069e8637783fdae.jpg"
|
24 |
-
|
25 |
-
|
26 |
-
@ultroid_cmd(pattern="akinator")
|
27 |
-
async def doit(e):
|
28 |
-
sta = akinator.Akinator()
|
29 |
-
games.update({e.chat_id: {e.id: sta}})
|
30 |
-
try:
|
31 |
-
m = await e.client.inline_query(asst.me.username, f"aki_{e.chat_id}_{e.id}")
|
32 |
-
await m[0].click(e.chat_id)
|
33 |
-
except BotMethodInvalidError:
|
34 |
-
return await asst.send_file(
|
35 |
-
e.chat_id,
|
36 |
-
aki_photo,
|
37 |
-
buttons=Button.inline(get_string("aki_2"), data=f"aki_{e.chat_id}_{e.id}"),
|
38 |
-
)
|
39 |
-
if e.out:
|
40 |
-
await e.delete()
|
41 |
-
|
42 |
-
|
43 |
-
@callback(re.compile("aki_?(.*)"), owner=True)
|
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(get_string("com_1"))
|
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(get_string("aki_1"), 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_?(.*)"), owner=True)
|
64 |
-
async def okah(e):
|
65 |
-
mk = e.pattern_match.group(1).decode("utf-8").split("_")
|
66 |
-
ch = int(mk[0])
|
67 |
-
mid = int(mk[1])
|
68 |
-
ans = mk[2]
|
69 |
-
try:
|
70 |
-
gm = games[ch][mid]
|
71 |
-
except KeyError:
|
72 |
-
await e.answer(get_string("aki_3"))
|
73 |
-
return
|
74 |
-
text = gm.answer(ans)
|
75 |
-
if gm.progression >= 80:
|
76 |
-
gm.win()
|
77 |
-
gs = gm.first_guess
|
78 |
-
text = "It's " + gs["name"] + "\n " + gs["description"]
|
79 |
-
return await e.edit(text, file=gs["absolute_picture_path"])
|
80 |
-
bts = [Button.inline(o, f"aka_{ch}_{mid}_{o}") for o in ["Yes", "No", "Idk"]]
|
81 |
-
cts = [
|
82 |
-
Button.inline(o, f"aka_{ch}_{mid}_{o}") for o in ["Probably", "Probably Not"]
|
83 |
-
]
|
84 |
-
|
85 |
-
bts = [bts, cts]
|
86 |
-
await e.edit(text, buttons=bts)
|
87 |
-
|
88 |
-
|
89 |
-
@in_pattern(re.compile("aki_?(.*)"), owner=True)
|
90 |
-
async def eiagx(e):
|
91 |
-
bts = Button.inline(get_string("aki_2"), data=e.text)
|
92 |
-
ci = types.InputWebDocument(aki_photo, 0, "image/jpeg", [])
|
93 |
-
ans = [
|
94 |
-
await e.builder.article(
|
95 |
-
"Akinator",
|
96 |
-
type="photo",
|
97 |
-
content=ci,
|
98 |
-
text="Akinator",
|
99 |
-
thumb=ci,
|
100 |
-
buttons=bts,
|
101 |
-
include_media=True,
|
102 |
-
)
|
103 |
-
]
|
104 |
-
await e.answer(ans)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins/antiflood.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -24,21 +24,11 @@ from pyUltroid.dB.antiflood_db import get_flood, get_flood_limit, rem_flood, set
|
|
24 |
from pyUltroid.functions.admins import admin_check
|
25 |
from telethon.events import NewMessage as NewMsg
|
26 |
|
27 |
-
from . import
|
28 |
-
Button,
|
29 |
-
Redis,
|
30 |
-
asst,
|
31 |
-
callback,
|
32 |
-
eod,
|
33 |
-
eor,
|
34 |
-
get_string,
|
35 |
-
ultroid_bot,
|
36 |
-
ultroid_cmd,
|
37 |
-
)
|
38 |
|
39 |
_check_flood = {}
|
40 |
|
41 |
-
if Redis("ANTIFLOOD")
|
42 |
|
43 |
@ultroid_bot.on(
|
44 |
NewMsg(
|
@@ -49,14 +39,14 @@ if Redis("ANTIFLOOD") is not (None or ""):
|
|
49 |
count = 1
|
50 |
chat = (await event.get_chat()).title
|
51 |
if event.chat_id in _check_flood.keys():
|
52 |
-
if event.sender_id ==
|
53 |
count = _check_flood[event.chat_id][event.sender_id]
|
54 |
_check_flood[event.chat_id] = {event.sender_id: count + 1}
|
55 |
else:
|
56 |
_check_flood[event.chat_id] = {event.sender_id: count}
|
57 |
else:
|
58 |
_check_flood[event.chat_id] = {event.sender_id: count}
|
59 |
-
if await admin_check(event) or event.sender.bot:
|
60 |
return
|
61 |
if event.sender_id in DEVLIST:
|
62 |
return
|
@@ -105,9 +95,9 @@ async def unmuting(e):
|
|
105 |
async def setflood(e):
|
106 |
input_ = e.pattern_match.group(1)
|
107 |
if not input_:
|
108 |
-
return await eor(
|
109 |
if not input_.isdigit():
|
110 |
-
return await eor(
|
111 |
m = set_flood(e.chat_id, input_)
|
112 |
if m:
|
113 |
return await eod(e, get_string("antiflood_4").format(input_))
|
@@ -124,8 +114,8 @@ async def remove_flood(e):
|
|
124 |
except BaseException:
|
125 |
pass
|
126 |
if hmm:
|
127 |
-
return await eor(
|
128 |
-
await eor(
|
129 |
|
130 |
|
131 |
@ultroid_cmd(
|
@@ -135,5 +125,5 @@ async def remove_flood(e):
|
|
135 |
async def getflood(e):
|
136 |
ok = get_flood_limit(e.chat_id)
|
137 |
if ok:
|
138 |
-
return await eor(
|
139 |
-
await eor(
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
24 |
from pyUltroid.functions.admins import admin_check
|
25 |
from telethon.events import NewMessage as NewMsg
|
26 |
|
27 |
+
from . import Button, Redis, asst, callback, eod, get_string, ultroid_bot, ultroid_cmd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
_check_flood = {}
|
30 |
|
31 |
+
if Redis("ANTIFLOOD"):
|
32 |
|
33 |
@ultroid_bot.on(
|
34 |
NewMsg(
|
|
|
39 |
count = 1
|
40 |
chat = (await event.get_chat()).title
|
41 |
if event.chat_id in _check_flood.keys():
|
42 |
+
if event.sender_id == list(_check_flood[event.chat_id].keys())[0]:
|
43 |
count = _check_flood[event.chat_id][event.sender_id]
|
44 |
_check_flood[event.chat_id] = {event.sender_id: count + 1}
|
45 |
else:
|
46 |
_check_flood[event.chat_id] = {event.sender_id: count}
|
47 |
else:
|
48 |
_check_flood[event.chat_id] = {event.sender_id: count}
|
49 |
+
if await admin_check(event, silent=True) or event.sender.bot:
|
50 |
return
|
51 |
if event.sender_id in DEVLIST:
|
52 |
return
|
|
|
95 |
async def setflood(e):
|
96 |
input_ = e.pattern_match.group(1)
|
97 |
if not input_:
|
98 |
+
return await e.eor("`What?`", time=5)
|
99 |
if not input_.isdigit():
|
100 |
+
return await e.eor(get_string("com_3"), time=5)
|
101 |
m = set_flood(e.chat_id, input_)
|
102 |
if m:
|
103 |
return await eod(e, get_string("antiflood_4").format(input_))
|
|
|
114 |
except BaseException:
|
115 |
pass
|
116 |
if hmm:
|
117 |
+
return await e.eor(get_string("antiflood_1"), time=5)
|
118 |
+
await e.eor(get_string("antiflood_2"), time=5)
|
119 |
|
120 |
|
121 |
@ultroid_cmd(
|
|
|
125 |
async def getflood(e):
|
126 |
ok = get_flood_limit(e.chat_id)
|
127 |
if ok:
|
128 |
+
return await e.eor(get_string("antiflood_5").format(ok), time=5)
|
129 |
+
await e.eor(get_string("antiflood_2"), time=5)
|
plugins/asstcmd.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -21,9 +21,9 @@ import os
|
|
21 |
from pyUltroid.dB.asstcmd_db import *
|
22 |
from pyUltroid.functions.tools import create_tl_btn, format_btn, get_msg_button
|
23 |
from telegraph import upload_file as uf
|
24 |
-
from telethon
|
25 |
|
26 |
-
from . import
|
27 |
|
28 |
|
29 |
@ultroid_cmd(pattern="addcmd ?(.*)")
|
@@ -31,7 +31,7 @@ async def ac(e):
|
|
31 |
wrd = (e.pattern_match.group(1)).lower()
|
32 |
wt = await e.get_reply_message()
|
33 |
if not (wt and wrd):
|
34 |
-
return await eor(
|
35 |
if "/" in wrd:
|
36 |
wrd = wrd.replace("/", "")
|
37 |
btn = format_btn(wt.buttons) if wt.buttons else None
|
@@ -44,36 +44,42 @@ async def ac(e):
|
|
44 |
m = "https://telegra.ph" + variable[0]
|
45 |
elif wut == "video":
|
46 |
if wt.media.document.size > 8 * 1000 * 1000:
|
47 |
-
return await eor(
|
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:
|
55 |
txt = wt.text
|
56 |
if not btn:
|
57 |
txt, btn = get_msg_button(wt.text)
|
58 |
add_cmd(wrd, txt, m, btn)
|
59 |
else:
|
60 |
-
add_cmd(wrd, None, m)
|
61 |
else:
|
62 |
txt = wt.text
|
63 |
if not btn:
|
64 |
txt, btn = get_msg_button(wt.text)
|
65 |
add_cmd(wrd, txt, None, btn)
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
|
69 |
@ultroid_cmd(pattern="remcmd ?(.*)")
|
70 |
async def rc(e):
|
71 |
wrd = (e.pattern_match.group(1)).lower()
|
72 |
if not wrd:
|
73 |
-
return await eor(
|
74 |
wrd = wrd.replace("/", "")
|
75 |
rem_cmd(wrd)
|
76 |
-
await eor(
|
77 |
|
78 |
|
79 |
@ultroid_cmd(pattern="listcmd$")
|
@@ -82,15 +88,23 @@ async def lscmd(e):
|
|
82 |
ok = get_string("asstcmd_6")
|
83 |
for x in list_cmds():
|
84 |
ok += "/" + x + "\n"
|
85 |
-
return await eor(
|
86 |
-
return await eor(
|
87 |
|
88 |
|
89 |
-
|
90 |
-
async def ascmds(e):
|
91 |
xx = (e.text.replace("/", "")).lower().split()[0]
|
92 |
if cmd_reply(xx):
|
93 |
msg, media, bt = cmd_reply(xx)
|
94 |
if bt:
|
95 |
bt = create_tl_btn(bt)
|
96 |
await e.reply(msg, file=media, buttons=bt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
21 |
from pyUltroid.dB.asstcmd_db import *
|
22 |
from pyUltroid.functions.tools import create_tl_btn, format_btn, get_msg_button
|
23 |
from telegraph import upload_file as uf
|
24 |
+
from telethon import events, utils
|
25 |
|
26 |
+
from . import asst, get_string, mediainfo, ultroid_cmd
|
27 |
|
28 |
|
29 |
@ultroid_cmd(pattern="addcmd ?(.*)")
|
|
|
31 |
wrd = (e.pattern_match.group(1)).lower()
|
32 |
wt = await e.get_reply_message()
|
33 |
if not (wt and wrd):
|
34 |
+
return await e.eor(get_string("asstcmd_1"), time=5)
|
35 |
if "/" in wrd:
|
36 |
wrd = wrd.replace("/", "")
|
37 |
btn = format_btn(wt.buttons) if wt.buttons else None
|
|
|
44 |
m = "https://telegra.ph" + variable[0]
|
45 |
elif wut == "video":
|
46 |
if wt.media.document.size > 8 * 1000 * 1000:
|
47 |
+
return await e.eor(get_string("com_4"), 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 = utils.pack_bot_file_id(wt.media)
|
54 |
if wt.text:
|
55 |
txt = wt.text
|
56 |
if not btn:
|
57 |
txt, btn = get_msg_button(wt.text)
|
58 |
add_cmd(wrd, txt, m, btn)
|
59 |
else:
|
60 |
+
add_cmd(wrd, None, m, btn)
|
61 |
else:
|
62 |
txt = wt.text
|
63 |
if not btn:
|
64 |
txt, btn = get_msg_button(wt.text)
|
65 |
add_cmd(wrd, txt, None, btn)
|
66 |
+
asst.add_handler(
|
67 |
+
astcmds,
|
68 |
+
events.NewMessage(
|
69 |
+
func=lambda x: x.text.startswith("/") and x.text[1:] in list(list_cmds())
|
70 |
+
),
|
71 |
+
)
|
72 |
+
await e.eor(get_string("asstcmd_4").format(wrd))
|
73 |
|
74 |
|
75 |
@ultroid_cmd(pattern="remcmd ?(.*)")
|
76 |
async def rc(e):
|
77 |
wrd = (e.pattern_match.group(1)).lower()
|
78 |
if not wrd:
|
79 |
+
return await e.eor(get_string("asstcmd_2"), time=5)
|
80 |
wrd = wrd.replace("/", "")
|
81 |
rem_cmd(wrd)
|
82 |
+
await e.eor(get_string("asstcmd_3").format(wrd))
|
83 |
|
84 |
|
85 |
@ultroid_cmd(pattern="listcmd$")
|
|
|
88 |
ok = get_string("asstcmd_6")
|
89 |
for x in list_cmds():
|
90 |
ok += "/" + x + "\n"
|
91 |
+
return await e.eor(ok)
|
92 |
+
return await e.eor(get_string("asstcmd_5"))
|
93 |
|
94 |
|
95 |
+
async def astcmds(e):
|
|
|
96 |
xx = (e.text.replace("/", "")).lower().split()[0]
|
97 |
if cmd_reply(xx):
|
98 |
msg, media, bt = cmd_reply(xx)
|
99 |
if bt:
|
100 |
bt = create_tl_btn(bt)
|
101 |
await e.reply(msg, file=media, buttons=bt)
|
102 |
+
|
103 |
+
|
104 |
+
if udB.get_key("ASST_CMDS"):
|
105 |
+
asst.add_handler(
|
106 |
+
astcmds,
|
107 |
+
events.NewMessage(
|
108 |
+
func=lambda x: x.text.startswith("/") and x.text[1:] in list(list_cmds())
|
109 |
+
),
|
110 |
+
)
|
plugins/audiotools.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -49,7 +49,7 @@ async def vnc(e):
|
|
49 |
r = await e.get_reply_message()
|
50 |
if not mediainfo(r.media).startswith(("audio", "video")):
|
51 |
return await eod(e, get_string("spcltool_1"))
|
52 |
-
xxx = await eor(
|
53 |
dl = r.file.name
|
54 |
c_time = time.time()
|
55 |
file = await downloader(
|
@@ -89,7 +89,7 @@ async def trim_aud(e):
|
|
89 |
name = ""
|
90 |
if not name:
|
91 |
name = dt.now().isoformat("_", "seconds") + ".mp4"
|
92 |
-
xxx = await eor(
|
93 |
c_time = time.time()
|
94 |
file = await downloader(
|
95 |
"resources/downloads/" + name,
|
@@ -144,17 +144,17 @@ async def trim_aud(e):
|
|
144 |
)
|
145 |
await xxx.delete()
|
146 |
else:
|
147 |
-
await eor(
|
148 |
|
149 |
|
150 |
@ultroid_cmd(pattern="extractaudio$")
|
151 |
async def ex_aud(e):
|
152 |
reply = await e.get_reply_message()
|
153 |
if not (reply and reply.media and mediainfo(reply.media).startswith("video")):
|
154 |
-
return await eor(
|
155 |
name = reply.file.name or "video.mp4"
|
156 |
vfile = reply.media.document
|
157 |
-
msg = await eor(
|
158 |
c_time = time.time()
|
159 |
file = await downloader(
|
160 |
"resources/downloads/" + name,
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
49 |
r = await e.get_reply_message()
|
50 |
if not mediainfo(r.media).startswith(("audio", "video")):
|
51 |
return await eod(e, get_string("spcltool_1"))
|
52 |
+
xxx = await e.eor(get_string("com_1"))
|
53 |
dl = r.file.name
|
54 |
c_time = time.time()
|
55 |
file = await downloader(
|
|
|
89 |
name = ""
|
90 |
if not name:
|
91 |
name = dt.now().isoformat("_", "seconds") + ".mp4"
|
92 |
+
xxx = await e.eor(get_string("audiotools_5"))
|
93 |
c_time = time.time()
|
94 |
file = await downloader(
|
95 |
"resources/downloads/" + name,
|
|
|
144 |
)
|
145 |
await xxx.delete()
|
146 |
else:
|
147 |
+
await e.eor(get_string("audiotools_1"), time=5)
|
148 |
|
149 |
|
150 |
@ultroid_cmd(pattern="extractaudio$")
|
151 |
async def ex_aud(e):
|
152 |
reply = await e.get_reply_message()
|
153 |
if not (reply and reply.media and mediainfo(reply.media).startswith("video")):
|
154 |
+
return await e.eor(get_string("audiotools_8"))
|
155 |
name = reply.file.name or "video.mp4"
|
156 |
vfile = reply.media.document
|
157 |
+
msg = await e.eor(get_string("com_1"))
|
158 |
c_time = time.time()
|
159 |
file = await downloader(
|
160 |
"resources/downloads/" + name,
|
plugins/autocorrect.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -14,25 +14,30 @@
|
|
14 |
|
15 |
import string
|
16 |
|
17 |
-
from
|
|
|
|
|
|
|
|
|
|
|
18 |
from google_trans_new import google_translator
|
19 |
from telethon import events
|
20 |
|
21 |
-
from . import HNDLR, Redis, eor, get_string, udB, ultroid_bot, ultroid_cmd
|
22 |
-
|
23 |
|
24 |
@ultroid_cmd(pattern="autocorrect", fullsudo=True)
|
25 |
async def acc(e):
|
26 |
if Redis("AUTOCORRECT") != "True":
|
27 |
-
udB.
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
31 |
|
32 |
|
33 |
-
@ultroid_bot.on(events.NewMessage(outgoing=True, func=lambda x: x.text))
|
34 |
async def gramme(event):
|
35 |
-
if
|
36 |
return
|
37 |
t = event.text
|
38 |
if t[0] == HNDLR or t[0].lower() not in string.ascii_lowercase or t.endswith(".."):
|
@@ -47,3 +52,9 @@ async def gramme(event):
|
|
47 |
await event.edit(res)
|
48 |
except BaseException:
|
49 |
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
14 |
|
15 |
import string
|
16 |
|
17 |
+
from . import HNDLR, eor, get_string, udB, ultroid_bot, ultroid_cmd # ignore: pylint
|
18 |
+
|
19 |
+
try:
|
20 |
+
from gingerit.gingerit import GingerIt
|
21 |
+
except ImportError:
|
22 |
+
LOGS.info("GingerIt not found")
|
23 |
from google_trans_new import google_translator
|
24 |
from telethon import events
|
25 |
|
|
|
|
|
26 |
|
27 |
@ultroid_cmd(pattern="autocorrect", fullsudo=True)
|
28 |
async def acc(e):
|
29 |
if Redis("AUTOCORRECT") != "True":
|
30 |
+
udB.set_key("AUTOCORRECT", "True")
|
31 |
+
ultroid_bot.add_handler(
|
32 |
+
gramme, events.NewMessage(outgoing=True, func=lambda x: x.text)
|
33 |
+
)
|
34 |
+
return await e.eor(get_string("act_1"), time=5)
|
35 |
+
udB.del_key("AUTOCORRECT")
|
36 |
+
await e.eor(get_string("act_2"), time=5)
|
37 |
|
38 |
|
|
|
39 |
async def gramme(event):
|
40 |
+
if not udB.get_key("AUTOCORRECT"):
|
41 |
return
|
42 |
t = event.text
|
43 |
if t[0] == HNDLR or t[0].lower() not in string.ascii_lowercase or t.endswith(".."):
|
|
|
52 |
await event.edit(res)
|
53 |
except BaseException:
|
54 |
pass
|
55 |
+
|
56 |
+
|
57 |
+
if udB.get_key("AUTOCORRECT"):
|
58 |
+
ultroid_bot.add_handler(
|
59 |
+
gramme, events.NewMessage(outgoing=True, func=lambda x: x.text)
|
60 |
+
)
|
plugins/autopic.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -10,49 +10,90 @@
|
|
10 |
• `{i}autopic <search query>`
|
11 |
Will change your profile pic at defined intervals with pics related to the given topic.
|
12 |
|
13 |
-
• `{i}
|
14 |
-
Stop the AutoPic command.
|
15 |
-
|
16 |
"""
|
17 |
import asyncio
|
18 |
import os
|
|
|
|
|
19 |
from random import shuffle
|
20 |
|
21 |
-
from pyUltroid.functions.
|
22 |
from telethon.tl.functions.photos import UploadProfilePhotoRequest
|
23 |
|
24 |
-
from . import
|
25 |
|
26 |
|
27 |
@ultroid_cmd(pattern="autopic ?(.*)")
|
28 |
async def autopic(e):
|
29 |
search = e.pattern_match.group(1)
|
|
|
|
|
|
|
30 |
if not search:
|
31 |
-
return await eor(
|
32 |
-
e = await eor(
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
while True:
|
41 |
-
for lie in
|
42 |
-
if udB.
|
43 |
return
|
44 |
-
|
45 |
-
file = await e.client.upload_file(kar)
|
46 |
await e.client(UploadProfilePhotoRequest(file))
|
47 |
-
os.remove(kar)
|
48 |
await asyncio.sleep(SLEEP_TIME)
|
49 |
shuffle(clls)
|
50 |
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
10 |
• `{i}autopic <search query>`
|
11 |
Will change your profile pic at defined intervals with pics related to the given topic.
|
12 |
|
13 |
+
• `{i}autopic` : stop autopic if active.
|
|
|
|
|
14 |
"""
|
15 |
import asyncio
|
16 |
import os
|
17 |
+
import random
|
18 |
+
from glob import glob
|
19 |
from random import shuffle
|
20 |
|
21 |
+
from pyUltroid.functions.google_image import googleimagesdownload
|
22 |
from telethon.tl.functions.photos import UploadProfilePhotoRequest
|
23 |
|
24 |
+
from . import LOGS, get_string, udB, ultroid_bot, ultroid_cmd
|
25 |
|
26 |
|
27 |
@ultroid_cmd(pattern="autopic ?(.*)")
|
28 |
async def autopic(e):
|
29 |
search = e.pattern_match.group(1)
|
30 |
+
if udB.get_key("AUTOPIC") and not search:
|
31 |
+
udB.del_key("AUTOPIC")
|
32 |
+
return await e.eor(get_string("autopic_5"))
|
33 |
if not search:
|
34 |
+
return await e.eor(get_string("autopic_1"), time=5)
|
35 |
+
e = await e.eor(get_string("com_1"))
|
36 |
+
gi = googleimagesdownload()
|
37 |
+
args = {
|
38 |
+
"keywords": search,
|
39 |
+
"limit": 50,
|
40 |
+
"format": "jpg",
|
41 |
+
"output_directory": "./resources/downloads/",
|
42 |
+
}
|
43 |
+
try:
|
44 |
+
pth = await gi.download(args)
|
45 |
+
ok = pth[0][search]
|
46 |
+
except Exception as er:
|
47 |
+
LOGS.exception(er)
|
48 |
+
return await e.eor(str(er))
|
49 |
+
if not ok:
|
50 |
+
return await e.eor(get_string("autopic_2").format(search), time=5)
|
51 |
+
await e.eor(get_string("autopic_3").format(search))
|
52 |
+
udB.set_key("AUTOPIC", search)
|
53 |
+
SLEEP_TIME = udB.get_key("SLEEP_TIME") or 1221
|
54 |
while True:
|
55 |
+
for lie in ok:
|
56 |
+
if udB.get_key("AUTOPIC") != search:
|
57 |
return
|
58 |
+
file = await e.client.upload_file(lie)
|
|
|
59 |
await e.client(UploadProfilePhotoRequest(file))
|
|
|
60 |
await asyncio.sleep(SLEEP_TIME)
|
61 |
shuffle(clls)
|
62 |
|
63 |
|
64 |
+
if search := udB.get_key("AUTOPIC"):
|
65 |
+
gi = googleimagesdownload()
|
66 |
+
args = {
|
67 |
+
"keywords": search,
|
68 |
+
"limit": 50,
|
69 |
+
"format": "jpg",
|
70 |
+
"output_directory": "./resources/downloads/",
|
71 |
+
}
|
72 |
+
images = []
|
73 |
+
if os.path.exists(f"./resources/downloads/{search}"):
|
74 |
+
images = glob(f"resources/downloads/{search}/*")
|
75 |
+
sleep = udB.get_key("SLEEP_TIME") or 1221
|
76 |
+
|
77 |
+
async def autopic_func():
|
78 |
+
if udB.get_key("AUTOPIC") != search:
|
79 |
+
return
|
80 |
+
if not images:
|
81 |
+
try:
|
82 |
+
pth = await gi.download(args)
|
83 |
+
ok = pth[0][search]
|
84 |
+
images.extend(ok)
|
85 |
+
except Exception as er:
|
86 |
+
LOGS.exception(er)
|
87 |
+
return
|
88 |
+
else:
|
89 |
+
ok = images
|
90 |
+
img = random.choice(ok)
|
91 |
+
file = await ultroid_bot.upload_file(img)
|
92 |
+
await ultroid_bot(UploadProfilePhotoRequest(file))
|
93 |
+
shuffle(ok)
|
94 |
+
|
95 |
+
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
96 |
+
|
97 |
+
schedule = AsyncIOScheduler()
|
98 |
+
schedule.add_job(autopic_func, "interval", seconds=sleep)
|
99 |
+
schedule.start()
|
plugins/blacklist.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -27,7 +27,7 @@ from pyUltroid.dB.blacklist_db import (
|
|
27 |
rem_blacklist,
|
28 |
)
|
29 |
|
30 |
-
from . import
|
31 |
|
32 |
|
33 |
@ultroid_cmd(pattern="blacklist ?(.*)", admins_only=True)
|
@@ -35,12 +35,13 @@ async def af(e):
|
|
35 |
wrd = e.pattern_match.group(1)
|
36 |
chat = e.chat_id
|
37 |
if not (wrd):
|
38 |
-
return await eor(
|
39 |
wrd = e.text[11:]
|
40 |
heh = wrd.split(" ")
|
41 |
for z in heh:
|
42 |
add_blacklist(int(chat), z.lower())
|
43 |
-
|
|
|
44 |
|
45 |
|
46 |
@ultroid_cmd(pattern="remblacklist ?(.*)", admins_only=True)
|
@@ -48,12 +49,12 @@ async def rf(e):
|
|
48 |
wrd = e.pattern_match.group(1)
|
49 |
chat = e.chat_id
|
50 |
if not wrd:
|
51 |
-
return await eor(
|
52 |
wrd = e.text[14:]
|
53 |
heh = wrd.split(" ")
|
54 |
for z in heh:
|
55 |
rem_blacklist(int(chat), z.lower())
|
56 |
-
await eor(
|
57 |
|
58 |
|
59 |
@ultroid_cmd(pattern="listblacklist$", admins_only=True)
|
@@ -61,12 +62,11 @@ async def lsnote(e):
|
|
61 |
x = list_blacklist(e.chat_id)
|
62 |
if x:
|
63 |
sd = get_string("blk_5")
|
64 |
-
return await eor(
|
65 |
-
await eor(
|
66 |
|
67 |
|
68 |
-
|
69 |
-
async def bl(e):
|
70 |
x = get_blacklist(e.chat_id)
|
71 |
if x:
|
72 |
for z in e.text.lower().split():
|
@@ -77,3 +77,7 @@ async def bl(e):
|
|
77 |
break
|
78 |
except BaseException:
|
79 |
break
|
|
|
|
|
|
|
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
27 |
rem_blacklist,
|
28 |
)
|
29 |
|
30 |
+
from . import events, get_string, udB, ultroid_bot, ultroid_cmd
|
31 |
|
32 |
|
33 |
@ultroid_cmd(pattern="blacklist ?(.*)", admins_only=True)
|
|
|
35 |
wrd = e.pattern_match.group(1)
|
36 |
chat = e.chat_id
|
37 |
if not (wrd):
|
38 |
+
return await e.eor(get_string("blk_1"), time=5)
|
39 |
wrd = e.text[11:]
|
40 |
heh = wrd.split(" ")
|
41 |
for z in heh:
|
42 |
add_blacklist(int(chat), z.lower())
|
43 |
+
ultroid_bot.add_handler(blacklist, events.NewMessage(incoming=True))
|
44 |
+
await e.eor(get_string("blk_2").format(wrd))
|
45 |
|
46 |
|
47 |
@ultroid_cmd(pattern="remblacklist ?(.*)", admins_only=True)
|
|
|
49 |
wrd = e.pattern_match.group(1)
|
50 |
chat = e.chat_id
|
51 |
if not wrd:
|
52 |
+
return await e.eor(get_string("blk_3"), time=5)
|
53 |
wrd = e.text[14:]
|
54 |
heh = wrd.split(" ")
|
55 |
for z in heh:
|
56 |
rem_blacklist(int(chat), z.lower())
|
57 |
+
await e.eor(get_string("blk_4").format(wrd))
|
58 |
|
59 |
|
60 |
@ultroid_cmd(pattern="listblacklist$", admins_only=True)
|
|
|
62 |
x = list_blacklist(e.chat_id)
|
63 |
if x:
|
64 |
sd = get_string("blk_5")
|
65 |
+
return await e.eor(sd + x)
|
66 |
+
await e.eor(get_string("blk_6"))
|
67 |
|
68 |
|
69 |
+
async def blacklist(e):
|
|
|
70 |
x = get_blacklist(e.chat_id)
|
71 |
if x:
|
72 |
for z in e.text.lower().split():
|
|
|
77 |
break
|
78 |
except BaseException:
|
79 |
break
|
80 |
+
|
81 |
+
|
82 |
+
if udB.get_key("BLACKLIST_DB"):
|
83 |
+
ultroid_bot.add_handler(blacklist, events.NewMessage(incoming=True))
|
plugins/bot.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -7,12 +7,15 @@
|
|
7 |
"""
|
8 |
✘ Commands Available
|
9 |
|
10 |
-
• `{i}alive` | `{i}
|
11 |
Check if your bot is working.
|
12 |
|
13 |
• `{i}ping`
|
14 |
Check Ultroid's response time.
|
15 |
|
|
|
|
|
|
|
16 |
• `{i}cmds`
|
17 |
View all plugin names.
|
18 |
|
@@ -21,10 +24,8 @@
|
|
21 |
|
22 |
• `{i}logs (sys)`
|
23 |
Get the full terminal logs.
|
24 |
-
|
25 |
• `{i}logs carbon`
|
26 |
Get the carbonized sys logs.
|
27 |
-
|
28 |
• `{i}logs heroku`
|
29 |
Get the latest 100 lines of heroku logs.
|
30 |
|
@@ -40,19 +41,20 @@ from random import choice
|
|
40 |
from git import Repo
|
41 |
from pyUltroid.version import __version__ as UltVer
|
42 |
from telethon import __version__
|
43 |
-
from telethon.errors.rpcerrorlist import
|
|
|
|
|
|
|
44 |
from telethon.utils import resolve_bot_file_id
|
45 |
|
46 |
-
try:
|
47 |
-
from carbonnow import Carbon
|
48 |
-
except ImportError:
|
49 |
-
Carbon = None
|
50 |
-
|
51 |
from . import (
|
52 |
ATRA_COL,
|
|
|
53 |
LOGS,
|
54 |
OWNER_NAME,
|
|
|
55 |
Button,
|
|
|
56 |
Telegraph,
|
57 |
Var,
|
58 |
allcmds,
|
@@ -72,8 +74,17 @@ from . import (
|
|
72 |
udB,
|
73 |
ultroid_cmd,
|
74 |
ultroid_version,
|
|
|
75 |
)
|
76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
# Will move to strings
|
78 |
alive_txt = """
|
79 |
The Ultroid Userbot
|
@@ -83,6 +94,8 @@ The Ultroid Userbot
|
|
83 |
◍ Telethon - {}
|
84 |
"""
|
85 |
|
|
|
|
|
86 |
|
87 |
@callback("alive")
|
88 |
async def alive(event):
|
@@ -91,90 +104,92 @@ async def alive(event):
|
|
91 |
|
92 |
|
93 |
@ultroid_cmd(
|
94 |
-
pattern="alive
|
95 |
)
|
96 |
async def lol(ult):
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
uptime = time_formatter((time.time() - start_time) * 1000)
|
99 |
-
header = udB.
|
100 |
y = Repo().active_branch
|
101 |
xx = Repo().remotes[0].config_reader.get("url")
|
102 |
rep = xx.replace(".git", f"/tree/{y}")
|
103 |
kk = f" `[{y}]({rep})` "
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
try:
|
118 |
-
await ult.reply(als, file=pic, link_preview=False)
|
119 |
-
await ult.delete()
|
120 |
-
except ChatSendMediaForbiddenError:
|
121 |
-
await eor(ult, als, link_preview=False)
|
122 |
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
try:
|
124 |
-
await ult.reply(
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
127 |
except ChatSendMediaForbiddenError:
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
rep = xx.replace(".git", f"/tree/{y}")
|
149 |
-
kk = f" `[{y}]({rep})` "
|
150 |
-
als = (get_string("alive_1")).format(
|
151 |
-
header,
|
152 |
-
OWNER_NAME,
|
153 |
-
ultroid_version,
|
154 |
-
UltVer,
|
155 |
-
uptime,
|
156 |
-
pyver(),
|
157 |
-
__version__,
|
158 |
-
kk,
|
159 |
-
)
|
160 |
-
buttons = [
|
161 |
-
[Button.inline(get_string("bot_2"), "alive")],
|
162 |
-
[
|
163 |
-
Button.url(get_string("bot_3"), "https://github.com/TeamUltroid/Ultroid"),
|
164 |
-
Button.url(get_string("bot_4"), "t.me/UltroidSupport"),
|
165 |
-
],
|
166 |
-
]
|
167 |
-
await ult.client.send_message(
|
168 |
-
ult.chat_id, als, file=pic, buttons=buttons, link_preview=False
|
169 |
)
|
170 |
|
171 |
|
172 |
@ultroid_cmd(pattern="ping$", chats=[], type=["official", "assistant"])
|
173 |
async def _(event):
|
174 |
-
if event.out:
|
175 |
-
await event.delete()
|
176 |
start = time.time()
|
177 |
-
x = await event.
|
178 |
end = round((time.time() - start) * 1000)
|
179 |
uptime = time_formatter((time.time() - start_time) * 1000)
|
180 |
await x.edit(get_string("ping").format(end, uptime))
|
@@ -195,12 +210,15 @@ heroku_api = Var.HEROKU_API
|
|
195 |
fullsudo=True,
|
196 |
)
|
197 |
async def restartbt(ult):
|
198 |
-
ok = await eor(
|
199 |
call_back()
|
200 |
if heroku_api:
|
201 |
return await restart(ok)
|
202 |
await bash("git pull && pip3 install -r requirements.txt")
|
203 |
-
|
|
|
|
|
|
|
204 |
|
205 |
|
206 |
@ultroid_cmd(
|
@@ -217,52 +235,54 @@ async def shutdownbot(ult):
|
|
217 |
)
|
218 |
async def _(event):
|
219 |
opt = event.pattern_match.group(1)
|
|
|
220 |
if opt == "heroku":
|
221 |
await heroku_logs(event)
|
222 |
elif opt == "carbon" and Carbon:
|
223 |
-
event = await eor(
|
224 |
-
code = open(
|
225 |
file = await Carbon(
|
226 |
-
|
227 |
code=code,
|
228 |
-
|
229 |
-
)
|
230 |
await event.reply("**Ultroid Logs.**", file=file)
|
|
|
|
|
|
|
231 |
else:
|
232 |
-
await def_logs(event)
|
233 |
-
await event.
|
234 |
|
235 |
|
236 |
@in_pattern("alive", owner=True)
|
237 |
async def inline_alive(ult):
|
238 |
-
pic = udB.
|
239 |
uptime = time_formatter((time.time() - start_time) * 1000)
|
240 |
-
header = udB.
|
241 |
y = Repo().active_branch
|
242 |
xx = Repo().remotes[0].config_reader.get("url")
|
243 |
rep = xx.replace(".git", f"/tree/{y}")
|
244 |
-
kk = f"
|
245 |
-
als =
|
246 |
header,
|
247 |
-
OWNER_NAME,
|
248 |
ultroid_version,
|
249 |
UltVer,
|
250 |
-
uptime,
|
251 |
pyver(),
|
252 |
-
|
253 |
kk,
|
254 |
)
|
255 |
-
|
256 |
-
|
257 |
-
Button.url(get_string("bot_3"), "https://github.com/TeamUltroid/Ultroid"),
|
258 |
-
Button.url(get_string("bot_4"), "t.me/UltroidSupport"),
|
259 |
-
]
|
260 |
-
]
|
261 |
builder = ult.builder
|
262 |
if pic:
|
263 |
try:
|
264 |
if ".jpg" in pic:
|
265 |
-
results = [
|
|
|
|
|
|
|
|
|
266 |
else:
|
267 |
_pic = resolve_bot_file_id(pic)
|
268 |
if _pic:
|
@@ -275,6 +295,7 @@ async def inline_alive(ult):
|
|
275 |
pic,
|
276 |
title="Inline Alive",
|
277 |
description="@TheUltroid",
|
|
|
278 |
buttons=buttons,
|
279 |
)
|
280 |
]
|
@@ -282,6 +303,55 @@ async def inline_alive(ult):
|
|
282 |
except BaseException as er:
|
283 |
LOGS.info(er)
|
284 |
result = [
|
285 |
-
await builder.article(
|
|
|
|
|
286 |
]
|
287 |
await ult.answer(result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
7 |
"""
|
8 |
✘ Commands Available
|
9 |
|
10 |
+
• `{i}alive` | `{i}alive inline`
|
11 |
Check if your bot is working.
|
12 |
|
13 |
• `{i}ping`
|
14 |
Check Ultroid's response time.
|
15 |
|
16 |
+
• `{i}update`
|
17 |
+
See changelogs if any update is available.
|
18 |
+
|
19 |
• `{i}cmds`
|
20 |
View all plugin names.
|
21 |
|
|
|
24 |
|
25 |
• `{i}logs (sys)`
|
26 |
Get the full terminal logs.
|
|
|
27 |
• `{i}logs carbon`
|
28 |
Get the carbonized sys logs.
|
|
|
29 |
• `{i}logs heroku`
|
30 |
Get the latest 100 lines of heroku logs.
|
31 |
|
|
|
41 |
from git import Repo
|
42 |
from pyUltroid.version import __version__ as UltVer
|
43 |
from telethon import __version__
|
44 |
+
from telethon.errors.rpcerrorlist import (
|
45 |
+
BotMethodInvalidError,
|
46 |
+
ChatSendMediaForbiddenError,
|
47 |
+
)
|
48 |
from telethon.utils import resolve_bot_file_id
|
49 |
|
|
|
|
|
|
|
|
|
|
|
50 |
from . import (
|
51 |
ATRA_COL,
|
52 |
+
INLINE_PIC,
|
53 |
LOGS,
|
54 |
OWNER_NAME,
|
55 |
+
ULTROID_IMAGES,
|
56 |
Button,
|
57 |
+
Carbon,
|
58 |
Telegraph,
|
59 |
Var,
|
60 |
allcmds,
|
|
|
74 |
udB,
|
75 |
ultroid_cmd,
|
76 |
ultroid_version,
|
77 |
+
updater,
|
78 |
)
|
79 |
|
80 |
+
ULTPIC = INLINE_PIC or choice(ULTROID_IMAGES)
|
81 |
+
buttons = [
|
82 |
+
[
|
83 |
+
Button.url(get_string("bot_3"), "https://github.com/TeamUltroid/Ultroid"),
|
84 |
+
Button.url(get_string("bot_4"), "t.me/UltroidSupport"),
|
85 |
+
]
|
86 |
+
]
|
87 |
+
|
88 |
# Will move to strings
|
89 |
alive_txt = """
|
90 |
The Ultroid Userbot
|
|
|
94 |
◍ Telethon - {}
|
95 |
"""
|
96 |
|
97 |
+
in_alive = "{}\n\n🌀 <b>Ultroid Version -><b> <code>{}</code>\n🌀 <b>PyUltroid -></b> <code>{}</code>\n🌀 <b>Python -></b> <code>{}</code>\n🌀 <b>Uptime -></b> <code>{}</code>\n🌀 <b>Branch -></b> [ {} ]\n\n• <b>Join @TheUltroid</b>"
|
98 |
+
|
99 |
|
100 |
@callback("alive")
|
101 |
async def alive(event):
|
|
|
104 |
|
105 |
|
106 |
@ultroid_cmd(
|
107 |
+
pattern="alive ?(.*)",
|
108 |
)
|
109 |
async def lol(ult):
|
110 |
+
match = ult.pattern_match.group(1)
|
111 |
+
inline = None
|
112 |
+
if match in ["inline", "i"]:
|
113 |
+
try:
|
114 |
+
res = await ult.client.inline_query(asst.me.username, "alive")
|
115 |
+
return await res[0].click(ult.chat_id)
|
116 |
+
except BotMethodInvalidError:
|
117 |
+
pass
|
118 |
+
except BaseException as er:
|
119 |
+
LOGS.exception(er)
|
120 |
+
inline = True
|
121 |
+
pic = udB.get_key("ALIVE_PIC")
|
122 |
uptime = time_formatter((time.time() - start_time) * 1000)
|
123 |
+
header = udB.get_key("ALIVE_TEXT") or get_string("bot_1")
|
124 |
y = Repo().active_branch
|
125 |
xx = Repo().remotes[0].config_reader.get("url")
|
126 |
rep = xx.replace(".git", f"/tree/{y}")
|
127 |
kk = f" `[{y}]({rep})` "
|
128 |
+
if inline:
|
129 |
+
kk = f"<a href={rep}>{y}</a>"
|
130 |
+
parse = "html"
|
131 |
+
als = in_alive.format(
|
132 |
+
header,
|
133 |
+
ultroid_version,
|
134 |
+
UltVer,
|
135 |
+
pyver(),
|
136 |
+
uptime,
|
137 |
+
kk,
|
138 |
+
)
|
139 |
+
if _e := udB.get_key("ALIVE_EMOJI"):
|
140 |
+
als = als.replace("🌀", _e)
|
|
|
|
|
|
|
|
|
|
|
141 |
else:
|
142 |
+
parse = "md"
|
143 |
+
als = (get_string("alive_1")).format(
|
144 |
+
header,
|
145 |
+
OWNER_NAME,
|
146 |
+
ultroid_version,
|
147 |
+
UltVer,
|
148 |
+
uptime,
|
149 |
+
pyver(),
|
150 |
+
__version__,
|
151 |
+
kk,
|
152 |
+
)
|
153 |
+
if a := udB.get_key("ALIVE_EMOJI"):
|
154 |
+
als = als.replace("✵", a)
|
155 |
+
if pic:
|
156 |
try:
|
157 |
+
await ult.reply(
|
158 |
+
als,
|
159 |
+
file=pic,
|
160 |
+
parse_mode=parse,
|
161 |
+
link_preview=False,
|
162 |
+
buttons=buttons if inline else None,
|
163 |
+
)
|
164 |
+
await ult.try_delete()
|
165 |
except ChatSendMediaForbiddenError:
|
166 |
+
pass
|
167 |
+
except BaseException as er:
|
168 |
+
LOGS.exception(er)
|
169 |
+
try:
|
170 |
+
await ult.reply(file=pic)
|
171 |
+
await ult.reply(
|
172 |
+
als,
|
173 |
+
parse_mode=parse,
|
174 |
+
buttons=buttons if inline else None,
|
175 |
+
link_preview=False,
|
176 |
+
)
|
177 |
+
return await ult.try_delete()
|
178 |
+
except BaseException as er:
|
179 |
+
LOGS.exception(er)
|
180 |
+
await eor(
|
181 |
+
ult,
|
182 |
+
als,
|
183 |
+
parse_mode=parse,
|
184 |
+
link_preview=False,
|
185 |
+
buttons=buttons if inline else None,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
)
|
187 |
|
188 |
|
189 |
@ultroid_cmd(pattern="ping$", chats=[], type=["official", "assistant"])
|
190 |
async def _(event):
|
|
|
|
|
191 |
start = time.time()
|
192 |
+
x = await event.eor("Pong !")
|
193 |
end = round((time.time() - start) * 1000)
|
194 |
uptime = time_formatter((time.time() - start_time) * 1000)
|
195 |
await x.edit(get_string("ping").format(end, uptime))
|
|
|
210 |
fullsudo=True,
|
211 |
)
|
212 |
async def restartbt(ult):
|
213 |
+
ok = await ult.eor(get_string("bot_5"))
|
214 |
call_back()
|
215 |
if heroku_api:
|
216 |
return await restart(ok)
|
217 |
await bash("git pull && pip3 install -r requirements.txt")
|
218 |
+
if len(sys.argv) > 1:
|
219 |
+
os.execl(sys.executable, sys.executable, "main.py")
|
220 |
+
else:
|
221 |
+
os.execl(sys.executable, sys.executable, "-m", "pyUltroid")
|
222 |
|
223 |
|
224 |
@ultroid_cmd(
|
|
|
235 |
)
|
236 |
async def _(event):
|
237 |
opt = event.pattern_match.group(1)
|
238 |
+
file = f"ultroid{sys.argv[-1]}.log" if len(sys.argv) > 1 else "ultroid.log"
|
239 |
if opt == "heroku":
|
240 |
await heroku_logs(event)
|
241 |
elif opt == "carbon" and Carbon:
|
242 |
+
event = await event.eor(get_string("com_1"))
|
243 |
+
code = open(file, "r").read()[-2500:]
|
244 |
file = await Carbon(
|
245 |
+
file_name="ultroid-logs",
|
246 |
code=code,
|
247 |
+
backgroundColor=choice(ATRA_COL),
|
248 |
+
)
|
249 |
await event.reply("**Ultroid Logs.**", file=file)
|
250 |
+
elif opt == "open":
|
251 |
+
file = open("ultroid.log", "r").read()[-4000:]
|
252 |
+
return await event.eor(f"`{file}`")
|
253 |
else:
|
254 |
+
await def_logs(event, file)
|
255 |
+
await event.try_delete()
|
256 |
|
257 |
|
258 |
@in_pattern("alive", owner=True)
|
259 |
async def inline_alive(ult):
|
260 |
+
pic = udB.get_key("ALIVE_PIC")
|
261 |
uptime = time_formatter((time.time() - start_time) * 1000)
|
262 |
+
header = udB.get_key("ALIVE_TEXT") or get_string("bot_1")
|
263 |
y = Repo().active_branch
|
264 |
xx = Repo().remotes[0].config_reader.get("url")
|
265 |
rep = xx.replace(".git", f"/tree/{y}")
|
266 |
+
kk = f"<a href={rep}>{y}</a>"
|
267 |
+
als = in_alive.format(
|
268 |
header,
|
|
|
269 |
ultroid_version,
|
270 |
UltVer,
|
|
|
271 |
pyver(),
|
272 |
+
uptime,
|
273 |
kk,
|
274 |
)
|
275 |
+
if _e := udB.get_key("ALIVE_EMOJI"):
|
276 |
+
als = als.replace("🌀", _e)
|
|
|
|
|
|
|
|
|
277 |
builder = ult.builder
|
278 |
if pic:
|
279 |
try:
|
280 |
if ".jpg" in pic:
|
281 |
+
results = [
|
282 |
+
await builder.photo(
|
283 |
+
pic, text=als, parse_mode="html", buttons=buttons
|
284 |
+
)
|
285 |
+
]
|
286 |
else:
|
287 |
_pic = resolve_bot_file_id(pic)
|
288 |
if _pic:
|
|
|
295 |
pic,
|
296 |
title="Inline Alive",
|
297 |
description="@TheUltroid",
|
298 |
+
parse_mode="html",
|
299 |
buttons=buttons,
|
300 |
)
|
301 |
]
|
|
|
303 |
except BaseException as er:
|
304 |
LOGS.info(er)
|
305 |
result = [
|
306 |
+
await builder.article(
|
307 |
+
"Alive", text=als, parse_mode="html", link_preview=False, buttons=buttons
|
308 |
+
)
|
309 |
]
|
310 |
await ult.answer(result)
|
311 |
+
|
312 |
+
|
313 |
+
@ultroid_cmd(pattern="update ?(.*)")
|
314 |
+
async def _(e):
|
315 |
+
xx = await e.eor(get_string("upd_1"))
|
316 |
+
if e.pattern_match.group(1) and (
|
317 |
+
"fast" in e.pattern_match.group(1) or "soft" in e.pattern_match.group(1)
|
318 |
+
):
|
319 |
+
await bash("git pull -f && pip3 install -r requirements.txt")
|
320 |
+
call_back()
|
321 |
+
await xx.edit(get_string("upd_7"))
|
322 |
+
os.execl(sys.executable, "python3", "-m", "pyUltroid")
|
323 |
+
return
|
324 |
+
m = await updater()
|
325 |
+
branch = (Repo.init()).active_branch
|
326 |
+
if m:
|
327 |
+
x = await asst.send_file(
|
328 |
+
udB.get_key("LOG_CHANNEL"),
|
329 |
+
ULTPIC,
|
330 |
+
caption="• **Update Available** •",
|
331 |
+
force_document=False,
|
332 |
+
buttons=Button.inline("Changelogs", data="changes"),
|
333 |
+
)
|
334 |
+
Link = x.message_link
|
335 |
+
await xx.edit(
|
336 |
+
f'<strong><a href="{Link}">[ChangeLogs]</a></strong>',
|
337 |
+
parse_mode="html",
|
338 |
+
link_preview=False,
|
339 |
+
)
|
340 |
+
else:
|
341 |
+
await xx.edit(
|
342 |
+
f'<code>Your BOT is </code><strong>up-to-date</strong><code> with </code><strong><a href="https://github.com/TeamUltroid/Ultroid/tree/{branch}">[{branch}]</a></strong>',
|
343 |
+
parse_mode="html",
|
344 |
+
link_preview=False,
|
345 |
+
)
|
346 |
+
|
347 |
+
|
348 |
+
@callback("updtavail", owner=True)
|
349 |
+
async def updava(event):
|
350 |
+
await event.delete()
|
351 |
+
await asst.send_file(
|
352 |
+
udB.get_key("LOG_CHANNEL"),
|
353 |
+
ULTPIC,
|
354 |
+
caption="• **Update Available** •",
|
355 |
+
force_document=False,
|
356 |
+
buttons=Button.inline("Changelogs", data="changes"),
|
357 |
+
)
|
plugins/broadcast.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -36,8 +36,7 @@ from . import HNDLR, LOGS, eor, get_string, udB, ultroid_bot, ultroid_cmd
|
|
36 |
)
|
37 |
async def broadcast_adder(event):
|
38 |
msgg = event.pattern_match.group(1)
|
39 |
-
x = await eor(
|
40 |
-
aldone = new = crsh = 0
|
41 |
if msgg == "all":
|
42 |
await x.edit(get_string("bd_2"))
|
43 |
chats = [
|
@@ -45,6 +44,7 @@ async def broadcast_adder(event):
|
|
45 |
for e in await event.client.get_dialogs()
|
46 |
if (e.is_group or e.is_channel)
|
47 |
]
|
|
|
48 |
for i in chats:
|
49 |
try:
|
50 |
if (
|
@@ -73,7 +73,7 @@ async def broadcast_adder(event):
|
|
73 |
await event.delete()
|
74 |
return
|
75 |
chat_id = event.chat_id
|
76 |
-
if int(chat_id) == int(udB.
|
77 |
return
|
78 |
if not is_channel_added(chat_id):
|
79 |
xx = add_channel(chat_id)
|
@@ -95,10 +95,10 @@ async def broadcast_adder(event):
|
|
95 |
)
|
96 |
async def broadcast_remover(event):
|
97 |
chat_id = event.pattern_match.group(1)
|
98 |
-
x = await eor(
|
99 |
if chat_id == "all":
|
100 |
await x.edit(get_string("bd_8"))
|
101 |
-
udB.
|
102 |
await x.edit("Database cleared.")
|
103 |
return
|
104 |
if is_channel_added(chat_id):
|
@@ -121,7 +121,7 @@ async def broadcast_remover(event):
|
|
121 |
pattern="listchannels$",
|
122 |
)
|
123 |
async def list_all(event):
|
124 |
-
x = await eor(
|
125 |
channels = get_channels()
|
126 |
num = get_no_channels()
|
127 |
if num == 0:
|
@@ -156,10 +156,10 @@ async def list_all(event):
|
|
156 |
)
|
157 |
async def forw(event):
|
158 |
if not event.is_reply:
|
159 |
-
return await eor(
|
160 |
ultroid_bot = event.client
|
161 |
channels = get_channels()
|
162 |
-
x = await eor(
|
163 |
if get_no_channels() == 0:
|
164 |
return await x.edit(f"Please add channels by using `{HNDLR}add` in them.")
|
165 |
error_count = 0
|
@@ -177,7 +177,7 @@ async def forw(event):
|
|
177 |
except Exception:
|
178 |
try:
|
179 |
await ultroid_bot.send_message(
|
180 |
-
int(udB.
|
181 |
f"Error in sending at {channel}.",
|
182 |
)
|
183 |
except Exception as Em:
|
@@ -189,7 +189,7 @@ async def forw(event):
|
|
189 |
await x.edit(f"{sent_count} messages sent with {error_count} errors.")
|
190 |
if error_count > 0:
|
191 |
await ultroid_bot.send_message(
|
192 |
-
int(udB.
|
193 |
)
|
194 |
|
195 |
|
@@ -198,7 +198,7 @@ async def forw(event):
|
|
198 |
allow_sudo=False,
|
199 |
)
|
200 |
async def sending(event):
|
201 |
-
x = await eor(
|
202 |
if not event.is_reply:
|
203 |
return await x.edit(get_string("ex_1"))
|
204 |
channels = get_channels()
|
@@ -222,7 +222,7 @@ async def sending(event):
|
|
222 |
except Exception as error:
|
223 |
|
224 |
await ultroid_bot.send_message(
|
225 |
-
int(udB.
|
226 |
f"Error in sending at {channel}.\n\n{error}",
|
227 |
)
|
228 |
error_count += 1
|
@@ -232,6 +232,6 @@ async def sending(event):
|
|
232 |
await x.edit(f"{sent_count} messages sent with {error_count} errors.")
|
233 |
if error_count > 0:
|
234 |
await ultroid_bot.send_message(
|
235 |
-
int(udB.
|
236 |
f"{error_count} Errors",
|
237 |
)
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
36 |
)
|
37 |
async def broadcast_adder(event):
|
38 |
msgg = event.pattern_match.group(1)
|
39 |
+
x = await event.eor(get_string("bd_1"))
|
|
|
40 |
if msgg == "all":
|
41 |
await x.edit(get_string("bd_2"))
|
42 |
chats = [
|
|
|
44 |
for e in await event.client.get_dialogs()
|
45 |
if (e.is_group or e.is_channel)
|
46 |
]
|
47 |
+
new = 0
|
48 |
for i in chats:
|
49 |
try:
|
50 |
if (
|
|
|
73 |
await event.delete()
|
74 |
return
|
75 |
chat_id = event.chat_id
|
76 |
+
if int(chat_id) == int(udB.get_key("LOG_CHANNEL")):
|
77 |
return
|
78 |
if not is_channel_added(chat_id):
|
79 |
xx = add_channel(chat_id)
|
|
|
95 |
)
|
96 |
async def broadcast_remover(event):
|
97 |
chat_id = event.pattern_match.group(1)
|
98 |
+
x = await event.eor(get_string("com_1"))
|
99 |
if chat_id == "all":
|
100 |
await x.edit(get_string("bd_8"))
|
101 |
+
udB.del_key("BROADCAST")
|
102 |
await x.edit("Database cleared.")
|
103 |
return
|
104 |
if is_channel_added(chat_id):
|
|
|
121 |
pattern="listchannels$",
|
122 |
)
|
123 |
async def list_all(event):
|
124 |
+
x = await event.eor(get_string("com_1"))
|
125 |
channels = get_channels()
|
126 |
num = get_no_channels()
|
127 |
if num == 0:
|
|
|
156 |
)
|
157 |
async def forw(event):
|
158 |
if not event.is_reply:
|
159 |
+
return await event.eor(get_string("ex_1"))
|
160 |
ultroid_bot = event.client
|
161 |
channels = get_channels()
|
162 |
+
x = await event.eor("Sending...")
|
163 |
if get_no_channels() == 0:
|
164 |
return await x.edit(f"Please add channels by using `{HNDLR}add` in them.")
|
165 |
error_count = 0
|
|
|
177 |
except Exception:
|
178 |
try:
|
179 |
await ultroid_bot.send_message(
|
180 |
+
int(udB.get_key("LOG_CHANNEL")),
|
181 |
f"Error in sending at {channel}.",
|
182 |
)
|
183 |
except Exception as Em:
|
|
|
189 |
await x.edit(f"{sent_count} messages sent with {error_count} errors.")
|
190 |
if error_count > 0:
|
191 |
await ultroid_bot.send_message(
|
192 |
+
int(udB.get_key("LOG_CHANNEL")), f"{error_count} Errors"
|
193 |
)
|
194 |
|
195 |
|
|
|
198 |
allow_sudo=False,
|
199 |
)
|
200 |
async def sending(event):
|
201 |
+
x = await event.eor(get_string("com_1"))
|
202 |
if not event.is_reply:
|
203 |
return await x.edit(get_string("ex_1"))
|
204 |
channels = get_channels()
|
|
|
222 |
except Exception as error:
|
223 |
|
224 |
await ultroid_bot.send_message(
|
225 |
+
int(udB.get_key("LOG_CHANNEL")),
|
226 |
f"Error in sending at {channel}.\n\n{error}",
|
227 |
)
|
228 |
error_count += 1
|
|
|
232 |
await x.edit(f"{sent_count} messages sent with {error_count} errors.")
|
233 |
if error_count > 0:
|
234 |
await ultroid_bot.send_message(
|
235 |
+
int(udB.get_key("LOG_CHANNEL")),
|
236 |
f"{error_count} Errors",
|
237 |
)
|
plugins/button.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -32,28 +32,28 @@ async def butt(event):
|
|
32 |
text = wt.text
|
33 |
if wt.media:
|
34 |
wut = mediainfo(wt.media)
|
35 |
-
if wut.startswith(("pic", "gif")):
|
36 |
dl = await wt.download_media()
|
37 |
variable = uf(dl)
|
38 |
media = "https://telegra.ph" + variable[0]
|
39 |
elif wut == "video":
|
40 |
if wt.media.document.size > 8 * 1000 * 1000:
|
41 |
-
return await eor(
|
42 |
dl = await wt.download_media()
|
43 |
variable = uf(dl)
|
44 |
os.remove(dl)
|
45 |
media = "https://telegra.ph" + variable[0]
|
46 |
else:
|
47 |
-
pack_bot_file_id(wt.media)
|
48 |
-
|
49 |
-
text = event.text.split(maxsplit=1)
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
f"**Please give some text in correct format.**\n\n`{HNDLR}help button`",
|
54 |
)
|
55 |
-
text = text[1]
|
56 |
text, buttons = get_msg_button(text)
|
57 |
if buttons:
|
58 |
buttons = create_tl_btn(buttons)
|
59 |
-
|
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
32 |
text = wt.text
|
33 |
if wt.media:
|
34 |
wut = mediainfo(wt.media)
|
35 |
+
if wut and wut.startswith(("pic", "gif")):
|
36 |
dl = await wt.download_media()
|
37 |
variable = uf(dl)
|
38 |
media = "https://telegra.ph" + variable[0]
|
39 |
elif wut == "video":
|
40 |
if wt.media.document.size > 8 * 1000 * 1000:
|
41 |
+
return await event.eor(get_string("com_4"), time=5)
|
42 |
dl = await wt.download_media()
|
43 |
variable = uf(dl)
|
44 |
os.remove(dl)
|
45 |
media = "https://telegra.ph" + variable[0]
|
46 |
else:
|
47 |
+
media = pack_bot_file_id(wt.media)
|
48 |
+
try:
|
49 |
+
text = event.text.split(maxsplit=1)[1]
|
50 |
+
except IndexError:
|
51 |
+
if not text:
|
52 |
+
return await event.eor(
|
53 |
f"**Please give some text in correct format.**\n\n`{HNDLR}help button`",
|
54 |
)
|
|
|
55 |
text, buttons = get_msg_button(text)
|
56 |
if buttons:
|
57 |
buttons = create_tl_btn(buttons)
|
58 |
+
await something(event, text, media, buttons)
|
59 |
+
await event.delete()
|
plugins/calculator.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -45,7 +45,7 @@ lst.append([Button.inline("=", data="calc=")])
|
|
45 |
|
46 |
@ultroid_cmd(pattern="calc")
|
47 |
async def icalc(e):
|
48 |
-
udB.
|
49 |
if e.client._bot:
|
50 |
return await e.reply(get_string("calc_1"), buttons=lst)
|
51 |
results = await e.client.inline_query(asst.me.username, "calc")
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
45 |
|
46 |
@ultroid_cmd(pattern="calc")
|
47 |
async def icalc(e):
|
48 |
+
udB.del_key("calc")
|
49 |
if e.client._bot:
|
50 |
return await e.reply(get_string("calc_1"), buttons=lst)
|
51 |
results = await e.client.inline_query(asst.me.username, "calc")
|
plugins/carbon.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -18,9 +18,7 @@
|
|
18 |
"""
|
19 |
import random
|
20 |
|
21 |
-
from
|
22 |
-
|
23 |
-
from . import eor, get_string, inline_mention, os, ultroid_cmd
|
24 |
|
25 |
all_col = [
|
26 |
"Black",
|
@@ -178,9 +176,9 @@ all_col = [
|
|
178 |
pattern="(rc|c)arbon",
|
179 |
)
|
180 |
async def crbn(event):
|
181 |
-
xxxx = await eor(
|
182 |
te = event.text
|
183 |
-
col = random.choice(all_col) if te[1] == "r" else
|
184 |
if event.reply_to_msg_id:
|
185 |
temp = await event.get_reply_message()
|
186 |
if temp.media:
|
@@ -195,10 +193,7 @@ async def crbn(event):
|
|
195 |
code = event.text.split(" ", maxsplit=1)[1]
|
196 |
except IndexError:
|
197 |
return await eor(xxxx, get_string("carbon_2"))
|
198 |
-
|
199 |
-
base_url="https://carbonara.vercel.app/api/cook", code=code, background=col
|
200 |
-
)
|
201 |
-
xx = await carbon.memorize("ultroid_carbon")
|
202 |
await xxxx.delete()
|
203 |
await event.reply(
|
204 |
f"Carbonised by {inline_mention(event.sender)}",
|
@@ -212,8 +207,8 @@ async def crbn(event):
|
|
212 |
async def crbn(event):
|
213 |
match = event.pattern_match.group(1)
|
214 |
if not match:
|
215 |
-
return await eor(
|
216 |
-
msg = await eor(
|
217 |
if event.reply_to_msg_id:
|
218 |
temp = await event.get_reply_message()
|
219 |
if temp.media:
|
@@ -230,13 +225,7 @@ async def crbn(event):
|
|
230 |
match = match[0]
|
231 |
except IndexError:
|
232 |
return await eor(msg, get_string("carbon_2"))
|
233 |
-
|
234 |
-
base_url="https://carbonara.vercel.app/api/cook", code=code, background=match
|
235 |
-
)
|
236 |
-
try:
|
237 |
-
xx = await carbon.memorize("ultroid_carbon")
|
238 |
-
except Exception as er:
|
239 |
-
return await msg.edit(str(er))
|
240 |
await msg.delete()
|
241 |
await event.reply(
|
242 |
f"Carbonised by {inline_mention(event.sender)}",
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
18 |
"""
|
19 |
import random
|
20 |
|
21 |
+
from . import Carbon, eor, get_string, inline_mention, os, ultroid_cmd
|
|
|
|
|
22 |
|
23 |
all_col = [
|
24 |
"Black",
|
|
|
176 |
pattern="(rc|c)arbon",
|
177 |
)
|
178 |
async def crbn(event):
|
179 |
+
xxxx = await event.eor(get_string("com_1"))
|
180 |
te = event.text
|
181 |
+
col = random.choice(all_col) if te[1] == "r" else "White"
|
182 |
if event.reply_to_msg_id:
|
183 |
temp = await event.get_reply_message()
|
184 |
if temp.media:
|
|
|
193 |
code = event.text.split(" ", maxsplit=1)[1]
|
194 |
except IndexError:
|
195 |
return await eor(xxxx, get_string("carbon_2"))
|
196 |
+
xx = await Carbon(code=code, file_name="ultroid_carbon", backgroundColor=col)
|
|
|
|
|
|
|
197 |
await xxxx.delete()
|
198 |
await event.reply(
|
199 |
f"Carbonised by {inline_mention(event.sender)}",
|
|
|
207 |
async def crbn(event):
|
208 |
match = event.pattern_match.group(1)
|
209 |
if not match:
|
210 |
+
return await event.eor(get_string("carbon_3"))
|
211 |
+
msg = await event.eor(get_string("com_1"))
|
212 |
if event.reply_to_msg_id:
|
213 |
temp = await event.get_reply_message()
|
214 |
if temp.media:
|
|
|
225 |
match = match[0]
|
226 |
except IndexError:
|
227 |
return await eor(msg, get_string("carbon_2"))
|
228 |
+
xx = await Carbon(code=code, backgroundColor=match)
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
await msg.delete()
|
230 |
await event.reply(
|
231 |
f"Carbonised by {inline_mention(event.sender)}",
|
plugins/channelhacks.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -32,7 +32,7 @@
|
|
32 |
Show List of Ur channels
|
33 |
|
34 |
'you can set many channels in database'
|
35 |
-
'For activating auto-post use `{i}
|
36 |
"""
|
37 |
|
38 |
import asyncio
|
@@ -56,7 +56,7 @@ from . import asst, eor, events, get_string, udB, ultroid_bot, ultroid_cmd
|
|
56 |
|
57 |
@ultroid_bot.on(events.NewMessage())
|
58 |
async def _(e):
|
59 |
-
if udB.
|
60 |
return
|
61 |
x = get_source_channels()
|
62 |
th = await e.get_chat()
|
@@ -67,13 +67,13 @@ async def _(e):
|
|
67 |
try:
|
68 |
await ultroid_bot.send_message(int(ys), e.message)
|
69 |
except Exception as ex:
|
70 |
-
await asst.send_message(int(udB
|
71 |
|
72 |
|
73 |
@ultroid_cmd(pattern="shift (.*)")
|
74 |
async def _(e):
|
75 |
x = e.pattern_match.group(1)
|
76 |
-
z = await eor(
|
77 |
a, b = x.split("|")
|
78 |
try:
|
79 |
c = int(a)
|
@@ -113,18 +113,18 @@ async def source(e):
|
|
113 |
return
|
114 |
if not is_source_channel_added(y):
|
115 |
add_source_channel(y)
|
116 |
-
await eor(
|
117 |
elif is_source_channel_added(y):
|
118 |
-
await eor(
|
119 |
|
120 |
|
121 |
@ultroid_cmd(pattern="dsource ?(.*)")
|
122 |
async def dd(event):
|
123 |
chat_id = event.pattern_match.group(1)
|
124 |
-
x = await eor(
|
125 |
if chat_id == "all":
|
126 |
await x.edit(get_string("bd_8"))
|
127 |
-
udB.
|
128 |
await x.edit(get_string("cha_4"))
|
129 |
return
|
130 |
try:
|
@@ -147,7 +147,7 @@ async def dd(event):
|
|
147 |
|
148 |
@ultroid_cmd(pattern="listsource")
|
149 |
async def list_all(event):
|
150 |
-
x = await eor(
|
151 |
channels = get_source_channels()
|
152 |
num = get_no_source_channels()
|
153 |
if num == 0:
|
@@ -191,18 +191,18 @@ async def destination(e):
|
|
191 |
return
|
192 |
if not is_destination_added(y):
|
193 |
add_destination(y)
|
194 |
-
await eor(
|
195 |
elif is_destination_added(y):
|
196 |
-
await eor(
|
197 |
|
198 |
|
199 |
@ultroid_cmd(pattern="ddest ?(.*)")
|
200 |
async def dd(event):
|
201 |
chat_id = event.pattern_match.group(1)
|
202 |
-
x = await eor(
|
203 |
if chat_id == "all":
|
204 |
await x.edit(get_string("bd_8"))
|
205 |
-
udB.
|
206 |
await x.edit("Destinations database cleared.")
|
207 |
return
|
208 |
try:
|
@@ -226,7 +226,7 @@ async def dd(event):
|
|
226 |
@ultroid_cmd(pattern="listdest")
|
227 |
async def list_all(event):
|
228 |
ultroid_bot = event.client
|
229 |
-
x = await eor(
|
230 |
channels = get_destinations()
|
231 |
num = get_no_destinations()
|
232 |
if not num:
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
32 |
Show List of Ur channels
|
33 |
|
34 |
'you can set many channels in database'
|
35 |
+
'For activating auto-post use `{i}setdb AUTOPOST True` '
|
36 |
"""
|
37 |
|
38 |
import asyncio
|
|
|
56 |
|
57 |
@ultroid_bot.on(events.NewMessage())
|
58 |
async def _(e):
|
59 |
+
if udB.get_key("AUTOPOST") != "True":
|
60 |
return
|
61 |
x = get_source_channels()
|
62 |
th = await e.get_chat()
|
|
|
67 |
try:
|
68 |
await ultroid_bot.send_message(int(ys), e.message)
|
69 |
except Exception as ex:
|
70 |
+
await asst.send_message(int(udB.get_key("LOG_CHANNEL")), str(ex))
|
71 |
|
72 |
|
73 |
@ultroid_cmd(pattern="shift (.*)")
|
74 |
async def _(e):
|
75 |
x = e.pattern_match.group(1)
|
76 |
+
z = await e.eor(get_string("com_1"))
|
77 |
a, b = x.split("|")
|
78 |
try:
|
79 |
c = int(a)
|
|
|
113 |
return
|
114 |
if not is_source_channel_added(y):
|
115 |
add_source_channel(y)
|
116 |
+
await e.eor(get_string("cha_2"))
|
117 |
elif is_source_channel_added(y):
|
118 |
+
await e.eor(get_string("cha_3"))
|
119 |
|
120 |
|
121 |
@ultroid_cmd(pattern="dsource ?(.*)")
|
122 |
async def dd(event):
|
123 |
chat_id = event.pattern_match.group(1)
|
124 |
+
x = await event.eor(get_string("com_1"))
|
125 |
if chat_id == "all":
|
126 |
await x.edit(get_string("bd_8"))
|
127 |
+
udB.del_key("CH_SOURCE")
|
128 |
await x.edit(get_string("cha_4"))
|
129 |
return
|
130 |
try:
|
|
|
147 |
|
148 |
@ultroid_cmd(pattern="listsource")
|
149 |
async def list_all(event):
|
150 |
+
x = await event.eor(get_string("com_1"))
|
151 |
channels = get_source_channels()
|
152 |
num = get_no_source_channels()
|
153 |
if num == 0:
|
|
|
191 |
return
|
192 |
if not is_destination_added(y):
|
193 |
add_destination(y)
|
194 |
+
await e.eor("Destination added succesfully")
|
195 |
elif is_destination_added(y):
|
196 |
+
await e.eor("Destination channel already added")
|
197 |
|
198 |
|
199 |
@ultroid_cmd(pattern="ddest ?(.*)")
|
200 |
async def dd(event):
|
201 |
chat_id = event.pattern_match.group(1)
|
202 |
+
x = await event.eor(get_string("com_1"))
|
203 |
if chat_id == "all":
|
204 |
await x.edit(get_string("bd_8"))
|
205 |
+
udB.del_key("CH_DESTINATION")
|
206 |
await x.edit("Destinations database cleared.")
|
207 |
return
|
208 |
try:
|
|
|
226 |
@ultroid_cmd(pattern="listdest")
|
227 |
async def list_all(event):
|
228 |
ultroid_bot = event.client
|
229 |
+
x = await event.eor(get_string("com_1"))
|
230 |
channels = get_destinations()
|
231 |
num = get_no_destinations()
|
232 |
if not num:
|
plugins/{chat_bot.py → chatbot.py}
RENAMED
@@ -1,5 +1,5 @@
|
|
1 |
# Ultroid - UserBot
|
2 |
-
# Copyright (C)
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
@@ -20,10 +20,9 @@
|
|
20 |
List the currently AI added users.
|
21 |
"""
|
22 |
|
23 |
-
from pyUltroid.dB.chatBot_db import add_chatbot, get_all_added, rem_chatbot
|
24 |
from pyUltroid.functions.tools import get_chatbot_reply
|
25 |
|
26 |
-
from . import eod,
|
27 |
|
28 |
|
29 |
@ultroid_cmd(pattern="repai")
|
@@ -36,7 +35,7 @@ async def im_lonely_chat_with_me(event):
|
|
36 |
except IndexError:
|
37 |
return await eod(event, get_string("tban_1"), time=10)
|
38 |
reply_ = await get_chatbot_reply(message=message)
|
39 |
-
await eor(
|
40 |
|
41 |
|
42 |
@ultroid_cmd(pattern="addai")
|
@@ -51,9 +50,10 @@ async def rem_chatBot(event):
|
|
51 |
|
52 |
@ultroid_cmd(pattern="listai")
|
53 |
async def lister(event):
|
54 |
-
|
|
|
55 |
if not users:
|
56 |
-
return await eor(
|
57 |
msg = "**Total List Of AI Enabled Users In This Chat :**\n\n"
|
58 |
for i in users:
|
59 |
try:
|
@@ -62,32 +62,38 @@ async def lister(event):
|
|
62 |
except BaseException:
|
63 |
user = f"`{i}`"
|
64 |
msg += "• {}\n".format(user)
|
65 |
-
await eor(
|
66 |
|
67 |
|
68 |
async def chat_bot_fn(event, type_):
|
69 |
if event.reply_to:
|
70 |
-
|
71 |
-
user = await re_.get_sender()
|
72 |
-
user_id = re_.sender_id
|
73 |
else:
|
74 |
temp = event.text.split(maxsplit=1)
|
75 |
try:
|
76 |
-
|
77 |
-
user_id = user.id
|
78 |
except BaseException:
|
79 |
if event.is_private:
|
80 |
-
|
81 |
-
user = await event.get_chat()
|
82 |
else:
|
83 |
return await eod(
|
84 |
event,
|
85 |
get_string("chab_1"),
|
86 |
)
|
|
|
|
|
|
|
87 |
if type_ == "add":
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
20 |
List the currently AI added users.
|
21 |
"""
|
22 |
|
|
|
23 |
from pyUltroid.functions.tools import get_chatbot_reply
|
24 |
|
25 |
+
from . import eod, get_string, inline_mention, udB, ultroid_cmd
|
26 |
|
27 |
|
28 |
@ultroid_cmd(pattern="repai")
|
|
|
35 |
except IndexError:
|
36 |
return await eod(event, get_string("tban_1"), time=10)
|
37 |
reply_ = await get_chatbot_reply(message=message)
|
38 |
+
await event.eor(reply_)
|
39 |
|
40 |
|
41 |
@ultroid_cmd(pattern="addai")
|
|
|
50 |
|
51 |
@ultroid_cmd(pattern="listai")
|
52 |
async def lister(event):
|
53 |
+
key = udB.get_key("CHATBOT_USERS") or {}
|
54 |
+
users = key.get(event.chat_id, [])
|
55 |
if not users:
|
56 |
+
return await event.eor(get_string("chab_2"), time=5)
|
57 |
msg = "**Total List Of AI Enabled Users In This Chat :**\n\n"
|
58 |
for i in users:
|
59 |
try:
|
|
|
62 |
except BaseException:
|
63 |
user = f"`{i}`"
|
64 |
msg += "• {}\n".format(user)
|
65 |
+
await event.eor(msg, link_preview=False)
|
66 |
|
67 |
|
68 |
async def chat_bot_fn(event, type_):
|
69 |
if event.reply_to:
|
70 |
+
user_ = (await event.get_reply_message()).sender
|
|
|
|
|
71 |
else:
|
72 |
temp = event.text.split(maxsplit=1)
|
73 |
try:
|
74 |
+
user_ = await event.client.get_entity(temp[1])
|
|
|
75 |
except BaseException:
|
76 |
if event.is_private:
|
77 |
+
user_ = event.chat
|
|
|
78 |
else:
|
79 |
return await eod(
|
80 |
event,
|
81 |
get_string("chab_1"),
|
82 |
)
|
83 |
+
key = udB.get_key("CHATBOT_USERS") or {}
|
84 |
+
chat = event.chat_id
|
85 |
+
user = user_.id
|
86 |
if type_ == "add":
|
87 |
+
if key.get(chat):
|
88 |
+
if user not in key[chat]:
|
89 |
+
key[chat].append(user)
|
90 |
+
else:
|
91 |
+
key.update({chat: [user]})
|
92 |
+
elif type_ == "remov":
|
93 |
+
if key.get(chat):
|
94 |
+
if user in key[chat]:
|
95 |
+
key[chat].remove(user)
|
96 |
+
if chat in key and not key[chat]:
|
97 |
+
del key[chat]
|
98 |
+
udB.set_key("CHATBOT_USERS", str(key))
|
99 |
+
await event.eor(f"**ChatBot:**\n{type_}ed {inline_mention(user_)}")
|
plugins/chats.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -42,12 +42,12 @@ from telethon.tl.functions.channels import (
|
|
42 |
)
|
43 |
from telethon.tl.functions.messages import (
|
44 |
CreateChatRequest,
|
45 |
-
DeleteChatUserRequest,
|
46 |
ExportChatInviteRequest,
|
47 |
GetFullChatRequest,
|
48 |
)
|
49 |
from telethon.tl.types import (
|
50 |
ChannelParticipantsKicked,
|
|
|
51 |
UserStatusEmpty,
|
52 |
UserStatusLastMonth,
|
53 |
UserStatusLastWeek,
|
@@ -56,17 +56,7 @@ from telethon.tl.types import (
|
|
56 |
UserStatusRecently,
|
57 |
)
|
58 |
|
59 |
-
from . import
|
60 |
-
HNDLR,
|
61 |
-
eor,
|
62 |
-
get_string,
|
63 |
-
get_user_id,
|
64 |
-
mediainfo,
|
65 |
-
os,
|
66 |
-
types,
|
67 |
-
udB,
|
68 |
-
ultroid_cmd,
|
69 |
-
)
|
70 |
|
71 |
|
72 |
@ultroid_cmd(
|
@@ -74,32 +64,36 @@ from . import (
|
|
74 |
groups_only=True,
|
75 |
)
|
76 |
async def _(e):
|
77 |
-
xx = await eor(
|
78 |
try:
|
79 |
match = e.text.split(" ", maxsplit=1)[1]
|
80 |
-
chat =
|
81 |
except IndexError:
|
82 |
chat = e.chat_id
|
83 |
try:
|
84 |
await e.client(DeleteChannelRequest(chat))
|
85 |
except TypeError:
|
86 |
-
return await eor(
|
87 |
except no_admin:
|
88 |
-
return await eor(
|
89 |
await e.client.send_message(
|
90 |
-
int(udB.
|
91 |
)
|
92 |
|
93 |
|
94 |
@ultroid_cmd(
|
95 |
pattern="getlink$",
|
96 |
groups_only=True,
|
97 |
-
|
98 |
)
|
99 |
async def _(e):
|
100 |
-
|
101 |
-
if
|
102 |
-
|
|
|
|
|
|
|
|
|
103 |
if isinstance(chat, types.Chat):
|
104 |
FC = await e.client(GetFullChatRequest(chat.id))
|
105 |
elif isinstance(chat, types.Channel):
|
@@ -113,9 +107,9 @@ async def _(e):
|
|
113 |
ExportChatInviteRequest(e.chat_id),
|
114 |
)
|
115 |
except no_admin:
|
116 |
-
return await eor(
|
117 |
link = r.link
|
118 |
-
await eor(
|
119 |
|
120 |
|
121 |
@ultroid_cmd(
|
@@ -129,22 +123,16 @@ async def _(e):
|
|
129 |
group_ = group_name.split(" ; ", maxsplit=1)
|
130 |
group_name = group_[0]
|
131 |
username = group_[1]
|
132 |
-
xx = await eor(
|
133 |
if type_of_group == "b":
|
134 |
try:
|
135 |
r = await e.client(
|
136 |
CreateChatRequest(
|
137 |
-
users=[
|
138 |
title=group_name,
|
139 |
),
|
140 |
)
|
141 |
created_chat_id = r.chats[0].id
|
142 |
-
await e.client(
|
143 |
-
DeleteChatUserRequest(
|
144 |
-
chat_id=created_chat_id,
|
145 |
-
user_id="@missrose_bot",
|
146 |
-
),
|
147 |
-
)
|
148 |
result = await e.client(
|
149 |
ExportChatInviteRequest(
|
150 |
peer=created_chat_id,
|
@@ -190,44 +178,38 @@ async def _(e):
|
|
190 |
|
191 |
|
192 |
@ultroid_cmd(
|
193 |
-
pattern="setgpic ?(.*)",
|
194 |
-
groups_only=True,
|
195 |
-
admins_only=True,
|
196 |
-
type=["official", "manager"],
|
197 |
)
|
198 |
async def _(ult):
|
199 |
if not ult.is_reply:
|
200 |
-
return await eor(
|
201 |
match = ult.pattern_match.group(1)
|
202 |
if not ult.client._bot and match:
|
203 |
try:
|
204 |
-
chat = await
|
205 |
except Exception as ok:
|
206 |
-
return await eor(
|
207 |
else:
|
208 |
chat = ult.chat_id
|
209 |
reply_message = await ult.get_reply_message()
|
210 |
if reply_message.media:
|
211 |
replfile = await reply_message.download_media()
|
212 |
else:
|
213 |
-
return await eor(
|
214 |
file = await ult.client.upload_file(replfile)
|
215 |
mediain = mediainfo(reply_message.media)
|
216 |
try:
|
217 |
if "pic" not in mediain:
|
218 |
file = types.InputChatUploadedPhoto(video=file)
|
219 |
await ult.client(EditPhotoRequest(chat, file))
|
220 |
-
await eor(
|
221 |
except Exception as ex:
|
222 |
-
await eor(
|
223 |
os.remove(replfile)
|
224 |
|
225 |
|
226 |
@ultroid_cmd(
|
227 |
-
pattern="delgpic ?(.*)",
|
228 |
-
groups_only=True,
|
229 |
-
admins_only=True,
|
230 |
-
type=["official", "manager"],
|
231 |
)
|
232 |
async def _(ult):
|
233 |
match = ult.pattern_match.group(1)
|
@@ -239,15 +221,12 @@ async def _(ult):
|
|
239 |
text = "`Removed Chat Photo..`"
|
240 |
except Exception as E:
|
241 |
text = str(E)
|
242 |
-
return await eor(
|
243 |
|
244 |
|
245 |
-
@ultroid_cmd(
|
246 |
-
pattern="unbanall$",
|
247 |
-
groups_only=True,
|
248 |
-
)
|
249 |
async def _(event):
|
250 |
-
xx = await eor(
|
251 |
p = 0
|
252 |
title = (await event.get_chat()).title
|
253 |
async for i in event.client.iter_participants(
|
@@ -258,9 +237,11 @@ async def _(event):
|
|
258 |
try:
|
259 |
await event.client.edit_permissions(event.chat_id, i, view_messages=True)
|
260 |
p += 1
|
261 |
-
except
|
262 |
pass
|
263 |
-
|
|
|
|
|
264 |
|
265 |
|
266 |
@ultroid_cmd(
|
@@ -270,7 +251,7 @@ async def _(event):
|
|
270 |
fullsudo=True,
|
271 |
)
|
272 |
async def _(event):
|
273 |
-
xx = await eor(
|
274 |
input_str = event.pattern_match.group(1)
|
275 |
p, a, b, c, d, m, n, y, w, o, q, r = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
276 |
async for i in event.client.iter_participants(event.chat_id):
|
@@ -369,4 +350,4 @@ async def _(event):
|
|
369 |
required_string += f" `{HNDLR}rmusers recently` **••** `{r}`\n"
|
370 |
required_string += f" `{HNDLR}rmusers bot` **••** `{b}`\n"
|
371 |
required_string += f" `{HNDLR}rmusers none` **••** `{n}`"
|
372 |
-
await eor(
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
42 |
)
|
43 |
from telethon.tl.functions.messages import (
|
44 |
CreateChatRequest,
|
|
|
45 |
ExportChatInviteRequest,
|
46 |
GetFullChatRequest,
|
47 |
)
|
48 |
from telethon.tl.types import (
|
49 |
ChannelParticipantsKicked,
|
50 |
+
User,
|
51 |
UserStatusEmpty,
|
52 |
UserStatusLastMonth,
|
53 |
UserStatusLastWeek,
|
|
|
56 |
UserStatusRecently,
|
57 |
)
|
58 |
|
59 |
+
from . import HNDLR, LOGS, asst, get_string, mediainfo, os, types, udB, ultroid_cmd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
|
62 |
@ultroid_cmd(
|
|
|
64 |
groups_only=True,
|
65 |
)
|
66 |
async def _(e):
|
67 |
+
xx = await e.eor(get_string("com_1"))
|
68 |
try:
|
69 |
match = e.text.split(" ", maxsplit=1)[1]
|
70 |
+
chat = await e.client.parse_id(match)
|
71 |
except IndexError:
|
72 |
chat = e.chat_id
|
73 |
try:
|
74 |
await e.client(DeleteChannelRequest(chat))
|
75 |
except TypeError:
|
76 |
+
return await xx.eor(get_string("chats_1"), time=10)
|
77 |
except no_admin:
|
78 |
+
return await xx.eor(get_string("chats_2"), time=10)
|
79 |
await e.client.send_message(
|
80 |
+
int(udB.get_key("LOG_CHANNEL")), get_string("chats_6").format(e.chat_id)
|
81 |
)
|
82 |
|
83 |
|
84 |
@ultroid_cmd(
|
85 |
pattern="getlink$",
|
86 |
groups_only=True,
|
87 |
+
manager=True,
|
88 |
)
|
89 |
async def _(e):
|
90 |
+
reply = await e.get_reply_message()
|
91 |
+
if reply and not isinstance(reply.sender, User):
|
92 |
+
chat = await reply.get_sender()
|
93 |
+
else:
|
94 |
+
chat = await e.get_chat()
|
95 |
+
if hasattr(chat, "username") and chat.username:
|
96 |
+
return await e.eor(f"Username: @{chat.username}")
|
97 |
if isinstance(chat, types.Chat):
|
98 |
FC = await e.client(GetFullChatRequest(chat.id))
|
99 |
elif isinstance(chat, types.Channel):
|
|
|
107 |
ExportChatInviteRequest(e.chat_id),
|
108 |
)
|
109 |
except no_admin:
|
110 |
+
return await e.eor(get_string("chats_2"), time=10)
|
111 |
link = r.link
|
112 |
+
await e.eor(f"Link:- {link}")
|
113 |
|
114 |
|
115 |
@ultroid_cmd(
|
|
|
123 |
group_ = group_name.split(" ; ", maxsplit=1)
|
124 |
group_name = group_[0]
|
125 |
username = group_[1]
|
126 |
+
xx = await e.eor(get_string("com_1"))
|
127 |
if type_of_group == "b":
|
128 |
try:
|
129 |
r = await e.client(
|
130 |
CreateChatRequest(
|
131 |
+
users=[asst.me.username],
|
132 |
title=group_name,
|
133 |
),
|
134 |
)
|
135 |
created_chat_id = r.chats[0].id
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
result = await e.client(
|
137 |
ExportChatInviteRequest(
|
138 |
peer=created_chat_id,
|
|
|
178 |
|
179 |
|
180 |
@ultroid_cmd(
|
181 |
+
pattern="setgpic ?(.*)", admins_only=True, manager=True, require="change_info"
|
|
|
|
|
|
|
182 |
)
|
183 |
async def _(ult):
|
184 |
if not ult.is_reply:
|
185 |
+
return await ult.eor("`Reply to a Media..`", time=5)
|
186 |
match = ult.pattern_match.group(1)
|
187 |
if not ult.client._bot and match:
|
188 |
try:
|
189 |
+
chat = await ult.client.parse_id(match)
|
190 |
except Exception as ok:
|
191 |
+
return await ult.eor(str(ok))
|
192 |
else:
|
193 |
chat = ult.chat_id
|
194 |
reply_message = await ult.get_reply_message()
|
195 |
if reply_message.media:
|
196 |
replfile = await reply_message.download_media()
|
197 |
else:
|
198 |
+
return await ult.eor("Reply to a Photo or Video..")
|
199 |
file = await ult.client.upload_file(replfile)
|
200 |
mediain = mediainfo(reply_message.media)
|
201 |
try:
|
202 |
if "pic" not in mediain:
|
203 |
file = types.InputChatUploadedPhoto(video=file)
|
204 |
await ult.client(EditPhotoRequest(chat, file))
|
205 |
+
await ult.eor("`Group Photo has Successfully Changed !`", time=5)
|
206 |
except Exception as ex:
|
207 |
+
await ult.eor("Error occured.\n`{}`".format(str(ex)), time=5)
|
208 |
os.remove(replfile)
|
209 |
|
210 |
|
211 |
@ultroid_cmd(
|
212 |
+
pattern="delgpic ?(.*)", admins_only=True, manager=True, require="change_info"
|
|
|
|
|
|
|
213 |
)
|
214 |
async def _(ult):
|
215 |
match = ult.pattern_match.group(1)
|
|
|
221 |
text = "`Removed Chat Photo..`"
|
222 |
except Exception as E:
|
223 |
text = str(E)
|
224 |
+
return await ult.eor(text, time=5)
|
225 |
|
226 |
|
227 |
+
@ultroid_cmd(pattern="unbanall$", manager=True, admins_only=True, require="ban_users")
|
|
|
|
|
|
|
228 |
async def _(event):
|
229 |
+
xx = await event.eor("Searching Participant Lists.")
|
230 |
p = 0
|
231 |
title = (await event.get_chat()).title
|
232 |
async for i in event.client.iter_participants(
|
|
|
237 |
try:
|
238 |
await event.client.edit_permissions(event.chat_id, i, view_messages=True)
|
239 |
p += 1
|
240 |
+
except no_admin:
|
241 |
pass
|
242 |
+
except BaseException as er:
|
243 |
+
LOGS.exception(er)
|
244 |
+
await xx.eor(f"{title}: {p} unbanned", time=5)
|
245 |
|
246 |
|
247 |
@ultroid_cmd(
|
|
|
251 |
fullsudo=True,
|
252 |
)
|
253 |
async def _(event):
|
254 |
+
xx = await event.eor(get_string("com_1"))
|
255 |
input_str = event.pattern_match.group(1)
|
256 |
p, a, b, c, d, m, n, y, w, o, q, r = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
257 |
async for i in event.client.iter_participants(event.chat_id):
|
|
|
350 |
required_string += f" `{HNDLR}rmusers recently` **••** `{r}`\n"
|
351 |
required_string += f" `{HNDLR}rmusers bot` **••** `{b}`\n"
|
352 |
required_string += f" `{HNDLR}rmusers none` **••** `{n}`"
|
353 |
+
await xx.eor(required_string)
|
plugins/{clean_action.py → cleanaction.py}
RENAMED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -18,35 +18,41 @@
|
|
18 |
|
19 |
"""
|
20 |
|
21 |
-
from
|
22 |
|
23 |
-
from . import
|
24 |
|
25 |
|
26 |
@ultroid_cmd(pattern="addclean$", admins_only=True)
|
27 |
async def _(e):
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
30 |
|
31 |
|
32 |
@ultroid_cmd(pattern="remclean$")
|
33 |
async def _(e):
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
36 |
|
37 |
|
38 |
@ultroid_cmd(pattern="listclean$")
|
39 |
async def _(e):
|
40 |
-
k = udB.
|
41 |
if k:
|
42 |
-
k = k.split(" ")
|
43 |
o = ""
|
44 |
for x in k:
|
45 |
try:
|
46 |
-
title = e.
|
47 |
except BaseException:
|
48 |
title = get_string("clan_3")
|
49 |
-
o += x
|
50 |
-
await eor(
|
51 |
else:
|
52 |
-
await eor(
|
|
|
1 |
# Ultroid - UserBot
|
2 |
+
# Copyright (C) 2021-2022 TeamUltroid
|
3 |
#
|
4 |
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
# PLease read the GNU Affero General Public License in
|
|
|
18 |
|
19 |
"""
|
20 |
|
21 |
+
from telethon.utils import get_display_name
|
22 |
|
23 |
+
from . import get_string, udB, ultroid_cmd
|
24 |
|
25 |
|
26 |
@ultroid_cmd(pattern="addclean$", admins_only=True)
|
27 |
async def _(e):
|
28 |
+
key = udB.get_key("CLEANCHAT") or []
|
29 |
+
if e.chat_id in key:
|
30 |
+
return await eod(e, get_string("clan_5"))
|
31 |
+
key.append(e.chat_id)
|
32 |
+
udB.set_key("CLEANCHAT", key)
|
33 |
+
await e.eor(get_string("clan_1"), time=5)
|
34 |
|
35 |
|
36 |
@ultroid_cmd(pattern="remclean$")
|
37 |
async def _(e):
|
38 |
+
key = udB.get_key("CLEANCHAT") or []
|
39 |
+
if e.chat_id in key:
|
40 |
+
key.remove(e.chat_id)
|
41 |
+
udB.set_key("CLEANCHAT", key)
|
42 |
+
await e.eor(get_string("clan_2"), time=5)
|
43 |
|
44 |
|
45 |
@ultroid_cmd(pattern="listclean$")
|
46 |
async def _(e):
|
47 |
+
k = udB.get_key("CLEANCHAT")
|
48 |
if k:
|
|
|
49 |
o = ""
|
50 |
for x in k:
|
51 |
try:
|
52 |
+
title = get_display_name(await e.client.get_entity(x))
|
53 |
except BaseException:
|
54 |
title = get_string("clan_3")
|
55 |
+
o += f"{x} {title}\n"
|
56 |
+
await e.eor(o)
|
57 |
else:
|
58 |
+
await e.eor(get_string("clan_4"), time=5)
|