Shivam commited on
Commit ·
2e79dc0
1
Parent(s): a7e554d
Initial commit for Hugging Face Space
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .env +0 -12
- .gitattributes +3 -0
- CODE_OF_CONDUCT.md +128 -0
- CONTRIBUTING.md +23 -0
- Dockerfile +57 -16
- FileStream/__init__.py +0 -5
- FileStream/__main__.py +0 -77
- FileStream/bot/__init__.py +0 -25
- FileStream/bot/clients.py +0 -59
- FileStream/bot/plugins/admin.py +0 -160
- FileStream/bot/plugins/callback.py +0 -198
- FileStream/bot/plugins/start.py +0 -149
- FileStream/bot/plugins/stream.py +0 -96
- FileStream/config.py +0 -41
- FileStream/server/__init__.py +0 -7
- FileStream/server/exceptions.py +0 -5
- FileStream/server/stream_routes.py +0 -136
- FileStream/template/dl.html +0 -44
- FileStream/template/play.html +0 -171
- FileStream/utils/__init__.py +0 -3
- FileStream/utils/bot_utils.py +0 -216
- FileStream/utils/broadcast_helper.py +0 -19
- FileStream/utils/custom_dl.py +0 -214
- FileStream/utils/database.py +0 -134
- FileStream/utils/file_properties.py +0 -144
- FileStream/utils/human_readable.py +0 -10
- FileStream/utils/render_template.py +0 -30
- FileStream/utils/time_format.py +0 -22
- FileStream/utils/translation.py +0 -72
- FileStreamBot +0 -1
- Filer +1 -0
- LICENSE +661 -0
- Procfile +0 -1
- addons.txt +19 -0
- app.json +0 -117
- assistant/__init__.py +34 -0
- assistant/callbackstuffs.py +1325 -0
- assistant/games.py +317 -0
- assistant/initial.py +84 -0
- assistant/inlinestuff.py +623 -0
- assistant/localization.py +47 -0
- assistant/manager/__init__.py +11 -0
- assistant/manager/_help.py +134 -0
- assistant/manager/_on_adds.py +23 -0
- assistant/manager/admins.py +50 -0
- assistant/manager/afk.py +110 -0
- assistant/manager/misc.py +64 -0
- assistant/manager/stickermanager.py +180 -0
- assistant/pmbot.py +150 -0
- assistant/start.py +240 -0
.env
DELETED
|
@@ -1,12 +0,0 @@
|
|
| 1 |
-
API_ID = 28238386
|
| 2 |
-
API_HASH = b466f3f2023129c2737f6af0f5a59efa
|
| 3 |
-
BOT_TOKEN = 7872827994:AAE21CqczkEldf1IzCHn45tentXskDiS4Es
|
| 4 |
-
ULOG_CHANNEL = -1002340006444
|
| 5 |
-
FLOG_CHANNEL = -1002340006444
|
| 6 |
-
DATABASE_URL = mongodb+srv://harshkr0095:Harsh8083@cluster0.bnqjd.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0
|
| 7 |
-
FQDN = 192.168.27.1
|
| 8 |
-
HAS_SSL = False
|
| 9 |
-
#MULTI_TOKEN1 = 12345678:bot_token_multi_client_1
|
| 10 |
-
#MULTI_TOKEN2 = 12345678:bot_token_multi_client_2
|
| 11 |
-
OWNER_ID = 987456321
|
| 12 |
-
PORT = 8080
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.gitattributes
CHANGED
|
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
*.otf filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
*.ttf filter=lfs diff=lfs merge=lfs -text
|
CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Contributor Covenant Code of Conduct
|
| 2 |
+
|
| 3 |
+
## Our Pledge
|
| 4 |
+
|
| 5 |
+
We as members, contributors, and leaders pledge to make participation in our
|
| 6 |
+
community a harassment-free experience for everyone, regardless of age, body
|
| 7 |
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
| 8 |
+
identity and expression, level of experience, education, socio-economic status,
|
| 9 |
+
nationality, personal appearance, race, religion, or sexual identity
|
| 10 |
+
and orientation.
|
| 11 |
+
|
| 12 |
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
| 13 |
+
diverse, inclusive, and healthy community.
|
| 14 |
+
|
| 15 |
+
## Our Standards
|
| 16 |
+
|
| 17 |
+
Examples of behavior that contributes to a positive environment for our
|
| 18 |
+
community include:
|
| 19 |
+
|
| 20 |
+
* Demonstrating empathy and kindness toward other people
|
| 21 |
+
* Being respectful of differing opinions, viewpoints, and experiences
|
| 22 |
+
* Giving and gracefully accepting constructive feedback
|
| 23 |
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
| 24 |
+
and learning from the experience
|
| 25 |
+
* Focusing on what is best not just for us as individuals, but for the
|
| 26 |
+
overall community
|
| 27 |
+
|
| 28 |
+
Examples of unacceptable behavior include:
|
| 29 |
+
|
| 30 |
+
* The use of sexualized language or imagery, and sexual attention or
|
| 31 |
+
advances of any kind
|
| 32 |
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
| 33 |
+
* Public or private harassment
|
| 34 |
+
* Publishing others' private information, such as a physical or email
|
| 35 |
+
address, without their explicit permission
|
| 36 |
+
* Other conduct which could reasonably be considered inappropriate in a
|
| 37 |
+
professional setting
|
| 38 |
+
|
| 39 |
+
## Enforcement Responsibilities
|
| 40 |
+
|
| 41 |
+
Community leaders are responsible for clarifying and enforcing our standards of
|
| 42 |
+
acceptable behavior and will take appropriate and fair corrective action in
|
| 43 |
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
| 44 |
+
or harmful.
|
| 45 |
+
|
| 46 |
+
Community leaders have the right and responsibility to remove, edit, or reject
|
| 47 |
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
| 48 |
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
| 49 |
+
decisions when appropriate.
|
| 50 |
+
|
| 51 |
+
## Scope
|
| 52 |
+
|
| 53 |
+
This Code of Conduct applies within all community spaces, and also applies when
|
| 54 |
+
an individual is officially representing the community in public spaces.
|
| 55 |
+
Examples of representing our community include using an official e-mail address,
|
| 56 |
+
posting via an official social media account, or acting as an appointed
|
| 57 |
+
representative at an online or offline event.
|
| 58 |
+
|
| 59 |
+
## Enforcement
|
| 60 |
+
|
| 61 |
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
| 62 |
+
reported to the community leaders responsible for enforcement at
|
| 63 |
+
teamultroid@ultroid.tech.
|
| 64 |
+
All complaints will be reviewed and investigated promptly and fairly.
|
| 65 |
+
|
| 66 |
+
All community leaders are obligated to respect the privacy and security of the
|
| 67 |
+
reporter of any incident.
|
| 68 |
+
|
| 69 |
+
## Enforcement Guidelines
|
| 70 |
+
|
| 71 |
+
Community leaders will follow these Community Impact Guidelines in determining
|
| 72 |
+
the consequences for any action they deem in violation of this Code of Conduct:
|
| 73 |
+
|
| 74 |
+
### 1. Correction
|
| 75 |
+
|
| 76 |
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
| 77 |
+
unprofessional or unwelcome in the community.
|
| 78 |
+
|
| 79 |
+
**Consequence**: A private, written warning from community leaders, providing
|
| 80 |
+
clarity around the nature of the violation and an explanation of why the
|
| 81 |
+
behavior was inappropriate. A public apology may be requested.
|
| 82 |
+
|
| 83 |
+
### 2. Warning
|
| 84 |
+
|
| 85 |
+
**Community Impact**: A violation through a single incident or series
|
| 86 |
+
of actions.
|
| 87 |
+
|
| 88 |
+
**Consequence**: A warning with consequences for continued behavior. No
|
| 89 |
+
interaction with the people involved, including unsolicited interaction with
|
| 90 |
+
those enforcing the Code of Conduct, for a specified period of time. This
|
| 91 |
+
includes avoiding interactions in community spaces as well as external channels
|
| 92 |
+
like social media. Violating these terms may lead to a temporary or
|
| 93 |
+
permanent ban.
|
| 94 |
+
|
| 95 |
+
### 3. Temporary Ban
|
| 96 |
+
|
| 97 |
+
**Community Impact**: A serious violation of community standards, including
|
| 98 |
+
sustained inappropriate behavior.
|
| 99 |
+
|
| 100 |
+
**Consequence**: A temporary ban from any sort of interaction or public
|
| 101 |
+
communication with the community for a specified period of time. No public or
|
| 102 |
+
private interaction with the people involved, including unsolicited interaction
|
| 103 |
+
with those enforcing the Code of Conduct, is allowed during this period.
|
| 104 |
+
Violating these terms may lead to a permanent ban.
|
| 105 |
+
|
| 106 |
+
### 4. Permanent Ban
|
| 107 |
+
|
| 108 |
+
**Community Impact**: Demonstrating a pattern of violation of community
|
| 109 |
+
standards, including sustained inappropriate behavior, harassment of an
|
| 110 |
+
individual, or aggression toward or disparagement of classes of individuals.
|
| 111 |
+
|
| 112 |
+
**Consequence**: A permanent ban from any sort of public interaction within
|
| 113 |
+
the community.
|
| 114 |
+
|
| 115 |
+
## Attribution
|
| 116 |
+
|
| 117 |
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
| 118 |
+
version 2.0, available at
|
| 119 |
+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
| 120 |
+
|
| 121 |
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
| 122 |
+
enforcement ladder](https://github.com/mozilla/diversity).
|
| 123 |
+
|
| 124 |
+
[homepage]: https://www.contributor-covenant.org
|
| 125 |
+
|
| 126 |
+
For answers to common questions about this code of conduct, see the FAQ at
|
| 127 |
+
https://www.contributor-covenant.org/faq. Translations are available at
|
| 128 |
+
https://www.contributor-covenant.org/translations.
|
CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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`.
|
| 13 |
+
- If you are busy or getting trouble while making changes, you can just open the issue (explaining it).
|
| 14 |
+
|
| 15 |
+
### Contributing
|
| 16 |
+
- You can [fork](https://github.com/TeamUltroid/Ultroid/fork) this repository.
|
| 17 |
+
- You can commits your changes now.
|
| 18 |
+
- You can [Git-Squash](https://docs.github.com/en/get-started/using-git/about-git-rebase) your commits, if they are more. [Optional]
|
| 19 |
+
- At last, You are ready to [`make a Pull Request`](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request).
|
| 20 |
+
- Make sure that, your `Pull Request` contain an explaining title and issue number if it closes any open issue.
|
| 21 |
+
|
| 22 |
+
### Thanks
|
| 23 |
+
- Congrats! 💫 you have successfully made your Contribution to Ultroid.
|
Dockerfile
CHANGED
|
@@ -1,22 +1,63 @@
|
|
| 1 |
-
|
| 2 |
-
FROM ghcr.io/wolfi-dev/alpine-base
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
ca-certificates
|
| 11 |
|
| 12 |
-
# Download and install Ollama
|
| 13 |
-
RUN curl -L https://ollama.com/download/$OLLAMA_VERSION/ollama-linux-amd64.tar.gz | tar -xz -C /usr/local/bin
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
RUN
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.9.5-buster
|
|
|
|
| 2 |
|
| 3 |
+
# Fix apt sources for old Buster release
|
| 4 |
+
RUN sed -i 's|deb.debian.org|archive.debian.org|g' /etc/apt/sources.list && \
|
| 5 |
+
sed -i 's|security.debian.org|archive.debian.org|g' /etc/apt/sources.list && \
|
| 6 |
+
sed -i '/stretch-updates/d' /etc/apt/sources.list && \
|
| 7 |
+
echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/99no-check-valid-until
|
| 8 |
+
|
| 9 |
|
| 10 |
+
# Set timezone
|
| 11 |
+
ENV TZ=Asia/Kolkata
|
| 12 |
+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
|
|
|
| 13 |
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
# Install dependencies
|
| 16 |
+
RUN apt-get update && \
|
| 17 |
+
apt-get install -y --no-install-recommends \
|
| 18 |
+
neofetch \
|
| 19 |
+
git \
|
| 20 |
+
curl \
|
| 21 |
+
wget \
|
| 22 |
+
mediainfo \
|
| 23 |
+
ffmpeg && \
|
| 24 |
+
apt-get autoremove --purge -y && \
|
| 25 |
+
rm -rf /var/lib/apt/lists/*
|
| 26 |
|
| 27 |
+
# Set working directory
|
| 28 |
+
WORKDIR /Ult
|
| 29 |
|
| 30 |
+
# Copy the application code
|
| 31 |
+
COPY . .
|
| 32 |
+
|
| 33 |
+
RUN pip3 install --no-cache-dir -r reqs.txt
|
| 34 |
+
RUN pip3 install -U pip
|
| 35 |
+
RUN pip3 install -U redis
|
| 36 |
+
|
| 37 |
+
RUN pip3 install --no-cache-dir -r addons.txt
|
| 38 |
+
RUN pip3 install --no-cache-dir -r requirements.txt
|
| 39 |
+
RUN pip3 install --no-cache-dir -r res*/st*/op*
|
| 40 |
+
|
| 41 |
+
# Set appropriate permissions
|
| 42 |
+
RUN chown -R 1000:0 /Ult \
|
| 43 |
+
&& chown -R 1000:0 . \
|
| 44 |
+
&& chmod 777 . \
|
| 45 |
+
&& chmod 777 /usr \
|
| 46 |
+
&& chown -R 1000:0 /usr \
|
| 47 |
+
&& chmod -R 755 /Ult \
|
| 48 |
+
&& chmod +x /Ult/start.sh
|
| 49 |
+
|
| 50 |
+
# Install FFmpeg
|
| 51 |
+
RUN wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz && \
|
| 52 |
+
wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz.md5 && \
|
| 53 |
+
md5sum -c ffmpeg-git-amd64-static.tar.xz.md5 && \
|
| 54 |
+
tar xvf ffmpeg-git-amd64-static.tar.xz && \
|
| 55 |
+
mv ffmpeg-git*/ffmpeg ffmpeg-git*/ffprobe /usr/local/bin/
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
# Expose port
|
| 60 |
+
EXPOSE 7860
|
| 61 |
+
|
| 62 |
+
# Start the application
|
| 63 |
+
CMD ["bash", "-c", "python3 server.py & python3 -m pyUltroid"]
|
FileStream/__init__.py
DELETED
|
@@ -1,5 +0,0 @@
|
|
| 1 |
-
import time
|
| 2 |
-
|
| 3 |
-
__version__ = "1.1.0"
|
| 4 |
-
StartTime = time.time()
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileStream/__main__.py
DELETED
|
@@ -1,77 +0,0 @@
|
|
| 1 |
-
import sys
|
| 2 |
-
import asyncio
|
| 3 |
-
import logging
|
| 4 |
-
import traceback
|
| 5 |
-
import logging.handlers as handlers
|
| 6 |
-
from FileStream.config import Telegram, Server
|
| 7 |
-
from aiohttp import web
|
| 8 |
-
from pyrogram import idle
|
| 9 |
-
|
| 10 |
-
from FileStream.bot import FileStream
|
| 11 |
-
from FileStream.server import web_server
|
| 12 |
-
from FileStream.bot.clients import initialize_clients
|
| 13 |
-
|
| 14 |
-
logging.basicConfig(
|
| 15 |
-
level=logging.INFO,
|
| 16 |
-
datefmt="%d/%m/%Y %H:%M:%S",
|
| 17 |
-
format='[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s',
|
| 18 |
-
handlers=[logging.StreamHandler(stream=sys.stdout),
|
| 19 |
-
handlers.RotatingFileHandler("streambot.log", mode="a", maxBytes=104857600, backupCount=2, encoding="utf-8")],)
|
| 20 |
-
|
| 21 |
-
logging.getLogger("aiohttp").setLevel(logging.ERROR)
|
| 22 |
-
logging.getLogger("pyrogram").setLevel(logging.ERROR)
|
| 23 |
-
logging.getLogger("aiohttp.web").setLevel(logging.ERROR)
|
| 24 |
-
|
| 25 |
-
server = web.AppRunner(web_server())
|
| 26 |
-
|
| 27 |
-
loop = asyncio.get_event_loop()
|
| 28 |
-
|
| 29 |
-
async def start_services():
|
| 30 |
-
print()
|
| 31 |
-
if Telegram.SECONDARY:
|
| 32 |
-
print("------------------ Starting as Secondary Server ------------------")
|
| 33 |
-
else:
|
| 34 |
-
print("------------------- Starting as Primary Server -------------------")
|
| 35 |
-
print()
|
| 36 |
-
print("-------------------- Initializing Telegram Bot --------------------")
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
await FileStream.start()
|
| 40 |
-
bot_info = await FileStream.get_me()
|
| 41 |
-
FileStream.id = bot_info.id
|
| 42 |
-
FileStream.username = bot_info.username
|
| 43 |
-
FileStream.fname=bot_info.first_name
|
| 44 |
-
print("------------------------------ DONE ------------------------------")
|
| 45 |
-
print()
|
| 46 |
-
print("---------------------- Initializing Clients ----------------------")
|
| 47 |
-
await initialize_clients()
|
| 48 |
-
print("------------------------------ DONE ------------------------------")
|
| 49 |
-
print()
|
| 50 |
-
print("--------------------- Initializing Web Server ---------------------")
|
| 51 |
-
await server.setup()
|
| 52 |
-
await web.TCPSite(server, Server.BIND_ADDRESS, Server.PORT).start()
|
| 53 |
-
print("------------------------------ DONE ------------------------------")
|
| 54 |
-
print()
|
| 55 |
-
print("------------------------- Service Started -------------------------")
|
| 56 |
-
print(" bot =>> {}".format(bot_info.first_name))
|
| 57 |
-
if bot_info.dc_id:
|
| 58 |
-
print(" DC ID =>> {}".format(str(bot_info.dc_id)))
|
| 59 |
-
print(" URL =>> {}".format(Server.URL))
|
| 60 |
-
print("------------------------------------------------------------------")
|
| 61 |
-
await idle()
|
| 62 |
-
|
| 63 |
-
async def cleanup():
|
| 64 |
-
await server.cleanup()
|
| 65 |
-
await FileStream.stop()
|
| 66 |
-
|
| 67 |
-
if __name__ == "__main__":
|
| 68 |
-
try:
|
| 69 |
-
loop.run_until_complete(start_services())
|
| 70 |
-
except KeyboardInterrupt:
|
| 71 |
-
pass
|
| 72 |
-
except Exception as err:
|
| 73 |
-
logging.error(traceback.format_exc())
|
| 74 |
-
finally:
|
| 75 |
-
loop.run_until_complete(cleanup())
|
| 76 |
-
loop.stop()
|
| 77 |
-
print("------------------------ Stopped Services ------------------------")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileStream/bot/__init__.py
DELETED
|
@@ -1,25 +0,0 @@
|
|
| 1 |
-
from ..config import Telegram
|
| 2 |
-
from pyrogram import Client
|
| 3 |
-
|
| 4 |
-
if Telegram.SECONDARY:
|
| 5 |
-
plugins=None
|
| 6 |
-
no_updates=True
|
| 7 |
-
else:
|
| 8 |
-
plugins={"root": "FileStream/bot/plugins"}
|
| 9 |
-
no_updates=None
|
| 10 |
-
|
| 11 |
-
FileStream = Client(
|
| 12 |
-
name="FileStream",
|
| 13 |
-
api_id=Telegram.API_ID,
|
| 14 |
-
api_hash=Telegram.API_HASH,
|
| 15 |
-
workdir="FileStream",
|
| 16 |
-
plugins=plugins,
|
| 17 |
-
bot_token=Telegram.BOT_TOKEN,
|
| 18 |
-
sleep_threshold=Telegram.SLEEP_THRESHOLD,
|
| 19 |
-
workers=Telegram.WORKERS,
|
| 20 |
-
no_updates=no_updates
|
| 21 |
-
)
|
| 22 |
-
|
| 23 |
-
multi_clients = {}
|
| 24 |
-
work_loads = {}
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileStream/bot/clients.py
DELETED
|
@@ -1,59 +0,0 @@
|
|
| 1 |
-
import asyncio
|
| 2 |
-
import logging
|
| 3 |
-
from os import environ
|
| 4 |
-
from ..config import Telegram
|
| 5 |
-
from pyrogram import Client
|
| 6 |
-
from . import multi_clients, work_loads, FileStream
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
async def initialize_clients():
|
| 10 |
-
all_tokens = dict(
|
| 11 |
-
(c + 1, t)
|
| 12 |
-
for c, (_, t) in enumerate(
|
| 13 |
-
filter(
|
| 14 |
-
lambda n: n[0].startswith("MULTI_TOKEN"), sorted(environ.items())
|
| 15 |
-
)
|
| 16 |
-
)
|
| 17 |
-
)
|
| 18 |
-
if not all_tokens:
|
| 19 |
-
multi_clients[0] = FileStream
|
| 20 |
-
work_loads[0] = 0
|
| 21 |
-
print("No additional clients found, using default client")
|
| 22 |
-
return
|
| 23 |
-
|
| 24 |
-
async def start_client(client_id, token):
|
| 25 |
-
try:
|
| 26 |
-
if len(token) >= 100:
|
| 27 |
-
session_string=token
|
| 28 |
-
bot_token=None
|
| 29 |
-
print(f'Starting Client - {client_id} Using Session String')
|
| 30 |
-
else:
|
| 31 |
-
session_string=None
|
| 32 |
-
bot_token=token
|
| 33 |
-
print(f'Starting Client - {client_id} Using Bot Token')
|
| 34 |
-
if client_id == len(all_tokens):
|
| 35 |
-
await asyncio.sleep(2)
|
| 36 |
-
print("This will take some time, please wait...")
|
| 37 |
-
client = await Client(
|
| 38 |
-
name=str(client_id),
|
| 39 |
-
api_id=Telegram.API_ID,
|
| 40 |
-
api_hash=Telegram.API_HASH,
|
| 41 |
-
bot_token=bot_token,
|
| 42 |
-
sleep_threshold=Telegram.SLEEP_THRESHOLD,
|
| 43 |
-
no_updates=True,
|
| 44 |
-
session_string=session_string,
|
| 45 |
-
in_memory=True,
|
| 46 |
-
).start()
|
| 47 |
-
client.id = (await client.get_me()).id
|
| 48 |
-
work_loads[client_id] = 0
|
| 49 |
-
return client_id, client
|
| 50 |
-
except Exception:
|
| 51 |
-
logging.error(f"Failed starting Client - {client_id} Error:", exc_info=True)
|
| 52 |
-
|
| 53 |
-
clients = await asyncio.gather(*[start_client(i, token) for i, token in all_tokens.items()])
|
| 54 |
-
multi_clients.update(dict(clients))
|
| 55 |
-
if len(multi_clients) != 1:
|
| 56 |
-
Telegram.MULTI_CLIENT = True
|
| 57 |
-
print("Multi-Client Mode Enabled")
|
| 58 |
-
else:
|
| 59 |
-
print("No additional clients were initialized, using default client")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileStream/bot/plugins/admin.py
DELETED
|
@@ -1,160 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import time
|
| 3 |
-
import string
|
| 4 |
-
import random
|
| 5 |
-
import asyncio
|
| 6 |
-
import aiofiles
|
| 7 |
-
import datetime
|
| 8 |
-
|
| 9 |
-
from FileStream.utils.broadcast_helper import send_msg
|
| 10 |
-
from FileStream.utils.database import Database
|
| 11 |
-
from FileStream.bot import FileStream
|
| 12 |
-
from FileStream.server.exceptions import FIleNotFound
|
| 13 |
-
from FileStream.config import Telegram, Server
|
| 14 |
-
from pyrogram import filters, Client
|
| 15 |
-
from pyrogram.types import Message
|
| 16 |
-
from pyrogram.enums.parse_mode import ParseMode
|
| 17 |
-
|
| 18 |
-
db = Database(Telegram.DATABASE_URL, Telegram.SESSION_NAME)
|
| 19 |
-
broadcast_ids = {}
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
@FileStream.on_message(filters.command("status") & filters.private & filters.user(Telegram.OWNER_ID))
|
| 23 |
-
async def sts(c: Client, m: Message):
|
| 24 |
-
await m.reply_text(text=f"""**Total Users in DB:** `{await db.total_users_count()}`
|
| 25 |
-
**Banned Users in DB:** `{await db.total_banned_users_count()}`
|
| 26 |
-
**Total Links Generated: ** `{await db.total_files()}`"""
|
| 27 |
-
, parse_mode=ParseMode.MARKDOWN, quote=True)
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
@FileStream.on_message(filters.command("ban") & filters.private & filters.user(Telegram.OWNER_ID))
|
| 31 |
-
async def sts(b, m: Message):
|
| 32 |
-
id = m.text.split("/ban ")[-1]
|
| 33 |
-
if not await db.is_user_banned(int(id)):
|
| 34 |
-
try:
|
| 35 |
-
await db.ban_user(int(id))
|
| 36 |
-
await db.delete_user(int(id))
|
| 37 |
-
await m.reply_text(text=f"`{id}`** is Banned** ", parse_mode=ParseMode.MARKDOWN, quote=True)
|
| 38 |
-
if not str(id).startswith('-100'):
|
| 39 |
-
await b.send_message(
|
| 40 |
-
chat_id=id,
|
| 41 |
-
text="**Your Banned to Use The Bot**",
|
| 42 |
-
parse_mode=ParseMode.MARKDOWN,
|
| 43 |
-
disable_web_page_preview=True
|
| 44 |
-
)
|
| 45 |
-
except Exception as e:
|
| 46 |
-
await m.reply_text(text=f"**something went wrong: {e}** ", parse_mode=ParseMode.MARKDOWN, quote=True)
|
| 47 |
-
else:
|
| 48 |
-
await m.reply_text(text=f"`{id}`** is Already Banned** ", parse_mode=ParseMode.MARKDOWN, quote=True)
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
@FileStream.on_message(filters.command("unban") & filters.private & filters.user(Telegram.OWNER_ID))
|
| 52 |
-
async def sts(b, m: Message):
|
| 53 |
-
id = m.text.split("/unban ")[-1]
|
| 54 |
-
if await db.is_user_banned(int(id)):
|
| 55 |
-
try:
|
| 56 |
-
await db.unban_user(int(id))
|
| 57 |
-
await m.reply_text(text=f"`{id}`** is Unbanned** ", parse_mode=ParseMode.MARKDOWN, quote=True)
|
| 58 |
-
if not str(id).startswith('-100'):
|
| 59 |
-
await b.send_message(
|
| 60 |
-
chat_id=id,
|
| 61 |
-
text="**Your Unbanned now Use can use The Bot**",
|
| 62 |
-
parse_mode=ParseMode.MARKDOWN,
|
| 63 |
-
disable_web_page_preview=True
|
| 64 |
-
)
|
| 65 |
-
except Exception as e:
|
| 66 |
-
await m.reply_text(text=f"** something went wrong: {e}**", parse_mode=ParseMode.MARKDOWN, quote=True)
|
| 67 |
-
else:
|
| 68 |
-
await m.reply_text(text=f"`{id}`** is not Banned** ", parse_mode=ParseMode.MARKDOWN, quote=True)
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
@FileStream.on_message(filters.command("broadcast") & filters.private & filters.user(Telegram.OWNER_ID) & filters.reply)
|
| 72 |
-
async def broadcast_(c, m):
|
| 73 |
-
all_users = await db.get_all_users()
|
| 74 |
-
broadcast_msg = m.reply_to_message
|
| 75 |
-
while True:
|
| 76 |
-
broadcast_id = ''.join([random.choice(string.ascii_letters) for i in range(3)])
|
| 77 |
-
if not broadcast_ids.get(broadcast_id):
|
| 78 |
-
break
|
| 79 |
-
out = await m.reply_text(
|
| 80 |
-
text=f"Broadcast initiated! You will be notified with log file when all the users are notified."
|
| 81 |
-
)
|
| 82 |
-
start_time = time.time()
|
| 83 |
-
total_users = await db.total_users_count()
|
| 84 |
-
done = 0
|
| 85 |
-
failed = 0
|
| 86 |
-
success = 0
|
| 87 |
-
broadcast_ids[broadcast_id] = dict(
|
| 88 |
-
total=total_users,
|
| 89 |
-
current=done,
|
| 90 |
-
failed=failed,
|
| 91 |
-
success=success
|
| 92 |
-
)
|
| 93 |
-
async with aiofiles.open('broadcast.txt', 'w') as broadcast_log_file:
|
| 94 |
-
async for user in all_users:
|
| 95 |
-
sts, msg = await send_msg(
|
| 96 |
-
user_id=int(user['id']),
|
| 97 |
-
message=broadcast_msg
|
| 98 |
-
)
|
| 99 |
-
if msg is not None:
|
| 100 |
-
await broadcast_log_file.write(msg)
|
| 101 |
-
if sts == 200:
|
| 102 |
-
success += 1
|
| 103 |
-
else:
|
| 104 |
-
failed += 1
|
| 105 |
-
if sts == 400:
|
| 106 |
-
await db.delete_user(user['id'])
|
| 107 |
-
done += 1
|
| 108 |
-
if broadcast_ids.get(broadcast_id) is None:
|
| 109 |
-
break
|
| 110 |
-
else:
|
| 111 |
-
broadcast_ids[broadcast_id].update(
|
| 112 |
-
dict(
|
| 113 |
-
current=done,
|
| 114 |
-
failed=failed,
|
| 115 |
-
success=success
|
| 116 |
-
)
|
| 117 |
-
)
|
| 118 |
-
try:
|
| 119 |
-
await out.edit_text(f"Broadcast Status\n\ncurrent: {done}\nfailed:{failed}\nsuccess: {success}")
|
| 120 |
-
except:
|
| 121 |
-
pass
|
| 122 |
-
if broadcast_ids.get(broadcast_id):
|
| 123 |
-
broadcast_ids.pop(broadcast_id)
|
| 124 |
-
completed_in = datetime.timedelta(seconds=int(time.time() - start_time))
|
| 125 |
-
await asyncio.sleep(3)
|
| 126 |
-
await out.delete()
|
| 127 |
-
if failed == 0:
|
| 128 |
-
await m.reply_text(
|
| 129 |
-
text=f"broadcast completed in `{completed_in}`\n\nTotal users {total_users}.\nTotal done {done}, {success} success and {failed} failed.",
|
| 130 |
-
quote=True
|
| 131 |
-
)
|
| 132 |
-
else:
|
| 133 |
-
await m.reply_document(
|
| 134 |
-
document='broadcast.txt',
|
| 135 |
-
caption=f"broadcast completed in `{completed_in}`\n\nTotal users {total_users}.\nTotal done {done}, {success} success and {failed} failed.",
|
| 136 |
-
quote=True
|
| 137 |
-
)
|
| 138 |
-
os.remove('broadcast.txt')
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
@FileStream.on_message(filters.command("del") & filters.private & filters.user(Telegram.OWNER_ID))
|
| 142 |
-
async def sts(c: Client, m: Message):
|
| 143 |
-
file_id = m.text.split(" ")[-1]
|
| 144 |
-
try:
|
| 145 |
-
file_info = await db.get_file(file_id)
|
| 146 |
-
except FIleNotFound:
|
| 147 |
-
await m.reply_text(
|
| 148 |
-
text=f"**ꜰɪʟᴇ ᴀʟʀᴇᴀᴅʏ ᴅᴇʟᴇᴛᴇᴅ**",
|
| 149 |
-
quote=True
|
| 150 |
-
)
|
| 151 |
-
return
|
| 152 |
-
await db.delete_one_file(file_info['_id'])
|
| 153 |
-
await db.count_links(file_info['user_id'], "-")
|
| 154 |
-
await m.reply_text(
|
| 155 |
-
text=f"**Fɪʟᴇ Dᴇʟᴇᴛᴇᴅ Sᴜᴄᴄᴇssғᴜʟʟʏ !** ",
|
| 156 |
-
quote=True
|
| 157 |
-
)
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
|
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 |
-
import math
|
| 3 |
-
from FileStream import __version__
|
| 4 |
-
from FileStream.bot import FileStream
|
| 5 |
-
from FileStream.config import Telegram, Server
|
| 6 |
-
from FileStream.utils.translation import LANG, BUTTON
|
| 7 |
-
from FileStream.utils.bot_utils import gen_link
|
| 8 |
-
from FileStream.utils.database import Database
|
| 9 |
-
from FileStream.utils.human_readable import humanbytes
|
| 10 |
-
from FileStream.server.exceptions import FIleNotFound
|
| 11 |
-
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery
|
| 12 |
-
from pyrogram.file_id import FileId, FileType, PHOTO_TYPES
|
| 13 |
-
from pyrogram.enums.parse_mode import ParseMode
|
| 14 |
-
db = Database(Telegram.DATABASE_URL, Telegram.SESSION_NAME)
|
| 15 |
-
|
| 16 |
-
#---------------------[ START CMD ]---------------------#
|
| 17 |
-
@FileStream.on_callback_query()
|
| 18 |
-
async def cb_data(bot, update: CallbackQuery):
|
| 19 |
-
usr_cmd = update.data.split("_")
|
| 20 |
-
if usr_cmd[0] == "home":
|
| 21 |
-
await update.message.edit_text(
|
| 22 |
-
text=LANG.START_TEXT.format(update.from_user.mention, FileStream.username),
|
| 23 |
-
disable_web_page_preview=True,
|
| 24 |
-
reply_markup=BUTTON.START_BUTTONS
|
| 25 |
-
)
|
| 26 |
-
elif usr_cmd[0] == "help":
|
| 27 |
-
await update.message.edit_text(
|
| 28 |
-
text=LANG.HELP_TEXT.format(Telegram.OWNER_ID),
|
| 29 |
-
disable_web_page_preview=True,
|
| 30 |
-
reply_markup=BUTTON.HELP_BUTTONS
|
| 31 |
-
)
|
| 32 |
-
elif usr_cmd[0] == "about":
|
| 33 |
-
await update.message.edit_text(
|
| 34 |
-
text=LANG.ABOUT_TEXT.format(FileStream.fname, __version__),
|
| 35 |
-
disable_web_page_preview=True,
|
| 36 |
-
reply_markup=BUTTON.ABOUT_BUTTONS
|
| 37 |
-
)
|
| 38 |
-
|
| 39 |
-
#---------------------[ MY FILES CMD ]---------------------#
|
| 40 |
-
|
| 41 |
-
elif usr_cmd[0] == "N/A":
|
| 42 |
-
await update.answer("N/A", True)
|
| 43 |
-
elif usr_cmd[0] == "close":
|
| 44 |
-
await update.message.delete()
|
| 45 |
-
elif usr_cmd[0] == "msgdelete":
|
| 46 |
-
await update.message.edit_caption(
|
| 47 |
-
caption= "**Cᴏɴғɪʀᴍ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴅᴇʟᴇᴛᴇ ᴛʜᴇ Fɪʟᴇ**\n\n",
|
| 48 |
-
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("ʏᴇs", callback_data=f"msgdelyes_{usr_cmd[1]}_{usr_cmd[2]}"), InlineKeyboardButton("ɴᴏ", callback_data=f"myfile_{usr_cmd[1]}_{usr_cmd[2]}")]])
|
| 49 |
-
)
|
| 50 |
-
elif usr_cmd[0] == "msgdelyes":
|
| 51 |
-
await delete_user_file(usr_cmd[1], int(usr_cmd[2]), update)
|
| 52 |
-
return
|
| 53 |
-
elif usr_cmd[0] == "msgdelpvt":
|
| 54 |
-
await update.message.edit_caption(
|
| 55 |
-
caption= "**Cᴏɴғɪʀᴍ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴅᴇʟᴇᴛᴇ ᴛʜᴇ Fɪʟᴇ**\n\n",
|
| 56 |
-
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("ʏᴇs", callback_data=f"msgdelpvtyes_{usr_cmd[1]}"), InlineKeyboardButton("ɴᴏ", callback_data=f"mainstream_{usr_cmd[1]}")]])
|
| 57 |
-
)
|
| 58 |
-
elif usr_cmd[0] == "msgdelpvtyes":
|
| 59 |
-
await delete_user_filex(usr_cmd[1], update)
|
| 60 |
-
return
|
| 61 |
-
|
| 62 |
-
elif usr_cmd[0] == "mainstream":
|
| 63 |
-
_id = usr_cmd[1]
|
| 64 |
-
reply_markup, stream_text = await gen_link(_id=_id)
|
| 65 |
-
await update.message.edit_text(
|
| 66 |
-
text=stream_text,
|
| 67 |
-
parse_mode=ParseMode.HTML,
|
| 68 |
-
disable_web_page_preview=True,
|
| 69 |
-
reply_markup=reply_markup,
|
| 70 |
-
)
|
| 71 |
-
|
| 72 |
-
elif usr_cmd[0] == "userfiles":
|
| 73 |
-
file_list, total_files = await gen_file_list_button(int(usr_cmd[1]), update.from_user.id)
|
| 74 |
-
await update.message.edit_caption(
|
| 75 |
-
caption="Total files: {}".format(total_files),
|
| 76 |
-
reply_markup=InlineKeyboardMarkup(file_list)
|
| 77 |
-
)
|
| 78 |
-
elif usr_cmd[0] == "myfile":
|
| 79 |
-
await gen_file_menu(usr_cmd[1], usr_cmd[2], update)
|
| 80 |
-
return
|
| 81 |
-
elif usr_cmd[0] == "sendfile":
|
| 82 |
-
myfile = await db.get_file(usr_cmd[1])
|
| 83 |
-
file_name = myfile['file_name']
|
| 84 |
-
await update.answer(f"Sending File {file_name}")
|
| 85 |
-
await update.message.reply_cached_media(myfile['file_id'], caption=f'**{file_name}**')
|
| 86 |
-
else:
|
| 87 |
-
await update.message.delete()
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
#---------------------[ MY FILES FUNC ]---------------------#
|
| 92 |
-
|
| 93 |
-
async def gen_file_list_button(file_list_no: int, user_id: int):
|
| 94 |
-
|
| 95 |
-
file_range=[file_list_no*10-10+1, file_list_no*10]
|
| 96 |
-
user_files, total_files=await db.find_files(user_id, file_range)
|
| 97 |
-
|
| 98 |
-
file_list=[]
|
| 99 |
-
async for x in user_files:
|
| 100 |
-
file_list.append([InlineKeyboardButton(x["file_name"], callback_data=f"myfile_{x['_id']}_{file_list_no}")])
|
| 101 |
-
if total_files > 10:
|
| 102 |
-
file_list.append(
|
| 103 |
-
[InlineKeyboardButton("◄", callback_data="{}".format("userfiles_"+str(file_list_no-1) if file_list_no > 1 else 'N/A')),
|
| 104 |
-
InlineKeyboardButton(f"{file_list_no}/{math.ceil(total_files/10)}", callback_data="N/A"),
|
| 105 |
-
InlineKeyboardButton("►", callback_data="{}".format("userfiles_"+str(file_list_no+1) if total_files > file_list_no*10 else 'N/A'))]
|
| 106 |
-
)
|
| 107 |
-
if not file_list:
|
| 108 |
-
file_list.append(
|
| 109 |
-
[InlineKeyboardButton("ᴇᴍᴘᴛʏ", callback_data="N/A")])
|
| 110 |
-
file_list.append([InlineKeyboardButton("ᴄʟᴏsᴇ", callback_data="close")])
|
| 111 |
-
return file_list, total_files
|
| 112 |
-
|
| 113 |
-
async def gen_file_menu(_id, file_list_no, update: CallbackQuery):
|
| 114 |
-
try:
|
| 115 |
-
myfile_info=await db.get_file(_id)
|
| 116 |
-
except FIleNotFound:
|
| 117 |
-
await update.answer("File Not Found")
|
| 118 |
-
return
|
| 119 |
-
|
| 120 |
-
file_id=FileId.decode(myfile_info['file_id'])
|
| 121 |
-
|
| 122 |
-
if file_id.file_type in PHOTO_TYPES:
|
| 123 |
-
file_type = "Image"
|
| 124 |
-
elif file_id.file_type == FileType.VOICE:
|
| 125 |
-
file_type = "Voice"
|
| 126 |
-
elif file_id.file_type in (FileType.VIDEO, FileType.ANIMATION, FileType.VIDEO_NOTE):
|
| 127 |
-
file_type = "Video"
|
| 128 |
-
elif file_id.file_type == FileType.DOCUMENT:
|
| 129 |
-
file_type = "Document"
|
| 130 |
-
elif file_id.file_type == FileType.STICKER:
|
| 131 |
-
file_type = "Sticker"
|
| 132 |
-
elif file_id.file_type == FileType.AUDIO:
|
| 133 |
-
file_type = "Audio"
|
| 134 |
-
else:
|
| 135 |
-
file_type = "Unknown"
|
| 136 |
-
|
| 137 |
-
page_link = f"{Server.URL}watch/{myfile_info['_id']}"
|
| 138 |
-
stream_link = f"{Server.URL}dl/{myfile_info['_id']}"
|
| 139 |
-
if "video" in file_type.lower():
|
| 140 |
-
MYFILES_BUTTONS = InlineKeyboardMarkup(
|
| 141 |
-
[
|
| 142 |
-
[InlineKeyboardButton("sᴛʀᴇᴀᴍ", url=page_link), InlineKeyboardButton("ᴅᴏᴡɴʟᴏᴀᴅ", url=stream_link)],
|
| 143 |
-
[InlineKeyboardButton("ɢᴇᴛ ғɪʟᴇ", callback_data=f"sendfile_{myfile_info['_id']}"),
|
| 144 |
-
InlineKeyboardButton("ʀᴇᴠᴏᴋᴇ ғɪʟᴇ", callback_data=f"msgdelete_{myfile_info['_id']}_{file_list_no}")],
|
| 145 |
-
[InlineKeyboardButton("ʙᴀᴄᴋ", callback_data="userfiles_{}".format(file_list_no))]
|
| 146 |
-
]
|
| 147 |
-
)
|
| 148 |
-
else:
|
| 149 |
-
MYFILES_BUTTONS = InlineKeyboardMarkup(
|
| 150 |
-
[
|
| 151 |
-
[InlineKeyboardButton("ᴅᴏᴡɴʟᴏᴀᴅ", url=stream_link)],
|
| 152 |
-
[InlineKeyboardButton("ɢᴇᴛ ғɪʟᴇ", callback_data=f"sendfile_{myfile_info['_id']}"),
|
| 153 |
-
InlineKeyboardButton("ʀᴇᴠᴏᴋᴇ ғɪʟᴇ", callback_data=f"msgdelete_{myfile_info['_id']}_{file_list_no}")],
|
| 154 |
-
[InlineKeyboardButton("ʙᴀᴄᴋ", callback_data="userfiles_{}".format(file_list_no))]
|
| 155 |
-
]
|
| 156 |
-
)
|
| 157 |
-
|
| 158 |
-
TiMe = myfile_info['time']
|
| 159 |
-
if type(TiMe) == float:
|
| 160 |
-
date = datetime.datetime.fromtimestamp(TiMe)
|
| 161 |
-
await update.edit_message_caption(
|
| 162 |
-
caption="**File Name :** `{}`\n**File Size :** `{}`\n**File Type :** `{}`\n**Created On :** `{}`".format(myfile_info['file_name'],
|
| 163 |
-
humanbytes(int(myfile_info['file_size'])),
|
| 164 |
-
file_type,
|
| 165 |
-
TiMe if isinstance(TiMe,str) else date.date()),
|
| 166 |
-
reply_markup=MYFILES_BUTTONS )
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
async def delete_user_file(_id, file_list_no: int, update:CallbackQuery):
|
| 170 |
-
|
| 171 |
-
try:
|
| 172 |
-
myfile_info=await db.get_file(_id)
|
| 173 |
-
except FIleNotFound:
|
| 174 |
-
await update.answer("File Already Deleted")
|
| 175 |
-
return
|
| 176 |
-
|
| 177 |
-
await db.delete_one_file(myfile_info['_id'])
|
| 178 |
-
await db.count_links(update.from_user.id, "-")
|
| 179 |
-
await update.message.edit_caption(
|
| 180 |
-
caption= "**Fɪʟᴇ Dᴇʟᴇᴛᴇᴅ Sᴜᴄᴄᴇssғᴜʟʟʏ !**" + update.message.caption.replace("Cᴏɴғɪʀᴍ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴅᴇʟᴇᴛᴇ ᴛʜᴇ Fɪʟᴇ", ""),
|
| 181 |
-
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("ʙᴀᴄᴋ", callback_data=f"userfiles_1")]])
|
| 182 |
-
)
|
| 183 |
-
|
| 184 |
-
async def delete_user_filex(_id, update:CallbackQuery):
|
| 185 |
-
|
| 186 |
-
try:
|
| 187 |
-
myfile_info=await db.get_file(_id)
|
| 188 |
-
except FIleNotFound:
|
| 189 |
-
await update.answer("File Already Deleted")
|
| 190 |
-
return
|
| 191 |
-
|
| 192 |
-
await db.delete_one_file(myfile_info['_id'])
|
| 193 |
-
await db.count_links(update.from_user.id, "-")
|
| 194 |
-
await update.message.edit_caption(
|
| 195 |
-
caption= "**Fɪʟᴇ Dᴇʟᴇᴛᴇᴅ Sᴜᴄᴄᴇssғᴜʟʟʏ !**\n\n",
|
| 196 |
-
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("ᴄʟᴏsᴇ", callback_data=f"close")]])
|
| 197 |
-
)
|
| 198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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|
| 2 |
-
import math
|
| 3 |
-
from FileStream import __version__
|
| 4 |
-
from FileStream.bot import FileStream
|
| 5 |
-
from FileStream.server.exceptions import FIleNotFound
|
| 6 |
-
from FileStream.utils.bot_utils import gen_linkx, verify_user
|
| 7 |
-
from FileStream.config import Telegram
|
| 8 |
-
from FileStream.utils.database import Database
|
| 9 |
-
from FileStream.utils.translation import LANG, BUTTON
|
| 10 |
-
from pyrogram import filters, Client
|
| 11 |
-
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, Message
|
| 12 |
-
from pyrogram.enums.parse_mode import ParseMode
|
| 13 |
-
import asyncio
|
| 14 |
-
|
| 15 |
-
db = Database(Telegram.DATABASE_URL, Telegram.SESSION_NAME)
|
| 16 |
-
|
| 17 |
-
@FileStream.on_message(filters.command('start') & filters.private)
|
| 18 |
-
async def start(bot: Client, message: Message):
|
| 19 |
-
if not await verify_user(bot, message):
|
| 20 |
-
return
|
| 21 |
-
usr_cmd = message.text.split("_")[-1]
|
| 22 |
-
|
| 23 |
-
if usr_cmd == "/start":
|
| 24 |
-
if Telegram.START_PIC:
|
| 25 |
-
await message.reply_photo(
|
| 26 |
-
photo=Telegram.START_PIC,
|
| 27 |
-
caption=LANG.START_TEXT.format(message.from_user.mention, FileStream.username),
|
| 28 |
-
parse_mode=ParseMode.HTML,
|
| 29 |
-
reply_markup=BUTTON.START_BUTTONS
|
| 30 |
-
)
|
| 31 |
-
else:
|
| 32 |
-
await message.reply_text(
|
| 33 |
-
text=LANG.START_TEXT.format(message.from_user.mention, FileStream.username),
|
| 34 |
-
parse_mode=ParseMode.HTML,
|
| 35 |
-
disable_web_page_preview=True,
|
| 36 |
-
reply_markup=BUTTON.START_BUTTONS
|
| 37 |
-
)
|
| 38 |
-
else:
|
| 39 |
-
if "stream_" in message.text:
|
| 40 |
-
try:
|
| 41 |
-
file_check = await db.get_file(usr_cmd)
|
| 42 |
-
file_id = str(file_check['_id'])
|
| 43 |
-
if file_id == usr_cmd:
|
| 44 |
-
reply_markup, stream_text = await gen_linkx(m=message, _id=file_id,
|
| 45 |
-
name=[FileStream.username, FileStream.fname])
|
| 46 |
-
await message.reply_text(
|
| 47 |
-
text=stream_text,
|
| 48 |
-
parse_mode=ParseMode.HTML,
|
| 49 |
-
disable_web_page_preview=True,
|
| 50 |
-
reply_markup=reply_markup,
|
| 51 |
-
quote=True
|
| 52 |
-
)
|
| 53 |
-
|
| 54 |
-
except FIleNotFound as e:
|
| 55 |
-
await message.reply_text("File Not Found")
|
| 56 |
-
except Exception as e:
|
| 57 |
-
await message.reply_text("Something Went Wrong")
|
| 58 |
-
logging.error(e)
|
| 59 |
-
|
| 60 |
-
elif "file_" in message.text:
|
| 61 |
-
try:
|
| 62 |
-
file_check = await db.get_file(usr_cmd)
|
| 63 |
-
db_id = str(file_check['_id'])
|
| 64 |
-
file_id = file_check['file_id']
|
| 65 |
-
file_name = file_check['file_name']
|
| 66 |
-
if db_id == usr_cmd:
|
| 67 |
-
filex = await message.reply_cached_media(file_id=file_id, caption=f'**{file_name}**')
|
| 68 |
-
await asyncio.sleep(3600)
|
| 69 |
-
try:
|
| 70 |
-
await filex.delete()
|
| 71 |
-
await message.delete()
|
| 72 |
-
except Exception:
|
| 73 |
-
pass
|
| 74 |
-
|
| 75 |
-
except FIleNotFound as e:
|
| 76 |
-
await message.reply_text("**File Not Found**")
|
| 77 |
-
except Exception as e:
|
| 78 |
-
await message.reply_text("Something Went Wrong")
|
| 79 |
-
logging.error(e)
|
| 80 |
-
|
| 81 |
-
else:
|
| 82 |
-
await message.reply_text(f"**Invalid Command**")
|
| 83 |
-
|
| 84 |
-
@FileStream.on_message(filters.private & filters.command(["about"]))
|
| 85 |
-
async def start(bot, message):
|
| 86 |
-
if not await verify_user(bot, message):
|
| 87 |
-
return
|
| 88 |
-
if Telegram.START_PIC:
|
| 89 |
-
await message.reply_photo(
|
| 90 |
-
photo=Telegram.START_PIC,
|
| 91 |
-
caption=LANG.ABOUT_TEXT.format(FileStream.fname, __version__),
|
| 92 |
-
parse_mode=ParseMode.HTML,
|
| 93 |
-
reply_markup=BUTTON.ABOUT_BUTTONS
|
| 94 |
-
)
|
| 95 |
-
else:
|
| 96 |
-
await message.reply_text(
|
| 97 |
-
text=LANG.ABOUT_TEXT.format(FileStream.fname, __version__),
|
| 98 |
-
disable_web_page_preview=True,
|
| 99 |
-
reply_markup=BUTTON.ABOUT_BUTTONS
|
| 100 |
-
)
|
| 101 |
-
|
| 102 |
-
@FileStream.on_message((filters.command('help')) & filters.private)
|
| 103 |
-
async def help_handler(bot, message):
|
| 104 |
-
if not await verify_user(bot, message):
|
| 105 |
-
return
|
| 106 |
-
if Telegram.START_PIC:
|
| 107 |
-
await message.reply_photo(
|
| 108 |
-
photo=Telegram.START_PIC,
|
| 109 |
-
caption=LANG.HELP_TEXT.format(Telegram.OWNER_ID),
|
| 110 |
-
parse_mode=ParseMode.HTML,
|
| 111 |
-
reply_markup=BUTTON.HELP_BUTTONS
|
| 112 |
-
)
|
| 113 |
-
else:
|
| 114 |
-
await message.reply_text(
|
| 115 |
-
text=LANG.HELP_TEXT.format(Telegram.OWNER_ID),
|
| 116 |
-
parse_mode=ParseMode.HTML,
|
| 117 |
-
disable_web_page_preview=True,
|
| 118 |
-
reply_markup=BUTTON.HELP_BUTTONS
|
| 119 |
-
)
|
| 120 |
-
|
| 121 |
-
# ---------------------------------------------------------------------------------------------------
|
| 122 |
-
|
| 123 |
-
@FileStream.on_message(filters.command('files') & filters.private)
|
| 124 |
-
async def my_files(bot: Client, message: Message):
|
| 125 |
-
if not await verify_user(bot, message):
|
| 126 |
-
return
|
| 127 |
-
user_files, total_files = await db.find_files(message.from_user.id, [1, 10])
|
| 128 |
-
|
| 129 |
-
file_list = []
|
| 130 |
-
async for x in user_files:
|
| 131 |
-
file_list.append([InlineKeyboardButton(x["file_name"], callback_data=f"myfile_{x['_id']}_{1}")])
|
| 132 |
-
if total_files > 10:
|
| 133 |
-
file_list.append(
|
| 134 |
-
[
|
| 135 |
-
InlineKeyboardButton("◄", callback_data="N/A"),
|
| 136 |
-
InlineKeyboardButton(f"1/{math.ceil(total_files / 10)}", callback_data="N/A"),
|
| 137 |
-
InlineKeyboardButton("►", callback_data="userfiles_2")
|
| 138 |
-
],
|
| 139 |
-
)
|
| 140 |
-
if not file_list:
|
| 141 |
-
file_list.append(
|
| 142 |
-
[InlineKeyboardButton("ᴇᴍᴘᴛʏ", callback_data="N/A")],
|
| 143 |
-
)
|
| 144 |
-
file_list.append([InlineKeyboardButton("ᴄʟᴏsᴇ", callback_data="close")])
|
| 145 |
-
await message.reply_photo(photo=Telegram.FILE_PIC,
|
| 146 |
-
caption="Total files: {}".format(total_files),
|
| 147 |
-
reply_markup=InlineKeyboardMarkup(file_list))
|
| 148 |
-
|
| 149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileStream/bot/plugins/stream.py
DELETED
|
@@ -1,96 +0,0 @@
|
|
| 1 |
-
|
| 2 |
-
import asyncio
|
| 3 |
-
from FileStream.bot import FileStream, multi_clients
|
| 4 |
-
from FileStream.utils.bot_utils import is_user_banned, is_user_exist, is_user_joined, gen_link, is_channel_banned, is_channel_exist, is_user_authorized
|
| 5 |
-
from FileStream.utils.database import Database
|
| 6 |
-
from FileStream.utils.file_properties import get_file_ids, get_file_info
|
| 7 |
-
from FileStream.config import Telegram
|
| 8 |
-
from pyrogram import filters, Client
|
| 9 |
-
from pyrogram.errors import FloodWait
|
| 10 |
-
from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
|
| 11 |
-
from pyrogram.enums.parse_mode import ParseMode
|
| 12 |
-
db = Database(Telegram.DATABASE_URL, Telegram.SESSION_NAME)
|
| 13 |
-
|
| 14 |
-
@FileStream.on_message(
|
| 15 |
-
filters.private
|
| 16 |
-
& (
|
| 17 |
-
filters.document
|
| 18 |
-
| filters.video
|
| 19 |
-
| filters.video_note
|
| 20 |
-
| filters.audio
|
| 21 |
-
| filters.voice
|
| 22 |
-
| filters.animation
|
| 23 |
-
| filters.photo
|
| 24 |
-
),
|
| 25 |
-
group=4,
|
| 26 |
-
)
|
| 27 |
-
async def private_receive_handler(bot: Client, message: Message):
|
| 28 |
-
if not await is_user_authorized(message):
|
| 29 |
-
return
|
| 30 |
-
if await is_user_banned(message):
|
| 31 |
-
return
|
| 32 |
-
|
| 33 |
-
await is_user_exist(bot, message)
|
| 34 |
-
if Telegram.FORCE_SUB:
|
| 35 |
-
if not await is_user_joined(bot, message):
|
| 36 |
-
return
|
| 37 |
-
try:
|
| 38 |
-
inserted_id = await db.add_file(get_file_info(message))
|
| 39 |
-
await get_file_ids(False, inserted_id, multi_clients, message)
|
| 40 |
-
reply_markup, stream_text = await gen_link(_id=inserted_id)
|
| 41 |
-
await message.reply_text(
|
| 42 |
-
text=stream_text,
|
| 43 |
-
parse_mode=ParseMode.HTML,
|
| 44 |
-
disable_web_page_preview=True,
|
| 45 |
-
reply_markup=reply_markup,
|
| 46 |
-
quote=True
|
| 47 |
-
)
|
| 48 |
-
except FloodWait as e:
|
| 49 |
-
print(f"Sleeping for {str(e.value)}s")
|
| 50 |
-
await asyncio.sleep(e.value)
|
| 51 |
-
await bot.send_message(chat_id=Telegram.ULOG_CHANNEL,
|
| 52 |
-
text=f"Gᴏᴛ FʟᴏᴏᴅWᴀɪᴛ ᴏғ {str(e.value)}s ғʀᴏᴍ [{message.from_user.first_name}](tg://user?id={message.from_user.id})\n\n**ᴜsᴇʀ ɪᴅ :** `{str(message.from_user.id)}`",
|
| 53 |
-
disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN)
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
@FileStream.on_message(
|
| 57 |
-
filters.channel
|
| 58 |
-
& ~filters.forwarded
|
| 59 |
-
& ~filters.media_group
|
| 60 |
-
& (
|
| 61 |
-
filters.document
|
| 62 |
-
| filters.video
|
| 63 |
-
| filters.video_note
|
| 64 |
-
| filters.audio
|
| 65 |
-
| filters.voice
|
| 66 |
-
| filters.photo
|
| 67 |
-
)
|
| 68 |
-
)
|
| 69 |
-
async def channel_receive_handler(bot: Client, message: Message):
|
| 70 |
-
if await is_channel_banned(bot, message):
|
| 71 |
-
return
|
| 72 |
-
await is_channel_exist(bot, message)
|
| 73 |
-
|
| 74 |
-
try:
|
| 75 |
-
inserted_id = await db.add_file(get_file_info(message))
|
| 76 |
-
await get_file_ids(False, inserted_id, multi_clients, message)
|
| 77 |
-
reply_markup, stream_link = await gen_link(_id=inserted_id)
|
| 78 |
-
await bot.edit_message_reply_markup(
|
| 79 |
-
chat_id=message.chat.id,
|
| 80 |
-
message_id=message.id,
|
| 81 |
-
reply_markup=InlineKeyboardMarkup(
|
| 82 |
-
[[InlineKeyboardButton("Dᴏᴡɴʟᴏᴀᴅ ʟɪɴᴋ 📥",
|
| 83 |
-
url=f"https://t.me/{FileStream.username}?start=stream_{str(inserted_id)}")]])
|
| 84 |
-
)
|
| 85 |
-
|
| 86 |
-
except FloodWait as w:
|
| 87 |
-
print(f"Sleeping for {str(w.x)}s")
|
| 88 |
-
await asyncio.sleep(w.x)
|
| 89 |
-
await bot.send_message(chat_id=Telegram.ULOG_CHANNEL,
|
| 90 |
-
text=f"ɢᴏᴛ ғʟᴏᴏᴅᴡᴀɪᴛ ᴏғ {str(w.x)}s ғʀᴏᴍ {message.chat.title}\n\n**ᴄʜᴀɴɴᴇʟ ɪᴅ :** `{str(message.chat.id)}`",
|
| 91 |
-
disable_web_page_preview=True)
|
| 92 |
-
except Exception as e:
|
| 93 |
-
await bot.send_message(chat_id=Telegram.ULOG_CHANNEL, text=f"**#EʀʀᴏʀTʀᴀᴄᴋᴇʙᴀᴄᴋ:** `{e}`",
|
| 94 |
-
disable_web_page_preview=True)
|
| 95 |
-
print(f"Cᴀɴ'ᴛ Eᴅɪᴛ Bʀᴏᴀᴅᴄᴀsᴛ Mᴇssᴀɢᴇ!\nEʀʀᴏʀ: **Gɪᴠᴇ ᴍᴇ ᴇᴅɪᴛ ᴘᴇʀᴍɪssɪᴏɴ ɪɴ ᴜᴘᴅᴀᴛᴇs ᴀɴᴅ ʙɪɴ Cʜᴀɴɴᴇʟ!{e}**")
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileStream/config.py
DELETED
|
@@ -1,41 +0,0 @@
|
|
| 1 |
-
from os import environ as env
|
| 2 |
-
from dotenv import load_dotenv
|
| 3 |
-
|
| 4 |
-
load_dotenv()
|
| 5 |
-
|
| 6 |
-
class Telegram:
|
| 7 |
-
API_ID = int(env.get("API_ID"))
|
| 8 |
-
API_HASH = str(env.get("API_HASH"))
|
| 9 |
-
BOT_TOKEN = str(env.get("BOT_TOKEN"))
|
| 10 |
-
OWNER_ID = int(env.get('OWNER_ID', '7978482443'))
|
| 11 |
-
WORKERS = int(env.get("WORKERS", "6")) # 6 workers = 6 commands at once
|
| 12 |
-
DATABASE_URL = str(env.get('DATABASE_URL'))
|
| 13 |
-
UPDATES_CHANNEL = str(env.get('UPDATES_CHANNEL', "Telegram"))
|
| 14 |
-
SESSION_NAME = str(env.get('SESSION_NAME', 'FileStream'))
|
| 15 |
-
FORCE_SUB_ID = env.get('FORCE_SUB_ID', None)
|
| 16 |
-
FORCE_SUB = env.get('FORCE_UPDATES_CHANNEL', False)
|
| 17 |
-
FORCE_SUB = True if str(FORCE_SUB).lower() == "true" else False
|
| 18 |
-
SLEEP_THRESHOLD = int(env.get("SLEEP_THRESHOLD", "60"))
|
| 19 |
-
FILE_PIC = env.get('FILE_PIC', "https://graph.org/file/5bb9935be0229adf98b73.jpg")
|
| 20 |
-
START_PIC = env.get('START_PIC', "https://graph.org/file/290af25276fa34fa8f0aa.jpg")
|
| 21 |
-
VERIFY_PIC = env.get('VERIFY_PIC', "https://graph.org/file/736e21cc0efa4d8c2a0e4.jpg")
|
| 22 |
-
MULTI_CLIENT = False
|
| 23 |
-
FLOG_CHANNEL = int(env.get("FLOG_CHANNEL", None)) # Logs channel for file logs
|
| 24 |
-
ULOG_CHANNEL = int(env.get("ULOG_CHANNEL", None)) # Logs channel for user logs
|
| 25 |
-
MODE = env.get("MODE", "primary")
|
| 26 |
-
SECONDARY = True if MODE.lower() == "secondary" else False
|
| 27 |
-
AUTH_USERS = list(set(int(x) for x in str(env.get("AUTH_USERS", "")).split()))
|
| 28 |
-
|
| 29 |
-
class Server:
|
| 30 |
-
PORT = int(env.get("PORT", 8080))
|
| 31 |
-
BIND_ADDRESS = str(env.get("BIND_ADDRESS", "0.0.0.0"))
|
| 32 |
-
PING_INTERVAL = int(env.get("PING_INTERVAL", "1200"))
|
| 33 |
-
HAS_SSL = str(env.get("HAS_SSL", "0").lower()) in ("1", "true", "t", "yes", "y")
|
| 34 |
-
NO_PORT = str(env.get("NO_PORT", "0").lower()) in ("1", "true", "t", "yes", "y")
|
| 35 |
-
FQDN = str(env.get("FQDN", BIND_ADDRESS))
|
| 36 |
-
URL = "http{}://{}{}/".format(
|
| 37 |
-
"s" if HAS_SSL else "", FQDN, "" if NO_PORT else ":" + str(PORT)
|
| 38 |
-
)
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileStream/server/__init__.py
DELETED
|
@@ -1,7 +0,0 @@
|
|
| 1 |
-
from aiohttp import web
|
| 2 |
-
from .stream_routes import routes
|
| 3 |
-
|
| 4 |
-
def web_server():
|
| 5 |
-
web_app = web.Application(client_max_size=30000000)
|
| 6 |
-
web_app.add_routes(routes)
|
| 7 |
-
return web_app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileStream/server/exceptions.py
DELETED
|
@@ -1,5 +0,0 @@
|
|
| 1 |
-
class InvalidHash(Exception):
|
| 2 |
-
message = "Invalid hash"
|
| 3 |
-
|
| 4 |
-
class FIleNotFound(Exception):
|
| 5 |
-
message = "File not found"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileStream/server/stream_routes.py
DELETED
|
@@ -1,136 +0,0 @@
|
|
| 1 |
-
import time
|
| 2 |
-
import math
|
| 3 |
-
import logging
|
| 4 |
-
import mimetypes
|
| 5 |
-
import traceback
|
| 6 |
-
from aiohttp import web
|
| 7 |
-
from aiohttp.http_exceptions import BadStatusLine
|
| 8 |
-
from FileStream.bot import multi_clients, work_loads, FileStream
|
| 9 |
-
from FileStream.config import Telegram, Server
|
| 10 |
-
from FileStream.server.exceptions import FIleNotFound, InvalidHash
|
| 11 |
-
from FileStream import utils, StartTime, __version__
|
| 12 |
-
from FileStream.utils.render_template import render_page
|
| 13 |
-
|
| 14 |
-
routes = web.RouteTableDef()
|
| 15 |
-
|
| 16 |
-
@routes.get("/status", allow_head=True)
|
| 17 |
-
async def root_route_handler(_):
|
| 18 |
-
return web.json_response(
|
| 19 |
-
{
|
| 20 |
-
"server_status": "running",
|
| 21 |
-
"uptime": utils.get_readable_time(time.time() - StartTime),
|
| 22 |
-
"telegram_bot": "@" + FileStream.username,
|
| 23 |
-
"connected_bots": len(multi_clients),
|
| 24 |
-
"loads": dict(
|
| 25 |
-
("bot" + str(c + 1), l)
|
| 26 |
-
for c, (_, l) in enumerate(
|
| 27 |
-
sorted(work_loads.items(), key=lambda x: x[1], reverse=True)
|
| 28 |
-
)
|
| 29 |
-
),
|
| 30 |
-
"version": __version__,
|
| 31 |
-
}
|
| 32 |
-
)
|
| 33 |
-
|
| 34 |
-
@routes.get("/watch/{path}", allow_head=True)
|
| 35 |
-
async def stream_handler(request: web.Request):
|
| 36 |
-
try:
|
| 37 |
-
path = request.match_info["path"]
|
| 38 |
-
return web.Response(text=await render_page(path), content_type='text/html')
|
| 39 |
-
except InvalidHash as e:
|
| 40 |
-
raise web.HTTPForbidden(text=e.message)
|
| 41 |
-
except FIleNotFound as e:
|
| 42 |
-
raise web.HTTPNotFound(text=e.message)
|
| 43 |
-
except (AttributeError, BadStatusLine, ConnectionResetError):
|
| 44 |
-
pass
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
@routes.get("/dl/{path}", allow_head=True)
|
| 48 |
-
async def stream_handler(request: web.Request):
|
| 49 |
-
try:
|
| 50 |
-
path = request.match_info["path"]
|
| 51 |
-
return await media_streamer(request, path)
|
| 52 |
-
except InvalidHash as e:
|
| 53 |
-
raise web.HTTPForbidden(text=e.message)
|
| 54 |
-
except FIleNotFound as e:
|
| 55 |
-
raise web.HTTPNotFound(text=e.message)
|
| 56 |
-
except (AttributeError, BadStatusLine, ConnectionResetError):
|
| 57 |
-
pass
|
| 58 |
-
except Exception as e:
|
| 59 |
-
traceback.print_exc()
|
| 60 |
-
logging.critical(e.with_traceback(None))
|
| 61 |
-
logging.debug(traceback.format_exc())
|
| 62 |
-
raise web.HTTPInternalServerError(text=str(e))
|
| 63 |
-
|
| 64 |
-
class_cache = {}
|
| 65 |
-
|
| 66 |
-
async def media_streamer(request: web.Request, db_id: str):
|
| 67 |
-
range_header = request.headers.get("Range", 0)
|
| 68 |
-
|
| 69 |
-
index = min(work_loads, key=work_loads.get)
|
| 70 |
-
faster_client = multi_clients[index]
|
| 71 |
-
|
| 72 |
-
if Telegram.MULTI_CLIENT:
|
| 73 |
-
logging.info(f"Client {index} is now serving {request.headers.get('X-FORWARDED-FOR',request.remote)}")
|
| 74 |
-
|
| 75 |
-
if faster_client in class_cache:
|
| 76 |
-
tg_connect = class_cache[faster_client]
|
| 77 |
-
logging.debug(f"Using cached ByteStreamer object for client {index}")
|
| 78 |
-
else:
|
| 79 |
-
logging.debug(f"Creating new ByteStreamer object for client {index}")
|
| 80 |
-
tg_connect = utils.ByteStreamer(faster_client)
|
| 81 |
-
class_cache[faster_client] = tg_connect
|
| 82 |
-
logging.debug("before calling get_file_properties")
|
| 83 |
-
file_id = await tg_connect.get_file_properties(db_id, multi_clients)
|
| 84 |
-
logging.debug("after calling get_file_properties")
|
| 85 |
-
|
| 86 |
-
file_size = file_id.file_size
|
| 87 |
-
|
| 88 |
-
if range_header:
|
| 89 |
-
from_bytes, until_bytes = range_header.replace("bytes=", "").split("-")
|
| 90 |
-
from_bytes = int(from_bytes)
|
| 91 |
-
until_bytes = int(until_bytes) if until_bytes else file_size - 1
|
| 92 |
-
else:
|
| 93 |
-
from_bytes = request.http_range.start or 0
|
| 94 |
-
until_bytes = (request.http_range.stop or file_size) - 1
|
| 95 |
-
|
| 96 |
-
if (until_bytes > file_size) or (from_bytes < 0) or (until_bytes < from_bytes):
|
| 97 |
-
return web.Response(
|
| 98 |
-
status=416,
|
| 99 |
-
body="416: Range not satisfiable",
|
| 100 |
-
headers={"Content-Range": f"bytes */{file_size}"},
|
| 101 |
-
)
|
| 102 |
-
|
| 103 |
-
chunk_size = 1024 * 1024
|
| 104 |
-
until_bytes = min(until_bytes, file_size - 1)
|
| 105 |
-
|
| 106 |
-
offset = from_bytes - (from_bytes % chunk_size)
|
| 107 |
-
first_part_cut = from_bytes - offset
|
| 108 |
-
last_part_cut = until_bytes % chunk_size + 1
|
| 109 |
-
|
| 110 |
-
req_length = until_bytes - from_bytes + 1
|
| 111 |
-
part_count = math.ceil(until_bytes / chunk_size) - math.floor(offset / chunk_size)
|
| 112 |
-
body = tg_connect.yield_file(
|
| 113 |
-
file_id, index, offset, first_part_cut, last_part_cut, part_count, chunk_size
|
| 114 |
-
)
|
| 115 |
-
|
| 116 |
-
mime_type = file_id.mime_type
|
| 117 |
-
file_name = utils.get_name(file_id)
|
| 118 |
-
disposition = "attachment"
|
| 119 |
-
|
| 120 |
-
if not mime_type:
|
| 121 |
-
mime_type = mimetypes.guess_type(file_name)[0] or "application/octet-stream"
|
| 122 |
-
|
| 123 |
-
# if "video/" in mime_type or "audio/" in mime_type:
|
| 124 |
-
# disposition = "inline"
|
| 125 |
-
|
| 126 |
-
return web.Response(
|
| 127 |
-
status=206 if range_header else 200,
|
| 128 |
-
body=body,
|
| 129 |
-
headers={
|
| 130 |
-
"Content-Type": f"{mime_type}",
|
| 131 |
-
"Content-Range": f"bytes {from_bytes}-{until_bytes}/{file_size}",
|
| 132 |
-
"Content-Length": str(req_length),
|
| 133 |
-
"Content-Disposition": f'{disposition}; filename="{file_name}"',
|
| 134 |
-
"Accept-Ranges": "bytes",
|
| 135 |
-
},
|
| 136 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileStream/template/dl.html
DELETED
|
@@ -1,44 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8">
|
| 5 |
-
<meta property="og:image" content="https://www.flaticon.com/premium-icon/icons/svg/2626/2626281.svg" itemprop="thumbnailUrl">
|
| 6 |
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
| 7 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 8 |
-
<title>{{file_name}}</title>
|
| 9 |
-
<link rel="stylesheet" type='text/css' href="https://drive.google.com/uc?export=view&id=1pVLG4gZy7jdow3sO-wFS06aP_A9QX0O6">
|
| 10 |
-
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway">
|
| 11 |
-
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Delius">
|
| 12 |
-
</head>
|
| 13 |
-
|
| 14 |
-
<body class='cyber'>
|
| 15 |
-
<header>
|
| 16 |
-
<div class="toogle"></div>
|
| 17 |
-
<div id="file-name" class="cyber">
|
| 18 |
-
{{file_name}}
|
| 19 |
-
</div>
|
| 20 |
-
</header>
|
| 21 |
-
|
| 22 |
-
<div class="container">
|
| 23 |
-
<a href="{{file_url}}">
|
| 24 |
-
<button class="cybr-btn">
|
| 25 |
-
Download
|
| 26 |
-
<span aria-hidden>_</span>
|
| 27 |
-
<span aria-hidden class="cybr-btn__glitch">_404 Error</span>
|
| 28 |
-
<span aria-hidden class="cybr-btn__tag">_%s</span>
|
| 29 |
-
</button>
|
| 30 |
-
</a>
|
| 31 |
-
</div>
|
| 32 |
-
<script>
|
| 33 |
-
const body = document.querySelector('body');
|
| 34 |
-
const title = document.querySelector('#file-name');
|
| 35 |
-
const footer = document.querySelector('footer');
|
| 36 |
-
const toogle = document.querySelector('.toogle');
|
| 37 |
-
toogle.onclick = () => {
|
| 38 |
-
body.classList.toggle('dark')
|
| 39 |
-
footer.classList.toggle('dark')
|
| 40 |
-
title.classList.toggle('dark')
|
| 41 |
-
}
|
| 42 |
-
</script>
|
| 43 |
-
</body>
|
| 44 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileStream/template/play.html
DELETED
|
@@ -1,171 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
|
| 4 |
-
<head>
|
| 5 |
-
<meta charset="UTF-8">
|
| 6 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
-
<title>FileStreamBot | {{file_name}}</title>
|
| 8 |
-
<link rel="icon" href="https://i.ibb.co/Hh4kF2b/icon.png" type="image/x-icon">
|
| 9 |
-
<link rel="shortcut icon" href="https://i.ibb.co/Hh4kF2b/icon.png" type="image/x-icon">
|
| 10 |
-
<link rel="stylesheet" href="https://unpkg.com/sheryjs/dist/Shery.css" />
|
| 11 |
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/proavipatil/data@main/fs/src/style.css">
|
| 12 |
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/proavipatil/data@main/fs/src/plyr.css">
|
| 13 |
-
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 14 |
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 15 |
-
<link href="https://fonts.googleapis.com/css2?family=Josefin+Sans:wght@500;700&display=swap" rel="stylesheet">
|
| 16 |
-
<script src="https://cdn.tailwindcss.com"></script>
|
| 17 |
-
|
| 18 |
-
</head>
|
| 19 |
-
|
| 20 |
-
<body>
|
| 21 |
-
<nav>
|
| 22 |
-
<div class="nleft">
|
| 23 |
-
<a href="#">
|
| 24 |
-
<h3 id="heading" style="z-index: 100;" class="magnet title">FILE STREAM</h3>
|
| 25 |
-
</a>
|
| 26 |
-
</div>
|
| 27 |
-
<div class="nryt">
|
| 28 |
-
<a class="home-btn magnet" href="#main" onclick="toggleWidthnav(this)">HOME</a>
|
| 29 |
-
|
| 30 |
-
<a href="#abtus" class="about-btn magnet" onclick="toggleWidthnav(this)">ABOUT</a>
|
| 31 |
-
</div>
|
| 32 |
-
</nav>
|
| 33 |
-
<center>
|
| 34 |
-
<div class="about-nav">
|
| 35 |
-
<a href="#abtus" class="wlcm magnet" onclick="toggleWidth(this)">WELCOME</a>
|
| 36 |
-
<a href="#channels" class="abt-chnl magnet" onclick="toggleWidth(this)">CHANNELS</a>
|
| 37 |
-
<a href="#contact" class="magnet contact-btn" onclick="toggleWidth(this)">CONTACT</a>
|
| 38 |
-
</div>
|
| 39 |
-
</center>
|
| 40 |
-
|
| 41 |
-
<div class="outer">
|
| 42 |
-
<div class="inner">
|
| 43 |
-
<div class="main" id="main">
|
| 44 |
-
<video id="player" class="player" src="{{file_url}}" type="video/mp4" playsinline controls
|
| 45 |
-
width="100%"></video>
|
| 46 |
-
<div class="player"></div>
|
| 47 |
-
<div class="file-name">
|
| 48 |
-
<h4 style="display: inline;">File Name: </h4>
|
| 49 |
-
<p style="display: inline;" id="myDiv">{{file_name}}</p><br>
|
| 50 |
-
<h4 style="display: inline;">File Size: </h4>
|
| 51 |
-
<p style="display: inline;">{{file_size}}</p>
|
| 52 |
-
</div>
|
| 53 |
-
<div class="downloadBtn">
|
| 54 |
-
<button class="magnet" onclick="streamDownload()">
|
| 55 |
-
<img style="height: 30px;" src="https://i.ibb.co/RjzYttX/dl.png" alt="">download video
|
| 56 |
-
</button>
|
| 57 |
-
<button class="magnet" onclick="copyStreamLink()">
|
| 58 |
-
<img src="https://i.ibb.co/CM4Y586/link.png" alt="Copy Link">copy link
|
| 59 |
-
</button>
|
| 60 |
-
<button class="magnet" onclick="vlc_player()">
|
| 61 |
-
<img src="https://i.ibb.co/px6fQs1/vlc.png" alt="">watch in VLC PLAYER
|
| 62 |
-
</button>
|
| 63 |
-
<button class="magnet" onclick="mx_player()">
|
| 64 |
-
<img src="https://i.ibb.co/41WvtQ3/mx.png" alt="">watch in MX PLAYER
|
| 65 |
-
</button>
|
| 66 |
-
<button class="magnet" onclick="n_player()">
|
| 67 |
-
<img src="https://i.ibb.co/Hd2dS4t/nPlayer.png" alt="">watch in nPlayer
|
| 68 |
-
</button>
|
| 69 |
-
</div>
|
| 70 |
-
|
| 71 |
-
</div>
|
| 72 |
-
<div class="abt">
|
| 73 |
-
<div class="about">
|
| 74 |
-
<div class="about-dets">
|
| 75 |
-
|
| 76 |
-
<div class="abt-sec" id="abtus" style="padding: 160px 30px;">
|
| 77 |
-
<h1 style="text-align: center;">WELCOME TO OUR <Span>FILE STREAM</Span> BOT</h1>
|
| 78 |
-
<p style="text-align: center; line-height: 2;word-spacing: 2px; letter-spacing: 0.8px;">
|
| 79 |
-
This is a Telegram Bot to Stream <span>Movies</span> and <span>Series</span> directly on
|
| 80 |
-
Telegram. You can also
|
| 81 |
-
<span>download</span> them if you want. This bot is developed by <a
|
| 82 |
-
href="https://github.com/AviPatilPro"><span style="font-weight: 700;">Avi</span></a>
|
| 83 |
-
<br><br>If you like this bot, then don't
|
| 84 |
-
forget to share it with your friends and family.
|
| 85 |
-
</p>
|
| 86 |
-
</div>
|
| 87 |
-
|
| 88 |
-
<div class="abt-sec" id="channels">
|
| 89 |
-
<h1>JOIN OUR <span>TELEGRAM</span> CHANNELS</h1>
|
| 90 |
-
<div class="links chnl-link">
|
| 91 |
-
<a class="magnet" href="https://t.me/CheapieDeals">
|
| 92 |
-
<button>CHEAP DEALS</button>
|
| 93 |
-
</a>
|
| 94 |
-
<a class="magnet" href="https://t.me/FilmyPixel">
|
| 95 |
-
<button>FILMYPIXEL</button>
|
| 96 |
-
</a>
|
| 97 |
-
<a class="magnet" href="https://t.me/PostersZone">
|
| 98 |
-
<button>POSTERS ZONE</button>
|
| 99 |
-
</a>
|
| 100 |
-
<a class="magnet" href="https://t.me/EpitomeQuality">
|
| 101 |
-
<button>EPITOME QUALITY</button>
|
| 102 |
-
</a>
|
| 103 |
-
</div>
|
| 104 |
-
</div>
|
| 105 |
-
|
| 106 |
-
<div class="abt-sec" id="contact">
|
| 107 |
-
<p style="text-align: center;">Report Bugs and Contact us on Telegram Below</p>
|
| 108 |
-
<div class="links contact">
|
| 109 |
-
<a href="https://t.me/AvishkarPatil">
|
| 110 |
-
<button>CONTACT</button>
|
| 111 |
-
</a>
|
| 112 |
-
</div>
|
| 113 |
-
</div>
|
| 114 |
-
|
| 115 |
-
</div>
|
| 116 |
-
</div>
|
| 117 |
-
</div>
|
| 118 |
-
</div>
|
| 119 |
-
<footer>
|
| 120 |
-
<center>
|
| 121 |
-
|
| 122 |
-
<div class="movie-cont">
|
| 123 |
-
<div class="movieSug">
|
| 124 |
-
<div class="movieDets">
|
| 125 |
-
|
| 126 |
-
</div>
|
| 127 |
-
<div class="movieimg">
|
| 128 |
-
<img src="">
|
| 129 |
-
</div>
|
| 130 |
-
</div>
|
| 131 |
-
<div class="low-width-movie-dets">
|
| 132 |
-
<div class="movieStsBar">
|
| 133 |
-
<div class="movieDets-mini">
|
| 134 |
-
|
| 135 |
-
</div>
|
| 136 |
-
</div>
|
| 137 |
-
</div>
|
| 138 |
-
<button class="ranMovBtn" onclick="getDets()">Get More Movies Suggestion</button>
|
| 139 |
-
</div>
|
| 140 |
-
|
| 141 |
-
</center>
|
| 142 |
-
|
| 143 |
-
<center>
|
| 144 |
-
<div class="copyright">
|
| 145 |
-
<h5 class="text-center">Copyright © 2024 <a href="https://github.com/AviPatilPro"><span
|
| 146 |
-
style="font-weight: 700;">Avishkar Patil</span></a>. All
|
| 147 |
-
Rights Reserved.</h5>
|
| 148 |
-
</div>
|
| 149 |
-
</center>
|
| 150 |
-
</footer>
|
| 151 |
-
</div>
|
| 152 |
-
</body>
|
| 153 |
-
|
| 154 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
| 155 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/ScrollTrigger.min.js"></script>
|
| 156 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/0.155.0/three.min.js"></script>
|
| 157 |
-
<script src="https://cdn.jsdelivr.net/gh/automat/controlkit.js@master/bin/controlKit.min.js"></script>
|
| 158 |
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/sheryjs/dist/Shery.js"></script>
|
| 159 |
-
<script>
|
| 160 |
-
document.addEventListener("DOMContentLoaded", function () {
|
| 161 |
-
const uncopyableElement = document.querySelector(".uncopyable");
|
| 162 |
-
|
| 163 |
-
uncopyableElement.addEventListener("selectstart", function (event) {
|
| 164 |
-
event.preventDefault();
|
| 165 |
-
});
|
| 166 |
-
});
|
| 167 |
-
</script>
|
| 168 |
-
<script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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileStream/utils/__init__.py
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
from .time_format import get_readable_time
|
| 2 |
-
from .file_properties import get_name, get_file_ids
|
| 3 |
-
from .custom_dl import ByteStreamer
|
|
|
|
|
|
|
|
|
|
|
|
FileStream/utils/bot_utils.py
DELETED
|
@@ -1,216 +0,0 @@
|
|
| 1 |
-
from pyrogram.errors import UserNotParticipant, FloodWait
|
| 2 |
-
from pyrogram.enums.parse_mode import ParseMode
|
| 3 |
-
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, Message
|
| 4 |
-
from FileStream.utils.translation import LANG
|
| 5 |
-
from FileStream.utils.database import Database
|
| 6 |
-
from FileStream.utils.human_readable import humanbytes
|
| 7 |
-
from FileStream.config import Telegram, Server
|
| 8 |
-
from FileStream.bot import FileStream
|
| 9 |
-
import asyncio
|
| 10 |
-
from typing import (
|
| 11 |
-
Union
|
| 12 |
-
)
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
db = Database(Telegram.DATABASE_URL, Telegram.SESSION_NAME)
|
| 16 |
-
|
| 17 |
-
async def get_invite_link(bot, chat_id: Union[str, int]):
|
| 18 |
-
try:
|
| 19 |
-
invite_link = await bot.create_chat_invite_link(chat_id=chat_id)
|
| 20 |
-
return invite_link
|
| 21 |
-
except FloodWait as e:
|
| 22 |
-
print(f"Sleep of {e.value}s caused by FloodWait ...")
|
| 23 |
-
await asyncio.sleep(e.value)
|
| 24 |
-
return await get_invite_link(bot, chat_id)
|
| 25 |
-
|
| 26 |
-
async def is_user_joined(bot, message: Message):
|
| 27 |
-
if Telegram.FORCE_SUB_ID and Telegram.FORCE_SUB_ID.startswith("-100"):
|
| 28 |
-
channel_chat_id = int(Telegram.FORCE_SUB_ID) # When id startswith with -100
|
| 29 |
-
elif Telegram.FORCE_SUB_ID and (not Telegram.FORCE_SUB_ID.startswith("-100")):
|
| 30 |
-
channel_chat_id = Telegram.FORCE_SUB_ID # When id not startswith -100
|
| 31 |
-
else:
|
| 32 |
-
return 200
|
| 33 |
-
try:
|
| 34 |
-
user = await bot.get_chat_member(chat_id=channel_chat_id, user_id=message.from_user.id)
|
| 35 |
-
if user.status == "BANNED":
|
| 36 |
-
await message.reply_text(
|
| 37 |
-
text=LANG.BAN_TEXT.format(Telegram.OWNER_ID),
|
| 38 |
-
parse_mode=ParseMode.MARKDOWN,
|
| 39 |
-
disable_web_page_preview=True
|
| 40 |
-
)
|
| 41 |
-
return False
|
| 42 |
-
except UserNotParticipant:
|
| 43 |
-
invite_link = await get_invite_link(bot, chat_id=channel_chat_id)
|
| 44 |
-
if Telegram.VERIFY_PIC:
|
| 45 |
-
ver = await message.reply_photo(
|
| 46 |
-
photo=Telegram.VERIFY_PIC,
|
| 47 |
-
caption="<i>Jᴏɪɴ ᴍʏ ᴜᴘᴅᴀᴛᴇ ᴄʜᴀɴɴᴇʟ ᴛᴏ ᴜsᴇ ᴍᴇ 🔐</i>",
|
| 48 |
-
parse_mode=ParseMode.HTML,
|
| 49 |
-
reply_markup=InlineKeyboardMarkup(
|
| 50 |
-
[[
|
| 51 |
-
InlineKeyboardButton("❆ Jᴏɪɴ Oᴜʀ Cʜᴀɴɴᴇʟ ❆", url=invite_link.invite_link)
|
| 52 |
-
]]
|
| 53 |
-
)
|
| 54 |
-
)
|
| 55 |
-
else:
|
| 56 |
-
ver = await message.reply_text(
|
| 57 |
-
text = "<i>Jᴏɪɴ ᴍʏ ᴜᴘᴅᴀᴛᴇ ᴄʜᴀɴɴᴇʟ ᴛᴏ ᴜsᴇ ᴍᴇ 🔐</i>",
|
| 58 |
-
reply_markup=InlineKeyboardMarkup(
|
| 59 |
-
[[
|
| 60 |
-
InlineKeyboardButton("❆ Jᴏɪɴ Oᴜʀ Cʜᴀɴɴᴇʟ ❆", url=invite_link.invite_link)
|
| 61 |
-
]]
|
| 62 |
-
),
|
| 63 |
-
parse_mode=ParseMode.HTML
|
| 64 |
-
)
|
| 65 |
-
await asyncio.sleep(30)
|
| 66 |
-
try:
|
| 67 |
-
await ver.delete()
|
| 68 |
-
await message.delete()
|
| 69 |
-
except Exception:
|
| 70 |
-
pass
|
| 71 |
-
return False
|
| 72 |
-
except Exception:
|
| 73 |
-
await message.reply_text(
|
| 74 |
-
text = f"<i>Sᴏᴍᴇᴛʜɪɴɢ ᴡʀᴏɴɢ ᴄᴏɴᴛᴀᴄᴛ ᴍʏ ᴅᴇᴠᴇʟᴏᴘᴇʀ</i> <b><a href='https://t.me/{Telegram.UPDATES_CHANNEL}'>[ ᴄʟɪᴄᴋ ʜᴇʀᴇ ]</a></b>",
|
| 75 |
-
parse_mode=ParseMode.HTML,
|
| 76 |
-
disable_web_page_preview=True)
|
| 77 |
-
return False
|
| 78 |
-
return True
|
| 79 |
-
|
| 80 |
-
#---------------------[ PRIVATE GEN LINK + CALLBACK ]---------------------#
|
| 81 |
-
|
| 82 |
-
async def gen_link(_id):
|
| 83 |
-
file_info = await db.get_file(_id)
|
| 84 |
-
file_name = file_info['file_name']
|
| 85 |
-
file_size = humanbytes(file_info['file_size'])
|
| 86 |
-
mime_type = file_info['mime_type']
|
| 87 |
-
|
| 88 |
-
page_link = f"{Server.URL}watch/{_id}"
|
| 89 |
-
stream_link = f"{Server.URL}dl/{_id}"
|
| 90 |
-
file_link = f"https://t.me/{FileStream.username}?start=file_{_id}"
|
| 91 |
-
|
| 92 |
-
if "video" in mime_type:
|
| 93 |
-
stream_text = LANG.STREAM_TEXT.format(file_name, file_size, stream_link, page_link, file_link)
|
| 94 |
-
reply_markup = InlineKeyboardMarkup(
|
| 95 |
-
[
|
| 96 |
-
[InlineKeyboardButton("sᴛʀᴇᴀᴍ", url=page_link), InlineKeyboardButton("ᴅᴏᴡɴʟᴏᴀᴅ", url=stream_link)],
|
| 97 |
-
[InlineKeyboardButton("ɢᴇᴛ ғɪʟᴇ", url=file_link), InlineKeyboardButton("ʀᴇᴠᴏᴋᴇ ғɪʟᴇ", callback_data=f"msgdelpvt_{_id}")],
|
| 98 |
-
[InlineKeyboardButton("ᴄʟᴏsᴇ", callback_data="close")]
|
| 99 |
-
]
|
| 100 |
-
)
|
| 101 |
-
else:
|
| 102 |
-
stream_text = LANG.STREAM_TEXT_X.format(file_name, file_size, stream_link, file_link)
|
| 103 |
-
reply_markup = InlineKeyboardMarkup(
|
| 104 |
-
[
|
| 105 |
-
[InlineKeyboardButton("ᴅᴏᴡɴʟᴏᴀᴅ", url=stream_link)],
|
| 106 |
-
[InlineKeyboardButton("ɢᴇᴛ ғɪʟᴇ", url=file_link), InlineKeyboardButton("ʀᴇᴠᴏᴋᴇ ғɪʟᴇ", callback_data=f"msgdelpvt_{_id}")],
|
| 107 |
-
[InlineKeyboardButton("ᴄʟᴏsᴇ", callback_data="close")]
|
| 108 |
-
]
|
| 109 |
-
)
|
| 110 |
-
return reply_markup, stream_text
|
| 111 |
-
|
| 112 |
-
#---------------------[ GEN STREAM LINKS FOR CHANNEL ]---------------------#
|
| 113 |
-
|
| 114 |
-
async def gen_linkx(m:Message , _id, name: list):
|
| 115 |
-
file_info = await db.get_file(_id)
|
| 116 |
-
file_name = file_info['file_name']
|
| 117 |
-
mime_type = file_info['mime_type']
|
| 118 |
-
file_size = humanbytes(file_info['file_size'])
|
| 119 |
-
|
| 120 |
-
page_link = f"{Server.URL}watch/{_id}"
|
| 121 |
-
stream_link = f"{Server.URL}dl/{_id}"
|
| 122 |
-
file_link = f"https://t.me/{FileStream.username}?start=file_{_id}"
|
| 123 |
-
|
| 124 |
-
if "video" in mime_type:
|
| 125 |
-
stream_text= LANG.STREAM_TEXT_X.format(file_name, file_size, stream_link, page_link)
|
| 126 |
-
reply_markup = InlineKeyboardMarkup(
|
| 127 |
-
[
|
| 128 |
-
[InlineKeyboardButton("sᴛʀᴇᴀᴍ", url=page_link), InlineKeyboardButton("ᴅᴏᴡɴʟᴏᴀᴅ", url=stream_link)]
|
| 129 |
-
]
|
| 130 |
-
)
|
| 131 |
-
else:
|
| 132 |
-
stream_text= LANG.STREAM_TEXT_X.format(file_name, file_size, stream_link, file_link)
|
| 133 |
-
reply_markup = InlineKeyboardMarkup(
|
| 134 |
-
[
|
| 135 |
-
[InlineKeyboardButton("ᴅᴏᴡɴʟᴏᴀᴅ", url=stream_link)]
|
| 136 |
-
]
|
| 137 |
-
)
|
| 138 |
-
return reply_markup, stream_text
|
| 139 |
-
|
| 140 |
-
#---------------------[ USER BANNED ]---------------------#
|
| 141 |
-
|
| 142 |
-
async def is_user_banned(message):
|
| 143 |
-
if await db.is_user_banned(message.from_user.id):
|
| 144 |
-
await message.reply_text(
|
| 145 |
-
text=LANG.BAN_TEXT.format(Telegram.OWNER_ID),
|
| 146 |
-
parse_mode=ParseMode.MARKDOWN,
|
| 147 |
-
disable_web_page_preview=True
|
| 148 |
-
)
|
| 149 |
-
return True
|
| 150 |
-
return False
|
| 151 |
-
|
| 152 |
-
#---------------------[ CHANNEL BANNED ]---------------------#
|
| 153 |
-
|
| 154 |
-
async def is_channel_banned(bot, message):
|
| 155 |
-
if await db.is_user_banned(message.chat.id):
|
| 156 |
-
await bot.edit_message_reply_markup(
|
| 157 |
-
chat_id=message.chat.id,
|
| 158 |
-
message_id=message.id,
|
| 159 |
-
reply_markup=InlineKeyboardMarkup([[
|
| 160 |
-
InlineKeyboardButton(f"ᴄʜᴀɴɴᴇʟ ɪs ʙᴀɴɴᴇᴅ", callback_data="N/A")]])
|
| 161 |
-
)
|
| 162 |
-
return True
|
| 163 |
-
return False
|
| 164 |
-
|
| 165 |
-
#---------------------[ USER AUTH ]---------------------#
|
| 166 |
-
|
| 167 |
-
async def is_user_authorized(message):
|
| 168 |
-
if hasattr(Telegram, 'AUTH_USERS') and Telegram.AUTH_USERS:
|
| 169 |
-
user_id = message.from_user.id
|
| 170 |
-
|
| 171 |
-
if user_id == Telegram.OWNER_ID:
|
| 172 |
-
return True
|
| 173 |
-
|
| 174 |
-
if not (user_id in Telegram.AUTH_USERS):
|
| 175 |
-
await message.reply_text(
|
| 176 |
-
text="Yᴏᴜ ᴀʀᴇ ɴᴏᴛ ᴀᴜᴛʜᴏʀɪᴢᴇᴅ ᴛᴏ ᴜsᴇ ᴛʜɪs ʙᴏᴛ.",
|
| 177 |
-
parse_mode=ParseMode.MARKDOWN,
|
| 178 |
-
disable_web_page_preview=True
|
| 179 |
-
)
|
| 180 |
-
return False
|
| 181 |
-
|
| 182 |
-
return True
|
| 183 |
-
|
| 184 |
-
#---------------------[ USER EXIST ]---------------------#
|
| 185 |
-
|
| 186 |
-
async def is_user_exist(bot, message):
|
| 187 |
-
if not bool(await db.get_user(message.from_user.id)):
|
| 188 |
-
await db.add_user(message.from_user.id)
|
| 189 |
-
await bot.send_message(
|
| 190 |
-
Telegram.ULOG_CHANNEL,
|
| 191 |
-
f"**#NᴇᴡUsᴇʀ**\n**⬩ ᴜsᴇʀ ɴᴀᴍᴇ :** [{message.from_user.first_name}](tg://user?id={message.from_user.id})\n**⬩ ᴜsᴇʀ ɪᴅ :** `{message.from_user.id}`"
|
| 192 |
-
)
|
| 193 |
-
|
| 194 |
-
async def is_channel_exist(bot, message):
|
| 195 |
-
if not bool(await db.get_user(message.chat.id)):
|
| 196 |
-
await db.add_user(message.chat.id)
|
| 197 |
-
members = await bot.get_chat_members_count(message.chat.id)
|
| 198 |
-
await bot.send_message(
|
| 199 |
-
Telegram.ULOG_CHANNEL,
|
| 200 |
-
f"**#NᴇᴡCʜᴀɴɴᴇʟ** \n**⬩ ᴄʜᴀᴛ ɴᴀᴍᴇ :** `{message.chat.title}`\n**⬩ ᴄʜᴀᴛ ɪᴅ :** `{message.chat.id}`\n**⬩ ᴛᴏᴛᴀʟ ᴍᴇᴍʙᴇʀs :** `{members}`"
|
| 201 |
-
)
|
| 202 |
-
|
| 203 |
-
async def verify_user(bot, message):
|
| 204 |
-
if not await is_user_authorized(message):
|
| 205 |
-
return False
|
| 206 |
-
|
| 207 |
-
if await is_user_banned(message):
|
| 208 |
-
return False
|
| 209 |
-
|
| 210 |
-
await is_user_exist(bot, message)
|
| 211 |
-
|
| 212 |
-
if Telegram.FORCE_SUB:
|
| 213 |
-
if not await is_user_joined(bot, message):
|
| 214 |
-
return False
|
| 215 |
-
|
| 216 |
-
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileStream/utils/broadcast_helper.py
DELETED
|
@@ -1,19 +0,0 @@
|
|
| 1 |
-
import asyncio
|
| 2 |
-
import traceback
|
| 3 |
-
from pyrogram.errors import FloodWait, InputUserDeactivated, UserIsBlocked, PeerIdInvalid
|
| 4 |
-
|
| 5 |
-
async def send_msg(user_id, message):
|
| 6 |
-
try:
|
| 7 |
-
await message.copy(chat_id=user_id)
|
| 8 |
-
return 200, None
|
| 9 |
-
except FloodWait as e:
|
| 10 |
-
await asyncio.sleep(e.value)
|
| 11 |
-
return send_msg(user_id, message)
|
| 12 |
-
except InputUserDeactivated:
|
| 13 |
-
return 400, f"{user_id} : deactivated\n"
|
| 14 |
-
except UserIsBlocked:
|
| 15 |
-
return 400, f"{user_id} : blocked the bot\n"
|
| 16 |
-
except PeerIdInvalid:
|
| 17 |
-
return 400, f"{user_id} : user id invalid\n"
|
| 18 |
-
except Exception as e:
|
| 19 |
-
return 500, f"{user_id} : {traceback.format_exc()}\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileStream/utils/custom_dl.py
DELETED
|
@@ -1,214 +0,0 @@
|
|
| 1 |
-
import asyncio
|
| 2 |
-
import logging
|
| 3 |
-
from typing import Dict, Union
|
| 4 |
-
from FileStream.bot import work_loads
|
| 5 |
-
from pyrogram import Client, utils, raw
|
| 6 |
-
from .file_properties import get_file_ids
|
| 7 |
-
from pyrogram.session import Session, Auth
|
| 8 |
-
from pyrogram.errors import AuthBytesInvalid
|
| 9 |
-
from pyrogram.file_id import FileId, FileType, ThumbnailSource
|
| 10 |
-
from pyrogram.types import Message
|
| 11 |
-
|
| 12 |
-
class ByteStreamer:
|
| 13 |
-
def __init__(self, client: Client):
|
| 14 |
-
self.clean_timer = 30 * 60
|
| 15 |
-
self.client: Client = client
|
| 16 |
-
self.cached_file_ids: Dict[str, FileId] = {}
|
| 17 |
-
asyncio.create_task(self.clean_cache())
|
| 18 |
-
|
| 19 |
-
async def get_file_properties(self, db_id: str, multi_clients) -> FileId:
|
| 20 |
-
"""
|
| 21 |
-
Returns the properties of a media of a specific message in a FIleId class.
|
| 22 |
-
if the properties are cached, then it'll return the cached results.
|
| 23 |
-
or it'll generate the properties from the Message ID and cache them.
|
| 24 |
-
"""
|
| 25 |
-
if not db_id in self.cached_file_ids:
|
| 26 |
-
logging.debug("Before Calling generate_file_properties")
|
| 27 |
-
await self.generate_file_properties(db_id, multi_clients)
|
| 28 |
-
logging.debug(f"Cached file properties for file with ID {db_id}")
|
| 29 |
-
return self.cached_file_ids[db_id]
|
| 30 |
-
|
| 31 |
-
async def generate_file_properties(self, db_id: str, multi_clients) -> FileId:
|
| 32 |
-
"""
|
| 33 |
-
Generates the properties of a media file on a specific message.
|
| 34 |
-
returns ths properties in a FIleId class.
|
| 35 |
-
"""
|
| 36 |
-
logging.debug("Before calling get_file_ids")
|
| 37 |
-
file_id = await get_file_ids(self.client, db_id, multi_clients, Message)
|
| 38 |
-
logging.debug(f"Generated file ID and Unique ID for file with ID {db_id}")
|
| 39 |
-
self.cached_file_ids[db_id] = file_id
|
| 40 |
-
logging.debug(f"Cached media file with ID {db_id}")
|
| 41 |
-
return self.cached_file_ids[db_id]
|
| 42 |
-
|
| 43 |
-
async def generate_media_session(self, client: Client, file_id: FileId) -> Session:
|
| 44 |
-
"""
|
| 45 |
-
Generates the media session for the DC that contains the media file.
|
| 46 |
-
This is required for getting the bytes from Telegram servers.
|
| 47 |
-
"""
|
| 48 |
-
|
| 49 |
-
media_session = client.media_sessions.get(file_id.dc_id, None)
|
| 50 |
-
|
| 51 |
-
if media_session is None:
|
| 52 |
-
if file_id.dc_id != await client.storage.dc_id():
|
| 53 |
-
media_session = Session(
|
| 54 |
-
client,
|
| 55 |
-
file_id.dc_id,
|
| 56 |
-
await Auth(
|
| 57 |
-
client, file_id.dc_id, await client.storage.test_mode()
|
| 58 |
-
).create(),
|
| 59 |
-
await client.storage.test_mode(),
|
| 60 |
-
is_media=True,
|
| 61 |
-
)
|
| 62 |
-
await media_session.start()
|
| 63 |
-
|
| 64 |
-
for _ in range(6):
|
| 65 |
-
exported_auth = await client.invoke(
|
| 66 |
-
raw.functions.auth.ExportAuthorization(dc_id=file_id.dc_id)
|
| 67 |
-
)
|
| 68 |
-
|
| 69 |
-
try:
|
| 70 |
-
await media_session.invoke(
|
| 71 |
-
raw.functions.auth.ImportAuthorization(
|
| 72 |
-
id=exported_auth.id, bytes=exported_auth.bytes
|
| 73 |
-
)
|
| 74 |
-
)
|
| 75 |
-
break
|
| 76 |
-
except AuthBytesInvalid:
|
| 77 |
-
logging.debug(
|
| 78 |
-
f"Invalid authorization bytes for DC {file_id.dc_id}"
|
| 79 |
-
)
|
| 80 |
-
continue
|
| 81 |
-
else:
|
| 82 |
-
await media_session.stop()
|
| 83 |
-
raise AuthBytesInvalid
|
| 84 |
-
else:
|
| 85 |
-
media_session = Session(
|
| 86 |
-
client,
|
| 87 |
-
file_id.dc_id,
|
| 88 |
-
await client.storage.auth_key(),
|
| 89 |
-
await client.storage.test_mode(),
|
| 90 |
-
is_media=True,
|
| 91 |
-
)
|
| 92 |
-
await media_session.start()
|
| 93 |
-
logging.debug(f"Created media session for DC {file_id.dc_id}")
|
| 94 |
-
client.media_sessions[file_id.dc_id] = media_session
|
| 95 |
-
else:
|
| 96 |
-
logging.debug(f"Using cached media session for DC {file_id.dc_id}")
|
| 97 |
-
return media_session
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
@staticmethod
|
| 101 |
-
async def get_location(file_id: FileId) -> Union[raw.types.InputPhotoFileLocation,
|
| 102 |
-
raw.types.InputDocumentFileLocation,
|
| 103 |
-
raw.types.InputPeerPhotoFileLocation,]:
|
| 104 |
-
"""
|
| 105 |
-
Returns the file location for the media file.
|
| 106 |
-
"""
|
| 107 |
-
file_type = file_id.file_type
|
| 108 |
-
|
| 109 |
-
if file_type == FileType.CHAT_PHOTO:
|
| 110 |
-
if file_id.chat_id > 0:
|
| 111 |
-
peer = raw.types.InputPeerUser(
|
| 112 |
-
user_id=file_id.chat_id, access_hash=file_id.chat_access_hash
|
| 113 |
-
)
|
| 114 |
-
else:
|
| 115 |
-
if file_id.chat_access_hash == 0:
|
| 116 |
-
peer = raw.types.InputPeerChat(chat_id=-file_id.chat_id)
|
| 117 |
-
else:
|
| 118 |
-
peer = raw.types.InputPeerChannel(
|
| 119 |
-
channel_id=utils.get_channel_id(file_id.chat_id),
|
| 120 |
-
access_hash=file_id.chat_access_hash,
|
| 121 |
-
)
|
| 122 |
-
|
| 123 |
-
location = raw.types.InputPeerPhotoFileLocation(
|
| 124 |
-
peer=peer,
|
| 125 |
-
volume_id=file_id.volume_id,
|
| 126 |
-
local_id=file_id.local_id,
|
| 127 |
-
big=file_id.thumbnail_source == ThumbnailSource.CHAT_PHOTO_BIG,
|
| 128 |
-
)
|
| 129 |
-
elif file_type == FileType.PHOTO:
|
| 130 |
-
location = raw.types.InputPhotoFileLocation(
|
| 131 |
-
id=file_id.media_id,
|
| 132 |
-
access_hash=file_id.access_hash,
|
| 133 |
-
file_reference=file_id.file_reference,
|
| 134 |
-
thumb_size=file_id.thumbnail_size,
|
| 135 |
-
)
|
| 136 |
-
else:
|
| 137 |
-
location = raw.types.InputDocumentFileLocation(
|
| 138 |
-
id=file_id.media_id,
|
| 139 |
-
access_hash=file_id.access_hash,
|
| 140 |
-
file_reference=file_id.file_reference,
|
| 141 |
-
thumb_size=file_id.thumbnail_size,
|
| 142 |
-
)
|
| 143 |
-
return location
|
| 144 |
-
|
| 145 |
-
async def yield_file(
|
| 146 |
-
self,
|
| 147 |
-
file_id: FileId,
|
| 148 |
-
index: int,
|
| 149 |
-
offset: int,
|
| 150 |
-
first_part_cut: int,
|
| 151 |
-
last_part_cut: int,
|
| 152 |
-
part_count: int,
|
| 153 |
-
chunk_size: int,
|
| 154 |
-
) -> Union[str, None]:
|
| 155 |
-
"""
|
| 156 |
-
Custom generator that yields the bytes of the media file.
|
| 157 |
-
Modded from <https://github.com/eyaadh/megadlbot_oss/blob/master/mega/telegram/utils/custom_download.py#L20>
|
| 158 |
-
Thanks to Eyaadh <https://github.com/eyaadh>
|
| 159 |
-
"""
|
| 160 |
-
client = self.client
|
| 161 |
-
work_loads[index] += 1
|
| 162 |
-
logging.debug(f"Starting to yielding file with client {index}.")
|
| 163 |
-
media_session = await self.generate_media_session(client, file_id)
|
| 164 |
-
|
| 165 |
-
current_part = 1
|
| 166 |
-
|
| 167 |
-
location = await self.get_location(file_id)
|
| 168 |
-
|
| 169 |
-
try:
|
| 170 |
-
r = await media_session.invoke(
|
| 171 |
-
raw.functions.upload.GetFile(
|
| 172 |
-
location=location, offset=offset, limit=chunk_size
|
| 173 |
-
),
|
| 174 |
-
)
|
| 175 |
-
if isinstance(r, raw.types.upload.File):
|
| 176 |
-
while True:
|
| 177 |
-
chunk = r.bytes
|
| 178 |
-
if not chunk:
|
| 179 |
-
break
|
| 180 |
-
elif part_count == 1:
|
| 181 |
-
yield chunk[first_part_cut:last_part_cut]
|
| 182 |
-
elif current_part == 1:
|
| 183 |
-
yield chunk[first_part_cut:]
|
| 184 |
-
elif current_part == part_count:
|
| 185 |
-
yield chunk[:last_part_cut]
|
| 186 |
-
else:
|
| 187 |
-
yield chunk
|
| 188 |
-
|
| 189 |
-
current_part += 1
|
| 190 |
-
offset += chunk_size
|
| 191 |
-
|
| 192 |
-
if current_part > part_count:
|
| 193 |
-
break
|
| 194 |
-
|
| 195 |
-
r = await media_session.invoke(
|
| 196 |
-
raw.functions.upload.GetFile(
|
| 197 |
-
location=location, offset=offset, limit=chunk_size
|
| 198 |
-
),
|
| 199 |
-
)
|
| 200 |
-
except (TimeoutError, AttributeError):
|
| 201 |
-
pass
|
| 202 |
-
finally:
|
| 203 |
-
logging.debug(f"Finished yielding file with {current_part} parts.")
|
| 204 |
-
work_loads[index] -= 1
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
async def clean_cache(self) -> None:
|
| 208 |
-
"""
|
| 209 |
-
function to clean the cache to reduce memory usage
|
| 210 |
-
"""
|
| 211 |
-
while True:
|
| 212 |
-
await asyncio.sleep(self.clean_timer)
|
| 213 |
-
self.cached_file_ids.clear()
|
| 214 |
-
logging.debug("Cleaned the cache")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 6 |
-
from FileStream.server.exceptions import FIleNotFound
|
| 7 |
-
|
| 8 |
-
class Database:
|
| 9 |
-
def __init__(self, uri, database_name):
|
| 10 |
-
self._client = motor.motor_asyncio.AsyncIOMotorClient(uri)
|
| 11 |
-
self.db = self._client[database_name]
|
| 12 |
-
self.col = self.db.users
|
| 13 |
-
self.black = self.db.blacklist
|
| 14 |
-
self.file = self.db.file
|
| 15 |
-
|
| 16 |
-
#---------------------[ NEW USER ]---------------------#
|
| 17 |
-
def new_user(self, id):
|
| 18 |
-
return dict(
|
| 19 |
-
id=id,
|
| 20 |
-
join_date=time.time(),
|
| 21 |
-
Links=0
|
| 22 |
-
)
|
| 23 |
-
|
| 24 |
-
# ---------------------[ ADD USER ]---------------------#
|
| 25 |
-
async def add_user(self, id):
|
| 26 |
-
user = self.new_user(id)
|
| 27 |
-
await self.col.insert_one(user)
|
| 28 |
-
|
| 29 |
-
# ---------------------[ GET USER ]---------------------#
|
| 30 |
-
async def get_user(self, id):
|
| 31 |
-
user = await self.col.find_one({'id': int(id)})
|
| 32 |
-
return user
|
| 33 |
-
|
| 34 |
-
# ---------------------[ CHECK USER ]---------------------#
|
| 35 |
-
async def total_users_count(self):
|
| 36 |
-
count = await self.col.count_documents({})
|
| 37 |
-
return count
|
| 38 |
-
|
| 39 |
-
async def get_all_users(self):
|
| 40 |
-
all_users = self.col.find({})
|
| 41 |
-
return all_users
|
| 42 |
-
|
| 43 |
-
# ---------------------[ REMOVE USER ]---------------------#
|
| 44 |
-
async def delete_user(self, user_id):
|
| 45 |
-
await self.col.delete_many({'id': int(user_id)})
|
| 46 |
-
|
| 47 |
-
# ---------------------[ BAN, UNBAN USER ]---------------------#
|
| 48 |
-
def black_user(self, id):
|
| 49 |
-
return dict(
|
| 50 |
-
id=id,
|
| 51 |
-
ban_date=time.time()
|
| 52 |
-
)
|
| 53 |
-
|
| 54 |
-
async def ban_user(self, id):
|
| 55 |
-
user = self.black_user(id)
|
| 56 |
-
await self.black.insert_one(user)
|
| 57 |
-
|
| 58 |
-
async def unban_user(self, id):
|
| 59 |
-
await self.black.delete_one({'id': int(id)})
|
| 60 |
-
|
| 61 |
-
async def is_user_banned(self, id):
|
| 62 |
-
user = await self.black.find_one({'id': int(id)})
|
| 63 |
-
return True if user else False
|
| 64 |
-
|
| 65 |
-
async def total_banned_users_count(self):
|
| 66 |
-
count = await self.black.count_documents({})
|
| 67 |
-
return count
|
| 68 |
-
|
| 69 |
-
# ---------------------[ ADD FILE TO DB ]---------------------#
|
| 70 |
-
async def add_file(self, file_info):
|
| 71 |
-
file_info["time"] = time.time()
|
| 72 |
-
fetch_old = await self.get_file_by_fileuniqueid(file_info["user_id"], file_info["file_unique_id"])
|
| 73 |
-
if fetch_old:
|
| 74 |
-
return fetch_old["_id"]
|
| 75 |
-
await self.count_links(file_info["user_id"], "+")
|
| 76 |
-
return (await self.file.insert_one(file_info)).inserted_id
|
| 77 |
-
|
| 78 |
-
# ---------------------[ FIND FILE IN DB ]---------------------#
|
| 79 |
-
async def find_files(self, user_id, range):
|
| 80 |
-
user_files=self.file.find({"user_id": user_id})
|
| 81 |
-
user_files.skip(range[0] - 1)
|
| 82 |
-
user_files.limit(range[1] - range[0] + 1)
|
| 83 |
-
user_files.sort('_id', pymongo.DESCENDING)
|
| 84 |
-
total_files = await self.file.count_documents({"user_id": user_id})
|
| 85 |
-
return user_files, total_files
|
| 86 |
-
|
| 87 |
-
async def get_file(self, _id):
|
| 88 |
-
try:
|
| 89 |
-
file_info=await self.file.find_one({"_id": ObjectId(_id)})
|
| 90 |
-
if not file_info:
|
| 91 |
-
raise FIleNotFound
|
| 92 |
-
return file_info
|
| 93 |
-
except InvalidId:
|
| 94 |
-
raise FIleNotFound
|
| 95 |
-
|
| 96 |
-
async def get_file_by_fileuniqueid(self, id, file_unique_id, many=False):
|
| 97 |
-
if many:
|
| 98 |
-
return self.file.find({"file_unique_id": file_unique_id})
|
| 99 |
-
else:
|
| 100 |
-
file_info=await self.file.find_one({"user_id": id, "file_unique_id": file_unique_id})
|
| 101 |
-
if file_info:
|
| 102 |
-
return file_info
|
| 103 |
-
return False
|
| 104 |
-
|
| 105 |
-
# ---------------------[ TOTAL FILES ]---------------------#
|
| 106 |
-
async def total_files(self, id=None):
|
| 107 |
-
if id:
|
| 108 |
-
return await self.file.count_documents({"user_id": id})
|
| 109 |
-
return await self.file.count_documents({})
|
| 110 |
-
|
| 111 |
-
# ---------------------[ DELETE FILES ]---------------------#
|
| 112 |
-
async def delete_one_file(self, _id):
|
| 113 |
-
await self.file.delete_one({'_id': ObjectId(_id)})
|
| 114 |
-
|
| 115 |
-
# ---------------------[ UPDATE FILES ]---------------------#
|
| 116 |
-
async def update_file_ids(self, _id, file_ids: dict):
|
| 117 |
-
await self.file.update_one({"_id": ObjectId(_id)}, {"$set": {"file_ids": file_ids}})
|
| 118 |
-
|
| 119 |
-
# ---------------------[ PAID SYS ]---------------------#
|
| 120 |
-
# async def link_available(self, id):
|
| 121 |
-
# user = await self.col.find_one({"id": id})
|
| 122 |
-
# if user.get("Plan") == "Plus":
|
| 123 |
-
# return "Plus"
|
| 124 |
-
# elif user.get("Plan") == "Free":
|
| 125 |
-
# files = await self.file.count_documents({"user_id": id})
|
| 126 |
-
# if files < 11:
|
| 127 |
-
# return True
|
| 128 |
-
# return False
|
| 129 |
-
|
| 130 |
-
async def count_links(self, id, operation: str):
|
| 131 |
-
if operation == "-":
|
| 132 |
-
await self.col.update_one({"id": id}, {"$inc": {"Links": -1}})
|
| 133 |
-
elif operation == "+":
|
| 134 |
-
await self.col.update_one({"id": id}, {"$inc": {"Links": 1}})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileStream/utils/file_properties.py
DELETED
|
@@ -1,144 +0,0 @@
|
|
| 1 |
-
from __future__ import annotations
|
| 2 |
-
import logging
|
| 3 |
-
from datetime import datetime
|
| 4 |
-
from pyrogram import Client
|
| 5 |
-
from typing import Any, Optional
|
| 6 |
-
|
| 7 |
-
from pyrogram.enums import ParseMode, ChatType
|
| 8 |
-
from pyrogram.types import Message
|
| 9 |
-
from pyrogram.file_id import FileId
|
| 10 |
-
from FileStream.bot import FileStream
|
| 11 |
-
from FileStream.utils.database import Database
|
| 12 |
-
from FileStream.config import Telegram, Server
|
| 13 |
-
|
| 14 |
-
db = Database(Telegram.DATABASE_URL, Telegram.SESSION_NAME)
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
async def get_file_ids(client: Client | bool, db_id: str, multi_clients, message) -> Optional[FileId]:
|
| 18 |
-
logging.debug("Starting of get_file_ids")
|
| 19 |
-
file_info = await db.get_file(db_id)
|
| 20 |
-
if (not "file_ids" in file_info) or not client:
|
| 21 |
-
logging.debug("Storing file_id of all clients in DB")
|
| 22 |
-
log_msg = await send_file(FileStream, db_id, file_info['file_id'], message)
|
| 23 |
-
await db.update_file_ids(db_id, await update_file_id(log_msg.id, multi_clients))
|
| 24 |
-
logging.debug("Stored file_id of all clients in DB")
|
| 25 |
-
if not client:
|
| 26 |
-
return
|
| 27 |
-
file_info = await db.get_file(db_id)
|
| 28 |
-
|
| 29 |
-
file_id_info = file_info.setdefault("file_ids", {})
|
| 30 |
-
if not str(client.id) in file_id_info:
|
| 31 |
-
logging.debug("Storing file_id in DB")
|
| 32 |
-
log_msg = await send_file(FileStream, db_id, file_info['file_id'], message)
|
| 33 |
-
msg = await client.get_messages(Telegram.FLOG_CHANNEL, log_msg.id)
|
| 34 |
-
media = get_media_from_message(msg)
|
| 35 |
-
file_id_info[str(client.id)] = getattr(media, "file_id", "")
|
| 36 |
-
await db.update_file_ids(db_id, file_id_info)
|
| 37 |
-
logging.debug("Stored file_id in DB")
|
| 38 |
-
|
| 39 |
-
logging.debug("Middle of get_file_ids")
|
| 40 |
-
file_id = FileId.decode(file_id_info[str(client.id)])
|
| 41 |
-
setattr(file_id, "file_size", file_info['file_size'])
|
| 42 |
-
setattr(file_id, "mime_type", file_info['mime_type'])
|
| 43 |
-
setattr(file_id, "file_name", file_info['file_name'])
|
| 44 |
-
setattr(file_id, "unique_id", file_info['file_unique_id'])
|
| 45 |
-
logging.debug("Ending of get_file_ids")
|
| 46 |
-
return file_id
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
def get_media_from_message(message: "Message") -> Any:
|
| 50 |
-
media_types = (
|
| 51 |
-
"audio",
|
| 52 |
-
"document",
|
| 53 |
-
"photo",
|
| 54 |
-
"sticker",
|
| 55 |
-
"animation",
|
| 56 |
-
"video",
|
| 57 |
-
"voice",
|
| 58 |
-
"video_note",
|
| 59 |
-
)
|
| 60 |
-
for attr in media_types:
|
| 61 |
-
media = getattr(message, attr, None)
|
| 62 |
-
if media:
|
| 63 |
-
return media
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
def get_media_file_size(m):
|
| 67 |
-
media = get_media_from_message(m)
|
| 68 |
-
return getattr(media, "file_size", "None")
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
def get_name(media_msg: Message | FileId) -> str:
|
| 72 |
-
if isinstance(media_msg, Message):
|
| 73 |
-
media = get_media_from_message(media_msg)
|
| 74 |
-
file_name = getattr(media, "file_name", "")
|
| 75 |
-
|
| 76 |
-
elif isinstance(media_msg, FileId):
|
| 77 |
-
file_name = getattr(media_msg, "file_name", "")
|
| 78 |
-
|
| 79 |
-
if not file_name:
|
| 80 |
-
if isinstance(media_msg, Message) and media_msg.media:
|
| 81 |
-
media_type = media_msg.media.value
|
| 82 |
-
elif media_msg.file_type:
|
| 83 |
-
media_type = media_msg.file_type.name.lower()
|
| 84 |
-
else:
|
| 85 |
-
media_type = "file"
|
| 86 |
-
|
| 87 |
-
formats = {
|
| 88 |
-
"photo": "jpg", "audio": "mp3", "voice": "ogg",
|
| 89 |
-
"video": "mp4", "animation": "mp4", "video_note": "mp4",
|
| 90 |
-
"sticker": "webp"
|
| 91 |
-
}
|
| 92 |
-
|
| 93 |
-
ext = formats.get(media_type)
|
| 94 |
-
ext = "." + ext if ext else ""
|
| 95 |
-
|
| 96 |
-
date = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
|
| 97 |
-
file_name = f"{media_type}-{date}{ext}"
|
| 98 |
-
|
| 99 |
-
return file_name
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
def get_file_info(message):
|
| 103 |
-
media = get_media_from_message(message)
|
| 104 |
-
if message.chat.type == ChatType.PRIVATE:
|
| 105 |
-
user_idx = message.from_user.id
|
| 106 |
-
else:
|
| 107 |
-
user_idx = message.chat.id
|
| 108 |
-
return {
|
| 109 |
-
"user_id": user_idx,
|
| 110 |
-
"file_id": getattr(media, "file_id", ""),
|
| 111 |
-
"file_unique_id": getattr(media, "file_unique_id", ""),
|
| 112 |
-
"file_name": get_name(message),
|
| 113 |
-
"file_size": getattr(media, "file_size", 0),
|
| 114 |
-
"mime_type": getattr(media, "mime_type", "None/unknown")
|
| 115 |
-
}
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
async def update_file_id(msg_id, multi_clients):
|
| 119 |
-
file_ids = {}
|
| 120 |
-
for client_id, client in multi_clients.items():
|
| 121 |
-
log_msg = await client.get_messages(Telegram.FLOG_CHANNEL, msg_id)
|
| 122 |
-
media = get_media_from_message(log_msg)
|
| 123 |
-
file_ids[str(client.id)] = getattr(media, "file_id", "")
|
| 124 |
-
|
| 125 |
-
return file_ids
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
async def send_file(client: Client, db_id, file_id: str, message):
|
| 129 |
-
file_caption = getattr(message, 'caption', None) or get_name(message)
|
| 130 |
-
log_msg = await client.send_cached_media(chat_id=Telegram.FLOG_CHANNEL, file_id=file_id,
|
| 131 |
-
caption=f'**{file_caption}**')
|
| 132 |
-
|
| 133 |
-
if message.chat.type == ChatType.PRIVATE:
|
| 134 |
-
await log_msg.reply_text(
|
| 135 |
-
text=f"**RᴇQᴜᴇꜱᴛᴇᴅ ʙʏ :** [{message.from_user.first_name}](tg://user?id={message.from_user.id})\n**Uꜱᴇʀ ɪᴅ :** `{message.from_user.id}`\n**Fɪʟᴇ ɪᴅ :** `{db_id}`",
|
| 136 |
-
disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN, quote=True)
|
| 137 |
-
else:
|
| 138 |
-
await log_msg.reply_text(
|
| 139 |
-
text=f"**RᴇQᴜᴇꜱᴛᴇᴅ ʙʏ :** {message.chat.title} \n**Cʜᴀɴɴᴇʟ ɪᴅ :** `{message.chat.id}`\n**Fɪʟᴇ ɪᴅ :** `{db_id}`",
|
| 140 |
-
disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN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-
if not size:
|
| 3 |
-
return ""
|
| 4 |
-
power = 2**10
|
| 5 |
-
n = 0
|
| 6 |
-
Dic_powerN = {0: ' ', 1: 'Ki', 2: 'Mi', 3: 'Gi', 4: 'Ti'}
|
| 7 |
-
while size > power:
|
| 8 |
-
size /= power
|
| 9 |
-
n += 1
|
| 10 |
-
return str(round(size, 2)) + " " + Dic_powerN[n] + 'B'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileStream/utils/render_template.py
DELETED
|
@@ -1,30 +0,0 @@
|
|
| 1 |
-
import aiohttp
|
| 2 |
-
import jinja2
|
| 3 |
-
import urllib.parse
|
| 4 |
-
from FileStream.config import Telegram, Server
|
| 5 |
-
from FileStream.utils.database import Database
|
| 6 |
-
from FileStream.utils.human_readable import humanbytes
|
| 7 |
-
db = Database(Telegram.DATABASE_URL, Telegram.SESSION_NAME)
|
| 8 |
-
|
| 9 |
-
async def render_page(db_id):
|
| 10 |
-
file_data=await db.get_file(db_id)
|
| 11 |
-
src = urllib.parse.urljoin(Server.URL, f'dl/{file_data["_id"]}')
|
| 12 |
-
file_size = humanbytes(file_data['file_size'])
|
| 13 |
-
file_name = file_data['file_name'].replace("_", " ")
|
| 14 |
-
|
| 15 |
-
if str((file_data['mime_type']).split('/')[0].strip()) == 'video':
|
| 16 |
-
template_file = "FileStream/template/play.html"
|
| 17 |
-
else:
|
| 18 |
-
template_file = "FileStream/template/dl.html"
|
| 19 |
-
async with aiohttp.ClientSession() as s:
|
| 20 |
-
async with s.get(src) as u:
|
| 21 |
-
file_size = humanbytes(int(u.headers.get('Content-Length')))
|
| 22 |
-
|
| 23 |
-
with open(template_file) as f:
|
| 24 |
-
template = jinja2.Template(f.read())
|
| 25 |
-
|
| 26 |
-
return template.render(
|
| 27 |
-
file_name=file_name,
|
| 28 |
-
file_url=src,
|
| 29 |
-
file_size=file_size
|
| 30 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileStream/utils/time_format.py
DELETED
|
@@ -1,22 +0,0 @@
|
|
| 1 |
-
def get_readable_time(seconds: int) -> str:
|
| 2 |
-
count = 0
|
| 3 |
-
readable_time = ""
|
| 4 |
-
time_list = []
|
| 5 |
-
time_suffix_list = ["s", "m", "h", " days"]
|
| 6 |
-
while count < 4:
|
| 7 |
-
count += 1
|
| 8 |
-
if count < 3:
|
| 9 |
-
remainder, result = divmod(seconds, 60)
|
| 10 |
-
else:
|
| 11 |
-
remainder, result = divmod(seconds, 24)
|
| 12 |
-
if seconds == 0 and remainder == 0:
|
| 13 |
-
break
|
| 14 |
-
time_list.append(int(result))
|
| 15 |
-
seconds = int(remainder)
|
| 16 |
-
for x in range(len(time_list)):
|
| 17 |
-
time_list[x] = str(time_list[x]) + time_suffix_list[x]
|
| 18 |
-
if len(time_list) == 4:
|
| 19 |
-
readable_time += time_list.pop() + ", "
|
| 20 |
-
time_list.reverse()
|
| 21 |
-
readable_time += ": ".join(time_list)
|
| 22 |
-
return readable_time
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileStream/utils/translation.py
DELETED
|
@@ -1,72 +0,0 @@
|
|
| 1 |
-
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
|
| 2 |
-
from FileStream.config import Telegram
|
| 3 |
-
|
| 4 |
-
class LANG(object):
|
| 5 |
-
|
| 6 |
-
START_TEXT = """
|
| 7 |
-
<b>👋 Hᴇʏ, </b>{}\n
|
| 8 |
-
<b>I'ᴍ ᴛᴇʟᴇɢʀᴀᴍ ғɪʟᴇs sᴛʀᴇᴀᴍɪɴɢ ʙᴏᴛ ᴀs ᴡᴇʟʟ ᴅɪʀᴇᴄᴛ ʟɪɴᴋs ɢᴇɴᴇʀᴀᴛᴏʀ</b>\n
|
| 9 |
-
<b>ᴡᴏʀᴋɪɴɢ ᴏɴ ᴄʜᴀɴɴᴇʟs ᴀɴᴅ ᴘʀɪᴠᴀᴛᴇ ᴄʜᴀᴛ</b>\n
|
| 10 |
-
<b>💕 @{}</b>\n"""
|
| 11 |
-
|
| 12 |
-
HELP_TEXT = """
|
| 13 |
-
<b>- ᴀᴅᴅ ᴍᴇ ᴀs ᴀɴ ᴀᴅᴍɪɴ ᴏɴ ᴛʜᴇ ᴄʜᴀɴɴᴇʟ</b>
|
| 14 |
-
<b>- sᴇɴᴅ ᴍᴇ ᴀɴʏ ᴅᴏᴄᴜᴍᴇɴᴛ ᴏʀ ᴍᴇᴅɪᴀ</b>
|
| 15 |
-
<b>- ɪ'ʟʟ ᴘʀᴏᴠɪᴅᴇ sᴛʀᴇᴀᴍᴀʙʟᴇ ʟɪɴᴋ</b>\n
|
| 16 |
-
<b>🔞 ᴀᴅᴜʟᴛ ᴄᴏɴᴛᴇɴᴛ sᴛʀɪᴄᴛʟʏ ᴘʀᴏʜɪʙɪᴛᴇᴅ.</b>\n
|
| 17 |
-
<i><b> ʀᴇᴘᴏʀᴛ ʙᴜɢs ᴛᴏ <a href='https://telegram.me/AvishkarPatil'>ᴅᴇᴠᴇʟᴏᴘᴇʀ</a></b></i>"""
|
| 18 |
-
|
| 19 |
-
ABOUT_TEXT = """
|
| 20 |
-
<b>⚜ ᴍʏ ɴᴀᴍᴇ : {}</b>\n
|
| 21 |
-
<b>✦ ᴠᴇʀsɪᴏɴ : {}</b>
|
| 22 |
-
<b>✦ ᴜᴘᴅᴀᴛᴇᴅ ᴏɴ : 06-January-2024</b>
|
| 23 |
-
<b>✦ ᴅᴇᴠᴇʟᴏᴘᴇʀ : <a href='https://telegram.me/AvishkarPatil'>Avishkar Patil</a></b>\n
|
| 24 |
-
"""
|
| 25 |
-
|
| 26 |
-
STREAM_TEXT = """
|
| 27 |
-
<i><u>𝗬𝗼𝘂𝗿 𝗟𝗶𝗻𝗸 𝗚𝗲𝗻𝗲𝗿𝗮𝘁𝗲𝗱 !</u></i>\n
|
| 28 |
-
<b>📂 Fɪʟᴇ ɴᴀᴍᴇ :</b> <b>{}</b>\n
|
| 29 |
-
<b>📦 Fɪʟᴇ ꜱɪᴢᴇ :</b> <code>{}</code>\n
|
| 30 |
-
<b>📥 Dᴏᴡɴʟᴏᴀᴅ :</b> <code>{}</code>\n
|
| 31 |
-
<b>🖥 Wᴀᴛᴄʜ :</b> <code>{}</code>\n
|
| 32 |
-
<b>🔗 Sʜᴀʀᴇ :</b> <code>{}</code>\n"""
|
| 33 |
-
|
| 34 |
-
STREAM_TEXT_X = """
|
| 35 |
-
<i><u>𝗬𝗼𝘂𝗿 𝗟𝗶𝗻𝗸 𝗚𝗲𝗻𝗲𝗿𝗮𝘁𝗲𝗱 !</u></i>\n
|
| 36 |
-
<b>📂 Fɪʟᴇ ɴᴀᴍᴇ :</b> <b>{}</b>\n
|
| 37 |
-
<b>📦 Fɪʟᴇ ꜱɪᴢᴇ :</b> <code>{}</code>\n
|
| 38 |
-
<b>📥 Dᴏᴡɴʟᴏᴀᴅ :</b> <code>{}</code>\n
|
| 39 |
-
<b>🔗 Sʜᴀʀᴇ :</b> <code>{}</code>\n"""
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
BAN_TEXT = "__Sᴏʀʀʏ Sɪʀ, Yᴏᴜ ᴀʀᴇ Bᴀɴɴᴇᴅ ᴛᴏ ᴜsᴇ ᴍᴇ.__\n\n**[Cᴏɴᴛᴀᴄᴛ Dᴇᴠᴇʟᴏᴘᴇʀ](tg://user?id={}) Tʜᴇʏ Wɪʟʟ Hᴇʟᴘ Yᴏᴜ**"
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
class BUTTON(object):
|
| 46 |
-
START_BUTTONS = InlineKeyboardMarkup(
|
| 47 |
-
[[
|
| 48 |
-
InlineKeyboardButton('ʜᴇʟᴘ', callback_data='help'),
|
| 49 |
-
InlineKeyboardButton('ᴀʙᴏᴜᴛ', callback_data='about'),
|
| 50 |
-
InlineKeyboardButton('ᴄʟᴏsᴇ', callback_data='close')
|
| 51 |
-
],
|
| 52 |
-
[InlineKeyboardButton("📢 ᴜᴘᴅᴀᴛᴇ ᴄʜᴀɴɴᴇʟ", url=f'https://t.me/{Telegram.UPDATES_CHANNEL}')]
|
| 53 |
-
]
|
| 54 |
-
)
|
| 55 |
-
HELP_BUTTONS = InlineKeyboardMarkup(
|
| 56 |
-
[[
|
| 57 |
-
InlineKeyboardButton('ʜᴏᴍᴇ', callback_data='home'),
|
| 58 |
-
InlineKeyboardButton('ᴀʙᴏᴜᴛ', callback_data='about'),
|
| 59 |
-
InlineKeyboardButton('ᴄʟᴏsᴇ', callback_data='close'),
|
| 60 |
-
],
|
| 61 |
-
[InlineKeyboardButton("📢 ᴜᴘᴅᴀᴛᴇ ᴄʜᴀɴɴᴇʟ", url=f'https://t.me/{Telegram.UPDATES_CHANNEL}')]
|
| 62 |
-
]
|
| 63 |
-
)
|
| 64 |
-
ABOUT_BUTTONS = InlineKeyboardMarkup(
|
| 65 |
-
[[
|
| 66 |
-
InlineKeyboardButton('ʜᴏᴍᴇ', callback_data='home'),
|
| 67 |
-
InlineKeyboardButton('ʜᴇʟᴘ', callback_data='help'),
|
| 68 |
-
InlineKeyboardButton('ᴄʟᴏsᴇ', callback_data='close'),
|
| 69 |
-
],
|
| 70 |
-
[InlineKeyboardButton("📢 ᴜᴘᴅᴀᴛᴇ ᴄʜᴀɴɴᴇʟ", url=f'https://t.me/{Telegram.UPDATES_CHANNEL}')]
|
| 71 |
-
]
|
| 72 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
GNU AFFERO GENERAL PUBLIC LICENSE
|
| 2 |
+
Version 3, 19 November 2007
|
| 3 |
+
|
| 4 |
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
| 5 |
+
Everyone is permitted to copy and distribute verbatim copies
|
| 6 |
+
of this license document, but changing it is not allowed.
|
| 7 |
+
|
| 8 |
+
Preamble
|
| 9 |
+
|
| 10 |
+
The GNU Affero General Public License is a free, copyleft license for
|
| 11 |
+
software and other kinds of works, specifically designed to ensure
|
| 12 |
+
cooperation with the community in the case of network server software.
|
| 13 |
+
|
| 14 |
+
The licenses for most software and other practical works are designed
|
| 15 |
+
to take away your freedom to share and change the works. By contrast,
|
| 16 |
+
our General Public Licenses are intended to guarantee your freedom to
|
| 17 |
+
share and change all versions of a program--to make sure it remains free
|
| 18 |
+
software for all its users.
|
| 19 |
+
|
| 20 |
+
When we speak of free software, we are referring to freedom, not
|
| 21 |
+
price. Our General Public Licenses are designed to make sure that you
|
| 22 |
+
have the freedom to distribute copies of free software (and charge for
|
| 23 |
+
them if you wish), that you receive source code or can get it if you
|
| 24 |
+
want it, that you can change the software or use pieces of it in new
|
| 25 |
+
free programs, and that you know you can do these things.
|
| 26 |
+
|
| 27 |
+
Developers that use our General Public Licenses protect your rights
|
| 28 |
+
with two steps: (1) assert copyright on the software, and (2) offer
|
| 29 |
+
you this License which gives you legal permission to copy, distribute
|
| 30 |
+
and/or modify the software.
|
| 31 |
+
|
| 32 |
+
A secondary benefit of defending all users' freedom is that
|
| 33 |
+
improvements made in alternate versions of the program, if they
|
| 34 |
+
receive widespread use, become available for other developers to
|
| 35 |
+
incorporate. Many developers of free software are heartened and
|
| 36 |
+
encouraged by the resulting cooperation. However, in the case of
|
| 37 |
+
software used on network servers, this result may fail to come about.
|
| 38 |
+
The GNU General Public License permits making a modified version and
|
| 39 |
+
letting the public access it on a server without ever releasing its
|
| 40 |
+
source code to the public.
|
| 41 |
+
|
| 42 |
+
The GNU Affero General Public License is designed specifically to
|
| 43 |
+
ensure that, in such cases, the modified source code becomes available
|
| 44 |
+
to the community. It requires the operator of a network server to
|
| 45 |
+
provide the source code of the modified version running there to the
|
| 46 |
+
users of that server. Therefore, public use of a modified version, on
|
| 47 |
+
a publicly accessible server, gives the public access to the source
|
| 48 |
+
code of the modified version.
|
| 49 |
+
|
| 50 |
+
An older license, called the Affero General Public License and
|
| 51 |
+
published by Affero, was designed to accomplish similar goals. This is
|
| 52 |
+
a different license, not a version of the Affero GPL, but Affero has
|
| 53 |
+
released a new version of the Affero GPL which permits relicensing under
|
| 54 |
+
this license.
|
| 55 |
+
|
| 56 |
+
The precise terms and conditions for copying, distribution and
|
| 57 |
+
modification follow.
|
| 58 |
+
|
| 59 |
+
TERMS AND CONDITIONS
|
| 60 |
+
|
| 61 |
+
0. Definitions.
|
| 62 |
+
|
| 63 |
+
"This License" refers to version 3 of the GNU Affero General Public License.
|
| 64 |
+
|
| 65 |
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
| 66 |
+
works, such as semiconductor masks.
|
| 67 |
+
|
| 68 |
+
"The Program" refers to any copyrightable work licensed under this
|
| 69 |
+
License. Each licensee is addressed as "you". "Licensees" and
|
| 70 |
+
"recipients" may be individuals or organizations.
|
| 71 |
+
|
| 72 |
+
To "modify" a work means to copy from or adapt all or part of the work
|
| 73 |
+
in a fashion requiring copyright permission, other than the making of an
|
| 74 |
+
exact copy. The resulting work is called a "modified version" of the
|
| 75 |
+
earlier work or a work "based on" the earlier work.
|
| 76 |
+
|
| 77 |
+
A "covered work" means either the unmodified Program or a work based
|
| 78 |
+
on the Program.
|
| 79 |
+
|
| 80 |
+
To "propagate" a work means to do anything with it that, without
|
| 81 |
+
permission, would make you directly or secondarily liable for
|
| 82 |
+
infringement under applicable copyright law, except executing it on a
|
| 83 |
+
computer or modifying a private copy. Propagation includes copying,
|
| 84 |
+
distribution (with or without modification), making available to the
|
| 85 |
+
public, and in some countries other activities as well.
|
| 86 |
+
|
| 87 |
+
To "convey" a work means any kind of propagation that enables other
|
| 88 |
+
parties to make or receive copies. Mere interaction with a user through
|
| 89 |
+
a computer network, with no transfer of a copy, is not conveying.
|
| 90 |
+
|
| 91 |
+
An interactive user interface displays "Appropriate Legal Notices"
|
| 92 |
+
to the extent that it includes a convenient and prominently visible
|
| 93 |
+
feature that (1) displays an appropriate copyright notice, and (2)
|
| 94 |
+
tells the user that there is no warranty for the work (except to the
|
| 95 |
+
extent that warranties are provided), that licensees may convey the
|
| 96 |
+
work under this License, and how to view a copy of this License. If
|
| 97 |
+
the interface presents a list of user commands or options, such as a
|
| 98 |
+
menu, a prominent item in the list meets this criterion.
|
| 99 |
+
|
| 100 |
+
1. Source Code.
|
| 101 |
+
|
| 102 |
+
The "source code" for a work means the preferred form of the work
|
| 103 |
+
for making modifications to it. "Object code" means any non-source
|
| 104 |
+
form of a work.
|
| 105 |
+
|
| 106 |
+
A "Standard Interface" means an interface that either is an official
|
| 107 |
+
standard defined by a recognized standards body, or, in the case of
|
| 108 |
+
interfaces specified for a particular programming language, one that
|
| 109 |
+
is widely used among developers working in that language.
|
| 110 |
+
|
| 111 |
+
The "System Libraries" of an executable work include anything, other
|
| 112 |
+
than the work as a whole, that (a) is included in the normal form of
|
| 113 |
+
packaging a Major Component, but which is not part of that Major
|
| 114 |
+
Component, and (b) serves only to enable use of the work with that
|
| 115 |
+
Major Component, or to implement a Standard Interface for which an
|
| 116 |
+
implementation is available to the public in source code form. A
|
| 117 |
+
"Major Component", in this context, means a major essential component
|
| 118 |
+
(kernel, window system, and so on) of the specific operating system
|
| 119 |
+
(if any) on which the executable work runs, or a compiler used to
|
| 120 |
+
produce the work, or an object code interpreter used to run it.
|
| 121 |
+
|
| 122 |
+
The "Corresponding Source" for a work in object code form means all
|
| 123 |
+
the source code needed to generate, install, and (for an executable
|
| 124 |
+
work) run the object code and to modify the work, including scripts to
|
| 125 |
+
control those activities. However, it does not include the work's
|
| 126 |
+
System Libraries, or general-purpose tools or generally available free
|
| 127 |
+
programs which are used unmodified in performing those activities but
|
| 128 |
+
which are not part of the work. For example, Corresponding Source
|
| 129 |
+
includes interface definition files associated with source files for
|
| 130 |
+
the work, and the source code for shared libraries and dynamically
|
| 131 |
+
linked subprograms that the work is specifically designed to require,
|
| 132 |
+
such as by intimate data communication or control flow between those
|
| 133 |
+
subprograms and other parts of the work.
|
| 134 |
+
|
| 135 |
+
The Corresponding Source need not include anything that users
|
| 136 |
+
can regenerate automatically from other parts of the Corresponding
|
| 137 |
+
Source.
|
| 138 |
+
|
| 139 |
+
The Corresponding Source for a work in source code form is that
|
| 140 |
+
same work.
|
| 141 |
+
|
| 142 |
+
2. Basic Permissions.
|
| 143 |
+
|
| 144 |
+
All rights granted under this License are granted for the term of
|
| 145 |
+
copyright on the Program, and are irrevocable provided the stated
|
| 146 |
+
conditions are met. This License explicitly affirms your unlimited
|
| 147 |
+
permission to run the unmodified Program. The output from running a
|
| 148 |
+
covered work is covered by this License only if the output, given its
|
| 149 |
+
content, constitutes a covered work. This License acknowledges your
|
| 150 |
+
rights of fair use or other equivalent, as provided by copyright law.
|
| 151 |
+
|
| 152 |
+
You may make, run and propagate covered works that you do not
|
| 153 |
+
convey, without conditions so long as your license otherwise remains
|
| 154 |
+
in force. You may convey covered works to others for the sole purpose
|
| 155 |
+
of having them make modifications exclusively for you, or provide you
|
| 156 |
+
with facilities for running those works, provided that you comply with
|
| 157 |
+
the terms of this License in conveying all material for which you do
|
| 158 |
+
not control copyright. Those thus making or running the covered works
|
| 159 |
+
for you must do so exclusively on your behalf, under your direction
|
| 160 |
+
and control, on terms that prohibit them from making any copies of
|
| 161 |
+
your copyrighted material outside their relationship with you.
|
| 162 |
+
|
| 163 |
+
Conveying under any other circumstances is permitted solely under
|
| 164 |
+
the conditions stated below. Sublicensing is not allowed; section 10
|
| 165 |
+
makes it unnecessary.
|
| 166 |
+
|
| 167 |
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
| 168 |
+
|
| 169 |
+
No covered work shall be deemed part of an effective technological
|
| 170 |
+
measure under any applicable law fulfilling obligations under article
|
| 171 |
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
| 172 |
+
similar laws prohibiting or restricting circumvention of such
|
| 173 |
+
measures.
|
| 174 |
+
|
| 175 |
+
When you convey a covered work, you waive any legal power to forbid
|
| 176 |
+
circumvention of technological measures to the extent such circumvention
|
| 177 |
+
is effected by exercising rights under this License with respect to
|
| 178 |
+
the covered work, and you disclaim any intention to limit operation or
|
| 179 |
+
modification of the work as a means of enforcing, against the work's
|
| 180 |
+
users, your or third parties' legal rights to forbid circumvention of
|
| 181 |
+
technological measures.
|
| 182 |
+
|
| 183 |
+
4. Conveying Verbatim Copies.
|
| 184 |
+
|
| 185 |
+
You may convey verbatim copies of the Program's source code as you
|
| 186 |
+
receive it, in any medium, provided that you conspicuously and
|
| 187 |
+
appropriately publish on each copy an appropriate copyright notice;
|
| 188 |
+
keep intact all notices stating that this License and any
|
| 189 |
+
non-permissive terms added in accord with section 7 apply to the code;
|
| 190 |
+
keep intact all notices of the absence of any warranty; and give all
|
| 191 |
+
recipients a copy of this License along with the Program.
|
| 192 |
+
|
| 193 |
+
You may charge any price or no price for each copy that you convey,
|
| 194 |
+
and you may offer support or warranty protection for a fee.
|
| 195 |
+
|
| 196 |
+
5. Conveying Modified Source Versions.
|
| 197 |
+
|
| 198 |
+
You may convey a work based on the Program, or the modifications to
|
| 199 |
+
produce it from the Program, in the form of source code under the
|
| 200 |
+
terms of section 4, provided that you also meet all of these conditions:
|
| 201 |
+
|
| 202 |
+
a) The work must carry prominent notices stating that you modified
|
| 203 |
+
it, and giving a relevant date.
|
| 204 |
+
|
| 205 |
+
b) The work must carry prominent notices stating that it is
|
| 206 |
+
released under this License and any conditions added under section
|
| 207 |
+
7. This requirement modifies the requirement in section 4 to
|
| 208 |
+
"keep intact all notices".
|
| 209 |
+
|
| 210 |
+
c) You must license the entire work, as a whole, under this
|
| 211 |
+
License to anyone who comes into possession of a copy. This
|
| 212 |
+
License will therefore apply, along with any applicable section 7
|
| 213 |
+
additional terms, to the whole of the work, and all its parts,
|
| 214 |
+
regardless of how they are packaged. This License gives no
|
| 215 |
+
permission to license the work in any other way, but it does not
|
| 216 |
+
invalidate such permission if you have separately received it.
|
| 217 |
+
|
| 218 |
+
d) If the work has interactive user interfaces, each must display
|
| 219 |
+
Appropriate Legal Notices; however, if the Program has interactive
|
| 220 |
+
interfaces that do not display Appropriate Legal Notices, your
|
| 221 |
+
work need not make them do so.
|
| 222 |
+
|
| 223 |
+
A compilation of a covered work with other separate and independent
|
| 224 |
+
works, which are not by their nature extensions of the covered work,
|
| 225 |
+
and which are not combined with it such as to form a larger program,
|
| 226 |
+
in or on a volume of a storage or distribution medium, is called an
|
| 227 |
+
"aggregate" if the compilation and its resulting copyright are not
|
| 228 |
+
used to limit the access or legal rights of the compilation's users
|
| 229 |
+
beyond what the individual works permit. Inclusion of a covered work
|
| 230 |
+
in an aggregate does not cause this License to apply to the other
|
| 231 |
+
parts of the aggregate.
|
| 232 |
+
|
| 233 |
+
6. Conveying Non-Source Forms.
|
| 234 |
+
|
| 235 |
+
You may convey a covered work in object code form under the terms
|
| 236 |
+
of sections 4 and 5, provided that you also convey the
|
| 237 |
+
machine-readable Corresponding Source under the terms of this License,
|
| 238 |
+
in one of these ways:
|
| 239 |
+
|
| 240 |
+
a) Convey the object code in, or embodied in, a physical product
|
| 241 |
+
(including a physical distribution medium), accompanied by the
|
| 242 |
+
Corresponding Source fixed on a durable physical medium
|
| 243 |
+
customarily used for software interchange.
|
| 244 |
+
|
| 245 |
+
b) Convey the object code in, or embodied in, a physical product
|
| 246 |
+
(including a physical distribution medium), accompanied by a
|
| 247 |
+
written offer, valid for at least three years and valid for as
|
| 248 |
+
long as you offer spare parts or customer support for that product
|
| 249 |
+
model, to give anyone who possesses the object code either (1) a
|
| 250 |
+
copy of the Corresponding Source for all the software in the
|
| 251 |
+
product that is covered by this License, on a durable physical
|
| 252 |
+
medium customarily used for software interchange, for a price no
|
| 253 |
+
more than your reasonable cost of physically performing this
|
| 254 |
+
conveying of source, or (2) access to copy the
|
| 255 |
+
Corresponding Source from a network server at no charge.
|
| 256 |
+
|
| 257 |
+
c) Convey individual copies of the object code with a copy of the
|
| 258 |
+
written offer to provide the Corresponding Source. This
|
| 259 |
+
alternative is allowed only occasionally and noncommercially, and
|
| 260 |
+
only if you received the object code with such an offer, in accord
|
| 261 |
+
with subsection 6b.
|
| 262 |
+
|
| 263 |
+
d) Convey the object code by offering access from a designated
|
| 264 |
+
place (gratis or for a charge), and offer equivalent access to the
|
| 265 |
+
Corresponding Source in the same way through the same place at no
|
| 266 |
+
further charge. You need not require recipients to copy the
|
| 267 |
+
Corresponding Source along with the object code. If the place to
|
| 268 |
+
copy the object code is a network server, the Corresponding Source
|
| 269 |
+
may be on a different server (operated by you or a third party)
|
| 270 |
+
that supports equivalent copying facilities, provided you maintain
|
| 271 |
+
clear directions next to the object code saying where to find the
|
| 272 |
+
Corresponding Source. Regardless of what server hosts the
|
| 273 |
+
Corresponding Source, you remain obligated to ensure that it is
|
| 274 |
+
available for as long as needed to satisfy these requirements.
|
| 275 |
+
|
| 276 |
+
e) Convey the object code using peer-to-peer transmission, provided
|
| 277 |
+
you inform other peers where the object code and Corresponding
|
| 278 |
+
Source of the work are being offered to the general public at no
|
| 279 |
+
charge under subsection 6d.
|
| 280 |
+
|
| 281 |
+
A separable portion of the object code, whose source code is excluded
|
| 282 |
+
from the Corresponding Source as a System Library, need not be
|
| 283 |
+
included in conveying the object code work.
|
| 284 |
+
|
| 285 |
+
A "User Product" is either (1) a "consumer product", which means any
|
| 286 |
+
tangible personal property which is normally used for personal, family,
|
| 287 |
+
or household purposes, or (2) anything designed or sold for incorporation
|
| 288 |
+
into a dwelling. In determining whether a product is a consumer product,
|
| 289 |
+
doubtful cases shall be resolved in favor of coverage. For a particular
|
| 290 |
+
product received by a particular user, "normally used" refers to a
|
| 291 |
+
typical or common use of that class of product, regardless of the status
|
| 292 |
+
of the particular user or of the way in which the particular user
|
| 293 |
+
actually uses, or expects or is expected to use, the product. A product
|
| 294 |
+
is a consumer product regardless of whether the product has substantial
|
| 295 |
+
commercial, industrial or non-consumer uses, unless such uses represent
|
| 296 |
+
the only significant mode of use of the product.
|
| 297 |
+
|
| 298 |
+
"Installation Information" for a User Product means any methods,
|
| 299 |
+
procedures, authorization keys, or other information required to install
|
| 300 |
+
and execute modified versions of a covered work in that User Product from
|
| 301 |
+
a modified version of its Corresponding Source. The information must
|
| 302 |
+
suffice to ensure that the continued functioning of the modified object
|
| 303 |
+
code is in no case prevented or interfered with solely because
|
| 304 |
+
modification has been made.
|
| 305 |
+
|
| 306 |
+
If you convey an object code work under this section in, or with, or
|
| 307 |
+
specifically for use in, a User Product, and the conveying occurs as
|
| 308 |
+
part of a transaction in which the right of possession and use of the
|
| 309 |
+
User Product is transferred to the recipient in perpetuity or for a
|
| 310 |
+
fixed term (regardless of how the transaction is characterized), the
|
| 311 |
+
Corresponding Source conveyed under this section must be accompanied
|
| 312 |
+
by the Installation Information. But this requirement does not apply
|
| 313 |
+
if neither you nor any third party retains the ability to install
|
| 314 |
+
modified object code on the User Product (for example, the work has
|
| 315 |
+
been installed in ROM).
|
| 316 |
+
|
| 317 |
+
The requirement to provide Installation Information does not include a
|
| 318 |
+
requirement to continue to provide support service, warranty, or updates
|
| 319 |
+
for a work that has been modified or installed by the recipient, or for
|
| 320 |
+
the User Product in which it has been modified or installed. Access to a
|
| 321 |
+
network may be denied when the modification itself materially and
|
| 322 |
+
adversely affects the operation of the network or violates the rules and
|
| 323 |
+
protocols for communication across the network.
|
| 324 |
+
|
| 325 |
+
Corresponding Source conveyed, and Installation Information provided,
|
| 326 |
+
in accord with this section must be in a format that is publicly
|
| 327 |
+
documented (and with an implementation available to the public in
|
| 328 |
+
source code form), and must require no special password or key for
|
| 329 |
+
unpacking, reading or copying.
|
| 330 |
+
|
| 331 |
+
7. Additional Terms.
|
| 332 |
+
|
| 333 |
+
"Additional permissions" are terms that supplement the terms of this
|
| 334 |
+
License by making exceptions from one or more of its conditions.
|
| 335 |
+
Additional permissions that are applicable to the entire Program shall
|
| 336 |
+
be treated as though they were included in this License, to the extent
|
| 337 |
+
that they are valid under applicable law. If additional permissions
|
| 338 |
+
apply only to part of the Program, that part may be used separately
|
| 339 |
+
under those permissions, but the entire Program remains governed by
|
| 340 |
+
this License without regard to the additional permissions.
|
| 341 |
+
|
| 342 |
+
When you convey a copy of a covered work, you may at your option
|
| 343 |
+
remove any additional permissions from that copy, or from any part of
|
| 344 |
+
it. (Additional permissions may be written to require their own
|
| 345 |
+
removal in certain cases when you modify the work.) You may place
|
| 346 |
+
additional permissions on material, added by you to a covered work,
|
| 347 |
+
for which you have or can give appropriate copyright permission.
|
| 348 |
+
|
| 349 |
+
Notwithstanding any other provision of this License, for material you
|
| 350 |
+
add to a covered work, you may (if authorized by the copyright holders of
|
| 351 |
+
that material) supplement the terms of this License with terms:
|
| 352 |
+
|
| 353 |
+
a) Disclaiming warranty or limiting liability differently from the
|
| 354 |
+
terms of sections 15 and 16 of this License; or
|
| 355 |
+
|
| 356 |
+
b) Requiring preservation of specified reasonable legal notices or
|
| 357 |
+
author attributions in that material or in the Appropriate Legal
|
| 358 |
+
Notices displayed by works containing it; or
|
| 359 |
+
|
| 360 |
+
c) Prohibiting misrepresentation of the origin of that material, or
|
| 361 |
+
requiring that modified versions of such material be marked in
|
| 362 |
+
reasonable ways as different from the original version; or
|
| 363 |
+
|
| 364 |
+
d) Limiting the use for publicity purposes of names of licensors or
|
| 365 |
+
authors of the material; or
|
| 366 |
+
|
| 367 |
+
e) Declining to grant rights under trademark law for use of some
|
| 368 |
+
trade names, trademarks, or service marks; or
|
| 369 |
+
|
| 370 |
+
f) Requiring indemnification of licensors and authors of that
|
| 371 |
+
material by anyone who conveys the material (or modified versions of
|
| 372 |
+
it) with contractual assumptions of liability to the recipient, for
|
| 373 |
+
any liability that these contractual assumptions directly impose on
|
| 374 |
+
those licensors and authors.
|
| 375 |
+
|
| 376 |
+
All other non-permissive additional terms are considered "further
|
| 377 |
+
restrictions" within the meaning of section 10. If the Program as you
|
| 378 |
+
received it, or any part of it, contains a notice stating that it is
|
| 379 |
+
governed by this License along with a term that is a further
|
| 380 |
+
restriction, you may remove that term. If a license document contains
|
| 381 |
+
a further restriction but permits relicensing or conveying under this
|
| 382 |
+
License, you may add to a covered work material governed by the terms
|
| 383 |
+
of that license document, provided that the further restriction does
|
| 384 |
+
not survive such relicensing or conveying.
|
| 385 |
+
|
| 386 |
+
If you add terms to a covered work in accord with this section, you
|
| 387 |
+
must place, in the relevant source files, a statement of the
|
| 388 |
+
additional terms that apply to those files, or a notice indicating
|
| 389 |
+
where to find the applicable terms.
|
| 390 |
+
|
| 391 |
+
Additional terms, permissive or non-permissive, may be stated in the
|
| 392 |
+
form of a separately written license, or stated as exceptions;
|
| 393 |
+
the above requirements apply either way.
|
| 394 |
+
|
| 395 |
+
8. Termination.
|
| 396 |
+
|
| 397 |
+
You may not propagate or modify a covered work except as expressly
|
| 398 |
+
provided under this License. Any attempt otherwise to propagate or
|
| 399 |
+
modify it is void, and will automatically terminate your rights under
|
| 400 |
+
this License (including any patent licenses granted under the third
|
| 401 |
+
paragraph of section 11).
|
| 402 |
+
|
| 403 |
+
However, if you cease all violation of this License, then your
|
| 404 |
+
license from a particular copyright holder is reinstated (a)
|
| 405 |
+
provisionally, unless and until the copyright holder explicitly and
|
| 406 |
+
finally terminates your license, and (b) permanently, if the copyright
|
| 407 |
+
holder fails to notify you of the violation by some reasonable means
|
| 408 |
+
prior to 60 days after the cessation.
|
| 409 |
+
|
| 410 |
+
Moreover, your license from a particular copyright holder is
|
| 411 |
+
reinstated permanently if the copyright holder notifies you of the
|
| 412 |
+
violation by some reasonable means, this is the first time you have
|
| 413 |
+
received notice of violation of this License (for any work) from that
|
| 414 |
+
copyright holder, and you cure the violation prior to 30 days after
|
| 415 |
+
your receipt of the notice.
|
| 416 |
+
|
| 417 |
+
Termination of your rights under this section does not terminate the
|
| 418 |
+
licenses of parties who have received copies or rights from you under
|
| 419 |
+
this License. If your rights have been terminated and not permanently
|
| 420 |
+
reinstated, you do not qualify to receive new licenses for the same
|
| 421 |
+
material under section 10.
|
| 422 |
+
|
| 423 |
+
9. Acceptance Not Required for Having Copies.
|
| 424 |
+
|
| 425 |
+
You are not required to accept this License in order to receive or
|
| 426 |
+
run a copy of the Program. Ancillary propagation of a covered work
|
| 427 |
+
occurring solely as a consequence of using peer-to-peer transmission
|
| 428 |
+
to receive a copy likewise does not require acceptance. However,
|
| 429 |
+
nothing other than this License grants you permission to propagate or
|
| 430 |
+
modify any covered work. These actions infringe copyright if you do
|
| 431 |
+
not accept this License. Therefore, by modifying or propagating a
|
| 432 |
+
covered work, you indicate your acceptance of this License to do so.
|
| 433 |
+
|
| 434 |
+
10. Automatic Licensing of Downstream Recipients.
|
| 435 |
+
|
| 436 |
+
Each time you convey a covered work, the recipient automatically
|
| 437 |
+
receives a license from the original licensors, to run, modify and
|
| 438 |
+
propagate that work, subject to this License. You are not responsible
|
| 439 |
+
for enforcing compliance by third parties with this License.
|
| 440 |
+
|
| 441 |
+
An "entity transaction" is a transaction transferring control of an
|
| 442 |
+
organization, or substantially all assets of one, or subdividing an
|
| 443 |
+
organization, or merging organizations. If propagation of a covered
|
| 444 |
+
work results from an entity transaction, each party to that
|
| 445 |
+
transaction who receives a copy of the work also receives whatever
|
| 446 |
+
licenses to the work the party's predecessor in interest had or could
|
| 447 |
+
give under the previous paragraph, plus a right to possession of the
|
| 448 |
+
Corresponding Source of the work from the predecessor in interest, if
|
| 449 |
+
the predecessor has it or can get it with reasonable efforts.
|
| 450 |
+
|
| 451 |
+
You may not impose any further restrictions on the exercise of the
|
| 452 |
+
rights granted or affirmed under this License. For example, you may
|
| 453 |
+
not impose a license fee, royalty, or other charge for exercise of
|
| 454 |
+
rights granted under this License, and you may not initiate litigation
|
| 455 |
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
| 456 |
+
any patent claim is infringed by making, using, selling, offering for
|
| 457 |
+
sale, or importing the Program or any portion of it.
|
| 458 |
+
|
| 459 |
+
11. Patents.
|
| 460 |
+
|
| 461 |
+
A "contributor" is a copyright holder who authorizes use under this
|
| 462 |
+
License of the Program or a work on which the Program is based. The
|
| 463 |
+
work thus licensed is called the contributor's "contributor version".
|
| 464 |
+
|
| 465 |
+
A contributor's "essential patent claims" are all patent claims
|
| 466 |
+
owned or controlled by the contributor, whether already acquired or
|
| 467 |
+
hereafter acquired, that would be infringed by some manner, permitted
|
| 468 |
+
by this License, of making, using, or selling its contributor version,
|
| 469 |
+
but do not include claims that would be infringed only as a
|
| 470 |
+
consequence of further modification of the contributor version. For
|
| 471 |
+
purposes of this definition, "control" includes the right to grant
|
| 472 |
+
patent sublicenses in a manner consistent with the requirements of
|
| 473 |
+
this License.
|
| 474 |
+
|
| 475 |
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
| 476 |
+
patent license under the contributor's essential patent claims, to
|
| 477 |
+
make, use, sell, offer for sale, import and otherwise run, modify and
|
| 478 |
+
propagate the contents of its contributor version.
|
| 479 |
+
|
| 480 |
+
In the following three paragraphs, a "patent license" is any express
|
| 481 |
+
agreement or commitment, however denominated, not to enforce a patent
|
| 482 |
+
(such as an express permission to practice a patent or covenant not to
|
| 483 |
+
sue for patent infringement). To "grant" such a patent license to a
|
| 484 |
+
party means to make such an agreement or commitment not to enforce a
|
| 485 |
+
patent against the party.
|
| 486 |
+
|
| 487 |
+
If you convey a covered work, knowingly relying on a patent license,
|
| 488 |
+
and the Corresponding Source of the work is not available for anyone
|
| 489 |
+
to copy, free of charge and under the terms of this License, through a
|
| 490 |
+
publicly available network server or other readily accessible means,
|
| 491 |
+
then you must either (1) cause the Corresponding Source to be so
|
| 492 |
+
available, or (2) arrange to deprive yourself of the benefit of the
|
| 493 |
+
patent license for this particular work, or (3) arrange, in a manner
|
| 494 |
+
consistent with the requirements of this License, to extend the patent
|
| 495 |
+
license to downstream recipients. "Knowingly relying" means you have
|
| 496 |
+
actual knowledge that, but for the patent license, your conveying the
|
| 497 |
+
covered work in a country, or your recipient's use of the covered work
|
| 498 |
+
in a country, would infringe one or more identifiable patents in that
|
| 499 |
+
country that you have reason to believe are valid.
|
| 500 |
+
|
| 501 |
+
If, pursuant to or in connection with a single transaction or
|
| 502 |
+
arrangement, you convey, or propagate by procuring conveyance of, a
|
| 503 |
+
covered work, and grant a patent license to some of the parties
|
| 504 |
+
receiving the covered work authorizing them to use, propagate, modify
|
| 505 |
+
or convey a specific copy of the covered work, then the patent license
|
| 506 |
+
you grant is automatically extended to all recipients of the covered
|
| 507 |
+
work and works based on it.
|
| 508 |
+
|
| 509 |
+
A patent license is "discriminatory" if it does not include within
|
| 510 |
+
the scope of its coverage, prohibits the exercise of, or is
|
| 511 |
+
conditioned on the non-exercise of one or more of the rights that are
|
| 512 |
+
specifically granted under this License. You may not convey a covered
|
| 513 |
+
work if you are a party to an arrangement with a third party that is
|
| 514 |
+
in the business of distributing software, under which you make payment
|
| 515 |
+
to the third party based on the extent of your activity of conveying
|
| 516 |
+
the work, and under which the third party grants, to any of the
|
| 517 |
+
parties who would receive the covered work from you, a discriminatory
|
| 518 |
+
patent license (a) in connection with copies of the covered work
|
| 519 |
+
conveyed by you (or copies made from those copies), or (b) primarily
|
| 520 |
+
for and in connection with specific products or compilations that
|
| 521 |
+
contain the covered work, unless you entered into that arrangement,
|
| 522 |
+
or that patent license was granted, prior to 28 March 2007.
|
| 523 |
+
|
| 524 |
+
Nothing in this License shall be construed as excluding or limiting
|
| 525 |
+
any implied license or other defenses to infringement that may
|
| 526 |
+
otherwise be available to you under applicable patent law.
|
| 527 |
+
|
| 528 |
+
12. No Surrender of Others' Freedom.
|
| 529 |
+
|
| 530 |
+
If conditions are imposed on you (whether by court order, agreement or
|
| 531 |
+
otherwise) that contradict the conditions of this License, they do not
|
| 532 |
+
excuse you from the conditions of this License. If you cannot convey a
|
| 533 |
+
covered work so as to satisfy simultaneously your obligations under this
|
| 534 |
+
License and any other pertinent obligations, then as a consequence you may
|
| 535 |
+
not convey it at all. For example, if you agree to terms that obligate you
|
| 536 |
+
to collect a royalty for further conveying from those to whom you convey
|
| 537 |
+
the Program, the only way you could satisfy both those terms and this
|
| 538 |
+
License would be to refrain entirely from conveying the Program.
|
| 539 |
+
|
| 540 |
+
13. Remote Network Interaction; Use with the GNU General Public License.
|
| 541 |
+
|
| 542 |
+
Notwithstanding any other provision of this License, if you modify the
|
| 543 |
+
Program, your modified version must prominently offer all users
|
| 544 |
+
interacting with it remotely through a computer network (if your version
|
| 545 |
+
supports such interaction) an opportunity to receive the Corresponding
|
| 546 |
+
Source of your version by providing access to the Corresponding Source
|
| 547 |
+
from a network server at no charge, through some standard or customary
|
| 548 |
+
means of facilitating copying of software. This Corresponding Source
|
| 549 |
+
shall include the Corresponding Source for any work covered by version 3
|
| 550 |
+
of the GNU General Public License that is incorporated pursuant to the
|
| 551 |
+
following paragraph.
|
| 552 |
+
|
| 553 |
+
Notwithstanding any other provision of this License, you have
|
| 554 |
+
permission to link or combine any covered work with a work licensed
|
| 555 |
+
under version 3 of the GNU General Public License into a single
|
| 556 |
+
combined work, and to convey the resulting work. The terms of this
|
| 557 |
+
License will continue to apply to the part which is the covered work,
|
| 558 |
+
but the work with which it is combined will remain governed by version
|
| 559 |
+
3 of the GNU General Public License.
|
| 560 |
+
|
| 561 |
+
14. Revised Versions of this License.
|
| 562 |
+
|
| 563 |
+
The Free Software Foundation may publish revised and/or new versions of
|
| 564 |
+
the GNU Affero General Public License from time to time. Such new versions
|
| 565 |
+
will be similar in spirit to the present version, but may differ in detail to
|
| 566 |
+
address new problems or concerns.
|
| 567 |
+
|
| 568 |
+
Each version is given a distinguishing version number. If the
|
| 569 |
+
Program specifies that a certain numbered version of the GNU Affero General
|
| 570 |
+
Public License "or any later version" applies to it, you have the
|
| 571 |
+
option of following the terms and conditions either of that numbered
|
| 572 |
+
version or of any later version published by the Free Software
|
| 573 |
+
Foundation. If the Program does not specify a version number of the
|
| 574 |
+
GNU Affero General Public License, you may choose any version ever published
|
| 575 |
+
by the Free Software Foundation.
|
| 576 |
+
|
| 577 |
+
If the Program specifies that a proxy can decide which future
|
| 578 |
+
versions of the GNU Affero General Public License can be used, that proxy's
|
| 579 |
+
public statement of acceptance of a version permanently authorizes you
|
| 580 |
+
to choose that version for the Program.
|
| 581 |
+
|
| 582 |
+
Later license versions may give you additional or different
|
| 583 |
+
permissions. However, no additional obligations are imposed on any
|
| 584 |
+
author or copyright holder as a result of your choosing to follow a
|
| 585 |
+
later version.
|
| 586 |
+
|
| 587 |
+
15. Disclaimer of Warranty.
|
| 588 |
+
|
| 589 |
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
| 590 |
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
| 591 |
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
| 592 |
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
| 593 |
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
| 594 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
| 595 |
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
| 596 |
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
| 597 |
+
|
| 598 |
+
16. Limitation of Liability.
|
| 599 |
+
|
| 600 |
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
| 601 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
| 602 |
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
| 603 |
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
| 604 |
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
| 605 |
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
| 606 |
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
| 607 |
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
| 608 |
+
SUCH DAMAGES.
|
| 609 |
+
|
| 610 |
+
17. Interpretation of Sections 15 and 16.
|
| 611 |
+
|
| 612 |
+
If the disclaimer of warranty and limitation of liability provided
|
| 613 |
+
above cannot be given local legal effect according to their terms,
|
| 614 |
+
reviewing courts shall apply local law that most closely approximates
|
| 615 |
+
an absolute waiver of all civil liability in connection with the
|
| 616 |
+
Program, unless a warranty or assumption of liability accompanies a
|
| 617 |
+
copy of the Program in return for a fee.
|
| 618 |
+
|
| 619 |
+
END OF TERMS AND CONDITIONS
|
| 620 |
+
|
| 621 |
+
How to Apply These Terms to Your New Programs
|
| 622 |
+
|
| 623 |
+
If you develop a new program, and you want it to be of the greatest
|
| 624 |
+
possible use to the public, the best way to achieve this is to make it
|
| 625 |
+
free software which everyone can redistribute and change under these terms.
|
| 626 |
+
|
| 627 |
+
To do so, attach the following notices to the program. It is safest
|
| 628 |
+
to attach them to the start of each source file to most effectively
|
| 629 |
+
state the exclusion of warranty; and each file should have at least
|
| 630 |
+
the "copyright" line and a pointer to where the full notice is found.
|
| 631 |
+
|
| 632 |
+
<one line to give the program's name and a brief idea of what it does.>
|
| 633 |
+
Copyright (C) <year> <name of author>
|
| 634 |
+
|
| 635 |
+
This program is free software: you can redistribute it and/or modify
|
| 636 |
+
it under the terms of the GNU Affero General Public License as published by
|
| 637 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 638 |
+
(at your option) any later version.
|
| 639 |
+
|
| 640 |
+
This program is distributed in the hope that it will be useful,
|
| 641 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 642 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 643 |
+
GNU Affero General Public License for more details.
|
| 644 |
+
|
| 645 |
+
You should have received a copy of the GNU Affero General Public License
|
| 646 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 647 |
+
|
| 648 |
+
Also add information on how to contact you by electronic and paper mail.
|
| 649 |
+
|
| 650 |
+
If your software can interact with users remotely through a computer
|
| 651 |
+
network, you should also make sure that it provides a way for users to
|
| 652 |
+
get its source. For example, if your program is a web application, its
|
| 653 |
+
interface could display a "Source" link that leads users to an archive
|
| 654 |
+
of the code. There are many ways you could offer source, and different
|
| 655 |
+
solutions will be better for different programs; see section 13 for the
|
| 656 |
+
specific requirements.
|
| 657 |
+
|
| 658 |
+
You should also get your employer (if you work as a programmer) or school,
|
| 659 |
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
| 660 |
+
For more information on this, and how to apply and follow the GNU AGPL, see
|
| 661 |
+
<https://www.gnu.org/licenses/>.
|
Procfile
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
web: python -m FileStream
|
|
|
|
|
|
addons.txt
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
covid
|
| 2 |
+
emoji
|
| 3 |
+
fonttools
|
| 4 |
+
gtts
|
| 5 |
+
# gingerit
|
| 6 |
+
jikanpy
|
| 7 |
+
git+https://github.com/New-dev0/AsyncLyricsExtractor.git
|
| 8 |
+
git+https://github.com/ufoptg/drawHub.git
|
| 9 |
+
pokedex.py
|
| 10 |
+
pyfiglet
|
| 11 |
+
pygments
|
| 12 |
+
pyjokes
|
| 13 |
+
quotefancy
|
| 14 |
+
shazamio
|
| 15 |
+
speechrecognition
|
| 16 |
+
speedtest-cli
|
| 17 |
+
textblob
|
| 18 |
+
wikipedia
|
| 19 |
+
https://github.com/ufoptg/google_trans_new/archive/refs/tags/1.2.0.zip
|
app.json
DELETED
|
@@ -1,117 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "FileStreamBot",
|
| 3 |
-
"description": "A Telegram Bot to Convert Telegram Files To Direct & Streamable Links.",
|
| 4 |
-
"keywords": [
|
| 5 |
-
"telegram",
|
| 6 |
-
"files",
|
| 7 |
-
"stream"
|
| 8 |
-
],
|
| 9 |
-
"repository": "https://github.com/avipatilpro/FileStreamBot/",
|
| 10 |
-
"success_url": "/",
|
| 11 |
-
"logo": "https://i.ibb.co/ZJzJ9Hq/link-3x.png",
|
| 12 |
-
"env": {
|
| 13 |
-
"ENV": {
|
| 14 |
-
"description": "Set this to True if you don't want to crash the bot",
|
| 15 |
-
"value": "True"
|
| 16 |
-
},
|
| 17 |
-
"API_ID": {
|
| 18 |
-
"description": "Get this value from https://my.telegram.org"
|
| 19 |
-
},
|
| 20 |
-
"API_HASH": {
|
| 21 |
-
"description": "Get this value from https://my.telegram.org"
|
| 22 |
-
},
|
| 23 |
-
"BOT_TOKEN": {
|
| 24 |
-
"description": "Get this value from @BotFather"
|
| 25 |
-
},
|
| 26 |
-
"FLOG_CHANNEL": {
|
| 27 |
-
"description": "ID of Channel Where store files sent by users. Read the readme for more info about this var"
|
| 28 |
-
},
|
| 29 |
-
"ULOG_CHANNEL": {
|
| 30 |
-
"description": "ID of Channel Where store New Users data. Read the readme for more info about this var"
|
| 31 |
-
},
|
| 32 |
-
"OWNER_ID": {
|
| 33 |
-
"description": "Your Telegram User ID as Owner"
|
| 34 |
-
},
|
| 35 |
-
"DATABASE_URL": {
|
| 36 |
-
"description": "MongoDB URI for saving User Data and Files List created by user."
|
| 37 |
-
},
|
| 38 |
-
"AUTH_USERS": {
|
| 39 |
-
"description": "Put IDs of Auth Usrs where bot will work. You can add multiple IDs & separate with Space.",
|
| 40 |
-
"required": false
|
| 41 |
-
},
|
| 42 |
-
"UPDATES_CHANNEL": {
|
| 43 |
-
"description": "Channel Username without `@` to set channel as Update Channel",
|
| 44 |
-
"required": false
|
| 45 |
-
},
|
| 46 |
-
"FORCE_SUB_ID": {
|
| 47 |
-
"description": "Channel ID starts with -100 to set channel as Force Sub Channel",
|
| 48 |
-
"required": false
|
| 49 |
-
},
|
| 50 |
-
"FORCE_SUB": {
|
| 51 |
-
"description": "Set to True, so every user have to Join update channel to use the bot.",
|
| 52 |
-
"required": false
|
| 53 |
-
},
|
| 54 |
-
"SLEEP_THRESHOLD": {
|
| 55 |
-
"description": "Set global flood wait threshold, auto-retry requests under 60s. ",
|
| 56 |
-
"required": false
|
| 57 |
-
},
|
| 58 |
-
"WORKERS": {
|
| 59 |
-
"description": "No. of workers that is to be assigned.",
|
| 60 |
-
"required": false
|
| 61 |
-
},
|
| 62 |
-
"PORT": {
|
| 63 |
-
"description": "The port that you want your webapp to be listened to",
|
| 64 |
-
"required": false
|
| 65 |
-
},
|
| 66 |
-
"NO_PORT": {
|
| 67 |
-
"description": "If you don't want your port to be displayed. Set True or False",
|
| 68 |
-
"value": "True",
|
| 69 |
-
"required": false
|
| 70 |
-
},
|
| 71 |
-
"HAS_SSL": {
|
| 72 |
-
"description": "(can be either True or False) If you want the generated links in https format.",
|
| 73 |
-
"value": "True",
|
| 74 |
-
"required": false
|
| 75 |
-
},
|
| 76 |
-
"BIND_ADDRESS": {
|
| 77 |
-
"description": "Your server bind address. default to 0.0.0.0",
|
| 78 |
-
"required": false
|
| 79 |
-
},
|
| 80 |
-
"FQDN": {
|
| 81 |
-
"description": "Heroku app Link without http/s://, you can set later. its required",
|
| 82 |
-
"required": false
|
| 83 |
-
},
|
| 84 |
-
"SESSION_NAME": {
|
| 85 |
-
"description": "Name for the Database created on your MongoDB. Defaults to FileStream",
|
| 86 |
-
"required": false
|
| 87 |
-
},
|
| 88 |
-
"FILE_PIC": {
|
| 89 |
-
"description": "To set Image at /files command. Defaults to pre-set image.",
|
| 90 |
-
"required": false
|
| 91 |
-
},
|
| 92 |
-
"START_PIC": {
|
| 93 |
-
"description": "To set Image at /start command. Defaults to pre-set image.",
|
| 94 |
-
"required": false
|
| 95 |
-
},
|
| 96 |
-
"VERIFY_PIC": {
|
| 97 |
-
"description": "To set Image at Force Subscribe Verify. Defaults to pre-set image.",
|
| 98 |
-
"required": false
|
| 99 |
-
},
|
| 100 |
-
"MODE": {
|
| 101 |
-
"description": "Should be set to `secondary` if you only want to use the server for serving files.",
|
| 102 |
-
"required": false
|
| 103 |
-
}
|
| 104 |
-
},
|
| 105 |
-
"buildpacks": [
|
| 106 |
-
{
|
| 107 |
-
"url": "heroku/python"
|
| 108 |
-
}
|
| 109 |
-
],
|
| 110 |
-
"stack": "heroku-22",
|
| 111 |
-
"formation": {
|
| 112 |
-
"web": {
|
| 113 |
-
"quantity": 1,
|
| 114 |
-
"size": "eco"
|
| 115 |
-
}
|
| 116 |
-
}
|
| 117 |
-
}
|
|
|
|
|
|
|
|
|
|
|
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ltroid/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 Button, custom
|
| 9 |
+
|
| 10 |
+
from plugins import ATRA_COL, InlinePlugin
|
| 11 |
+
from pyUltroid import *
|
| 12 |
+
from pyUltroid import _ult_cache
|
| 13 |
+
from pyUltroid._misc import owner_and_sudos
|
| 14 |
+
from pyUltroid._misc._assistant import asst_cmd, callback, in_pattern
|
| 15 |
+
from pyUltroid.fns.helper import *
|
| 16 |
+
from pyUltroid.fns.tools import get_stored_file
|
| 17 |
+
from strings import get_languages, get_string
|
| 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 as er:
|
| 29 |
+
LOGS.exception(er)
|
| 30 |
+
return await event.edit("`Something Went Wrong`")
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def get_back_button(name):
|
| 34 |
+
return [Button.inline("« Bᴀᴄᴋ", data=f"{name}")]
|
assistant/callbackstuffs.py
ADDED
|
@@ -0,0 +1,1325 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ultroid - UserBot
|
| 2 |
+
# Copyright (C) 2021-2023 TeamUltroid
|
| 3 |
+
#
|
| 4 |
+
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
| 5 |
+
# PLease read the GNU Affero General Public License in
|
| 6 |
+
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
| 7 |
+
|
| 8 |
+
import ast
|
| 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 |
+
|
| 19 |
+
try:
|
| 20 |
+
from pyUltroid.fns.gDrive import GDriveManager
|
| 21 |
+
except ImportError:
|
| 22 |
+
GDriveManager = None
|
| 23 |
+
from telegraph import upload_file as upl
|
| 24 |
+
from telethon import Button, events
|
| 25 |
+
from telethon.tl.types import MessageMediaWebPage
|
| 26 |
+
from telethon.utils import get_peer_id
|
| 27 |
+
|
| 28 |
+
from pyUltroid.fns.helper import fast_download, progress
|
| 29 |
+
from pyUltroid.fns.tools import Carbon, async_searcher, get_paste, telegraph_client
|
| 30 |
+
from pyUltroid.startup.loader import Loader
|
| 31 |
+
|
| 32 |
+
from . import *
|
| 33 |
+
|
| 34 |
+
# --------------------------------------------------------------------#
|
| 35 |
+
telegraph = telegraph_client()
|
| 36 |
+
GDrive = GDriveManager() if GDriveManager else None
|
| 37 |
+
# --------------------------------------------------------------------#
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def text_to_url(event):
|
| 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 @TeamUltroid:",
|
| 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 |
+
"alvcstm": {
|
| 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("SERP API", data="abs_sapi")],
|
| 181 |
+
[Button.inline("« Back", data="setter")],
|
| 182 |
+
],
|
| 183 |
+
},
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
_convo = {
|
| 187 |
+
"rmbg": {
|
| 188 |
+
"var": "RMBG_API",
|
| 189 |
+
"name": "Remove.bg API Key",
|
| 190 |
+
"text": get_string("ast_2"),
|
| 191 |
+
"back": "cbs_apiset",
|
| 192 |
+
},
|
| 193 |
+
"dapi": {
|
| 194 |
+
"var": "DEEP_AI",
|
| 195 |
+
"name": "Deep AI Api Key",
|
| 196 |
+
"text": "Get Your Deep Api from deepai.org and send here.",
|
| 197 |
+
"back": "cbs_apiset",
|
| 198 |
+
},
|
| 199 |
+
"oapi": {
|
| 200 |
+
"var": "OCR_API",
|
| 201 |
+
"name": "Ocr Api Key",
|
| 202 |
+
"text": "Get Your OCR api from ocr.space and send that Here.",
|
| 203 |
+
"back": "cbs_apiset",
|
| 204 |
+
},
|
| 205 |
+
"sapi": {
|
| 206 |
+
"var": "SERPAPI",
|
| 207 |
+
"name": "Serp Api Key",
|
| 208 |
+
"text": "Get Your SERP api from https://serpapi.com/users/sign_in and send that Here.",
|
| 209 |
+
"back": "cbs_apiset",
|
| 210 |
+
},
|
| 211 |
+
"pmlgg": {
|
| 212 |
+
"var": "PMLOGGROUP",
|
| 213 |
+
"name": "Pm Log Group",
|
| 214 |
+
"text": "Send chat id of chat which you want to save as Pm log Group.",
|
| 215 |
+
"back": "pml",
|
| 216 |
+
},
|
| 217 |
+
"vcs": {
|
| 218 |
+
"var": "VC_SESSION",
|
| 219 |
+
"name": "Vc Session",
|
| 220 |
+
"text": "**Vc session**\nEnter the New session u generated for vc bot.\n\nUse /cancel to terminate the operation.",
|
| 221 |
+
"back": "cbs_vcb",
|
| 222 |
+
},
|
| 223 |
+
"settag": {
|
| 224 |
+
"var": "TAG_LOG",
|
| 225 |
+
"name": "Tag Log Group",
|
| 226 |
+
"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.",
|
| 227 |
+
"back": "taglog",
|
| 228 |
+
},
|
| 229 |
+
"alvtx": {
|
| 230 |
+
"var": "ALIVE_TEXT",
|
| 231 |
+
"name": "Alive Text",
|
| 232 |
+
"text": "**Alive Text**\nEnter the new alive text.\n\nUse /cancel to terminate the operation.",
|
| 233 |
+
"back": "cbs_alvcstm",
|
| 234 |
+
},
|
| 235 |
+
"sfexf": {
|
| 236 |
+
"var": "EXCLUDE_FED",
|
| 237 |
+
"name": "Excluded Fed",
|
| 238 |
+
"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.",
|
| 239 |
+
"back": "cbs_sfban",
|
| 240 |
+
},
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
TOKEN_FILE = "resources/auths/auth_token.txt"
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
@callback(
|
| 248 |
+
re.compile(
|
| 249 |
+
"sndplug_(.*)",
|
| 250 |
+
),
|
| 251 |
+
owner=True,
|
| 252 |
+
)
|
| 253 |
+
async def send(eve):
|
| 254 |
+
key, name = (eve.data_match.group(1)).decode("UTF-8").split("_")
|
| 255 |
+
thumb = "resources/extras/inline.jpg"
|
| 256 |
+
await eve.answer("■ Sending ■")
|
| 257 |
+
data = f"uh_{key}_"
|
| 258 |
+
index = None
|
| 259 |
+
if "|" in name:
|
| 260 |
+
name, index = name.split("|")
|
| 261 |
+
key = "plugins" if key == "Official" else key.lower()
|
| 262 |
+
plugin = f"{key}/{name}.py"
|
| 263 |
+
_ = f"pasta-{plugin}"
|
| 264 |
+
if index is not None:
|
| 265 |
+
data += f"|{index}"
|
| 266 |
+
_ += f"|{index}"
|
| 267 |
+
buttons = [
|
| 268 |
+
[
|
| 269 |
+
Button.inline(
|
| 270 |
+
"« Pᴀsᴛᴇ »",
|
| 271 |
+
data=_,
|
| 272 |
+
)
|
| 273 |
+
],
|
| 274 |
+
[
|
| 275 |
+
Button.inline("« Bᴀᴄᴋ", data=data),
|
| 276 |
+
],
|
| 277 |
+
]
|
| 278 |
+
try:
|
| 279 |
+
await eve.edit(file=plugin, thumb=thumb, buttons=buttons)
|
| 280 |
+
except Exception as er:
|
| 281 |
+
await eve.answer(str(er), alert=True)
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
heroku_api, app_name = Var.HEROKU_API, Var.HEROKU_APP_NAME
|
| 285 |
+
|
| 286 |
+
|
| 287 |
+
@callback("updatenow", owner=True)
|
| 288 |
+
async def update(eve):
|
| 289 |
+
repo = Repo()
|
| 290 |
+
ac_br = repo.active_branch
|
| 291 |
+
ups_rem = repo.remote("upstream")
|
| 292 |
+
if heroku_api:
|
| 293 |
+
import heroku3
|
| 294 |
+
|
| 295 |
+
try:
|
| 296 |
+
heroku = heroku3.from_key(heroku_api)
|
| 297 |
+
heroku_app = None
|
| 298 |
+
heroku_applications = heroku.apps()
|
| 299 |
+
except BaseException as er:
|
| 300 |
+
LOGS.exception(er)
|
| 301 |
+
return await eve.edit("`Wrong HEROKU_API.`")
|
| 302 |
+
for app in heroku_applications:
|
| 303 |
+
if app.name == app_name:
|
| 304 |
+
heroku_app = app
|
| 305 |
+
if not heroku_app:
|
| 306 |
+
await eve.edit("`Wrong HEROKU_APP_NAME.`")
|
| 307 |
+
repo.__del__()
|
| 308 |
+
return
|
| 309 |
+
await eve.edit(get_string("clst_1"))
|
| 310 |
+
ups_rem.fetch(ac_br)
|
| 311 |
+
repo.git.reset("--hard", "FETCH_HEAD")
|
| 312 |
+
heroku_git_url = heroku_app.git_url.replace(
|
| 313 |
+
"https://", f"https://api:{heroku_api}@"
|
| 314 |
+
)
|
| 315 |
+
|
| 316 |
+
if "heroku" in repo.remotes:
|
| 317 |
+
remote = repo.remote("heroku")
|
| 318 |
+
remote.set_url(heroku_git_url)
|
| 319 |
+
else:
|
| 320 |
+
remote = repo.create_remote("heroku", heroku_git_url)
|
| 321 |
+
try:
|
| 322 |
+
remote.push(refspec=f"HEAD:refs/heads/{ac_br}", force=True)
|
| 323 |
+
except GitCommandError as error:
|
| 324 |
+
await eve.edit(f"`Here is the error log:\n{error}`")
|
| 325 |
+
repo.__del__()
|
| 326 |
+
return
|
| 327 |
+
await eve.edit("`Successfully Updated!\nRestarting, please wait...`")
|
| 328 |
+
else:
|
| 329 |
+
await eve.edit(get_string("clst_1"))
|
| 330 |
+
call_back()
|
| 331 |
+
await bash("git pull && pip3 install -r requirements.txt")
|
| 332 |
+
execl(sys.executable, sys.executable, "-m", "pyUltroid")
|
| 333 |
+
|
| 334 |
+
|
| 335 |
+
@callback(re.compile("changes(.*)"), owner=True)
|
| 336 |
+
async def changes(okk):
|
| 337 |
+
match = okk.data_match.group(1).decode("utf-8")
|
| 338 |
+
await okk.answer(get_string("clst_3"))
|
| 339 |
+
repo = Repo.init()
|
| 340 |
+
button = [[Button.inline("Update Now", data="updatenow")]]
|
| 341 |
+
changelog, tl_chnglog = await gen_chlog(
|
| 342 |
+
repo, f"HEAD..upstream/{repo.active_branch}"
|
| 343 |
+
)
|
| 344 |
+
cli = "\n\nClick the below button to update!"
|
| 345 |
+
if not match:
|
| 346 |
+
try:
|
| 347 |
+
if len(tl_chnglog) > 700:
|
| 348 |
+
tl_chnglog = f"{tl_chnglog[:700]}..."
|
| 349 |
+
button.append([Button.inline("View Complete", "changesall")])
|
| 350 |
+
await okk.edit("• Writing Changelogs 📝 •")
|
| 351 |
+
img = await Carbon(
|
| 352 |
+
file_name="changelog",
|
| 353 |
+
code=tl_chnglog,
|
| 354 |
+
backgroundColor=choice(ATRA_COL),
|
| 355 |
+
language="md",
|
| 356 |
+
)
|
| 357 |
+
return await okk.edit(
|
| 358 |
+
f"**• Ultroid Userbot •**{cli}", file=img, buttons=button
|
| 359 |
+
)
|
| 360 |
+
except Exception as er:
|
| 361 |
+
LOGS.exception(er)
|
| 362 |
+
changelog_str = changelog + cli
|
| 363 |
+
if len(changelog_str) > 1024:
|
| 364 |
+
await okk.edit(get_string("upd_4"))
|
| 365 |
+
await asyncio.sleep(2)
|
| 366 |
+
with open("ultroid_updates.txt", "w+") as file:
|
| 367 |
+
file.write(tl_chnglog)
|
| 368 |
+
await okk.edit(
|
| 369 |
+
get_string("upd_5"),
|
| 370 |
+
file="ultroid_updates.txt",
|
| 371 |
+
buttons=button,
|
| 372 |
+
)
|
| 373 |
+
remove("ultroid_updates.txt")
|
| 374 |
+
return
|
| 375 |
+
await okk.edit(
|
| 376 |
+
changelog_str,
|
| 377 |
+
buttons=button,
|
| 378 |
+
parse_mode="html",
|
| 379 |
+
)
|
| 380 |
+
|
| 381 |
+
|
| 382 |
+
@callback(
|
| 383 |
+
re.compile(
|
| 384 |
+
"pasta-(.*)",
|
| 385 |
+
),
|
| 386 |
+
owner=True,
|
| 387 |
+
)
|
| 388 |
+
async def _(e):
|
| 389 |
+
ok = (e.data_match.group(1)).decode("UTF-8")
|
| 390 |
+
index = None
|
| 391 |
+
if "|" in ok:
|
| 392 |
+
ok, index = ok.split("|")
|
| 393 |
+
with open(ok, "r") as hmm:
|
| 394 |
+
_, key = await get_paste(hmm.read())
|
| 395 |
+
link = f"https://spaceb.in/{key}"
|
| 396 |
+
raw = f"https://spaceb.in/api/v1/documents/{key}/raw"
|
| 397 |
+
if not _:
|
| 398 |
+
return await e.answer(key[:30], alert=True)
|
| 399 |
+
if ok.startswith("addons"):
|
| 400 |
+
key = "Addons"
|
| 401 |
+
elif ok.startswith("vcbot"):
|
| 402 |
+
key = "VCBot"
|
| 403 |
+
else:
|
| 404 |
+
key = "Official"
|
| 405 |
+
data = f"uh_{key}_"
|
| 406 |
+
if index is not None:
|
| 407 |
+
data += f"|{index}"
|
| 408 |
+
await e.edit(
|
| 409 |
+
"",
|
| 410 |
+
buttons=[
|
| 411 |
+
[Button.url("Lɪɴᴋ", link), Button.url("Rᴀᴡ", raw)],
|
| 412 |
+
[Button.inline("« Bᴀᴄᴋ", data=data)],
|
| 413 |
+
],
|
| 414 |
+
)
|
| 415 |
+
|
| 416 |
+
|
| 417 |
+
@callback(re.compile("cbs_(.*)"), owner=True)
|
| 418 |
+
async def _edit_to(event):
|
| 419 |
+
match = event.data_match.group(1).decode("utf-8")
|
| 420 |
+
data = _buttons.get(match)
|
| 421 |
+
if not data:
|
| 422 |
+
return
|
| 423 |
+
await event.edit(data["text"], buttons=data["buttons"], link_preview=False)
|
| 424 |
+
|
| 425 |
+
|
| 426 |
+
@callback(re.compile("abs_(.*)"), owner=True)
|
| 427 |
+
async def convo_handler(event: events.CallbackQuery):
|
| 428 |
+
match = event.data_match.group(1).decode("utf-8")
|
| 429 |
+
if not _convo.get(match):
|
| 430 |
+
return
|
| 431 |
+
await event.delete()
|
| 432 |
+
get_ = _convo[match]
|
| 433 |
+
back = get_["back"]
|
| 434 |
+
async with event.client.conversation(event.sender_id) as conv:
|
| 435 |
+
await conv.send_message(get_["text"])
|
| 436 |
+
response = await conv.get_response()
|
| 437 |
+
themssg = response.message
|
| 438 |
+
try:
|
| 439 |
+
themssg = ast.literal_eval(themssg)
|
| 440 |
+
except Exception:
|
| 441 |
+
pass
|
| 442 |
+
if themssg == "/cancel":
|
| 443 |
+
return await conv.send_message(
|
| 444 |
+
"Cancelled!!",
|
| 445 |
+
buttons=get_back_button(back),
|
| 446 |
+
)
|
| 447 |
+
await setit(event, get_["var"], themssg)
|
| 448 |
+
await conv.send_message(
|
| 449 |
+
f"{get_['name']} changed to `{themssg}`",
|
| 450 |
+
buttons=get_back_button(back),
|
| 451 |
+
)
|
| 452 |
+
|
| 453 |
+
|
| 454 |
+
@callback("authorise", owner=True)
|
| 455 |
+
async def _(e):
|
| 456 |
+
if not e.is_private:
|
| 457 |
+
return
|
| 458 |
+
url = GDrive._create_token_file()
|
| 459 |
+
await e.edit("Go to the below link and send the code!")
|
| 460 |
+
async with asst.conversation(e.sender_id) as conv:
|
| 461 |
+
await conv.send_message(url)
|
| 462 |
+
code = await conv.get_response()
|
| 463 |
+
if GDrive._create_token_file(code=code.text):
|
| 464 |
+
await conv.send_message(
|
| 465 |
+
"`Success!\nYou are all set to use Google Drive with Ultroid Userbot.`",
|
| 466 |
+
buttons=Button.inline("Main Menu", data="setter"),
|
| 467 |
+
)
|
| 468 |
+
else:
|
| 469 |
+
await conv.send_message("Wrong code! Click authorise again.")
|
| 470 |
+
|
| 471 |
+
|
| 472 |
+
@callback("folderid", owner=True, func=lambda x: x.is_private)
|
| 473 |
+
async def _(e):
|
| 474 |
+
if not e.is_private:
|
| 475 |
+
return
|
| 476 |
+
msg = (
|
| 477 |
+
"Send your FOLDER ID\n\n"
|
| 478 |
+
+ "For FOLDER ID:\n"
|
| 479 |
+
+ "1. Open Google Drive App.\n"
|
| 480 |
+
+ "2. Create Folder.\n"
|
| 481 |
+
+ "3. Make that folder public.\n"
|
| 482 |
+
+ "4. Send link of that folder."
|
| 483 |
+
)
|
| 484 |
+
await e.delete()
|
| 485 |
+
async with asst.conversation(e.sender_id, timeout=150) as conv:
|
| 486 |
+
await conv.send_message(msg)
|
| 487 |
+
repl = await conv.get_response()
|
| 488 |
+
id = repl.text
|
| 489 |
+
if id.startswith("https"):
|
| 490 |
+
id = id.split("?id=")[-1]
|
| 491 |
+
udB.set_key("GDRIVE_FOLDER_ID", id)
|
| 492 |
+
await repl.reply(
|
| 493 |
+
"`Success.`",
|
| 494 |
+
buttons=get_back_button("gdrive"),
|
| 495 |
+
)
|
| 496 |
+
|
| 497 |
+
|
| 498 |
+
@callback("gdrive", owner=True)
|
| 499 |
+
async def _(e):
|
| 500 |
+
if not e.is_private:
|
| 501 |
+
return
|
| 502 |
+
await e.edit(
|
| 503 |
+
"Click Authorise and send the code.\n\nYou can use your own CLIENT ID and SECRET by [this](https://t.me/UltroidUpdates/37)",
|
| 504 |
+
buttons=[
|
| 505 |
+
[
|
| 506 |
+
Button.inline("Folder ID", data="folderid"),
|
| 507 |
+
Button.inline("Authorise", data="authorise"),
|
| 508 |
+
],
|
| 509 |
+
[Button.inline("« Back", data="cbs_otvars")],
|
| 510 |
+
],
|
| 511 |
+
link_preview=False,
|
| 512 |
+
)
|
| 513 |
+
|
| 514 |
+
|
| 515 |
+
@callback("dmof", owner=True)
|
| 516 |
+
async def rhwhe(e):
|
| 517 |
+
if udB.get_key("DUAL_MODE"):
|
| 518 |
+
udB.del_key("DUAL_MODE")
|
| 519 |
+
key = "Off"
|
| 520 |
+
else:
|
| 521 |
+
udB.set_key("DUAL_MODE", "True")
|
| 522 |
+
key = "On"
|
| 523 |
+
Msg = f"Dual Mode : {key}"
|
| 524 |
+
await e.edit(Msg, buttons=get_back_button("cbs_otvars"))
|
| 525 |
+
|
| 526 |
+
|
| 527 |
+
@callback("dmhn", owner=True)
|
| 528 |
+
async def hndlrr(event):
|
| 529 |
+
await event.delete()
|
| 530 |
+
pru = event.sender_id
|
| 531 |
+
var = "DUAL_HNDLR"
|
| 532 |
+
name = "Dual Handler"
|
| 533 |
+
CH = udB.get_key(var) or "/"
|
| 534 |
+
async with event.client.conversation(pru) as conv:
|
| 535 |
+
await conv.send_message(
|
| 536 |
+
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.",
|
| 537 |
+
)
|
| 538 |
+
response = conv.wait_event(events.NewMessage(chats=pru))
|
| 539 |
+
response = await response
|
| 540 |
+
themssg = response.message.message
|
| 541 |
+
if themssg == "/cancel":
|
| 542 |
+
await conv.send_message(
|
| 543 |
+
"Cancelled!!",
|
| 544 |
+
buttons=get_back_button("cbs_otvars"),
|
| 545 |
+
)
|
| 546 |
+
elif len(themssg) > 1:
|
| 547 |
+
await conv.send_message(
|
| 548 |
+
"Incorrect Handler",
|
| 549 |
+
buttons=get_back_button("cbs_otvars"),
|
| 550 |
+
)
|
| 551 |
+
else:
|
| 552 |
+
await setit(event, var, themssg)
|
| 553 |
+
await conv.send_message(
|
| 554 |
+
f"{name} changed to {themssg}",
|
| 555 |
+
buttons=get_back_button("cbs_otvars"),
|
| 556 |
+
)
|
| 557 |
+
|
| 558 |
+
|
| 559 |
+
@callback("emoj", owner=True)
|
| 560 |
+
async def emoji(event):
|
| 561 |
+
await event.delete()
|
| 562 |
+
pru = event.sender_id
|
| 563 |
+
var = "EMOJI_IN_HELP"
|
| 564 |
+
name = f"Emoji in `{HNDLR}help` menu"
|
| 565 |
+
async with event.client.conversation(pru) as conv:
|
| 566 |
+
await conv.send_message("Send emoji u want to set 🙃.\n\nUse /cancel to cancel.")
|
| 567 |
+
response = conv.wait_event(events.NewMessage(chats=pru))
|
| 568 |
+
response = await response
|
| 569 |
+
themssg = response.message.message
|
| 570 |
+
if themssg == "/cancel":
|
| 571 |
+
await conv.send_message(
|
| 572 |
+
"Cancelled!!",
|
| 573 |
+
buttons=get_back_button("cbs_otvars"),
|
| 574 |
+
)
|
| 575 |
+
elif themssg.startswith(("/", HNDLR)):
|
| 576 |
+
await conv.send_message(
|
| 577 |
+
"Incorrect Emoji",
|
| 578 |
+
buttons=get_back_button("cbs_otvars"),
|
| 579 |
+
)
|
| 580 |
+
else:
|
| 581 |
+
await setit(event, var, themssg)
|
| 582 |
+
await conv.send_message(
|
| 583 |
+
f"{name} changed to {themssg}\n",
|
| 584 |
+
buttons=get_back_button("cbs_otvars"),
|
| 585 |
+
)
|
| 586 |
+
|
| 587 |
+
|
| 588 |
+
@callback("plg", owner=True)
|
| 589 |
+
async def pluginch(event):
|
| 590 |
+
await event.delete()
|
| 591 |
+
pru = event.sender_id
|
| 592 |
+
var = "PLUGIN_CHANNEL"
|
| 593 |
+
name = "Plugin Channel"
|
| 594 |
+
async with event.client.conversation(pru) as conv:
|
| 595 |
+
await conv.send_message(
|
| 596 |
+
"Send id or username of a channel from where u want to install all plugins\n\nOur Channel~ @ultroidplugins\n\nUse /cancel to cancel.",
|
| 597 |
+
)
|
| 598 |
+
response = conv.wait_event(events.NewMessage(chats=pru))
|
| 599 |
+
response = await response
|
| 600 |
+
themssg = response.message.message
|
| 601 |
+
if themssg == "/cancel":
|
| 602 |
+
await conv.send_message(
|
| 603 |
+
"Cancelled!!",
|
| 604 |
+
buttons=get_back_button("cbs_otvars"),
|
| 605 |
+
)
|
| 606 |
+
elif themssg.startswith(("/", HNDLR)):
|
| 607 |
+
await conv.send_message(
|
| 608 |
+
"Incorrect channel",
|
| 609 |
+
buttons=get_back_button("cbs_otvars"),
|
| 610 |
+
)
|
| 611 |
+
else:
|
| 612 |
+
await setit(event, var, themssg)
|
| 613 |
+
await conv.send_message(
|
| 614 |
+
f"{name} changed to {themssg}\n After Setting All Things Do Restart",
|
| 615 |
+
buttons=get_back_button("cbs_otvars"),
|
| 616 |
+
)
|
| 617 |
+
|
| 618 |
+
|
| 619 |
+
@callback("hhndlr", owner=True)
|
| 620 |
+
async def hndlrr(event):
|
| 621 |
+
await event.delete()
|
| 622 |
+
pru = event.sender_id
|
| 623 |
+
var = "HNDLR"
|
| 624 |
+
name = "Handler/ Trigger"
|
| 625 |
+
async with event.client.conversation(pru) as conv:
|
| 626 |
+
await conv.send_message(
|
| 627 |
+
f"Send The Symbol Which u want as Handler/Trigger to use bot\nUr Current Handler is [ `{HNDLR}` ]\n\n use /cancel to cancel.",
|
| 628 |
+
)
|
| 629 |
+
response = conv.wait_event(events.NewMessage(chats=pru))
|
| 630 |
+
response = await response
|
| 631 |
+
themssg = response.message.message
|
| 632 |
+
if themssg == "/cancel":
|
| 633 |
+
await conv.send_message(
|
| 634 |
+
"Cancelled!!",
|
| 635 |
+
buttons=get_back_button("cbs_otvars"),
|
| 636 |
+
)
|
| 637 |
+
elif len(themssg) > 1:
|
| 638 |
+
await conv.send_message(
|
| 639 |
+
"Incorrect Handler",
|
| 640 |
+
buttons=get_back_button("cbs_otvars"),
|
| 641 |
+
)
|
| 642 |
+
elif themssg.startswith(("/", "#", "@")):
|
| 643 |
+
await conv.send_message(
|
| 644 |
+
"This cannot be used as handler",
|
| 645 |
+
buttons=get_back_button("cbs_otvars"),
|
| 646 |
+
)
|
| 647 |
+
else:
|
| 648 |
+
await setit(event, var, themssg)
|
| 649 |
+
await conv.send_message(
|
| 650 |
+
f"{name} changed to {themssg}",
|
| 651 |
+
buttons=get_back_button("cbs_otvars"),
|
| 652 |
+
)
|
| 653 |
+
|
| 654 |
+
|
| 655 |
+
@callback("shndlr", owner=True)
|
| 656 |
+
async def hndlrr(event):
|
| 657 |
+
await event.delete()
|
| 658 |
+
pru = event.sender_id
|
| 659 |
+
var = "SUDO_HNDLR"
|
| 660 |
+
name = "Sudo Handler"
|
| 661 |
+
async with event.client.conversation(pru) as conv:
|
| 662 |
+
await conv.send_message(
|
| 663 |
+
"Send The Symbol Which u want as Sudo Handler/Trigger to use bot\n\n use /cancel to cancel."
|
| 664 |
+
)
|
| 665 |
+
|
| 666 |
+
response = conv.wait_event(events.NewMessage(chats=pru))
|
| 667 |
+
response = await response
|
| 668 |
+
themssg = response.message.message
|
| 669 |
+
if themssg == "/cancel":
|
| 670 |
+
await conv.send_message(
|
| 671 |
+
"Cancelled!!",
|
| 672 |
+
buttons=get_back_button("cbs_otvars"),
|
| 673 |
+
)
|
| 674 |
+
elif len(themssg) > 1:
|
| 675 |
+
await conv.send_message(
|
| 676 |
+
"Incorrect Handler",
|
| 677 |
+
buttons=get_back_button("cbs_otvars"),
|
| 678 |
+
)
|
| 679 |
+
elif themssg.startswith(("/", "#", "@")):
|
| 680 |
+
await conv.send_message(
|
| 681 |
+
"This cannot be used as handler",
|
| 682 |
+
buttons=get_back_button("cbs_otvars"),
|
| 683 |
+
)
|
| 684 |
+
else:
|
| 685 |
+
await setit(event, var, themssg)
|
| 686 |
+
await conv.send_message(
|
| 687 |
+
f"{name} changed to {themssg}",
|
| 688 |
+
buttons=get_back_button("cbs_otvars"),
|
| 689 |
+
)
|
| 690 |
+
|
| 691 |
+
|
| 692 |
+
@callback("taglog", owner=True)
|
| 693 |
+
async def tagloggrr(e):
|
| 694 |
+
BUTTON = [
|
| 695 |
+
[Button.inline("SET TAG LOG", data="abs_settag")],
|
| 696 |
+
[Button.inline("DELETE TAG LOG", data="deltag")],
|
| 697 |
+
get_back_button("cbs_otvars"),
|
| 698 |
+
]
|
| 699 |
+
await e.edit(
|
| 700 |
+
"Choose Options",
|
| 701 |
+
buttons=BUTTON,
|
| 702 |
+
)
|
| 703 |
+
|
| 704 |
+
|
| 705 |
+
@callback("deltag", owner=True)
|
| 706 |
+
async def _(e):
|
| 707 |
+
udB.del_key("TAG_LOG")
|
| 708 |
+
await e.answer("Done!!! Tag Logger has been turned Off")
|
| 709 |
+
|
| 710 |
+
|
| 711 |
+
@callback("eaddon", owner=True)
|
| 712 |
+
async def pmset(event):
|
| 713 |
+
BT = (
|
| 714 |
+
[Button.inline("Aᴅᴅᴏɴs Oғғ", data="edof")]
|
| 715 |
+
if udB.get_key("ADDONS")
|
| 716 |
+
else [Button.inline("Aᴅᴅᴏɴs Oɴ", data="edon")]
|
| 717 |
+
)
|
| 718 |
+
|
| 719 |
+
await event.edit(
|
| 720 |
+
"ADDONS~ Extra Plugins:",
|
| 721 |
+
buttons=[
|
| 722 |
+
BT,
|
| 723 |
+
[Button.inline("« Bᴀᴄᴋ", data="cbs_otvars")],
|
| 724 |
+
],
|
| 725 |
+
)
|
| 726 |
+
|
| 727 |
+
|
| 728 |
+
@callback("edon", owner=True)
|
| 729 |
+
async def eddon(event):
|
| 730 |
+
var = "ADDONS"
|
| 731 |
+
await setit(event, var, "True")
|
| 732 |
+
await event.edit(
|
| 733 |
+
"Done! ADDONS has been turned on!!\n\n After Setting All Things Do Restart",
|
| 734 |
+
buttons=get_back_button("eaddon"),
|
| 735 |
+
)
|
| 736 |
+
|
| 737 |
+
|
| 738 |
+
@callback("edof", owner=True)
|
| 739 |
+
async def eddof(event):
|
| 740 |
+
udB.set_key("ADDONS", "False")
|
| 741 |
+
await event.edit(
|
| 742 |
+
"Done! ADDONS has been turned off!! After Setting All Things Do Restart",
|
| 743 |
+
buttons=get_back_button("eaddon"),
|
| 744 |
+
)
|
| 745 |
+
|
| 746 |
+
|
| 747 |
+
@callback("sudo", owner=True)
|
| 748 |
+
async def pmset(event):
|
| 749 |
+
BT = (
|
| 750 |
+
[Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ Oғғ", data="ofsudo")]
|
| 751 |
+
if udB.get_key("SUDO")
|
| 752 |
+
else [Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ Oɴ", data="onsudo")]
|
| 753 |
+
)
|
| 754 |
+
|
| 755 |
+
await event.edit(
|
| 756 |
+
f"SUDO MODE ~ Some peoples can use ur Bot which u selected. To know More use `{HNDLR}help sudo`",
|
| 757 |
+
buttons=[
|
| 758 |
+
BT,
|
| 759 |
+
[Button.inline("« Bᴀᴄᴋ", data="cbs_otvars")],
|
| 760 |
+
],
|
| 761 |
+
)
|
| 762 |
+
|
| 763 |
+
|
| 764 |
+
@callback("onsudo", owner=True)
|
| 765 |
+
async def eddon(event):
|
| 766 |
+
var = "SUDO"
|
| 767 |
+
await setit(event, var, "True")
|
| 768 |
+
await event.edit(
|
| 769 |
+
"Done! SUDO MODE has been turned on!!\n\n After Setting All Things Do Restart",
|
| 770 |
+
buttons=get_back_button("sudo"),
|
| 771 |
+
)
|
| 772 |
+
|
| 773 |
+
|
| 774 |
+
@callback("ofsudo", owner=True)
|
| 775 |
+
async def eddof(event):
|
| 776 |
+
var = "SUDO"
|
| 777 |
+
await setit(event, var, "False")
|
| 778 |
+
await event.edit(
|
| 779 |
+
"Done! SUDO MODE has been turned off!! After Setting All Things Do Restart",
|
| 780 |
+
buttons=get_back_button("sudo"),
|
| 781 |
+
)
|
| 782 |
+
|
| 783 |
+
|
| 784 |
+
@callback("sfgrp", owner=True)
|
| 785 |
+
async def sfgrp(event):
|
| 786 |
+
await event.delete()
|
| 787 |
+
name = "FBan Group ID"
|
| 788 |
+
var = "FBAN_GROUP_ID"
|
| 789 |
+
pru = event.sender_id
|
| 790 |
+
async with asst.conversation(pru) as conv:
|
| 791 |
+
await conv.send_message(
|
| 792 |
+
f"Make a group, add @MissRose_Bot, send `{HNDLR}id`, copy that and send it here.\nUse /cancel to go back.",
|
| 793 |
+
)
|
| 794 |
+
response = conv.wait_event(events.NewMessage(chats=pru))
|
| 795 |
+
response = await response
|
| 796 |
+
themssg = response.message.message
|
| 797 |
+
if themssg == "/cancel":
|
| 798 |
+
return await conv.send_message(
|
| 799 |
+
"Cancelled!!",
|
| 800 |
+
buttons=get_back_button("cbs_sfban"),
|
| 801 |
+
)
|
| 802 |
+
await setit(event, var, themssg)
|
| 803 |
+
await conv.send_message(
|
| 804 |
+
f"{name} changed to {themssg}",
|
| 805 |
+
buttons=get_back_button("cbs_sfban"),
|
| 806 |
+
)
|
| 807 |
+
|
| 808 |
+
|
| 809 |
+
@callback("alvmed", owner=True)
|
| 810 |
+
async def media(event):
|
| 811 |
+
await event.delete()
|
| 812 |
+
pru = event.sender_id
|
| 813 |
+
var = "ALIVE_PIC"
|
| 814 |
+
name = "Alive Media"
|
| 815 |
+
async with event.client.conversation(pru) as conv:
|
| 816 |
+
await conv.send_message(
|
| 817 |
+
"**Alive Media**\nSend me a pic/gif/media to set as alive media.\n\nUse /cancel to terminate the operation.",
|
| 818 |
+
)
|
| 819 |
+
response = await conv.get_response()
|
| 820 |
+
try:
|
| 821 |
+
themssg = response.message
|
| 822 |
+
if themssg == "/cancel":
|
| 823 |
+
return await conv.send_message(
|
| 824 |
+
"Operation cancelled!!",
|
| 825 |
+
buttons=get_back_button("cbs_alvcstm"),
|
| 826 |
+
)
|
| 827 |
+
except BaseException as er:
|
| 828 |
+
LOGS.exception(er)
|
| 829 |
+
if (
|
| 830 |
+
not (response.text).startswith("/")
|
| 831 |
+
and response.text != ""
|
| 832 |
+
and (not response.media or isinstance(response.media, MessageMediaWebPage))
|
| 833 |
+
):
|
| 834 |
+
url = text_to_url(response)
|
| 835 |
+
elif response.sticker:
|
| 836 |
+
url = response.file.id
|
| 837 |
+
else:
|
| 838 |
+
media = await event.client.download_media(response, "alvpc")
|
| 839 |
+
try:
|
| 840 |
+
x = upl(media)
|
| 841 |
+
url = f"https://graph.org/{x[0]}"
|
| 842 |
+
remove(media)
|
| 843 |
+
except BaseException as er:
|
| 844 |
+
LOGS.exception(er)
|
| 845 |
+
return await conv.send_message(
|
| 846 |
+
"Terminated.",
|
| 847 |
+
buttons=get_back_button("cbs_alvcstm"),
|
| 848 |
+
)
|
| 849 |
+
await setit(event, var, url)
|
| 850 |
+
await conv.send_message(
|
| 851 |
+
f"{name} has been set.",
|
| 852 |
+
buttons=get_back_button("cbs_alvcstm"),
|
| 853 |
+
)
|
| 854 |
+
|
| 855 |
+
|
| 856 |
+
@callback("delmed", owner=True)
|
| 857 |
+
async def dell(event):
|
| 858 |
+
try:
|
| 859 |
+
udB.del_key("ALIVE_PIC")
|
| 860 |
+
return await event.edit(
|
| 861 |
+
get_string("clst_5"), buttons=get_back_button("cbs_alabs_vcstm")
|
| 862 |
+
)
|
| 863 |
+
except BaseException as er:
|
| 864 |
+
LOGS.exception(er)
|
| 865 |
+
return await event.edit(
|
| 866 |
+
get_string("clst_4"),
|
| 867 |
+
buttons=get_back_button("cbs_alabs_vcstm"),
|
| 868 |
+
)
|
| 869 |
+
|
| 870 |
+
|
| 871 |
+
@callback("inpm_in", owner=True)
|
| 872 |
+
async def inl_on(event):
|
| 873 |
+
var = "INLINE_PM"
|
| 874 |
+
await setit(event, var, "True")
|
| 875 |
+
await event.edit(
|
| 876 |
+
"Done!! PMPermit type has been set to inline!",
|
| 877 |
+
buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_pmtype")]],
|
| 878 |
+
)
|
| 879 |
+
|
| 880 |
+
|
| 881 |
+
@callback("inpm_no", owner=True)
|
| 882 |
+
async def inl_on(event):
|
| 883 |
+
var = "INLINE_PM"
|
| 884 |
+
await setit(event, var, "False")
|
| 885 |
+
await event.edit(
|
| 886 |
+
"Done!! PMPermit type has been set to normal!",
|
| 887 |
+
buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_pmtype")]],
|
| 888 |
+
)
|
| 889 |
+
|
| 890 |
+
|
| 891 |
+
@callback("pmtxt", owner=True)
|
| 892 |
+
async def name(event):
|
| 893 |
+
await event.delete()
|
| 894 |
+
pru = event.sender_id
|
| 895 |
+
var = "PM_TEXT"
|
| 896 |
+
name = "PM Text"
|
| 897 |
+
async with event.client.conversation(pru) as conv:
|
| 898 |
+
await conv.send_message(
|
| 899 |
+
"**PM Text**\nEnter the new Pmpermit text.\n\nu can use `{name}` `{fullname}` `{count}` `{mention}` `{username}` to get this from user Too\n\nUse /cancel to terminate the operation.",
|
| 900 |
+
)
|
| 901 |
+
response = conv.wait_event(events.NewMessage(chats=pru))
|
| 902 |
+
response = await response
|
| 903 |
+
themssg = response.message.message
|
| 904 |
+
if themssg == "/cancel":
|
| 905 |
+
return await conv.send_message(
|
| 906 |
+
"Cancelled!!",
|
| 907 |
+
buttons=get_back_button("cbs_pmcstm"),
|
| 908 |
+
)
|
| 909 |
+
if len(themssg) > 4090:
|
| 910 |
+
return await conv.send_message(
|
| 911 |
+
"Message too long!\nGive a shorter message please!!",
|
| 912 |
+
buttons=get_back_button("cbs_pmcstm"),
|
| 913 |
+
)
|
| 914 |
+
await setit(event, var, themssg)
|
| 915 |
+
await conv.send_message(
|
| 916 |
+
f"{name} changed to {themssg}\n\nAfter Setting All Things Do restart",
|
| 917 |
+
buttons=get_back_button("cbs_pmcstm"),
|
| 918 |
+
)
|
| 919 |
+
|
| 920 |
+
|
| 921 |
+
@callback("swarn", owner=True)
|
| 922 |
+
async def name(event):
|
| 923 |
+
m = range(1, 10)
|
| 924 |
+
tultd = [Button.inline(f"{x}", data=f"wrns_{x}") for x in m]
|
| 925 |
+
lst = list(zip(tultd[::3], tultd[1::3], tultd[2::3]))
|
| 926 |
+
lst.append([Button.inline("« Bᴀᴄᴋ", data="cbs_pmcstm")])
|
| 927 |
+
await event.edit(
|
| 928 |
+
"Select the number of warnings for a user before getting blocked in PMs.",
|
| 929 |
+
buttons=lst,
|
| 930 |
+
)
|
| 931 |
+
|
| 932 |
+
|
| 933 |
+
@callback(re.compile(b"wrns_(.*)"), owner=True)
|
| 934 |
+
async def set_wrns(event):
|
| 935 |
+
value = int(event.data_match.group(1).decode("UTF-8"))
|
| 936 |
+
if dn := udB.set_key("PMWARNS", value):
|
| 937 |
+
await event.edit(
|
| 938 |
+
f"PM Warns Set to {value}.\nNew users will have {value} chances in PMs before getting banned.",
|
| 939 |
+
buttons=get_back_button("cbs_pmcstm"),
|
| 940 |
+
)
|
| 941 |
+
else:
|
| 942 |
+
await event.edit(
|
| 943 |
+
f"Something went wrong, please check your {HNDLR}logs!",
|
| 944 |
+
buttons=get_back_button("cbs_pmcstm"),
|
| 945 |
+
)
|
| 946 |
+
|
| 947 |
+
|
| 948 |
+
@callback("pmmed", owner=True)
|
| 949 |
+
async def media(event):
|
| 950 |
+
await event.delete()
|
| 951 |
+
pru = event.sender_id
|
| 952 |
+
var = "PMPIC"
|
| 953 |
+
name = "PM Media"
|
| 954 |
+
async with event.client.conversation(pru) as conv:
|
| 955 |
+
await conv.send_message(
|
| 956 |
+
"**PM Media**\nSend me a pic/gif/sticker/link to set as pmpermit media.\n\nUse /cancel to terminate the operation.",
|
| 957 |
+
)
|
| 958 |
+
response = await conv.get_response()
|
| 959 |
+
try:
|
| 960 |
+
themssg = response.message
|
| 961 |
+
if themssg == "/cancel":
|
| 962 |
+
return await conv.send_message(
|
| 963 |
+
"Operation cancelled!!",
|
| 964 |
+
buttons=get_back_button("cbs_pmcstm"),
|
| 965 |
+
)
|
| 966 |
+
except BaseException as er:
|
| 967 |
+
LOGS.exception(er)
|
| 968 |
+
media = await event.client.download_media(response, "pmpc")
|
| 969 |
+
if (
|
| 970 |
+
not (response.text).startswith("/")
|
| 971 |
+
and response.text != ""
|
| 972 |
+
and (not response.media or isinstance(response.media, MessageMediaWebPage))
|
| 973 |
+
):
|
| 974 |
+
url = text_to_url(response)
|
| 975 |
+
elif response.sticker:
|
| 976 |
+
url = response.file.id
|
| 977 |
+
else:
|
| 978 |
+
try:
|
| 979 |
+
x = upl(media)
|
| 980 |
+
url = f"https://graph.org/{x[0]}"
|
| 981 |
+
remove(media)
|
| 982 |
+
except BaseException as er:
|
| 983 |
+
LOGS.exception(er)
|
| 984 |
+
return await conv.send_message(
|
| 985 |
+
"Terminated.",
|
| 986 |
+
buttons=get_back_button("cbs_pmcstm"),
|
| 987 |
+
)
|
| 988 |
+
await setit(event, var, url)
|
| 989 |
+
await conv.send_message(
|
| 990 |
+
f"{name} has been set.",
|
| 991 |
+
buttons=get_back_button("cbs_pmcstm"),
|
| 992 |
+
)
|
| 993 |
+
|
| 994 |
+
|
| 995 |
+
@callback("delpmmed", owner=True)
|
| 996 |
+
async def dell(event):
|
| 997 |
+
try:
|
| 998 |
+
udB.del_key("PMPIC")
|
| 999 |
+
return await event.edit(
|
| 1000 |
+
get_string("clst_5"), buttons=get_back_button("cbs_pmcstm")
|
| 1001 |
+
)
|
| 1002 |
+
except BaseException as er:
|
| 1003 |
+
LOGS.exception(er)
|
| 1004 |
+
return await event.edit(
|
| 1005 |
+
get_string("clst_4"),
|
| 1006 |
+
buttons=[[Button.inline("« Sᴇᴛᴛɪɴɢs", data="setter")]],
|
| 1007 |
+
)
|
| 1008 |
+
|
| 1009 |
+
|
| 1010 |
+
@callback("apon", owner=True)
|
| 1011 |
+
async def apon(event):
|
| 1012 |
+
var = "AUTOAPPROVE"
|
| 1013 |
+
await setit(event, var, "True")
|
| 1014 |
+
await event.edit(
|
| 1015 |
+
"Done!! AUTOAPPROVE Started!!",
|
| 1016 |
+
buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_apauto")]],
|
| 1017 |
+
)
|
| 1018 |
+
|
| 1019 |
+
|
| 1020 |
+
@callback("apof", owner=True)
|
| 1021 |
+
async def apof(event):
|
| 1022 |
+
try:
|
| 1023 |
+
udB.set_key("AUTOAPPROVE", "False")
|
| 1024 |
+
return await event.edit(
|
| 1025 |
+
"Done! AUTOAPPROVE Stopped!!",
|
| 1026 |
+
buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_apauto")]],
|
| 1027 |
+
)
|
| 1028 |
+
except BaseException as er:
|
| 1029 |
+
LOGS.exception(er)
|
| 1030 |
+
return await event.edit(
|
| 1031 |
+
get_string("clst_4"),
|
| 1032 |
+
buttons=[[Button.inline("« Sᴇᴛᴛɪɴɢs", data="setter")]],
|
| 1033 |
+
)
|
| 1034 |
+
|
| 1035 |
+
|
| 1036 |
+
@callback("pml", owner=True)
|
| 1037 |
+
async def l_vcs(event):
|
| 1038 |
+
BT = (
|
| 1039 |
+
[Button.inline("PMLOGGER OFF", data="pmlogof")]
|
| 1040 |
+
if udB.get_key("PMLOG")
|
| 1041 |
+
else [Button.inline("PMLOGGER ON", data="pmlog")]
|
| 1042 |
+
)
|
| 1043 |
+
|
| 1044 |
+
await event.edit(
|
| 1045 |
+
"PMLOGGER This Will Forward Ur Pm to Ur Private Group -",
|
| 1046 |
+
buttons=[
|
| 1047 |
+
BT,
|
| 1048 |
+
[Button.inline("PᴍLᴏɢɢᴇʀ Gʀᴏᴜᴘ", "abs_pmlgg")],
|
| 1049 |
+
[Button.inline("« Bᴀᴄᴋ", data="cbs_pmcstm")],
|
| 1050 |
+
],
|
| 1051 |
+
)
|
| 1052 |
+
|
| 1053 |
+
|
| 1054 |
+
@callback("pmlog", owner=True)
|
| 1055 |
+
async def pmlog(event):
|
| 1056 |
+
await setit(event, "PMLOG", "True")
|
| 1057 |
+
await event.edit(
|
| 1058 |
+
"Done!! PMLOGGER Started!!",
|
| 1059 |
+
buttons=[[Button.inline("« Bᴀᴄᴋ", data="pml")]],
|
| 1060 |
+
)
|
| 1061 |
+
|
| 1062 |
+
|
| 1063 |
+
@callback("pmlogof", owner=True)
|
| 1064 |
+
async def pmlogof(event):
|
| 1065 |
+
try:
|
| 1066 |
+
udB.del_key("PMLOG")
|
| 1067 |
+
return await event.edit(
|
| 1068 |
+
"Done! PMLOGGER Stopped!!",
|
| 1069 |
+
buttons=[[Button.inline("« Bᴀᴄᴋ", data="pml")]],
|
| 1070 |
+
)
|
| 1071 |
+
except BaseException as er:
|
| 1072 |
+
LOGS.exception(er)
|
| 1073 |
+
return await event.edit(
|
| 1074 |
+
get_string("clst_4"),
|
| 1075 |
+
buttons=[[Button.inline("« Sᴇᴛᴛɪɴɢs", data="setter")]],
|
| 1076 |
+
)
|
| 1077 |
+
|
| 1078 |
+
|
| 1079 |
+
@callback("pmon", owner=True)
|
| 1080 |
+
async def pmonn(event):
|
| 1081 |
+
var = "PMSETTING"
|
| 1082 |
+
await setit(event, var, "True")
|
| 1083 |
+
await event.edit(
|
| 1084 |
+
"Done! PMPermit has been turned on!!",
|
| 1085 |
+
buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_ppmset")]],
|
| 1086 |
+
)
|
| 1087 |
+
|
| 1088 |
+
|
| 1089 |
+
@callback("pmoff", owner=True)
|
| 1090 |
+
async def pmofff(event):
|
| 1091 |
+
var = "PMSETTING"
|
| 1092 |
+
await setit(event, var, "False")
|
| 1093 |
+
await event.edit(
|
| 1094 |
+
"Done! PMPermit has been turned off!!",
|
| 1095 |
+
buttons=[[Button.inline("« Bᴀᴄᴋ", data="cbs_ppmset")]],
|
| 1096 |
+
)
|
| 1097 |
+
|
| 1098 |
+
|
| 1099 |
+
@callback("botmew", owner=True)
|
| 1100 |
+
async def hhh(e):
|
| 1101 |
+
async with e.client.conversation(e.chat_id) as conv:
|
| 1102 |
+
await conv.send_message("Send Any Media to keep at your Bot's welcome ")
|
| 1103 |
+
msg = await conv.get_response()
|
| 1104 |
+
if not msg.media or msg.text.startswith("/"):
|
| 1105 |
+
return await conv.send_message(
|
| 1106 |
+
"Terminated!", buttons=get_back_button("cbs_chatbot")
|
| 1107 |
+
)
|
| 1108 |
+
udB.set_key("STARTMEDIA", msg.file.id)
|
| 1109 |
+
await conv.send_message("Done!", buttons=get_back_button("cbs_chatbot"))
|
| 1110 |
+
|
| 1111 |
+
|
| 1112 |
+
@callback("botinfe", owner=True)
|
| 1113 |
+
async def hhh(e):
|
| 1114 |
+
async with e.client.conversation(e.chat_id) as conv:
|
| 1115 |
+
await conv.send_message(
|
| 1116 |
+
"Send message to set to Display, when user Press Info button in Bot Welcome!\n\nsend `False` to completely remove that button.."
|
| 1117 |
+
)
|
| 1118 |
+
msg = await conv.get_response()
|
| 1119 |
+
if msg.media or msg.text.startswith("/"):
|
| 1120 |
+
return await conv.send_message(
|
| 1121 |
+
"Terminated!", buttons=get_back_button("cbs_chatbot")
|
| 1122 |
+
)
|
| 1123 |
+
udB.set_key("BOT_INFO_START", msg.text)
|
| 1124 |
+
await conv.send_message("Done!", buttons=get_back_button("cbs_chatbot"))
|
| 1125 |
+
|
| 1126 |
+
|
| 1127 |
+
@callback("pmfs", owner=True)
|
| 1128 |
+
async def heheh(event):
|
| 1129 |
+
Ll = []
|
| 1130 |
+
err = ""
|
| 1131 |
+
async with event.client.conversation(event.chat_id) as conv:
|
| 1132 |
+
await conv.send_message(
|
| 1133 |
+
"• 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.."
|
| 1134 |
+
)
|
| 1135 |
+
await conv.send_message(
|
| 1136 |
+
"Example : \n`-1001234567\n-100778888`\n\nFor Multiple Chat(s)."
|
| 1137 |
+
)
|
| 1138 |
+
try:
|
| 1139 |
+
msg = await conv.get_response()
|
| 1140 |
+
except AsyncTimeOut:
|
| 1141 |
+
return await conv.send_message("**• TimeUp!**\nStart from /start back.")
|
| 1142 |
+
if not msg.text or msg.text.startswith("/"):
|
| 1143 |
+
timyork = "Cancelled!"
|
| 1144 |
+
if msg.text == "/clear":
|
| 1145 |
+
udB.del_key("PMBOT_FSUB")
|
| 1146 |
+
timyork = "Done! Force Subscribe Stopped\nRestart your Bot!"
|
| 1147 |
+
return await conv.send_message(
|
| 1148 |
+
"Cancelled!", buttons=get_back_button("cbs_chatbot")
|
| 1149 |
+
)
|
| 1150 |
+
for chat in msg.message.split("\n"):
|
| 1151 |
+
if chat.startswith("-") or chat.isdigit():
|
| 1152 |
+
chat = int(chat)
|
| 1153 |
+
try:
|
| 1154 |
+
CHSJSHS = await event.client.get_entity(chat)
|
| 1155 |
+
Ll.append(get_peer_id(CHSJSHS))
|
| 1156 |
+
except Exception as er:
|
| 1157 |
+
err += f"**{chat}** : {er}\n"
|
| 1158 |
+
if err:
|
| 1159 |
+
return await conv.send_message(err)
|
| 1160 |
+
udB.set_key("PMBOT_FSUB", str(Ll))
|
| 1161 |
+
await conv.send_message(
|
| 1162 |
+
"Done!\nRestart Your Bot.", buttons=get_back_button("cbs_chatbot")
|
| 1163 |
+
)
|
| 1164 |
+
|
| 1165 |
+
|
| 1166 |
+
@callback("bwel", owner=True)
|
| 1167 |
+
async def name(event):
|
| 1168 |
+
await event.delete()
|
| 1169 |
+
pru = event.sender_id
|
| 1170 |
+
var = "STARTMSG"
|
| 1171 |
+
name = "Bot Welcome Message:"
|
| 1172 |
+
async with event.client.conversation(pru) as conv:
|
| 1173 |
+
await conv.send_message(
|
| 1174 |
+
"**BOT WELCOME MSG**\nEnter the msg which u want to show when someone start your assistant Bot.\nYou Can use `{me}` , `{mention}` Parameters Too\nUse /cancel to terminate the operation.",
|
| 1175 |
+
)
|
| 1176 |
+
response = conv.wait_event(events.NewMessage(chats=pru))
|
| 1177 |
+
response = await response
|
| 1178 |
+
themssg = response.message.message
|
| 1179 |
+
if themssg == "/cancel":
|
| 1180 |
+
return await conv.send_message(
|
| 1181 |
+
"Cancelled!!",
|
| 1182 |
+
buttons=get_back_button("cbs_chatbot"),
|
| 1183 |
+
)
|
| 1184 |
+
await setit(event, var, themssg)
|
| 1185 |
+
await conv.send_message(
|
| 1186 |
+
f"{name} changed to {themssg}",
|
| 1187 |
+
buttons=get_back_button("cbs_chatbot"),
|
| 1188 |
+
)
|
| 1189 |
+
|
| 1190 |
+
|
| 1191 |
+
@callback("onchbot", owner=True)
|
| 1192 |
+
async def chon(event):
|
| 1193 |
+
var = "PMBOT"
|
| 1194 |
+
await setit(event, var, "True")
|
| 1195 |
+
Loader(path="assistant/pmbot.py", key="PM Bot").load()
|
| 1196 |
+
if AST_PLUGINS.get("pmbot"):
|
| 1197 |
+
for i, e in AST_PLUGINS["pmbot"]:
|
| 1198 |
+
event.client.remove_event_handler(i)
|
| 1199 |
+
for i, e in AST_PLUGINS["pmbot"]:
|
| 1200 |
+
event.client.add_event_handler(i, events.NewMessage(**e))
|
| 1201 |
+
await event.edit(
|
| 1202 |
+
"Done! Now u Can Chat With People Via This Bot",
|
| 1203 |
+
buttons=[Button.inline("« Bᴀᴄᴋ", data="cbs_chatbot")],
|
| 1204 |
+
)
|
| 1205 |
+
|
| 1206 |
+
|
| 1207 |
+
@callback("ofchbot", owner=True)
|
| 1208 |
+
async def chon(event):
|
| 1209 |
+
var = "PMBOT"
|
| 1210 |
+
await setit(event, var, "False")
|
| 1211 |
+
if AST_PLUGINS.get("pmbot"):
|
| 1212 |
+
for i, e in AST_PLUGINS["pmbot"]:
|
| 1213 |
+
event.client.remove_event_handler(i)
|
| 1214 |
+
await event.edit(
|
| 1215 |
+
"Done! Chat People Via This Bot Stopped.",
|
| 1216 |
+
buttons=[Button.inline("« Bᴀᴄᴋ", data="cbs_chatbot")],
|
| 1217 |
+
)
|
| 1218 |
+
|
| 1219 |
+
|
| 1220 |
+
@callback("inli_pic", owner=True)
|
| 1221 |
+
async def media(event):
|
| 1222 |
+
await event.delete()
|
| 1223 |
+
pru = event.sender_id
|
| 1224 |
+
var = "INLINE_PIC"
|
| 1225 |
+
name = "Inline Media"
|
| 1226 |
+
async with event.client.conversation(pru) as conv:
|
| 1227 |
+
await conv.send_message(
|
| 1228 |
+
"**Inline Media**\nSend me a pic/gif/ or link to set as inline media.\n\nUse /cancel to terminate the operation.",
|
| 1229 |
+
)
|
| 1230 |
+
response = await conv.get_response()
|
| 1231 |
+
try:
|
| 1232 |
+
themssg = response.message
|
| 1233 |
+
if themssg == "/cancel":
|
| 1234 |
+
return await conv.send_message(
|
| 1235 |
+
"Operation cancelled!!",
|
| 1236 |
+
buttons=get_back_button("setter"),
|
| 1237 |
+
)
|
| 1238 |
+
except BaseException as er:
|
| 1239 |
+
LOGS.exception(er)
|
| 1240 |
+
media = await event.client.download_media(response, "inlpic")
|
| 1241 |
+
if (
|
| 1242 |
+
not (response.text).startswith("/")
|
| 1243 |
+
and response.text != ""
|
| 1244 |
+
and (not response.media or isinstance(response.media, MessageMediaWebPage))
|
| 1245 |
+
):
|
| 1246 |
+
url = text_to_url(response)
|
| 1247 |
+
else:
|
| 1248 |
+
try:
|
| 1249 |
+
x = upl(media)
|
| 1250 |
+
url = f"https://graph.org/{x[0]}"
|
| 1251 |
+
remove(media)
|
| 1252 |
+
except BaseException as er:
|
| 1253 |
+
LOGS.exception(er)
|
| 1254 |
+
return await conv.send_message(
|
| 1255 |
+
"Terminated.",
|
| 1256 |
+
buttons=get_back_button("setter"),
|
| 1257 |
+
)
|
| 1258 |
+
await setit(event, var, url)
|
| 1259 |
+
await conv.send_message(
|
| 1260 |
+
f"{name} has been set.",
|
| 1261 |
+
buttons=get_back_button("setter"),
|
| 1262 |
+
)
|
| 1263 |
+
|
| 1264 |
+
|
| 1265 |
+
FD_MEDIA = {}
|
| 1266 |
+
|
| 1267 |
+
|
| 1268 |
+
@callback(re.compile("fd(.*)"), owner=True)
|
| 1269 |
+
async def fdroid_dler(event):
|
| 1270 |
+
uri = event.data_match.group(1).decode("utf-8")
|
| 1271 |
+
if FD_MEDIA.get(uri):
|
| 1272 |
+
return await event.edit(file=FD_MEDIA[uri])
|
| 1273 |
+
await event.answer("• Starting Download •", alert=True)
|
| 1274 |
+
await event.edit("• Downloading.. •")
|
| 1275 |
+
URL = f"https://f-droid.org/packages/{uri}"
|
| 1276 |
+
conte = await async_searcher(URL, re_content=True)
|
| 1277 |
+
BSC = bs(conte, "html.parser", from_encoding="utf-8")
|
| 1278 |
+
dl_ = BSC.find("p", "package-version-download").find("a")["href"]
|
| 1279 |
+
title = BSC.find("h3", "package-name").text.strip()
|
| 1280 |
+
thumb = BSC.find("img", "package-icon")["src"]
|
| 1281 |
+
if thumb.startswith("/"):
|
| 1282 |
+
thumb = f"https://f-droid.org{thumb}"
|
| 1283 |
+
thumb, _ = await fast_download(thumb, filename=f"{uri}.png")
|
| 1284 |
+
s_time = time.time()
|
| 1285 |
+
file, _ = await fast_download(
|
| 1286 |
+
dl_,
|
| 1287 |
+
filename=f"{title}.apk",
|
| 1288 |
+
progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
|
| 1289 |
+
progress(
|
| 1290 |
+
d,
|
| 1291 |
+
t,
|
| 1292 |
+
event,
|
| 1293 |
+
s_time,
|
| 1294 |
+
"Downloading...",
|
| 1295 |
+
)
|
| 1296 |
+
),
|
| 1297 |
+
)
|
| 1298 |
+
|
| 1299 |
+
time.time()
|
| 1300 |
+
n_file = await event.client.fast_uploader(
|
| 1301 |
+
file, show_progress=True, event=event, message="Uploading...", to_delete=True
|
| 1302 |
+
)
|
| 1303 |
+
buttons = Button.switch_inline("Search Back", query="fdroid", same_peer=True)
|
| 1304 |
+
try:
|
| 1305 |
+
msg = await event.edit(
|
| 1306 |
+
f"**• [{title}]({URL}) •**", file=n_file, thumb=thumb, buttons=buttons
|
| 1307 |
+
)
|
| 1308 |
+
except Exception as er:
|
| 1309 |
+
LOGS.exception(er)
|
| 1310 |
+
try:
|
| 1311 |
+
msg = await event.client.edit_message(
|
| 1312 |
+
await event.get_input_chat(),
|
| 1313 |
+
event.message_id,
|
| 1314 |
+
f"**• [{title}]({URL}) •**",
|
| 1315 |
+
buttons=buttons,
|
| 1316 |
+
thumb=thumb,
|
| 1317 |
+
file=n_file,
|
| 1318 |
+
)
|
| 1319 |
+
except Exception as er:
|
| 1320 |
+
os.remove(thumb)
|
| 1321 |
+
LOGS.exception(er)
|
| 1322 |
+
return await event.edit(f"**ERROR**: `{er}`", buttons=buttons)
|
| 1323 |
+
if msg and hasattr(msg, "media"):
|
| 1324 |
+
FD_MEDIA.update({uri: msg.media})
|
| 1325 |
+
os.remove(thumb)
|
assistant/games.py
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ultroid - UserBot
|
| 2 |
+
# Copyright (C) 2021-2024 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 re
|
| 18 |
+
|
| 19 |
+
from akipy.async_akipy import Akinator, akipyLOGS
|
| 20 |
+
from telethon.errors.rpcerrorlist import BotMethodInvalidError
|
| 21 |
+
from telethon.events import Raw
|
| 22 |
+
from telethon.tl.types import InputMediaPoll, Poll, PollAnswer, UpdateMessagePollVote
|
| 23 |
+
|
| 24 |
+
from pyUltroid._misc._decorators import ultroid_cmd
|
| 25 |
+
from pyUltroid.fns.helper import inline_mention
|
| 26 |
+
from pyUltroid.fns.tools import async_searcher
|
| 27 |
+
|
| 28 |
+
from . import * # Ensure this import matches your project structure
|
| 29 |
+
|
| 30 |
+
games = {}
|
| 31 |
+
aki_photo = "https://graph.org/file/3cc8825c029fd0cab9edc.jpg"
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
@ultroid_cmd(pattern="akinator")
|
| 35 |
+
async def akina(e):
|
| 36 |
+
sta = Akinator()
|
| 37 |
+
games[e.chat_id] = {e.id: sta}
|
| 38 |
+
LOGS.info(f"Game started for chat {e.chat_id} with ID {e.id}.")
|
| 39 |
+
try:
|
| 40 |
+
m = await e.client.inline_query(asst.me.username, f"aki_{e.chat_id}_{e.id}")
|
| 41 |
+
await m[0].click(e.chat_id)
|
| 42 |
+
akipyLOGS.info(f"Clicked inline result for chat {e.chat_id}")
|
| 43 |
+
except BotMethodInvalidError as err:
|
| 44 |
+
akipyLOGS.error(f"BotMethodInvalidError: {err}")
|
| 45 |
+
await asst.send_file(
|
| 46 |
+
e.chat_id,
|
| 47 |
+
aki_photo,
|
| 48 |
+
buttons=Button.inline(get_string("aki_2"), data=f"aki_{e.chat_id}_{e.id}"),
|
| 49 |
+
)
|
| 50 |
+
except Exception as er:
|
| 51 |
+
akipyLOGS.error(f"Unexpected error: {er}")
|
| 52 |
+
return await e.eor(f"ERROR : {er}")
|
| 53 |
+
if e.out:
|
| 54 |
+
await e.delete()
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
@asst_cmd(pattern="akinator", owner=True)
|
| 58 |
+
async def _akokk(e):
|
| 59 |
+
await akina(e)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
@callback(re.compile("aki_(.*)"), owner=True)
|
| 63 |
+
async def doai(e):
|
| 64 |
+
adt = e.pattern_match.group(1).strip().decode("utf-8")
|
| 65 |
+
dt = adt.split("_")
|
| 66 |
+
ch = int(dt[0])
|
| 67 |
+
mid = int(dt[1])
|
| 68 |
+
await e.edit(get_string("com_1"))
|
| 69 |
+
try:
|
| 70 |
+
await games[ch][mid].start_game(child_mode=False)
|
| 71 |
+
bts = [Button.inline(o, f"aka_{adt}_{o}") for o in ["Yes", "No", "Idk"]]
|
| 72 |
+
cts = [Button.inline(o, f"aka_{adt}_{o}") for o in ["Probably", "Probably Not"]]
|
| 73 |
+
bts = [bts, cts]
|
| 74 |
+
await e.edit(f"Q. {games[ch][mid].question}", buttons=bts)
|
| 75 |
+
except KeyError:
|
| 76 |
+
return await e.answer(get_string("aki_1"), alert=True)
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
@callback(re.compile("aka_(.*)"), owner=True)
|
| 80 |
+
async def okah(e):
|
| 81 |
+
try:
|
| 82 |
+
mk = e.pattern_match.group(1).decode("utf-8").split("_")
|
| 83 |
+
#akipyLOGS.info(f"Parsed values: {mk}")
|
| 84 |
+
|
| 85 |
+
if len(mk) < 3:
|
| 86 |
+
akipyLOGS.error("Pattern match did not return enough parts.")
|
| 87 |
+
return await e.answer("Invalid data received.", alert=True)
|
| 88 |
+
|
| 89 |
+
ch = int(mk[0])
|
| 90 |
+
mid = int(mk[1])
|
| 91 |
+
ans = mk[2]
|
| 92 |
+
|
| 93 |
+
gm = games[ch][mid]
|
| 94 |
+
await gm.answer(ans)
|
| 95 |
+
|
| 96 |
+
# Check for the final guess in the API response
|
| 97 |
+
if gm.name_proposition and gm.description_proposition:
|
| 98 |
+
gm.win = True
|
| 99 |
+
text = f"It's {gm.name_proposition}\n{gm.description_proposition}"
|
| 100 |
+
await e.edit(text, file=gm.photo)
|
| 101 |
+
else:
|
| 102 |
+
# Game is not won yet, continue asking questions
|
| 103 |
+
buttons = [
|
| 104 |
+
[Button.inline(o, f"aka_{ch}_{mid}_{o}") for o in ["Yes", "No", "Idk"]],
|
| 105 |
+
[Button.inline(o, f"aka_{ch}_{mid}_{o}") for o in ["Probably", "Probably Not"]],
|
| 106 |
+
]
|
| 107 |
+
await e.edit(gm.question, buttons=buttons)
|
| 108 |
+
|
| 109 |
+
except KeyError:
|
| 110 |
+
await e.answer(get_string("aki_3"))
|
| 111 |
+
except Exception as ex:
|
| 112 |
+
akipyLOGS.error(f"An unexpected error occurred: {ex}")
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
@in_pattern(re.compile("aki_?(.*)"), owner=True)
|
| 116 |
+
async def eiagx(e):
|
| 117 |
+
bts = Button.inline(get_string("aki_2"), data=e.text)
|
| 118 |
+
ci = types.InputWebDocument(aki_photo, 0, "image/jpeg", [])
|
| 119 |
+
ans = [
|
| 120 |
+
await e.builder.article(
|
| 121 |
+
"Akinator",
|
| 122 |
+
type="photo",
|
| 123 |
+
content=ci,
|
| 124 |
+
text="Akinator",
|
| 125 |
+
thumb=ci,
|
| 126 |
+
buttons=bts,
|
| 127 |
+
include_media=True,
|
| 128 |
+
)
|
| 129 |
+
]
|
| 130 |
+
await e.answer(ans)
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
# ----------------------- Main Command ------------------- #
|
| 134 |
+
|
| 135 |
+
GIMAGES = [
|
| 136 |
+
"https://graph.org/file/1c51015bae5205a65fd69.jpg",
|
| 137 |
+
"https://imgwhale.xyz/3xyr322l64j9590",
|
| 138 |
+
]
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
@asst_cmd(pattern="startgame", owner=True)
|
| 142 |
+
async def magic(event):
|
| 143 |
+
buttons = [
|
| 144 |
+
[Button.inline("Trivia Quiz", "trzia")],
|
| 145 |
+
[Button.inline("Cancel ❌", "delit")],
|
| 146 |
+
]
|
| 147 |
+
await event.reply(
|
| 148 |
+
get_string("games_1"),
|
| 149 |
+
file=choice(GIMAGES),
|
| 150 |
+
buttons=buttons,
|
| 151 |
+
)
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
# -------------------------- Trivia ----------------------- #
|
| 155 |
+
|
| 156 |
+
TR_BTS = {}
|
| 157 |
+
DIFI_KEYS = ["Easy", "Medium", "Hard"]
|
| 158 |
+
TRIVIA_CHATS = {}
|
| 159 |
+
POLLS = {}
|
| 160 |
+
CONGO_STICKER = [
|
| 161 |
+
"CAADAgADSgIAAladvQrJasZoYBh68AI",
|
| 162 |
+
"CAADAgADXhIAAuyZKUl879mlR_dkOwI",
|
| 163 |
+
"CAADAgADpQAD9wLID-xfZCDwOI5LAg",
|
| 164 |
+
"CAADAgADjAADECECEFZM-SrKO9GgAg",
|
| 165 |
+
"CAADAgADSwIAAj-VzArAzNCDiGWAHAI",
|
| 166 |
+
"CAADAgADhQADwZxgDIuMHR9IU10iAg",
|
| 167 |
+
"CAADAgADiwMAAsSraAuoe2BwYu1sdQI",
|
| 168 |
+
]
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
@callback("delit", owner=True)
|
| 172 |
+
async def delete_it(event):
|
| 173 |
+
await event.delete()
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
@callback(re.compile("ctdown(.*)"), owner=True)
|
| 177 |
+
async def ct_spam(e):
|
| 178 |
+
n = e.data_match.group(1).decode("utf-8")
|
| 179 |
+
await e.answer(f"Wait {n} seconds..", alert=True)
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
@callback(re.compile("trzia(.*)"), owner=True)
|
| 183 |
+
async def choose_cata(event):
|
| 184 |
+
match = event.data_match.group(1).decode("utf-8")
|
| 185 |
+
if not match:
|
| 186 |
+
if TR_BTS.get("category"):
|
| 187 |
+
buttons = TR_BTS["category"]
|
| 188 |
+
else:
|
| 189 |
+
req = (
|
| 190 |
+
await async_searcher(
|
| 191 |
+
"https://opentdb.com/api_category.php", re_json=True
|
| 192 |
+
)
|
| 193 |
+
)["trivia_categories"]
|
| 194 |
+
btt = []
|
| 195 |
+
for i in req:
|
| 196 |
+
name = i["name"]
|
| 197 |
+
if ":" in name:
|
| 198 |
+
name = name.split(":")[1]
|
| 199 |
+
btt.append(Button.inline(name, f"trziad_{i['id']}"))
|
| 200 |
+
buttons = list(zip(btt[::2], btt[1::2]))
|
| 201 |
+
if len(btt) % 2 == 1:
|
| 202 |
+
buttons.append((btt[-1],))
|
| 203 |
+
buttons.append([Button.inline("Cancel ❌", "delit")])
|
| 204 |
+
TR_BTS.update({"category": buttons})
|
| 205 |
+
text = get_string("games_2")
|
| 206 |
+
elif match[0] == "d":
|
| 207 |
+
cat = match[1:]
|
| 208 |
+
buttons = [[Button.inline(i, f"trziac{cat}_{i}") for i in DIFI_KEYS]]
|
| 209 |
+
buttons.append(get_back_button("trzia"))
|
| 210 |
+
text = get_string("games_3")
|
| 211 |
+
elif match[0] == "c":
|
| 212 |
+
m = match[1:]
|
| 213 |
+
buttons = [[Button.inline(str(i), f"trziat{m}_{i}") for i in range(10, 70, 20)]]
|
| 214 |
+
text = get_string("games_4")
|
| 215 |
+
elif match[0] == "t":
|
| 216 |
+
m_ = match[1:]
|
| 217 |
+
buttons = [
|
| 218 |
+
[Button.inline(str(i), f"trzias{m_}_{i}") for i in [10, 30, 60, 120]]
|
| 219 |
+
]
|
| 220 |
+
text = get_string("games_5")
|
| 221 |
+
elif match[0] == "s":
|
| 222 |
+
chat = event.chat_id
|
| 223 |
+
cat, le, nu, in_ = match[2:].split("_")
|
| 224 |
+
msg = await event.edit(get_string("games_6").format(le, nu))
|
| 225 |
+
for i in reversed(range(5)):
|
| 226 |
+
msg = await msg.edit(buttons=Button.inline(f"{i} ⏰", f"ctdown{i}"))
|
| 227 |
+
await asyncio.sleep(1)
|
| 228 |
+
await msg.edit(
|
| 229 |
+
msg.text + "\n\n• Send /cancel to stop the Quiz...", buttons=None
|
| 230 |
+
)
|
| 231 |
+
qsss = await async_searcher(
|
| 232 |
+
f"https://opentdb.com/api.php?amount={nu}&category={cat}&difficulty={le.lower()}",
|
| 233 |
+
re_json=True,
|
| 234 |
+
)
|
| 235 |
+
qs = qsss["results"]
|
| 236 |
+
if not qs:
|
| 237 |
+
await event.respond("Sorry, No Question Found for the given Criteria..")
|
| 238 |
+
await event.delete()
|
| 239 |
+
return
|
| 240 |
+
TRIVIA_CHATS.update({chat: {}})
|
| 241 |
+
for copper, q in enumerate(qs):
|
| 242 |
+
if TRIVIA_CHATS[chat].get("cancel") is not None:
|
| 243 |
+
break
|
| 244 |
+
ansi = str(uuid.uuid1()).split("-")[0].encode()
|
| 245 |
+
opts = [PollAnswer(unescape(q["correct_answer"]), ansi)]
|
| 246 |
+
[
|
| 247 |
+
opts.append(
|
| 248 |
+
PollAnswer(unescape(a), str(uuid.uuid1()).split("-")[0].encode())
|
| 249 |
+
)
|
| 250 |
+
for a in q["incorrect_answers"]
|
| 251 |
+
]
|
| 252 |
+
shuffle(opts)
|
| 253 |
+
poll = InputMediaPoll(
|
| 254 |
+
Poll(
|
| 255 |
+
0,
|
| 256 |
+
f"[{copper+1}]. " + unescape(q["question"]),
|
| 257 |
+
answers=opts,
|
| 258 |
+
public_voters=True,
|
| 259 |
+
quiz=True,
|
| 260 |
+
close_period=int(in_),
|
| 261 |
+
),
|
| 262 |
+
correct_answers=[ansi],
|
| 263 |
+
solution="Join @TeamUltroid",
|
| 264 |
+
solution_entities=[],
|
| 265 |
+
)
|
| 266 |
+
m_ = await event.client.send_message(chat, file=poll)
|
| 267 |
+
POLLS.update({m_.poll.poll.id: {"chat": m_.chat_id, "answer": ansi}})
|
| 268 |
+
await asyncio.sleep(int(in_))
|
| 269 |
+
if not TRIVIA_CHATS[chat]:
|
| 270 |
+
await event.respond(
|
| 271 |
+
"No-One Got Any Score in the Quiz!\nBetter Luck Next Time!"
|
| 272 |
+
)
|
| 273 |
+
else:
|
| 274 |
+
try:
|
| 275 |
+
await event.respond(file=choice(CONGO_STICKER))
|
| 276 |
+
except ChatSendStickersForbiddenError:
|
| 277 |
+
pass
|
| 278 |
+
LBD = "🎯 **Scoreboard of the Quiz.**\n\n"
|
| 279 |
+
TRC = TRIVIA_CHATS[chat]
|
| 280 |
+
if "cancel" in TRC.keys():
|
| 281 |
+
del TRC["cancel"]
|
| 282 |
+
for userid, user_score in dict(
|
| 283 |
+
sorted(TRC.items(), key=operator.itemgetter(1), reverse=True)
|
| 284 |
+
).items():
|
| 285 |
+
user = inline_mention(await event.client.get_entity(userid))
|
| 286 |
+
LBD += f"••• {user} - {user_score}\n"
|
| 287 |
+
await event.respond(LBD)
|
| 288 |
+
del TRIVIA_CHATS[chat]
|
| 289 |
+
list_ = list(POLLS.copy().keys())
|
| 290 |
+
for key in list_:
|
| 291 |
+
if POLLS[key]["chat"] == chat:
|
| 292 |
+
del POLLS[key]
|
| 293 |
+
return
|
| 294 |
+
await event.edit(text, buttons=buttons)
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
@asst.on(
|
| 298 |
+
Raw(UpdateMessagePollVote, func=lambda x: TRIVIA_CHATS and POLLS.get(x.poll_id))
|
| 299 |
+
)
|
| 300 |
+
async def pollish(eve):
|
| 301 |
+
if POLLS.get(eve.poll_id)["chat"] not in TRIVIA_CHATS.keys():
|
| 302 |
+
return
|
| 303 |
+
if POLLS[eve.poll_id]["answer"] != eve.options[0]:
|
| 304 |
+
return
|
| 305 |
+
chat = POLLS.get(eve.poll_id)["chat"]
|
| 306 |
+
user = eve.user_id
|
| 307 |
+
if not TRIVIA_CHATS.get(chat, {}).get(user):
|
| 308 |
+
TRIVIA_CHATS[chat][user] = 1
|
| 309 |
+
else:
|
| 310 |
+
TRIVIA_CHATS[chat][user] += 1
|
| 311 |
+
|
| 312 |
+
|
| 313 |
+
@asst_cmd("cancel", owner=True, func=lambda x: TRIVIA_CHATS.get(x.chat_id))
|
| 314 |
+
async def cancelish(event):
|
| 315 |
+
chat = TRIVIA_CHATS.get(event.chat_id)
|
| 316 |
+
chat.update({"cancel": True})
|
| 317 |
+
await event.respond("Cancelled!")
|
assistant/initial.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ultroid - UserBot
|
| 2 |
+
# Copyright (C) 2021-2023 TeamUltroid
|
| 3 |
+
#
|
| 4 |
+
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
| 5 |
+
# PLease read the GNU Affero General Public License in
|
| 6 |
+
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
| 7 |
+
|
| 8 |
+
import re
|
| 9 |
+
|
| 10 |
+
from . import *
|
| 11 |
+
|
| 12 |
+
STRINGS = {
|
| 13 |
+
1: """🎇 **Thanks for Deploying Ultroid Userbot!**
|
| 14 |
+
|
| 15 |
+
• Here, are the Some Basic stuff from, where you can Know, about its Usage.""",
|
| 16 |
+
2: """🎉** About Ultroid**
|
| 17 |
+
|
| 18 |
+
🧿 Ultroid is Pluggable and powerful Telethon Userbot, made in Python from Scratch. It is Aimed to Increase Security along with Addition of Other Useful Features.
|
| 19 |
+
|
| 20 |
+
❣ Made by **@TeamUltroid**""",
|
| 21 |
+
3: """**💡• FAQs •**
|
| 22 |
+
|
| 23 |
+
-> [Username Tracker](https://t.me/UltroidUpdates/24)
|
| 24 |
+
-> [Keeping Custom Addons Repo](https://t.me/UltroidUpdates/28)
|
| 25 |
+
-> [Disabling Deploy message](https://t.me/UltroidUpdates/27)
|
| 26 |
+
-> [Setting up TimeZone](https://t.me/UltroidUpdates/22)
|
| 27 |
+
-> [About Inline PmPermit](https://t.me/UltroidUpdates/21)
|
| 28 |
+
-> [About Dual Mode](https://t.me/UltroidUpdates/18)
|
| 29 |
+
-> [Custom Thumbnail](https://t.me/UltroidUpdates/13)
|
| 30 |
+
-> [About FullSudo](https://t.me/UltroidUpdates/11)
|
| 31 |
+
-> [Setting Up PmBot](https://t.me/UltroidUpdates/2)
|
| 32 |
+
-> [Also Check](https://t.me/UltroidUpdates/14)
|
| 33 |
+
|
| 34 |
+
**• To Know About Updates**
|
| 35 |
+
- Join @TeamUltroid.""",
|
| 36 |
+
4: f"""• `To Know All Available Commands`
|
| 37 |
+
|
| 38 |
+
- `{HNDLR}help`
|
| 39 |
+
- `{HNDLR}cmds`""",
|
| 40 |
+
5: """• **For Any Other Query or Suggestion**
|
| 41 |
+
- Move to **@UltroidSupportChat**.
|
| 42 |
+
|
| 43 |
+
• Thanks for Reaching till END.""",
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
@callback(re.compile("initft_(\\d+)"))
|
| 48 |
+
async def init_depl(e):
|
| 49 |
+
CURRENT = int(e.data_match.group(1))
|
| 50 |
+
if CURRENT == 5:
|
| 51 |
+
return await e.edit(
|
| 52 |
+
STRINGS[5],
|
| 53 |
+
buttons=Button.inline("<< Back", "initbk_4"),
|
| 54 |
+
link_preview=False,
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
await e.edit(
|
| 58 |
+
STRINGS[CURRENT],
|
| 59 |
+
buttons=[
|
| 60 |
+
Button.inline("<<", f"initbk_{str(CURRENT - 1)}"),
|
| 61 |
+
Button.inline(">>", f"initft_{str(CURRENT + 1)}"),
|
| 62 |
+
],
|
| 63 |
+
link_preview=False,
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
@callback(re.compile("initbk_(\\d+)"))
|
| 68 |
+
async def ineiq(e):
|
| 69 |
+
CURRENT = int(e.data_match.group(1))
|
| 70 |
+
if CURRENT == 1:
|
| 71 |
+
return await e.edit(
|
| 72 |
+
STRINGS[1],
|
| 73 |
+
buttons=Button.inline("Start Back >>", "initft_2"),
|
| 74 |
+
link_preview=False,
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
await e.edit(
|
| 78 |
+
STRINGS[CURRENT],
|
| 79 |
+
buttons=[
|
| 80 |
+
Button.inline("<<", f"initbk_{str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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ultroid - UserBot
|
| 2 |
+
# Copyright (C) 2021-2023 TeamUltroid
|
| 3 |
+
#
|
| 4 |
+
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
| 5 |
+
# PLease read the GNU Affero General Public License in
|
| 6 |
+
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
| 7 |
+
|
| 8 |
+
import base64
|
| 9 |
+
import inspect
|
| 10 |
+
from datetime import datetime
|
| 11 |
+
from html import unescape
|
| 12 |
+
from random import choice
|
| 13 |
+
from re import compile as re_compile
|
| 14 |
+
|
| 15 |
+
from bs4 import BeautifulSoup as bs
|
| 16 |
+
from telethon import Button
|
| 17 |
+
from telethon.tl.alltlobjects import LAYER, tlobjects
|
| 18 |
+
from telethon.tl.types import DocumentAttributeAudio as Audio
|
| 19 |
+
from telethon.tl.types import InputWebDocument as wb
|
| 20 |
+
|
| 21 |
+
from pyUltroid.fns.misc import google_search
|
| 22 |
+
from pyUltroid.fns.tools import (
|
| 23 |
+
_webupload_cache,
|
| 24 |
+
async_searcher,
|
| 25 |
+
get_ofox,
|
| 26 |
+
saavn_search,
|
| 27 |
+
webuploader,
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
from . import *
|
| 31 |
+
from . import _ult_cache
|
| 32 |
+
|
| 33 |
+
SUP_BUTTONS = [
|
| 34 |
+
[
|
| 35 |
+
Button.url("• Repo •", url="https://github.com/TeamUltroid/Ultroid"),
|
| 36 |
+
Button.url("• Support •", url="t.me/UltroidSupportChat"),
|
| 37 |
+
],
|
| 38 |
+
]
|
| 39 |
+
|
| 40 |
+
ofox = "https://graph.org/file/231f0049fcd722824f13b.jpg"
|
| 41 |
+
gugirl = "https://graph.org/file/0df54ae4541abca96aa11.jpg"
|
| 42 |
+
ultpic = "https://graph.org/file/4136aa1650bc9d4109cc5.jpg"
|
| 43 |
+
|
| 44 |
+
apis = [
|
| 45 |
+
"QUl6YVN5QXlEQnNZM1dSdEI1WVBDNmFCX3c4SkF5NlpkWE5jNkZV",
|
| 46 |
+
"QUl6YVN5QkYwenhMbFlsUE1wOXh3TVFxVktDUVJxOERnZHJMWHNn",
|
| 47 |
+
"QUl6YVN5RGRPS253blB3VklRX2xiSDVzWUU0Rm9YakFLSVFWMERR",
|
| 48 |
+
]
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
@in_pattern("ofox", owner=True)
|
| 52 |
+
async def _(e):
|
| 53 |
+
try:
|
| 54 |
+
match = e.text.split(" ", maxsplit=1)[1]
|
| 55 |
+
except IndexError:
|
| 56 |
+
kkkk = e.builder.article(
|
| 57 |
+
title="Enter Device Codename",
|
| 58 |
+
thumb=wb(ofox, 0, "image/jpeg", []),
|
| 59 |
+
text="**OFᴏx🦊Rᴇᴄᴏᴠᴇʀʏ**\n\nYou didn't search anything",
|
| 60 |
+
buttons=Button.switch_inline("Sᴇᴀʀᴄʜ Aɢᴀɪɴ", query="ofox ", same_peer=True),
|
| 61 |
+
)
|
| 62 |
+
return await e.answer([kkkk])
|
| 63 |
+
device, releases = await get_ofox(match)
|
| 64 |
+
if device.get("detail") is None:
|
| 65 |
+
fox = []
|
| 66 |
+
fullname = device["full_name"]
|
| 67 |
+
codename = device["codename"]
|
| 68 |
+
str(device["supported"])
|
| 69 |
+
maintainer = device["maintainer"]["name"]
|
| 70 |
+
link = f"https://orangefox.download/device/{codename}"
|
| 71 |
+
for data in releases["data"]:
|
| 72 |
+
release = data["type"]
|
| 73 |
+
version = data["version"]
|
| 74 |
+
size = humanbytes(data["size"])
|
| 75 |
+
release_date = datetime.utcfromtimestamp(data["date"]).strftime("%Y-%m-%d")
|
| 76 |
+
text = f"[\xad]({ofox})**OʀᴀɴɢᴇFᴏx Rᴇᴄᴏᴠᴇʀʏ Fᴏʀ**\n\n"
|
| 77 |
+
text += f"` Fᴜʟʟ Nᴀᴍᴇ: {fullname}`\n"
|
| 78 |
+
text += f"` Cᴏᴅᴇɴᴀᴍᴇ: {codename}`\n"
|
| 79 |
+
text += f"` Mᴀɪɴᴛᴀɪɴᴇʀ: {maintainer}`\n"
|
| 80 |
+
text += f"` Bᴜɪʟᴅ Tʏᴘᴇ: {release}`\n"
|
| 81 |
+
text += f"` Vᴇʀsɪᴏɴ: {version}`\n"
|
| 82 |
+
text += f"` Sɪᴢᴇ: {size}`\n"
|
| 83 |
+
text += f"` Bᴜɪʟᴅ Dᴀᴛᴇ: {release_date}`"
|
| 84 |
+
fox.append(
|
| 85 |
+
await e.builder.article(
|
| 86 |
+
title=f"{fullname}",
|
| 87 |
+
description=f"{version}\n{release_date}",
|
| 88 |
+
text=text,
|
| 89 |
+
thumb=wb(ofox, 0, "image/jpeg", []),
|
| 90 |
+
link_preview=True,
|
| 91 |
+
buttons=[
|
| 92 |
+
Button.url("Dᴏᴡɴʟᴏᴀᴅ", url=f"{link}"),
|
| 93 |
+
Button.switch_inline(
|
| 94 |
+
"Sᴇᴀʀᴄʜ Aɢᴀɪɴ", query="ofox ", same_peer=True
|
| 95 |
+
),
|
| 96 |
+
],
|
| 97 |
+
)
|
| 98 |
+
)
|
| 99 |
+
await e.answer(
|
| 100 |
+
fox, switch_pm="OrangeFox Recovery Search.", switch_pm_param="start"
|
| 101 |
+
)
|
| 102 |
+
else:
|
| 103 |
+
await e.answer(
|
| 104 |
+
[], switch_pm="OrangeFox Recovery Search.", switch_pm_param="start"
|
| 105 |
+
)
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
@in_pattern("fl2lnk ?(.*)", owner=True)
|
| 109 |
+
async def _(e):
|
| 110 |
+
match = e.pattern_match.group(1)
|
| 111 |
+
chat_id, msg_id = match.split(":")
|
| 112 |
+
filename = _webupload_cache[int(chat_id)][int(msg_id)]
|
| 113 |
+
if "/" in filename:
|
| 114 |
+
filename = filename.split("/")[-1]
|
| 115 |
+
__cache = f"{chat_id}:{msg_id}"
|
| 116 |
+
buttons = [
|
| 117 |
+
[
|
| 118 |
+
Button.inline("anonfiles", data=f"flanonfiles//{__cache}"),
|
| 119 |
+
Button.inline("transfer", data=f"fltransfer//{__cache}"),
|
| 120 |
+
],
|
| 121 |
+
[
|
| 122 |
+
Button.inline("bayfiles", data=f"flbayfiles//{__cache}"),
|
| 123 |
+
Button.inline("x0.at", data=f"flx0.at//{__cache}"),
|
| 124 |
+
],
|
| 125 |
+
[
|
| 126 |
+
Button.inline("file.io", data=f"flfile.io//{__cache}"),
|
| 127 |
+
Button.inline("siasky", data=f"flsiasky//{__cache}"),
|
| 128 |
+
],
|
| 129 |
+
]
|
| 130 |
+
try:
|
| 131 |
+
lnk = [
|
| 132 |
+
await e.builder.article(
|
| 133 |
+
title=f"Upload {filename}",
|
| 134 |
+
text=f"**File:**\n{filename}",
|
| 135 |
+
buttons=buttons,
|
| 136 |
+
)
|
| 137 |
+
]
|
| 138 |
+
except BaseException as er:
|
| 139 |
+
LOGS.exception(er)
|
| 140 |
+
lnk = [
|
| 141 |
+
await e.builder.article(
|
| 142 |
+
title="fl2lnk",
|
| 143 |
+
text="File not found",
|
| 144 |
+
)
|
| 145 |
+
]
|
| 146 |
+
await e.answer(lnk, switch_pm="File to Link.", switch_pm_param="start")
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
@callback(
|
| 150 |
+
re_compile(
|
| 151 |
+
"fl(.*)",
|
| 152 |
+
),
|
| 153 |
+
owner=True,
|
| 154 |
+
)
|
| 155 |
+
async def _(e):
|
| 156 |
+
t = (e.data).decode("UTF-8")
|
| 157 |
+
data = t[2:]
|
| 158 |
+
host = data.split("//")[0]
|
| 159 |
+
chat_id, msg_id = data.split("//")[1].split(":")
|
| 160 |
+
filename = _webupload_cache[int(chat_id)][int(msg_id)]
|
| 161 |
+
if "/" in filename:
|
| 162 |
+
filename = filename.split("/")[-1]
|
| 163 |
+
await e.edit(f"Uploading `{filename}` on {host}")
|
| 164 |
+
link = (await webuploader(chat_id, msg_id, host)).strip().replace("\n", "")
|
| 165 |
+
await e.edit(f"Uploaded `{filename}` on {host}.", buttons=Button.url("View", link))
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
@in_pattern("repo", owner=True)
|
| 169 |
+
async def repo(e):
|
| 170 |
+
res = [
|
| 171 |
+
await e.builder.article(
|
| 172 |
+
title="Ultroid Userbot",
|
| 173 |
+
description="Userbot | Telethon",
|
| 174 |
+
thumb=wb(ultpic, 0, "image/jpeg", []),
|
| 175 |
+
text="• **ULTROID USERBOT** •",
|
| 176 |
+
buttons=SUP_BUTTONS,
|
| 177 |
+
),
|
| 178 |
+
]
|
| 179 |
+
await e.answer(res, switch_pm="Ultroid Repo.", switch_pm_param="start")
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
@in_pattern("go", owner=True)
|
| 183 |
+
async def gsearch(q_event):
|
| 184 |
+
try:
|
| 185 |
+
match = q_event.text.split(maxsplit=1)[1]
|
| 186 |
+
except IndexError:
|
| 187 |
+
return await q_event.answer(
|
| 188 |
+
[], switch_pm="Google Search. Enter a query!", switch_pm_param="start"
|
| 189 |
+
)
|
| 190 |
+
searcher = []
|
| 191 |
+
gresults = await google_search(match)
|
| 192 |
+
for i in gresults:
|
| 193 |
+
try:
|
| 194 |
+
title = i["title"]
|
| 195 |
+
link = i["link"]
|
| 196 |
+
desc = i["description"]
|
| 197 |
+
searcher.append(
|
| 198 |
+
await q_event.builder.article(
|
| 199 |
+
title=title,
|
| 200 |
+
description=desc,
|
| 201 |
+
thumb=wb(gugirl, 0, "image/jpeg", []),
|
| 202 |
+
text=f"**Gᴏᴏɢʟᴇ Sᴇᴀʀᴄʜ**\n\n**••Tɪᴛʟᴇ••**\n`{title}`\n\n**••Dᴇsᴄʀɪᴘᴛɪᴏɴ••**\n`{desc}`",
|
| 203 |
+
link_preview=False,
|
| 204 |
+
buttons=[
|
| 205 |
+
[Button.url("Lɪɴᴋ", url=f"{link}")],
|
| 206 |
+
[
|
| 207 |
+
Button.switch_inline(
|
| 208 |
+
"Sᴇᴀʀᴄʜ Aɢᴀɪɴ",
|
| 209 |
+
query="go ",
|
| 210 |
+
same_peer=True,
|
| 211 |
+
),
|
| 212 |
+
Button.switch_inline(
|
| 213 |
+
"Sʜᴀʀᴇ",
|
| 214 |
+
query=f"go {match}",
|
| 215 |
+
same_peer=False,
|
| 216 |
+
),
|
| 217 |
+
],
|
| 218 |
+
],
|
| 219 |
+
),
|
| 220 |
+
)
|
| 221 |
+
except IndexError:
|
| 222 |
+
break
|
| 223 |
+
await q_event.answer(searcher, switch_pm="Google Search.", switch_pm_param="start")
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
@in_pattern("mods", owner=True)
|
| 227 |
+
async def _(e):
|
| 228 |
+
try:
|
| 229 |
+
quer = e.text.split(" ", maxsplit=1)[1]
|
| 230 |
+
except IndexError:
|
| 231 |
+
return await e.answer(
|
| 232 |
+
[], switch_pm="Mod Apps Search. Enter app name!", switch_pm_param="start"
|
| 233 |
+
)
|
| 234 |
+
start = 0 * 3 + 1
|
| 235 |
+
da = base64.b64decode(choice(apis)).decode("ascii")
|
| 236 |
+
url = f"https://www.googleapis.com/customsearch/v1?key={da}&cx=25b3b50edb928435b&q={quer}&start={start}"
|
| 237 |
+
data = await async_searcher(url, re_json=True)
|
| 238 |
+
search_items = data.get("items", [])
|
| 239 |
+
modss = []
|
| 240 |
+
for a in search_items:
|
| 241 |
+
title = a.get("title")
|
| 242 |
+
desc = a.get("snippet")
|
| 243 |
+
link = a.get("link")
|
| 244 |
+
text = f"**••Tɪᴛʟᴇ••** `{title}`\n\n"
|
| 245 |
+
text += f"**Dᴇsᴄʀɪᴘᴛɪᴏɴ** `{desc}`"
|
| 246 |
+
modss.append(
|
| 247 |
+
await e.builder.article(
|
| 248 |
+
title=title,
|
| 249 |
+
description=desc,
|
| 250 |
+
text=text,
|
| 251 |
+
link_preview=True,
|
| 252 |
+
buttons=[
|
| 253 |
+
[Button.url("Dᴏᴡɴʟᴏᴀᴅ", url=f"{link}")],
|
| 254 |
+
[
|
| 255 |
+
Button.switch_inline(
|
| 256 |
+
"Mᴏʀᴇ Mᴏᴅs",
|
| 257 |
+
query="mods ",
|
| 258 |
+
same_peer=True,
|
| 259 |
+
),
|
| 260 |
+
Button.switch_inline(
|
| 261 |
+
"Sʜᴀʀᴇ",
|
| 262 |
+
query=f"mods {quer}",
|
| 263 |
+
same_peer=False,
|
| 264 |
+
),
|
| 265 |
+
],
|
| 266 |
+
],
|
| 267 |
+
),
|
| 268 |
+
)
|
| 269 |
+
await e.answer(modss, switch_pm="Search Mod Applications.", switch_pm_param="start")
|
| 270 |
+
|
| 271 |
+
|
| 272 |
+
APP_CACHE = {}
|
| 273 |
+
RECENTS = {}
|
| 274 |
+
PLAY_API = "https://googleplay.onrender.com/api/apps?q="
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
@in_pattern("app", owner=True)
|
| 278 |
+
async def _(e):
|
| 279 |
+
try:
|
| 280 |
+
f = e.text.split(maxsplit=1)[1].lower()
|
| 281 |
+
except IndexError:
|
| 282 |
+
get_string("instu_1")
|
| 283 |
+
res = []
|
| 284 |
+
if APP_CACHE and RECENTS.get(e.sender_id):
|
| 285 |
+
res.extend(
|
| 286 |
+
APP_CACHE[a][0] for a in RECENTS[e.sender_id] if APP_CACHE.get(a)
|
| 287 |
+
)
|
| 288 |
+
return await e.answer(
|
| 289 |
+
res, switch_pm=get_string("instu_2"), switch_pm_param="start"
|
| 290 |
+
)
|
| 291 |
+
try:
|
| 292 |
+
return await e.answer(
|
| 293 |
+
APP_CACHE[f], switch_pm="Application Searcher.", switch_pm_param="start"
|
| 294 |
+
)
|
| 295 |
+
except KeyError:
|
| 296 |
+
pass
|
| 297 |
+
foles = []
|
| 298 |
+
url = PLAY_API + f.replace(" ", "+")
|
| 299 |
+
aap = await async_searcher(url, re_json=True)
|
| 300 |
+
for z in aap["results"][:50]:
|
| 301 |
+
url = "https://play.google.com/store/apps/details?id=" + z["appId"]
|
| 302 |
+
name = z["title"]
|
| 303 |
+
desc = unescape(z["summary"])[:300].replace("<br>", "\n") + "..."
|
| 304 |
+
dev = z["developer"]["devId"]
|
| 305 |
+
text = f"**••Aᴘᴘ Nᴀᴍᴇ••** [{name}]({url})\n"
|
| 306 |
+
text += f"**••Dᴇᴠᴇʟᴏᴘᴇʀ••** `{dev}`\n"
|
| 307 |
+
text += f"**••Dᴇsᴄʀɪᴘᴛɪᴏɴ••**\n`{desc}`"
|
| 308 |
+
foles.append(
|
| 309 |
+
await e.builder.article(
|
| 310 |
+
title=name,
|
| 311 |
+
description=dev,
|
| 312 |
+
thumb=wb(z["icon"], 0, "image/jpeg", []),
|
| 313 |
+
text=text,
|
| 314 |
+
link_preview=True,
|
| 315 |
+
buttons=[
|
| 316 |
+
[Button.url("Lɪɴᴋ", url=url)],
|
| 317 |
+
[
|
| 318 |
+
Button.switch_inline(
|
| 319 |
+
"Mᴏʀᴇ Aᴘᴘs",
|
| 320 |
+
query="app ",
|
| 321 |
+
same_peer=True,
|
| 322 |
+
),
|
| 323 |
+
Button.switch_inline(
|
| 324 |
+
"Sʜᴀʀᴇ",
|
| 325 |
+
query=f"app {f}",
|
| 326 |
+
same_peer=False,
|
| 327 |
+
),
|
| 328 |
+
],
|
| 329 |
+
],
|
| 330 |
+
),
|
| 331 |
+
)
|
| 332 |
+
APP_CACHE.update({f: foles})
|
| 333 |
+
if RECENTS.get(e.sender_id):
|
| 334 |
+
RECENTS[e.sender_id].append(f)
|
| 335 |
+
else:
|
| 336 |
+
RECENTS.update({e.sender_id: [f]})
|
| 337 |
+
await e.answer(foles, switch_pm="Application Searcher.", switch_pm_param="start")
|
| 338 |
+
|
| 339 |
+
|
| 340 |
+
PISTON_URI = "https://emkc.org/api/v2/piston/"
|
| 341 |
+
PISTON_LANGS = {}
|
| 342 |
+
|
| 343 |
+
|
| 344 |
+
@in_pattern("run", owner=True)
|
| 345 |
+
async def piston_run(event):
|
| 346 |
+
try:
|
| 347 |
+
lang = event.text.split()[1]
|
| 348 |
+
code = event.text.split(maxsplit=2)[2]
|
| 349 |
+
except IndexError:
|
| 350 |
+
result = await event.builder.article(
|
| 351 |
+
title="Bad Query",
|
| 352 |
+
description="Usage: [Language] [code]",
|
| 353 |
+
thumb=wb(
|
| 354 |
+
"https://graph.org/file/e33c57fc5f1044547e4d8.jpg", 0, "image/jpeg", []
|
| 355 |
+
),
|
| 356 |
+
text=f'**Inline Usage**\n\n`@{asst.me.username} run python print("hello world")`\n\n[Language List](https://graph.org/Ultroid-09-01-6)',
|
| 357 |
+
)
|
| 358 |
+
return await event.answer([result])
|
| 359 |
+
if not PISTON_LANGS:
|
| 360 |
+
se = await async_searcher(f"{PISTON_URI}runtimes", re_json=True)
|
| 361 |
+
PISTON_LANGS.update({lang.pop("language"): lang for lang in se})
|
| 362 |
+
if lang in PISTON_LANGS.keys():
|
| 363 |
+
version = PISTON_LANGS[lang]["version"]
|
| 364 |
+
else:
|
| 365 |
+
result = await event.builder.article(
|
| 366 |
+
title="Unsupported Language",
|
| 367 |
+
description="Usage: [Language] [code]",
|
| 368 |
+
thumb=wb(
|
| 369 |
+
"https://graph.org/file/e33c57fc5f1044547e4d8.jpg", 0, "image/jpeg", []
|
| 370 |
+
),
|
| 371 |
+
text=f'**Inline Usage**\n\n`@{asst.me.username} run python print("hello world")`\n\n[Language List](https://graph.org/Ultroid-09-01-6)',
|
| 372 |
+
)
|
| 373 |
+
return await event.answer([result])
|
| 374 |
+
output = await async_searcher(
|
| 375 |
+
f"{PISTON_URI}execute",
|
| 376 |
+
post=True,
|
| 377 |
+
json={
|
| 378 |
+
"language": lang,
|
| 379 |
+
"version": version,
|
| 380 |
+
"files": [{"content": code}],
|
| 381 |
+
},
|
| 382 |
+
re_json=True,
|
| 383 |
+
)
|
| 384 |
+
|
| 385 |
+
output = output["run"]["output"] or get_string("instu_4")
|
| 386 |
+
if len(output) > 3000:
|
| 387 |
+
output = f"{output[:3000]}..."
|
| 388 |
+
result = await event.builder.article(
|
| 389 |
+
title="Result",
|
| 390 |
+
description=output,
|
| 391 |
+
text=f"• **Language:**\n`{lang}`\n\n• **Code:**\n`{code}`\n\n• **Result:**\n`{output}`",
|
| 392 |
+
thumb=wb(
|
| 393 |
+
"https://graph.org/file/871ee4a481f58117dccc4.jpg", 0, "image/jpeg", []
|
| 394 |
+
),
|
| 395 |
+
buttons=Button.switch_inline("Fork", query=event.text, same_peer=True),
|
| 396 |
+
)
|
| 397 |
+
await event.answer([result], switch_pm="• Piston •", switch_pm_param="start")
|
| 398 |
+
|
| 399 |
+
|
| 400 |
+
FDROID_ = {}
|
| 401 |
+
|
| 402 |
+
|
| 403 |
+
@in_pattern("fdroid", owner=True)
|
| 404 |
+
async def do_magic(event):
|
| 405 |
+
try:
|
| 406 |
+
match = event.text.split(" ", maxsplit=1)[1].lower()
|
| 407 |
+
except IndexError:
|
| 408 |
+
return await event.answer(
|
| 409 |
+
[], switch_pm="Enter Query to Search", switch_pm_param="start"
|
| 410 |
+
)
|
| 411 |
+
if FDROID_.get(match):
|
| 412 |
+
return await event.answer(
|
| 413 |
+
FDROID_[match], switch_pm=f"• Results for {match}", switch_pm_param="start"
|
| 414 |
+
)
|
| 415 |
+
link = "https://search.f-droid.org/?q=" + match.replace(" ", "+")
|
| 416 |
+
content = await async_searcher(link, re_content=True)
|
| 417 |
+
BSC = bs(content, "html.parser", from_encoding="utf-8")
|
| 418 |
+
ress = []
|
| 419 |
+
for dat in BSC.find_all("a", "package-header")[:10]:
|
| 420 |
+
image = dat.find("img", "package-icon")["src"]
|
| 421 |
+
if image.endswith("/"):
|
| 422 |
+
image = "https://graph.org/file/a8dd4a92c5a53a89d0eff.jpg"
|
| 423 |
+
title = dat.find("h4", "package-name").text.strip()
|
| 424 |
+
desc = dat.find("span", "package-summary").text.strip()
|
| 425 |
+
text = f"• **Name :** `{title}`\n\n"
|
| 426 |
+
text += f"• **Description :** `{desc}`\n"
|
| 427 |
+
text += f"• **License :** `{dat.find('span', 'package-license').text.strip()}`"
|
| 428 |
+
imga = wb(image, 0, "image/jpeg", [])
|
| 429 |
+
ress.append(
|
| 430 |
+
await event.builder.article(
|
| 431 |
+
title=title,
|
| 432 |
+
type="photo",
|
| 433 |
+
description=desc,
|
| 434 |
+
text=text,
|
| 435 |
+
content=imga,
|
| 436 |
+
thumb=imga,
|
| 437 |
+
include_media=True,
|
| 438 |
+
buttons=[
|
| 439 |
+
Button.inline(
|
| 440 |
+
"• Download •", "fd" + dat["href"].split("packages/")[-1]
|
| 441 |
+
),
|
| 442 |
+
Button.switch_inline("• Share •", query=event.text),
|
| 443 |
+
],
|
| 444 |
+
)
|
| 445 |
+
)
|
| 446 |
+
msg = f"Showing {len(ress)} Results!" if ress else "No Results Found"
|
| 447 |
+
FDROID_.update({match: ress})
|
| 448 |
+
await event.answer(ress, switch_pm=msg, switch_pm_param="start")
|
| 449 |
+
|
| 450 |
+
|
| 451 |
+
# Thanks to OpenSource
|
| 452 |
+
_bearer_collected = [
|
| 453 |
+
"AAAAAAAAAAAAAAAAAAAAALIKKgEAAAAA1DRuS%2BI7ZRKiagD6KHYmreaXomo%3DP5Vaje4UTtEkODg0fX7nCh5laSrchhtLxeyEqxXpv0w9ZKspLD",
|
| 454 |
+
"AAAAAAAAAAAAAAAAAAAAAL5iUAEAAAAAmo6FYRjqdKlI3cNziIm%2BHUQB9Xs%3DS31pj0mxARMTOk2g9dvQ1yP9wknvY4FPBPUlE00smJcncw4dPR",
|
| 455 |
+
"AAAAAAAAAAAAAAAAAAAAAN6sVgEAAAAAMMjMMWrwgGyv7YQOWN%2FSAsO5SGM%3Dg8MG9Jq93Rlllaok6eht7HvRCruN4Vpzp4NaVsZaaHHWSTzKI8",
|
| 456 |
+
]
|
| 457 |
+
|
| 458 |
+
|
| 459 |
+
@in_pattern("twitter", owner=True)
|
| 460 |
+
async def twitter_search(event):
|
| 461 |
+
try:
|
| 462 |
+
match = event.text.split(maxsplit=1)[1].lower()
|
| 463 |
+
except IndexError:
|
| 464 |
+
return await event.answer(
|
| 465 |
+
[], switch_pm="Enter Query to Search", switch_pm_param="start"
|
| 466 |
+
)
|
| 467 |
+
try:
|
| 468 |
+
return await event.answer(
|
| 469 |
+
_ult_cache["twitter"][match],
|
| 470 |
+
switch_pm="• Twitter Search •",
|
| 471 |
+
switch_pm_param="start",
|
| 472 |
+
)
|
| 473 |
+
except KeyError:
|
| 474 |
+
pass
|
| 475 |
+
headers = {"Authorization": f"bearer {choice(_bearer_collected)}"}
|
| 476 |
+
res = await async_searcher(
|
| 477 |
+
f"https://api.twitter.com/1.1/users/search.json?q={match}",
|
| 478 |
+
headers=headers,
|
| 479 |
+
re_json=True,
|
| 480 |
+
)
|
| 481 |
+
reso = []
|
| 482 |
+
for user in res:
|
| 483 |
+
thumb = wb(user["profile_image_url_https"], 0, "image/jpeg", [])
|
| 484 |
+
if user.get("profile_banner_url"):
|
| 485 |
+
url = user["profile_banner_url"]
|
| 486 |
+
text = f"[\xad]({url})• **Name :** `{user['name']}`\n"
|
| 487 |
+
else:
|
| 488 |
+
text = f"• **Name :** `{user['name']}`\n"
|
| 489 |
+
text += f"• **Description :** `{user['description']}`\n"
|
| 490 |
+
text += f"• **Username :** `@{user['screen_name']}`\n"
|
| 491 |
+
text += f"• **Followers :** `{user['followers_count']}` • **Following :** `{user['friends_count']}`\n"
|
| 492 |
+
pro_ = "https://twitter.com/" + user["screen_name"]
|
| 493 |
+
text += f"• **Link :** [Click Here]({pro_})\n_"
|
| 494 |
+
reso.append(
|
| 495 |
+
await event.builder.article(
|
| 496 |
+
title=user["name"],
|
| 497 |
+
description=user["description"],
|
| 498 |
+
url=pro_,
|
| 499 |
+
text=text,
|
| 500 |
+
thumb=thumb,
|
| 501 |
+
)
|
| 502 |
+
)
|
| 503 |
+
swi_ = f"🐦 Showing {len(reso)} Results!" if reso else "No User Found :("
|
| 504 |
+
await event.answer(reso, switch_pm=swi_, switch_pm_param="start")
|
| 505 |
+
if _ult_cache.get("twitter"):
|
| 506 |
+
_ult_cache["twitter"].update({match: reso})
|
| 507 |
+
else:
|
| 508 |
+
_ult_cache.update({"twitter": {match: reso}})
|
| 509 |
+
|
| 510 |
+
|
| 511 |
+
_savn_cache = {}
|
| 512 |
+
|
| 513 |
+
|
| 514 |
+
@in_pattern("saavn", owner=True)
|
| 515 |
+
async def savn_s(event):
|
| 516 |
+
try:
|
| 517 |
+
query = event.text.split(maxsplit=1)[1].lower()
|
| 518 |
+
except IndexError:
|
| 519 |
+
return await event.answer(
|
| 520 |
+
[], switch_pm="Enter Query to search 🔍", switch_pm_param="start"
|
| 521 |
+
)
|
| 522 |
+
if query in _savn_cache:
|
| 523 |
+
return await event.answer(
|
| 524 |
+
_savn_cache[query],
|
| 525 |
+
switch_pm=f"Showing Results for {query}",
|
| 526 |
+
switch_pm_param="start",
|
| 527 |
+
)
|
| 528 |
+
results = await saavn_search(query)
|
| 529 |
+
swi = "🎵 Saavn Search" if results else "No Results Found!"
|
| 530 |
+
res = []
|
| 531 |
+
for song in results:
|
| 532 |
+
thumb = wb(song["image"], 0, "image/jpeg", [])
|
| 533 |
+
text = f"• **Title :** {song['title']}"
|
| 534 |
+
text += f"\n• **Year :** {song['year']}"
|
| 535 |
+
text += f"\n• **Lang :** {song['language']}"
|
| 536 |
+
text += f"\n• **Artist :** {song['artists']}"
|
| 537 |
+
text += f"\n• **Release Date :** {song['release_date']}"
|
| 538 |
+
res.append(
|
| 539 |
+
await event.builder.article(
|
| 540 |
+
title=song["title"],
|
| 541 |
+
description=song["artists"],
|
| 542 |
+
type="audio",
|
| 543 |
+
text=text,
|
| 544 |
+
include_media=True,
|
| 545 |
+
buttons=Button.switch_inline(
|
| 546 |
+
"Search Again 🔍", query="saavn", same_peer=True
|
| 547 |
+
),
|
| 548 |
+
thumb=thumb,
|
| 549 |
+
content=wb(
|
| 550 |
+
song["url"],
|
| 551 |
+
0,
|
| 552 |
+
"audio/mp4",
|
| 553 |
+
[
|
| 554 |
+
Audio(
|
| 555 |
+
title=song["title"],
|
| 556 |
+
duration=int(song["duration"]),
|
| 557 |
+
performer=song["artists"],
|
| 558 |
+
)
|
| 559 |
+
],
|
| 560 |
+
),
|
| 561 |
+
)
|
| 562 |
+
)
|
| 563 |
+
await event.answer(res, switch_pm=swi, switch_pm_param="start")
|
| 564 |
+
_savn_cache.update({query: res})
|
| 565 |
+
|
| 566 |
+
|
| 567 |
+
@in_pattern("tl", owner=True)
|
| 568 |
+
async def inline_tl(ult):
|
| 569 |
+
try:
|
| 570 |
+
match = ult.text.split(maxsplit=1)[1]
|
| 571 |
+
except IndexError:
|
| 572 |
+
text = f"**Telegram TlObjects Searcher.**\n__(Don't use if you don't know what it is!)__\n\n• Example Usage\n`@{asst.me.username} tl GetFullUserRequest`"
|
| 573 |
+
return await ult.answer(
|
| 574 |
+
[
|
| 575 |
+
await ult.builder.article(
|
| 576 |
+
title="How to Use?",
|
| 577 |
+
description="Tl Searcher by Ultroid",
|
| 578 |
+
url="https://t.me/TeamUltroid",
|
| 579 |
+
text=text,
|
| 580 |
+
)
|
| 581 |
+
],
|
| 582 |
+
switch_pm="Tl Search 🔍",
|
| 583 |
+
switch_pm_param="start",
|
| 584 |
+
)
|
| 585 |
+
res = []
|
| 586 |
+
for key in tlobjects.values():
|
| 587 |
+
if match.lower() in key.__name__.lower():
|
| 588 |
+
tyyp = "Function" if "tl.functions." in str(key) else "Type"
|
| 589 |
+
text = f"**Name:** `{key.__name__}`\n"
|
| 590 |
+
text += f"**Category:** `{tyyp}`\n"
|
| 591 |
+
text += f"\n`from {key.__module__} import {key.__name__}`\n\n"
|
| 592 |
+
if args := str(inspect.signature(key))[1:][:-1]:
|
| 593 |
+
text += "**Parameter:**\n"
|
| 594 |
+
for para in args.split(","):
|
| 595 |
+
text += " " * 4 + "`" + para + "`\n"
|
| 596 |
+
text += f"\n**Layer:** `{LAYER}`"
|
| 597 |
+
res.append(
|
| 598 |
+
await ult.builder.article(
|
| 599 |
+
title=key.__name__,
|
| 600 |
+
description=tyyp,
|
| 601 |
+
url="https://t.me/TeamUltroid",
|
| 602 |
+
text=text[:4000],
|
| 603 |
+
)
|
| 604 |
+
)
|
| 605 |
+
mo = f"Showing {len(res)} results!" if res else f"No Results for {match}!"
|
| 606 |
+
await ult.answer(res[:50], switch_pm=mo, switch_pm_param="start")
|
| 607 |
+
|
| 608 |
+
|
| 609 |
+
InlinePlugin.update(
|
| 610 |
+
{
|
| 611 |
+
"Pʟᴀʏ Sᴛᴏʀᴇ Aᴘᴘs": "app telegram",
|
| 612 |
+
"Mᴏᴅᴅᴇᴅ Aᴘᴘs": "mods minecraft",
|
| 613 |
+
"Sᴇᴀʀᴄʜ Oɴ Gᴏᴏɢʟᴇ": "go TeamUltroid",
|
| 614 |
+
"WʜɪSᴘᴇʀ": "wspr @username Hello🎉",
|
| 615 |
+
"YᴏᴜTᴜʙᴇ Dᴏᴡɴʟᴏᴀᴅᴇʀ": "yt Ed Sheeran Perfect",
|
| 616 |
+
"Piston Eval": "run javascript console.log('Hello Ultroid')",
|
| 617 |
+
"OʀᴀɴɢᴇFᴏx🦊": "ofox beryllium",
|
| 618 |
+
"Tᴡɪᴛᴛᴇʀ Usᴇʀ": "twitter theultroid",
|
| 619 |
+
"Fᴅʀᴏɪᴅ Sᴇᴀʀᴄʜ": "fdroid telegram",
|
| 620 |
+
"Sᴀᴀᴠɴ sᴇᴀʀᴄʜ": "saavn",
|
| 621 |
+
"Tʟ Sᴇᴀʀᴄʜ": "tl",
|
| 622 |
+
}
|
| 623 |
+
)
|
assistant/localization.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ultroid - UserBot
|
| 2 |
+
# Copyright (C) 2021-2023 TeamUltroid
|
| 3 |
+
#
|
| 4 |
+
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
| 5 |
+
# PLease read the GNU Affero General Public License in
|
| 6 |
+
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
| 7 |
+
|
| 8 |
+
import re
|
| 9 |
+
|
| 10 |
+
from . import (
|
| 11 |
+
Button,
|
| 12 |
+
ULTConfig,
|
| 13 |
+
callback,
|
| 14 |
+
get_back_button,
|
| 15 |
+
get_languages,
|
| 16 |
+
get_string,
|
| 17 |
+
udB,
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
@callback("lang", owner=True)
|
| 22 |
+
async def setlang(event):
|
| 23 |
+
languages = get_languages()
|
| 24 |
+
tultd = [
|
| 25 |
+
Button.inline(
|
| 26 |
+
f"{languages[ult]['natively']} [{ult.lower()}]",
|
| 27 |
+
data=f"set_{ult}",
|
| 28 |
+
)
|
| 29 |
+
for ult in languages
|
| 30 |
+
]
|
| 31 |
+
buttons = list(zip(tultd[::2], tultd[1::2]))
|
| 32 |
+
if len(tultd) % 2 == 1:
|
| 33 |
+
buttons.append((tultd[-1],))
|
| 34 |
+
buttons.append([Button.inline("« Back", data="mainmenu")])
|
| 35 |
+
await event.edit(get_string("ast_4"), buttons=buttons)
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
@callback(re.compile(b"set_(.*)"), owner=True)
|
| 39 |
+
async def settt(event):
|
| 40 |
+
lang = event.data_match.group(1).decode("UTF-8")
|
| 41 |
+
languages = get_languages()
|
| 42 |
+
ULTConfig.lang = lang
|
| 43 |
+
udB.del_key("language") if lang == "en" else udB.set_key("language", lang)
|
| 44 |
+
await event.edit(
|
| 45 |
+
f"Your language has been set to {languages[lang]['natively']} [{lang}].",
|
| 46 |
+
buttons=get_back_button("lang"),
|
| 47 |
+
)
|
assistant/manager/__init__.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ultroid - UserBot
|
| 2 |
+
# Copyright (C) 2021-2023 TeamUltroid
|
| 3 |
+
#
|
| 4 |
+
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
| 5 |
+
# PLease read the GNU Affero General Public License in
|
| 6 |
+
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
| 7 |
+
|
| 8 |
+
from pyUltroid._misc._decorators import ultroid_cmd
|
| 9 |
+
from pyUltroid.fns.helper import inline_mention
|
| 10 |
+
|
| 11 |
+
from .. import *
|
assistant/manager/_help.py
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ultroid - UserBot
|
| 2 |
+
# Copyright (C) 2021-2023 TeamUltroid
|
| 3 |
+
#
|
| 4 |
+
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
| 5 |
+
# PLease read the GNU Affero General Public License in
|
| 6 |
+
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
| 7 |
+
|
| 8 |
+
from . import *
|
| 9 |
+
|
| 10 |
+
START = """
|
| 11 |
+
🪅 **Help Menu** 🪅
|
| 12 |
+
|
| 13 |
+
✘ /start : Check I am Alive or not.
|
| 14 |
+
✘ /help : Get This Message.
|
| 15 |
+
✘ /repo : Get Bot's Repo..
|
| 16 |
+
|
| 17 |
+
🧑💻 Join **@TeamUltroid**
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
ADMINTOOLS = """✘ **AdminTools** ✘
|
| 21 |
+
|
| 22 |
+
• /pin : Pins the Replied Message
|
| 23 |
+
• /pinned : Get Pinned message in chat.
|
| 24 |
+
• /unpin : Unpin the Replied message
|
| 25 |
+
• /unpin all : Unpin all Pinned Messages.
|
| 26 |
+
|
| 27 |
+
• /ban (username/id/reply) : Ban the User
|
| 28 |
+
• /unban (username/id/reply) : UnBan the User.
|
| 29 |
+
|
| 30 |
+
• /mute (username/id/reply) : Mute the User.
|
| 31 |
+
• /unmute (username/id/reply) : Unmute the User.
|
| 32 |
+
|
| 33 |
+
• /tban (username/id/reply) (time) : Temporary ban a user
|
| 34 |
+
• /tmute (username/id/reply) (time) : temporary Mutes a User.
|
| 35 |
+
|
| 36 |
+
• /purge (purge messages)
|
| 37 |
+
|
| 38 |
+
• /setgpic (reply photo) : keep Chat Photo of Group.
|
| 39 |
+
• /delgpic : remove current chat Photo."""
|
| 40 |
+
|
| 41 |
+
UTILITIES = """
|
| 42 |
+
✘ ** Utilities ** ✘
|
| 43 |
+
|
| 44 |
+
• /info (reply/username/id) : get detailed info of user.
|
| 45 |
+
• /id : get chat/user id.
|
| 46 |
+
• /tr : Translate Languages..
|
| 47 |
+
• /q : Create Quotes.
|
| 48 |
+
|
| 49 |
+
• /paste (reply file/text) : paste content on Spaceb.in
|
| 50 |
+
• /meaning (text) : Get Meaning of that Word.
|
| 51 |
+
• /google (query) : Search Something on Google..
|
| 52 |
+
|
| 53 |
+
• /suggest (query/reply) : Creates a Yes / No Poll.
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
LOCKS = """
|
| 57 |
+
✘ ** Locks ** ✘
|
| 58 |
+
|
| 59 |
+
• /lock (query) : lock particular content in chat.
|
| 60 |
+
• /unlock (query) : Unlock some content.
|
| 61 |
+
|
| 62 |
+
• All Queries
|
| 63 |
+
- `msgs` : for messages.
|
| 64 |
+
- `inlines` : for inline queries.
|
| 65 |
+
- `media` : for all medias.
|
| 66 |
+
- `games` : for games.
|
| 67 |
+
- `sticker` : for stickers.
|
| 68 |
+
- `polls` : for polls.
|
| 69 |
+
- `gif` : for gifs.
|
| 70 |
+
- `pin` : for pins.
|
| 71 |
+
- `changeinfo` : for change info right.
|
| 72 |
+
"""
|
| 73 |
+
|
| 74 |
+
MISC = """
|
| 75 |
+
✘ **Misc** ✘
|
| 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():
|
| 91 |
+
BTTS = []
|
| 92 |
+
keys = STRINGS.copy()
|
| 93 |
+
while keys:
|
| 94 |
+
BT = []
|
| 95 |
+
for i in list(keys)[:2]:
|
| 96 |
+
text = f"{MNGE} {i} {MNGE}"
|
| 97 |
+
BT.append(Button.inline(text, f"hlp_{i}"))
|
| 98 |
+
del keys[i]
|
| 99 |
+
BTTS.append(BT)
|
| 100 |
+
url = f"https://t.me/{asst.me.username}?startgroup=true"
|
| 101 |
+
BTTS.append([Button.url("Add me to Group", url)])
|
| 102 |
+
return BTTS
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
@asst_cmd(pattern="help")
|
| 106 |
+
async def helpish(event):
|
| 107 |
+
if not event.is_private:
|
| 108 |
+
url = f"https://t.me/{asst.me.username}?start=start"
|
| 109 |
+
return await event.reply(
|
| 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)
|
| 120 |
+
async def ehwhshd(e):
|
| 121 |
+
buttons = get_buttons()
|
| 122 |
+
buttons.append([Button.inline("<< Back", "open")])
|
| 123 |
+
await e.edit(buttons=buttons)
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
@callback("mnghome")
|
| 127 |
+
async def home_aja(e):
|
| 128 |
+
await e.edit(START, buttons=get_buttons())
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
@callback(re.compile("hlp_(.*)"))
|
| 132 |
+
async def do_something(event):
|
| 133 |
+
match = event.pattern_match.group(1).strip().decode("utf-8")
|
| 134 |
+
await event.edit(STRINGS[match], buttons=Button.inline("<< Back", "mnghome"))
|
assistant/manager/_on_adds.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ultroid - UserBot
|
| 2 |
+
# Copyright (C) 2021-2023 TeamUltroid
|
| 3 |
+
#
|
| 4 |
+
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
| 5 |
+
# PLease read the GNU Affero General Public License in
|
| 6 |
+
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
| 7 |
+
|
| 8 |
+
from telethon 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:
|
| 22 |
+
sm = "Thanks for Adding me :)"
|
| 23 |
+
await e.reply(sm, link_preview=False)
|
assistant/manager/admins.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ultroid - UserBot
|
| 2 |
+
# Copyright (C) 2021-2023 TeamUltroid
|
| 3 |
+
#
|
| 4 |
+
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
| 5 |
+
# PLease read the GNU Affero General Public License in
|
| 6 |
+
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
| 7 |
+
|
| 8 |
+
import re
|
| 9 |
+
|
| 10 |
+
from telethon.errors.rpcerrorlist import UserNotParticipantError
|
| 11 |
+
|
| 12 |
+
from pyUltroid import _ult_cache
|
| 13 |
+
|
| 14 |
+
from . import *
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
@ultroid_cmd(pattern="d(kick|ban)", manager=True, require="ban_users")
|
| 18 |
+
async def dowj(e):
|
| 19 |
+
replied = await e.get_reply_message()
|
| 20 |
+
if replied:
|
| 21 |
+
user = replied.sender_id
|
| 22 |
+
else:
|
| 23 |
+
return await e.eor("Reply to a message...")
|
| 24 |
+
try:
|
| 25 |
+
await replied.delete()
|
| 26 |
+
if e.pattern_match.group(1).strip() == "kick":
|
| 27 |
+
await e.client.kick_participant(e.chat_id, user)
|
| 28 |
+
te = "Kicked"
|
| 29 |
+
else:
|
| 30 |
+
await e.client.edit_permissions(e.chat_id, user, view_messages=False)
|
| 31 |
+
te = "Banned"
|
| 32 |
+
await e.eor(f"{te} Successfully!")
|
| 33 |
+
except Exception as E:
|
| 34 |
+
await e.eor(str(E))
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
@callback(re.compile("cc_(.*)"), func=_ult_cache.get("admin_callback"))
|
| 38 |
+
async def callback_(event):
|
| 39 |
+
data = event.data_match.group(1).decode("utf-8")
|
| 40 |
+
if data not in _ult_cache.get("admin_callback", {}):
|
| 41 |
+
return
|
| 42 |
+
try:
|
| 43 |
+
perm = await event.client.get_permissions(event.chat_id, event.sender_id)
|
| 44 |
+
except UserNotParticipantError:
|
| 45 |
+
return await event.answer("Join the Group First!", alert=True)
|
| 46 |
+
if not perm.is_admin:
|
| 47 |
+
return await event.answer("You are not an Admin!", alert=True)
|
| 48 |
+
_ult_cache["admin_callback"].update({data: (event.sender, perm)})
|
| 49 |
+
await event.answer("Verification Done!")
|
| 50 |
+
await event.delete()
|
assistant/manager/afk.py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ultroid - UserBot
|
| 2 |
+
# Copyright (C) 2021-2023 TeamUltroid
|
| 3 |
+
#
|
| 4 |
+
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
| 5 |
+
# PLease read the GNU Affero General Public License in
|
| 6 |
+
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
| 7 |
+
|
| 8 |
+
from datetime import datetime as dt
|
| 9 |
+
|
| 10 |
+
from telethon.events import NewMessage
|
| 11 |
+
from telethon.tl.types import (
|
| 12 |
+
Message,
|
| 13 |
+
MessageEntityMention,
|
| 14 |
+
MessageEntityMentionName,
|
| 15 |
+
User,
|
| 16 |
+
)
|
| 17 |
+
from telethon.utils import get_display_name
|
| 18 |
+
|
| 19 |
+
from pyUltroid.fns.helper import inline_mention, time_formatter
|
| 20 |
+
|
| 21 |
+
from . import asst, asst_cmd
|
| 22 |
+
|
| 23 |
+
AFK = {}
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
@asst_cmd(pattern="afk", func=lambda x: not x.is_private)
|
| 27 |
+
async def go_afk(event):
|
| 28 |
+
sender = await event.get_sender()
|
| 29 |
+
if (not isinstance(sender, User)) or sender.bot:
|
| 30 |
+
return
|
| 31 |
+
try:
|
| 32 |
+
reason = event.text.split(" ", maxsplit=1)[1]
|
| 33 |
+
except IndexError:
|
| 34 |
+
reason = None
|
| 35 |
+
if event.is_reply and not reason:
|
| 36 |
+
replied = await event.get_reply_message()
|
| 37 |
+
if not reason and replied.text and not replied.media:
|
| 38 |
+
reason = replied.text
|
| 39 |
+
else:
|
| 40 |
+
reason = replied
|
| 41 |
+
time_ = dt.now()
|
| 42 |
+
if AFK.get(event.chat_id):
|
| 43 |
+
AFK[event.chat_id].update({event.sender_id: {"reason": reason, "time": time_}})
|
| 44 |
+
else:
|
| 45 |
+
AFK.update(
|
| 46 |
+
{event.chat_id: {event.sender_id: {"reason": reason, "time": time_}}}
|
| 47 |
+
)
|
| 48 |
+
mention = inline_mention(sender)
|
| 49 |
+
msg = f"**{mention} went AFK Now!**"
|
| 50 |
+
if reason and not isinstance(reason, str):
|
| 51 |
+
await event.reply(reason)
|
| 52 |
+
else:
|
| 53 |
+
msg += f"\n\n**Reason : ** `{reason}`"
|
| 54 |
+
await event.reply(msg)
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
@asst.on(NewMessage(func=lambda x: AFK.get(x.chat_id) and not x.is_private))
|
| 58 |
+
async def make_change(event):
|
| 59 |
+
if event.text.startswith("/afk"):
|
| 60 |
+
return
|
| 61 |
+
sender = await event.get_sender()
|
| 62 |
+
if (not isinstance(sender, User)) or sender.bot:
|
| 63 |
+
return
|
| 64 |
+
chat_ = AFK[event.chat_id]
|
| 65 |
+
if event.sender_id in chat_.keys():
|
| 66 |
+
name = get_display_name(event.sender)
|
| 67 |
+
cha_send = chat_[event.sender_id]
|
| 68 |
+
time_ = time_formatter((dt.now() - cha_send["time"]).seconds * 1000)
|
| 69 |
+
msg = f"**{name}** is No Longer AFK!\n**Was AFK for** {time_}"
|
| 70 |
+
await event.reply(msg)
|
| 71 |
+
del chat_[event.sender_id]
|
| 72 |
+
if not chat_:
|
| 73 |
+
del AFK[event.chat_id]
|
| 74 |
+
ST_SPAM = []
|
| 75 |
+
replied = await event.get_reply_message()
|
| 76 |
+
if replied:
|
| 77 |
+
name = get_display_name(replied.sender)
|
| 78 |
+
if replied.sender_id in chat_.keys():
|
| 79 |
+
s_der = chat_[replied.sender_id]
|
| 80 |
+
res_ = s_der["reason"]
|
| 81 |
+
time_ = time_formatter((dt.now() - s_der["time"]).seconds * 1000)
|
| 82 |
+
msg = f"**{name}** is AFK Currently!\n**From :** {time_}"
|
| 83 |
+
if res_ and isinstance(res_, str):
|
| 84 |
+
msg += f"\n**Reason :** {res_}"
|
| 85 |
+
elif res_ and isinstance(res_, Message):
|
| 86 |
+
await event.reply(res_)
|
| 87 |
+
await event.reply(msg)
|
| 88 |
+
ST_SPAM.append(replied.sender_id)
|
| 89 |
+
for ent, text in event.get_entities_text():
|
| 90 |
+
dont_send, entity = None, None
|
| 91 |
+
if isinstance(ent, MessageEntityMentionName):
|
| 92 |
+
c_id = ent.user_id
|
| 93 |
+
elif isinstance(ent, MessageEntityMention):
|
| 94 |
+
c_id = text
|
| 95 |
+
else:
|
| 96 |
+
c_id = None
|
| 97 |
+
if c_id:
|
| 98 |
+
entity = await event.client.get_entity(c_id)
|
| 99 |
+
if entity and entity.id in chat_.keys() and entity.id not in ST_SPAM:
|
| 100 |
+
ST_SPAM.append(entity.id)
|
| 101 |
+
s_der = chat_[entity.id]
|
| 102 |
+
name = get_display_name(entity)
|
| 103 |
+
res_ = s_der["reason"]
|
| 104 |
+
time_ = time_formatter((dt.now() - s_der["time"]).seconds * 1000)
|
| 105 |
+
msg = f"**{name}** is AFK Currently!\n**From :** {time_}"
|
| 106 |
+
if res_ and isinstance(res_, str):
|
| 107 |
+
msg += f"\n**Reason :** {res_}"
|
| 108 |
+
elif res_ and isinstance(res_, Message):
|
| 109 |
+
await event.reply(res_)
|
| 110 |
+
await event.reply(msg)
|
assistant/manager/misc.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ultroid - UserBot
|
| 2 |
+
# Copyright (C) 2021-2023 TeamUltroid
|
| 3 |
+
#
|
| 4 |
+
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
| 5 |
+
# PLease read the GNU Affero General Public License in
|
| 6 |
+
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
import random
|
| 10 |
+
|
| 11 |
+
import aiohttp
|
| 12 |
+
|
| 13 |
+
from pyUltroid.dB import DEVLIST
|
| 14 |
+
from pyUltroid.fns.admins import admin_check
|
| 15 |
+
|
| 16 |
+
from . import *
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
@asst_cmd(pattern="decide")
|
| 20 |
+
async def dheh(e):
|
| 21 |
+
text = ["Yes", "NoU", "Maybe", "IDK"]
|
| 22 |
+
text = random.choice(text)
|
| 23 |
+
ri = e.reply_to_msg_id or e.id
|
| 24 |
+
await e.client.send_message(e.chat_id, text, reply_to=ri)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
@asst_cmd(pattern="echo( (.*)|$)")
|
| 28 |
+
async def oqha(e):
|
| 29 |
+
if not await admin_check(e):
|
| 30 |
+
return
|
| 31 |
+
if match := e.pattern_match.group(1).strip():
|
| 32 |
+
text = match
|
| 33 |
+
reply_to = e
|
| 34 |
+
elif e.is_reply:
|
| 35 |
+
text = (await e.get_reply_message()).text
|
| 36 |
+
reply_to = e.reply_to_msg_id
|
| 37 |
+
else:
|
| 38 |
+
return await e.eor("What to Echo?", time=5)
|
| 39 |
+
try:
|
| 40 |
+
await e.delete()
|
| 41 |
+
except BaseException as ex:
|
| 42 |
+
LOGS.error(ex)
|
| 43 |
+
await e.client.send_message(e.chat_id, text, reply_to=reply_to)
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
@asst_cmd(pattern="kickme$")
|
| 47 |
+
async def doit(e):
|
| 48 |
+
if e.sender_id in DEVLIST:
|
| 49 |
+
return await eod(e, "`I will Not Kick You, my Developer..`")
|
| 50 |
+
try:
|
| 51 |
+
await e.client.kick_participant(e.chat_id, e.sender_id)
|
| 52 |
+
except Exception as Fe:
|
| 53 |
+
return await e.eor(str(Fe), time=5)
|
| 54 |
+
await e.eor("Yes, You are right, get out.", time=5)
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
@asst_cmd(pattern="joke$")
|
| 58 |
+
async def do_joke(e):
|
| 59 |
+
e = await e.get_reply_message() if e.is_reply else e
|
| 60 |
+
link = "https://v2.jokeapi.dev/joke/Any?blacklistFlags=nsfw,religious,political,racist,sexist,explicit&type=single"
|
| 61 |
+
async with aiohttp.ClientSession() as ses:
|
| 62 |
+
async with ses.get(link) as out:
|
| 63 |
+
out = await out.json()
|
| 64 |
+
await e.reply(out["joke"])
|
assistant/manager/stickermanager.py
ADDED
|
@@ -0,0 +1,180 @@
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ultroid - UserBot
|
| 2 |
+
# Copyright (C) 2021-2023 TeamUltroid
|
| 3 |
+
#
|
| 4 |
+
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
| 5 |
+
# PLease read the GNU Affero General Public License in
|
| 6 |
+
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
| 7 |
+
|
| 8 |
+
import random
|
| 9 |
+
|
| 10 |
+
from telethon import errors
|
| 11 |
+
from telethon.errors.rpcerrorlist import StickersetInvalidError
|
| 12 |
+
from telethon.tl.functions.messages import GetStickerSetRequest as GetSticker
|
| 13 |
+
from telethon.tl.functions.messages import UploadMediaRequest
|
| 14 |
+
from telethon.tl.functions.stickers import AddStickerToSetRequest as AddSticker
|
| 15 |
+
from telethon.tl.functions.stickers import CreateStickerSetRequest
|
| 16 |
+
from telethon.tl.types import InputPeerSelf
|
| 17 |
+
from telethon.tl.types import InputStickerSetItem as SetItem
|
| 18 |
+
from telethon.tl.types import InputStickerSetShortName, User
|
| 19 |
+
from telethon.utils import get_display_name, get_input_document
|
| 20 |
+
|
| 21 |
+
from pyUltroid.fns.misc import Quotly
|
| 22 |
+
from pyUltroid.fns.tools import TgConverter
|
| 23 |
+
|
| 24 |
+
from . import LOGS, asst, asst_cmd, udB
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
@asst_cmd(
|
| 28 |
+
pattern="kang",
|
| 29 |
+
)
|
| 30 |
+
async def kang_cmd(ult):
|
| 31 |
+
sender = await ult.get_sender()
|
| 32 |
+
if not isinstance(sender, User):
|
| 33 |
+
return
|
| 34 |
+
if not ult.is_reply:
|
| 35 |
+
return await ult.eor("`Reply to a sticker/photo..`", time=5)
|
| 36 |
+
reply = await ult.get_reply_message()
|
| 37 |
+
if sender.username:
|
| 38 |
+
pre = sender.username[:4]
|
| 39 |
+
else:
|
| 40 |
+
pre = random.random_string(length=3)
|
| 41 |
+
animated, dl, video = None, None, None
|
| 42 |
+
try:
|
| 43 |
+
emoji = ult.text.split(maxsplit=1)[1]
|
| 44 |
+
except IndexError:
|
| 45 |
+
emoji = None
|
| 46 |
+
if reply.sticker:
|
| 47 |
+
file = get_input_document(reply.sticker)
|
| 48 |
+
emoji = emoji or reply.file.emoji
|
| 49 |
+
name = reply.file.name
|
| 50 |
+
if name.endswith(".tgs"):
|
| 51 |
+
animated = True
|
| 52 |
+
dl = await reply.download_media()
|
| 53 |
+
elif name.endswith(".webm"):
|
| 54 |
+
video = True
|
| 55 |
+
dl = await reply.download_media()
|
| 56 |
+
elif reply.photo:
|
| 57 |
+
dl = await reply.download_media()
|
| 58 |
+
name = "sticker.webp"
|
| 59 |
+
image = TgConverter.resize_photo_sticker(dl)
|
| 60 |
+
image.save(name, "WEBP")
|
| 61 |
+
elif reply.text:
|
| 62 |
+
dl = await Quotly().create_quotly(reply)
|
| 63 |
+
else:
|
| 64 |
+
return await ult.eor("`Reply to sticker or text to add it in your pack...`")
|
| 65 |
+
if not emoji:
|
| 66 |
+
emoji = "🏵"
|
| 67 |
+
if dl:
|
| 68 |
+
upl = await ult.client.upload_file(dl)
|
| 69 |
+
file = get_input_document(
|
| 70 |
+
await ult.client(UploadMediaRequest(InputPeerSelf(), upl))
|
| 71 |
+
)
|
| 72 |
+
get_ = udB.get_key("STICKERS") or {}
|
| 73 |
+
type_ = "anim" if animated else "static"
|
| 74 |
+
if not get_.get(ult.sender_id) or not get_.get(ult.sender_id, {}).get(type_):
|
| 75 |
+
sn = f"{pre}_{ult.sender_id}"
|
| 76 |
+
title = f"{get_display_name(sender)}'s Kang Pack"
|
| 77 |
+
if animated:
|
| 78 |
+
type_ = "anim"
|
| 79 |
+
sn += "_anim"
|
| 80 |
+
title += " (Animated)"
|
| 81 |
+
elif video:
|
| 82 |
+
type_ = "vid"
|
| 83 |
+
sn += "_vid"
|
| 84 |
+
title += " (Video)"
|
| 85 |
+
sn += f"_by_{asst.me.username}"
|
| 86 |
+
try:
|
| 87 |
+
await asst(GetSticker(InputStickerSetShortName(sn), hash=0))
|
| 88 |
+
sn = sn.replace(str(ult.sender_id), f"{ult.sender_id}_{ult.id}")
|
| 89 |
+
except StickersetInvalidError:
|
| 90 |
+
pass
|
| 91 |
+
try:
|
| 92 |
+
pack = await ult.client(
|
| 93 |
+
CreateStickerSetRequest(
|
| 94 |
+
user_id=sender.id,
|
| 95 |
+
title=title,
|
| 96 |
+
short_name=sn,
|
| 97 |
+
stickers=[SetItem(file, emoji=emoji)],
|
| 98 |
+
videos=video,
|
| 99 |
+
animated=animated,
|
| 100 |
+
software="@TeamUltroid",
|
| 101 |
+
)
|
| 102 |
+
)
|
| 103 |
+
except Exception as er:
|
| 104 |
+
return await ult.eor(str(er))
|
| 105 |
+
sn = pack.set.short_name
|
| 106 |
+
if not get_.get(ult.sender_id):
|
| 107 |
+
get_.update({ult.sender_id: {type_: [sn]}})
|
| 108 |
+
else:
|
| 109 |
+
get_[ult.sender_id].update({type_: [sn]})
|
| 110 |
+
udB.set_key("STICKERS", get_)
|
| 111 |
+
return await ult.reply(
|
| 112 |
+
f"**Kanged Successfully!\nEmoji :** {emoji}\n**Link :** [Click Here](https://t.me/addstickers/{sn})"
|
| 113 |
+
)
|
| 114 |
+
name = get_[ult.sender_id][type_][-1]
|
| 115 |
+
try:
|
| 116 |
+
await asst(GetSticker(InputStickerSetShortName(name), hash=0))
|
| 117 |
+
except StickersetInvalidError:
|
| 118 |
+
get_[ult.sender_id][type_].remove(name)
|
| 119 |
+
try:
|
| 120 |
+
await asst(
|
| 121 |
+
AddSticker(InputStickerSetShortName(name), SetItem(file, emoji=emoji))
|
| 122 |
+
)
|
| 123 |
+
except (errors.StickerpackStickersTooMuchError, errors.StickersTooMuchError):
|
| 124 |
+
sn = f"{pre}{ult.sender_id}_{ult.id}"
|
| 125 |
+
title = f"{get_display_name(sender)}'s Kang Pack"
|
| 126 |
+
if animated:
|
| 127 |
+
sn += "_anim"
|
| 128 |
+
title += " (Animated)"
|
| 129 |
+
elif video:
|
| 130 |
+
sn += "_vid"
|
| 131 |
+
title += "(Video)"
|
| 132 |
+
sn += f"_by_{asst.me.username}"
|
| 133 |
+
try:
|
| 134 |
+
pack = await ult.client(
|
| 135 |
+
CreateStickerSetRequest(
|
| 136 |
+
user_id=sender.id,
|
| 137 |
+
title=title,
|
| 138 |
+
short_name=sn,
|
| 139 |
+
stickers=[SetItem(file, emoji=emoji)],
|
| 140 |
+
animated=animated,
|
| 141 |
+
)
|
| 142 |
+
)
|
| 143 |
+
except Exception as er:
|
| 144 |
+
return await ult.eor(str(er))
|
| 145 |
+
get_[ult.sender_id][type_].append(pack.set.short_name)
|
| 146 |
+
udB.set_key("STICKERS", get_)
|
| 147 |
+
return await ult.reply(
|
| 148 |
+
f"**Created New Kang Pack!\nEmoji :** {emoji}\n**Link :** [Click Here](https://t.me/addstickers/{sn})"
|
| 149 |
+
)
|
| 150 |
+
except Exception as er:
|
| 151 |
+
LOGS.exception(er)
|
| 152 |
+
return await ult.reply(str(er))
|
| 153 |
+
await ult.reply(
|
| 154 |
+
f"Sticker Added to Pack Successfully\n**Link :** [Click Here](https://t.me/addstickers/{name})"
|
| 155 |
+
)
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
@asst_cmd(pattern="listpack")
|
| 159 |
+
async def do_magic(ult):
|
| 160 |
+
ko = udB.get_key("STICKERS") or {}
|
| 161 |
+
if not ko.get(ult.sender_id):
|
| 162 |
+
return await ult.reply("No Sticker Pack Found!")
|
| 163 |
+
al_ = []
|
| 164 |
+
ul = ko[ult.sender_id]
|
| 165 |
+
for _ in ul.keys():
|
| 166 |
+
al_.extend(ul[_])
|
| 167 |
+
msg = "• **Stickers Owned by You!**\n\n"
|
| 168 |
+
for _ in al_:
|
| 169 |
+
try:
|
| 170 |
+
pack = await ult.client(GetSticker(InputStickerSetShortName(_), hash=0))
|
| 171 |
+
msg += f"• [{pack.set.title}](https://t.me/addstickers/{_})\n"
|
| 172 |
+
except StickerSetInvalidError:
|
| 173 |
+
if ul.get("anim") and _ in ul["anim"]:
|
| 174 |
+
ul["anim"].remove(_)
|
| 175 |
+
elif ul.get("vid") and _ in ul["vid"]:
|
| 176 |
+
ul["vid"].remove(_)
|
| 177 |
+
else:
|
| 178 |
+
ul["static"].remove(_)
|
| 179 |
+
udB.set_key("STICKERS", ko)
|
| 180 |
+
await ult.reply(msg)
|
assistant/pmbot.py
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ultroid - UserBot
|
| 2 |
+
# Copyright (C) 2021-2023 TeamUltroid
|
| 3 |
+
#
|
| 4 |
+
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
| 5 |
+
# PLease read the GNU Affero General Public License in
|
| 6 |
+
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
| 7 |
+
|
| 8 |
+
# https://github.com/xditya/TeleBot/blob/master/telebot/plugins/mybot/pmbot/incoming.py
|
| 9 |
+
|
| 10 |
+
# --------------------------------------- Imports -------------------------------------------- #
|
| 11 |
+
|
| 12 |
+
import os
|
| 13 |
+
|
| 14 |
+
from telethon.errors.rpcerrorlist import UserNotParticipantError
|
| 15 |
+
from telethon.tl.custom import Button
|
| 16 |
+
from telethon.tl.functions.channels import GetFullChannelRequest
|
| 17 |
+
from telethon.tl.functions.messages import GetFullChatRequest
|
| 18 |
+
from telethon.tl.types import Channel, Chat
|
| 19 |
+
from telethon.utils import get_display_name
|
| 20 |
+
|
| 21 |
+
from pyUltroid.dB.base import KeyManager
|
| 22 |
+
from pyUltroid.dB.botchat_db import *
|
| 23 |
+
from pyUltroid.fns.helper import inline_mention
|
| 24 |
+
|
| 25 |
+
from . import *
|
| 26 |
+
|
| 27 |
+
botb = KeyManager("BOTBLS", cast=list)
|
| 28 |
+
FSUB = udB.get_key("PMBOT_FSUB")
|
| 29 |
+
CACHE = {}
|
| 30 |
+
# --------------------------------------- Incoming -------------------------------------------- #
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
@asst_cmd(
|
| 34 |
+
load=AST_PLUGINS,
|
| 35 |
+
incoming=True,
|
| 36 |
+
func=lambda e: e.is_private and not botb.contains(e.sender_id),
|
| 37 |
+
)
|
| 38 |
+
async def on_new_mssg(event):
|
| 39 |
+
who = event.sender_id
|
| 40 |
+
# doesn't reply to that user anymore
|
| 41 |
+
if event.text.startswith("/") or who == OWNER_ID:
|
| 42 |
+
return
|
| 43 |
+
if FSUB:
|
| 44 |
+
MSG = ""
|
| 45 |
+
BTTS = []
|
| 46 |
+
for chat in FSUB:
|
| 47 |
+
try:
|
| 48 |
+
await event.client.get_permissions(chat, event.sender_id)
|
| 49 |
+
except UserNotParticipantError:
|
| 50 |
+
if not MSG:
|
| 51 |
+
MSG += get_string("pmbot_1")
|
| 52 |
+
try:
|
| 53 |
+
uri = ""
|
| 54 |
+
TAHC_ = await event.client.get_entity(chat)
|
| 55 |
+
if hasattr(TAHC_, "username") and TAHC_.username:
|
| 56 |
+
uri = f"t.me/{TAHC_.username}"
|
| 57 |
+
elif CACHE.get(chat):
|
| 58 |
+
uri = CACHE[chat]
|
| 59 |
+
else:
|
| 60 |
+
if isinstance(TAHC_, Channel):
|
| 61 |
+
FUGB = await event.client(GetFullChannelRequest(chat))
|
| 62 |
+
elif isinstance(TAHC_, Chat):
|
| 63 |
+
FUGB = await event.client(GetFullChatRequest(chat))
|
| 64 |
+
else:
|
| 65 |
+
return
|
| 66 |
+
if FUGB.full_chat.exported_invite:
|
| 67 |
+
CACHE[chat] = FUGB.full_chat.exported_invite.link
|
| 68 |
+
uri = CACHE[chat]
|
| 69 |
+
BTTS.append(Button.url(get_display_name(TAHC_), uri))
|
| 70 |
+
except Exception as er:
|
| 71 |
+
LOGS.exception(f"Error On PmBot Force Sub!\n - {chat} \n{er}")
|
| 72 |
+
if MSG and BTTS:
|
| 73 |
+
return await event.reply(MSG, buttons=BTTS)
|
| 74 |
+
xx = await event.forward_to(OWNER_ID)
|
| 75 |
+
if event.fwd_from:
|
| 76 |
+
await xx.reply(f"From {inline_mention(event.sender)} [`{event.sender_id}`]")
|
| 77 |
+
add_stuff(xx.id, who)
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
# --------------------------------------- Outgoing -------------------------------------------- #
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
@asst_cmd(
|
| 84 |
+
load=AST_PLUGINS,
|
| 85 |
+
from_users=[OWNER_ID],
|
| 86 |
+
incoming=True,
|
| 87 |
+
func=lambda e: e.is_private and e.is_reply,
|
| 88 |
+
)
|
| 89 |
+
async def on_out_mssg(event):
|
| 90 |
+
x = event.reply_to_msg_id
|
| 91 |
+
to_user = get_who(x)
|
| 92 |
+
if event.text.startswith("/who"):
|
| 93 |
+
try:
|
| 94 |
+
k = await asst.get_entity(to_user)
|
| 95 |
+
photu = await event.client.download_profile_photo(k.id)
|
| 96 |
+
await event.reply(
|
| 97 |
+
f"• **Name :** {get_display_name(k)}\n• **ID :** `{k.id}`\n• **Link :** {inline_mention(k)}",
|
| 98 |
+
file=photu,
|
| 99 |
+
)
|
| 100 |
+
if photu:
|
| 101 |
+
os.remove(photu)
|
| 102 |
+
return
|
| 103 |
+
except BaseException as er:
|
| 104 |
+
return await event.reply(f"**ERROR : **{str(er)}")
|
| 105 |
+
elif event.text.startswith("/"):
|
| 106 |
+
return
|
| 107 |
+
if to_user:
|
| 108 |
+
await asst.send_message(to_user, event.message)
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
# --------------------------------------- Ban/Unban -------------------------------------------- #
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
@asst_cmd(
|
| 115 |
+
pattern="ban",
|
| 116 |
+
load=AST_PLUGINS,
|
| 117 |
+
from_users=[OWNER_ID],
|
| 118 |
+
func=lambda x: x.is_private,
|
| 119 |
+
)
|
| 120 |
+
async def banhammer(event):
|
| 121 |
+
if not event.is_reply:
|
| 122 |
+
return await event.reply(get_string("pmbot_2"))
|
| 123 |
+
target = get_who(event.reply_to_msg_id)
|
| 124 |
+
if botb.contains(target):
|
| 125 |
+
return await event.reply(get_string("pmbot_3"))
|
| 126 |
+
|
| 127 |
+
botb.add(target)
|
| 128 |
+
await event.reply(f"#BAN\nUser : {target}")
|
| 129 |
+
await asst.send_message(target, get_string("pmbot_4"))
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
@asst_cmd(
|
| 133 |
+
pattern="unban",
|
| 134 |
+
load=AST_PLUGINS,
|
| 135 |
+
from_users=[OWNER_ID],
|
| 136 |
+
func=lambda x: x.is_private,
|
| 137 |
+
)
|
| 138 |
+
async def unbanhammer(event):
|
| 139 |
+
if not event.is_reply:
|
| 140 |
+
return await event.reply(get_string("pmbot_5"))
|
| 141 |
+
target = get_who(event.reply_to_msg_id)
|
| 142 |
+
if not botb.contains(target):
|
| 143 |
+
return await event.reply(get_string("pmbot_6"))
|
| 144 |
+
|
| 145 |
+
botb.remove(target)
|
| 146 |
+
await event.reply(f"#UNBAN\nUser : {target}")
|
| 147 |
+
await asst.send_message(target, get_string("pmbot_7"))
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
# --------------------------------------- END -------------------------------------------- #
|
assistant/start.py
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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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
|
| 9 |
+
|
| 10 |
+
from pytz import timezone as tz
|
| 11 |
+
from telethon import Button, events
|
| 12 |
+
from telethon.errors.rpcerrorlist import MessageDeleteForbiddenError
|
| 13 |
+
from telethon.utils import get_display_name
|
| 14 |
+
|
| 15 |
+
from pyUltroid._misc import SUDO_M, owner_and_sudos
|
| 16 |
+
from pyUltroid.dB.base import KeyManager
|
| 17 |
+
from pyUltroid.fns.helper import inline_mention
|
| 18 |
+
from strings import get_string
|
| 19 |
+
|
| 20 |
+
from . import *
|
| 21 |
+
|
| 22 |
+
Owner_info_msg = udB.get_key("BOT_INFO_START")
|
| 23 |
+
custom_info = True
|
| 24 |
+
if Owner_info_msg is None:
|
| 25 |
+
custom_info = False
|
| 26 |
+
Owner_info_msg = f"""
|
| 27 |
+
**Owner** - {OWNER_NAME}
|
| 28 |
+
**OwnerID** - `{OWNER_ID}`
|
| 29 |
+
|
| 30 |
+
**Message Forwards** - {udB.get_key("PMBOT")}
|
| 31 |
+
|
| 32 |
+
**Ultroid [v{ultroid_version}](https://github.com/TeamUltroid/Ultroid), powered by @TeamUltroid**
|
| 33 |
+
"""
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
_settings = [
|
| 37 |
+
[
|
| 38 |
+
Button.inline("API Kᴇʏs", data="cbs_apiset"),
|
| 39 |
+
Button.inline("Pᴍ Bᴏᴛ", data="cbs_chatbot"),
|
| 40 |
+
],
|
| 41 |
+
[
|
| 42 |
+
Button.inline("Aʟɪᴠᴇ", data="cbs_alvcstm"),
|
| 43 |
+
Button.inline("PᴍPᴇʀᴍɪᴛ", data="cbs_ppmset"),
|
| 44 |
+
],
|
| 45 |
+
[
|
| 46 |
+
Button.inline("Fᴇᴀᴛᴜʀᴇs", data="cbs_otvars"),
|
| 47 |
+
Button.inline("VC Sᴏɴɢ Bᴏᴛ", data="cbs_vcb"),
|
| 48 |
+
],
|
| 49 |
+
[Button.inline("« Bᴀᴄᴋ", data="mainmenu")],
|
| 50 |
+
]
|
| 51 |
+
|
| 52 |
+
_start = [
|
| 53 |
+
[
|
| 54 |
+
Button.inline("Lᴀɴɢᴜᴀɢᴇ 🌐", data="lang"),
|
| 55 |
+
Button.inline("Sᴇᴛᴛɪɴɢs ⚙️", data="setter"),
|
| 56 |
+
],
|
| 57 |
+
[
|
| 58 |
+
Button.inline("Sᴛᴀᴛs ✨", data="stat"),
|
| 59 |
+
Button.inline("Bʀᴏᴀᴅᴄᴀsᴛ 📻", data="bcast"),
|
| 60 |
+
],
|
| 61 |
+
[Button.inline("TɪᴍᴇZᴏɴᴇ 🌎", data="tz")],
|
| 62 |
+
]
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
@callback("ownerinfo")
|
| 66 |
+
async def own(event):
|
| 67 |
+
msg = Owner_info_msg.format(
|
| 68 |
+
mention=inline_mention(event.sender), me=inline_mention(ultroid_bot.me)
|
| 69 |
+
)
|
| 70 |
+
if custom_info:
|
| 71 |
+
msg += "\n\n• Powered by **@TeamUltroid**"
|
| 72 |
+
await event.edit(
|
| 73 |
+
msg,
|
| 74 |
+
buttons=[Button.inline("Close", data="closeit")],
|
| 75 |
+
link_preview=False,
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
@callback("closeit")
|
| 80 |
+
async def closet(lol):
|
| 81 |
+
try:
|
| 82 |
+
await lol.delete()
|
| 83 |
+
except MessageDeleteForbiddenError:
|
| 84 |
+
await lol.answer("MESSAGE_TOO_OLD", alert=True)
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
@asst_cmd(pattern="start( (.*)|$)", forwards=False, func=lambda x: not x.is_group)
|
| 88 |
+
async def ultroid(event):
|
| 89 |
+
args = event.pattern_match.group(1).strip()
|
| 90 |
+
keym = KeyManager("BOT_USERS", cast=list)
|
| 91 |
+
if not keym.contains(event.sender_id) and event.sender_id not in owner_and_sudos():
|
| 92 |
+
keym.add(event.sender_id)
|
| 93 |
+
kak_uiw = udB.get_key("OFF_START_LOG")
|
| 94 |
+
if not kak_uiw or kak_uiw != True:
|
| 95 |
+
msg = f"{inline_mention(event.sender)} `[{event.sender_id}]` started your [Assistant bot](@{asst.me.username})."
|
| 96 |
+
buttons = [[Button.inline("Info", "itkkstyo")]]
|
| 97 |
+
if event.sender.username:
|
| 98 |
+
buttons[0].append(
|
| 99 |
+
Button.mention(
|
| 100 |
+
"User", await event.client.get_input_entity(event.sender_id)
|
| 101 |
+
)
|
| 102 |
+
)
|
| 103 |
+
await event.client.send_message(
|
| 104 |
+
udB.get_key("LOG_CHANNEL"), msg, buttons=buttons
|
| 105 |
+
)
|
| 106 |
+
if event.sender_id not in SUDO_M.fullsudos:
|
| 107 |
+
ok = ""
|
| 108 |
+
me = inline_mention(ultroid_bot.me)
|
| 109 |
+
mention = inline_mention(event.sender)
|
| 110 |
+
if args and args != "set":
|
| 111 |
+
await get_stored_file(event, args)
|
| 112 |
+
if not udB.get_key("STARTMSG"):
|
| 113 |
+
if udB.get_key("PMBOT"):
|
| 114 |
+
ok = "You can contact my master using this bot!!\n\nSend your Message, I will Deliver it To Master."
|
| 115 |
+
await event.reply(
|
| 116 |
+
f"Hey there {mention}, this is Ultroid Assistant of {me}!\n\n{ok}",
|
| 117 |
+
file=udB.get_key("STARTMEDIA"),
|
| 118 |
+
buttons=[Button.inline("Info.", data="ownerinfo")]
|
| 119 |
+
if Owner_info_msg
|
| 120 |
+
else None,
|
| 121 |
+
)
|
| 122 |
+
else:
|
| 123 |
+
await event.reply(
|
| 124 |
+
udB.get_key("STARTMSG").format(me=me, mention=mention),
|
| 125 |
+
file=udB.get_key("STARTMEDIA"),
|
| 126 |
+
buttons=[Button.inline("Info.", data="ownerinfo")]
|
| 127 |
+
if Owner_info_msg
|
| 128 |
+
else None,
|
| 129 |
+
)
|
| 130 |
+
else:
|
| 131 |
+
name = get_display_name(event.sender)
|
| 132 |
+
if args == "set":
|
| 133 |
+
await event.reply(
|
| 134 |
+
"Choose from the below options -",
|
| 135 |
+
buttons=_settings,
|
| 136 |
+
)
|
| 137 |
+
elif args:
|
| 138 |
+
await get_stored_file(event, args)
|
| 139 |
+
else:
|
| 140 |
+
await event.reply(
|
| 141 |
+
get_string("ast_3").format(name),
|
| 142 |
+
buttons=_start,
|
| 143 |
+
)
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
@callback("itkkstyo", owner=True)
|
| 147 |
+
async def ekekdhdb(e):
|
| 148 |
+
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"
|
| 149 |
+
await e.answer(text, alert=True)
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
@callback("mainmenu", owner=True, func=lambda x: not x.is_group)
|
| 153 |
+
async def ultroid(event):
|
| 154 |
+
await event.edit(
|
| 155 |
+
get_string("ast_3").format(OWNER_NAME),
|
| 156 |
+
buttons=_start,
|
| 157 |
+
)
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
@callback("stat", owner=True)
|
| 161 |
+
async def botstat(event):
|
| 162 |
+
ok = len(udB.get_key("BOT_USERS") or [])
|
| 163 |
+
msg = """Ultroid Assistant - Stats
|
| 164 |
+
Total Users - {}""".format(
|
| 165 |
+
ok,
|
| 166 |
+
)
|
| 167 |
+
await event.answer(msg, cache_time=0, alert=True)
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
@callback("bcast", owner=True)
|
| 171 |
+
async def bdcast(event):
|
| 172 |
+
keym = KeyManager("BOT_USERS", cast=list)
|
| 173 |
+
total = keym.count()
|
| 174 |
+
await event.edit(f"• Broadcast to {total} users.")
|
| 175 |
+
async with event.client.conversation(OWNER_ID) as conv:
|
| 176 |
+
await conv.send_message(
|
| 177 |
+
"Enter your broadcast message.\nUse /cancel to stop the broadcast.",
|
| 178 |
+
)
|
| 179 |
+
response = await conv.get_response()
|
| 180 |
+
if response.message == "/cancel":
|
| 181 |
+
return await conv.send_message("Cancelled!!")
|
| 182 |
+
success = 0
|
| 183 |
+
fail = 0
|
| 184 |
+
await conv.send_message(f"Starting a broadcast to {total} users...")
|
| 185 |
+
start = datetime.now()
|
| 186 |
+
for i in keym.get():
|
| 187 |
+
try:
|
| 188 |
+
await asst.send_message(int(i), response)
|
| 189 |
+
success += 1
|
| 190 |
+
except BaseException:
|
| 191 |
+
fail += 1
|
| 192 |
+
end = datetime.now()
|
| 193 |
+
time_taken = (end - start).seconds
|
| 194 |
+
await conv.send_message(
|
| 195 |
+
f"""
|
| 196 |
+
**Broadcast completed in {time_taken} seconds.**
|
| 197 |
+
Total Users in Bot - {total}
|
| 198 |
+
**Sent to** : `{success} users.`
|
| 199 |
+
**Failed for** : `{fail} user(s).`""",
|
| 200 |
+
)
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
@callback("setter", owner=True)
|
| 204 |
+
async def setting(event):
|
| 205 |
+
await event.edit(
|
| 206 |
+
"Choose from the below options -",
|
| 207 |
+
buttons=_settings,
|
| 208 |
+
)
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
@callback("tz", owner=True)
|
| 212 |
+
async def timezone_(event):
|
| 213 |
+
await event.delete()
|
| 214 |
+
pru = event.sender_id
|
| 215 |
+
var = "TIMEZONE"
|
| 216 |
+
name = "Timezone"
|
| 217 |
+
async with event.client.conversation(pru) as conv:
|
| 218 |
+
await conv.send_message(
|
| 219 |
+
"Send Your TimeZone From This List [Check From Here](http://www.timezoneconverter.com/cgi-bin/findzone.tzc)"
|
| 220 |
+
)
|
| 221 |
+
response = conv.wait_event(events.NewMessage(chats=pru))
|
| 222 |
+
response = await response
|
| 223 |
+
themssg = response.message.message
|
| 224 |
+
if themssg == "/cancel":
|
| 225 |
+
return await conv.send_message(
|
| 226 |
+
"Cancelled!!",
|
| 227 |
+
buttons=get_back_button("mainmenu"),
|
| 228 |
+
)
|
| 229 |
+
try:
|
| 230 |
+
tz(themssg)
|
| 231 |
+
await setit(event, var, themssg)
|
| 232 |
+
await conv.send_message(
|
| 233 |
+
f"{name} changed to {themssg}\n",
|
| 234 |
+
buttons=get_back_button("mainmenu"),
|
| 235 |
+
)
|
| 236 |
+
except BaseException:
|
| 237 |
+
await conv.send_message(
|
| 238 |
+
"Wrong TimeZone, Try again",
|
| 239 |
+
buttons=get_back_button("mainmenu"),
|
| 240 |
+
)
|