From 6f44b386aad7c8b9d52a1db401dc330b6be58beb Mon Sep 17 00:00:00 2001 From: 1Danish-00 Date: Mon, 11 Oct 2021 00:27:23 +0530 Subject: [PATCH] v0.2 11/10/2021 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: New-dev0 Co-authored-by: Amit Sharma Co-authored-by: TechiError Co-authored-by: Aditya Co-authored-by: Sonya Nikiforova Co-authored-by: M̲αραт Co-authored-by: Muhamad Risman Aziz Co-authored-by: Arnab Paryali Co-authored-by: hellboi_atul Co-authored-by: sppidy --- CODE_OF_CONDUCT.md | 128 ++++++ CONTRIBUTING.md | 17 + Dockerfile | 15 +- README.md | 5 +- assistant/__init__.py | 10 +- assistant/api_setter.py | 22 +- assistant/callbackstuffs.py | 344 +++++++------- assistant/inlinestuff.py | 295 ++++++------ assistant/localization.py | 11 +- assistant/manager/__init__.py | 5 +- assistant/manager/_help.py | 8 +- assistant/manager/_on_adds.py | 5 +- assistant/manager/misc.py | 12 +- assistant/ping.py | 18 - assistant/piston.py | 45 -- assistant/pmbot.py | 144 ++++++ assistant/pmbot/__init__.py | 7 - assistant/pmbot/banuser.py | 45 -- assistant/pmbot/incoming.py | 29 -- assistant/pmbot/outgoing.py | 34 -- assistant/start.py | 78 ++-- assistant/ytdl.py | 43 +- plugins/__init__.py | 48 +- plugins/{_ChatActions.py => _chatactions.py} | 105 +++-- plugins/_help.py | 69 +-- plugins/_inline.py | 460 ++++++++++--------- plugins/_ultroid.py | 6 +- plugins/_userlogs.py | 68 +-- plugins/_wspr.py | 208 +++++---- plugins/admintools.py | 169 ++++--- plugins/afk.py | 34 +- plugins/akinator.py | 24 +- plugins/anime.py | 103 ----- plugins/antiflood.py | 50 +- plugins/ascii.py | 37 -- plugins/{asst_cmd.py => asstcmd.py} | 50 +- plugins/audiotools.py | 73 +-- plugins/autocorrect.py | 18 +- plugins/autopic.py | 27 +- plugins/blacklist.py | 26 +- plugins/bot.py | 97 ++-- plugins/botecho.py | 60 --- plugins/broadcast.py | 28 +- plugins/button.py | 59 +++ plugins/calculator.py | 23 +- plugins/carbon.py | 20 +- plugins/channelhacks.py | 71 +-- plugins/chat_bot.py | 15 +- plugins/chats.py | 240 +++++++++- plugins/clean_action.py | 13 +- plugins/compressor.py | 209 +++++---- plugins/converter.py | 63 ++- plugins/core.py | 51 +- plugins/dayevents.py | 43 -- plugins/devtools.py | 33 +- plugins/dm.py | 53 --- plugins/download_upload.py | 100 ++-- plugins/echo.py | 5 +- plugins/extra.py | 9 +- plugins/fakeaction.py | 7 +- plugins/fedutils.py | 67 ++- plugins/filter.py | 35 +- plugins/fontgen.py | 48 +- plugins/forcesubscribe.py | 103 +++-- plugins/gadgets.py | 50 -- plugins/gdrive.py | 19 +- plugins/get_addons.py | 47 -- plugins/giftools.py | 12 +- plugins/github.py | 59 --- plugins/glitch.py | 10 +- plugins/globaltools.py | 137 ++++-- plugins/google.py | 140 ------ plugins/greetings.py | 93 ++-- plugins/groups.py | 216 --------- plugins/image.py | 46 -- plugins/imagetools.py | 82 ++-- plugins/instagram.py | 151 ++++-- plugins/locks.py | 12 +- plugins/logo.py | 20 +- plugins/{mediainfo.py => mediatools.py} | 15 +- plugins/megadl.py | 18 +- plugins/misc.py | 153 ++++++ plugins/mute.py | 14 +- plugins/nightmode.py | 26 +- plugins/notes.py | 48 +- plugins/nsfw_filter.py | 5 +- plugins/other.py | 88 ++++ plugins/pdftools.py | 20 +- plugins/pinterest.py | 50 -- plugins/pmpermit.py | 215 +++++---- plugins/polls.py | 4 +- plugins/profanity_filter.py | 10 +- plugins/profile.py | 34 +- plugins/qrcode.py | 8 +- plugins/randomuser.py | 21 - plugins/redis.py | 5 +- plugins/resize.py | 10 +- plugins/saavn.py | 50 -- plugins/save.py | 44 -- plugins/schedule_msg.py | 18 +- plugins/search.py | 216 +++++++++ plugins/snips.py | 40 +- plugins/specialtools.py | 89 ++-- plugins/stickertools.py | 142 +++--- plugins/sudo.py | 11 +- plugins/tag.py | 3 +- plugins/tools.py | 34 +- plugins/unsplash.py | 32 +- plugins/updater.py | 42 +- plugins/usage.py | 9 +- plugins/utilities.py | 110 ++--- plugins/variables.py | 3 +- plugins/vctools.py | 4 +- plugins/videotools.py | 52 ++- plugins/warn.py | 9 +- plugins/webshot.py | 11 +- plugins/webupload.py | 14 +- plugins/whichsong.py | 18 +- plugins/words.py | 81 ++-- plugins/writer.py | 37 +- plugins/youtube.py | 28 +- plugins/ziptools.py | 50 +- requirements.txt | 6 +- resources/extras/fonts.py | 275 ----------- resources/extras/local-requirements.txt | 64 --- resources/session/session.sh | 2 +- resources/startup/locals.py | 3 +- resources/startup/optional-requirements.txt | 44 ++ resources/startup/termux.sh | 123 +++++ resources/startup/ubuntu-termux.sh | 86 ++++ strings/README.md | 30 ++ strings/__init__.py | 2 +- strings/strings.py | 14 +- strings/strings/ar.yml | 3 +- strings/strings/az.yml | 1 + strings/strings/bn.yml | 2 - strings/strings/cn.yml | 4 +- strings/strings/en.yml | 399 +++++++++++++++- strings/strings/es.yml | 3 +- strings/strings/fa.yml | 3 +- strings/strings/fr.yml | 1 + strings/strings/gu.yml | 3 +- strings/strings/hi.yml | 1 + strings/strings/id.yml | 439 +++++++++++++++--- strings/strings/it.yml | 3 +- strings/strings/ka.yml | 3 +- strings/strings/ml.yml | 3 +- strings/strings/mr.yml | 3 +- strings/strings/my.yml | 2 - strings/strings/od.yml | 3 +- strings/strings/pt-br.yml | 3 +- strings/strings/ru.yml | 414 ++++++++++++++++- strings/strings/si.yml | 3 +- strings/strings/ta.yml | 3 +- strings/strings/tr.yml | 3 +- vcbot/__init__.py | 30 +- vcbot/auth.py | 18 +- vcbot/controls.py | 47 +- vcbot/play.py | 117 ++++- vcbot/queue.py | 29 +- vcbot/radio.py | 89 ---- vcbot/vctools.py | 6 +- vcbot/videoplay.py | 17 +- vcbot/volume.py | 48 -- vcbot/ytplaylist.py | 8 +- 165 files changed, 5537 insertions(+), 4155 deletions(-) create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md delete mode 100644 assistant/ping.py delete mode 100644 assistant/piston.py create mode 100644 assistant/pmbot.py delete mode 100644 assistant/pmbot/__init__.py delete mode 100644 assistant/pmbot/banuser.py delete mode 100644 assistant/pmbot/incoming.py delete mode 100644 assistant/pmbot/outgoing.py rename plugins/{_ChatActions.py => _chatactions.py} (68%) delete mode 100644 plugins/anime.py delete mode 100644 plugins/ascii.py rename plugins/{asst_cmd.py => asstcmd.py} (60%) delete mode 100644 plugins/botecho.py create mode 100644 plugins/button.py delete mode 100644 plugins/dayevents.py delete mode 100644 plugins/dm.py delete mode 100644 plugins/gadgets.py delete mode 100644 plugins/get_addons.py delete mode 100644 plugins/github.py delete mode 100644 plugins/google.py delete mode 100644 plugins/groups.py delete mode 100644 plugins/image.py rename plugins/{mediainfo.py => mediatools.py} (86%) create mode 100644 plugins/misc.py create mode 100644 plugins/other.py delete mode 100644 plugins/pinterest.py delete mode 100644 plugins/randomuser.py delete mode 100644 plugins/saavn.py delete mode 100644 plugins/save.py create mode 100644 plugins/search.py delete mode 100644 resources/extras/fonts.py delete mode 100644 resources/extras/local-requirements.txt create mode 100644 resources/startup/optional-requirements.txt create mode 100644 resources/startup/termux.sh create mode 100644 resources/startup/ubuntu-termux.sh create mode 100644 strings/README.md delete mode 100644 vcbot/radio.py delete mode 100644 vcbot/volume.py diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..fabd871 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +teamultroid@ultroid.tech. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..fbb4d2d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,17 @@ +# Welcome To Contributing Guide +Any contribution done to this repository will be appreciated! 🎉 + +### Issues +- Search for existing Similar issues. +- You can open a issue first before contributing, If it contain some major changes like `bug fixes` or `feature addition`. +- If you are busy or getting trouble while making changes, you can just open the issue (explaining it). + +### Contributing +- You can [fork](https://github.com/TeamUltroid/Ultroid/fork) this repository. +- You can commits your changes now. +- You can [Git-Squash](https://docs.github.com/en/get-started/using-git/about-git-rebase) your commits, if they are more. [Optional] +- 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). +- Make sure that, your `Pull Request` contain an explaining title and issue number if it closes any open issue. + +### Thanks +- Congrats! 💫 you have successfully made your Contribution to Ultroid. diff --git a/Dockerfile b/Dockerfile index d271e38..e865c24 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,15 +7,16 @@ FROM theteamultroid/ultroid:main # set timezone ENV TZ=Asia/Kolkata -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone -# clone the repo and change workdir -RUN git clone https://github.com/TeamUltroid/Ultroid.git /root/TeamUltroid/ +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \ + + # cloning the repo and installing requirements. + && git clone https://github.com/TeamUltroid/Ultroid.git /root/TeamUltroid/ \ + && pip3 install --no-cache-dir -r root/TeamUltroid/requirements.txt \ + && pip3 uninstall av -y && pip3 install av --no-binary av + +# changing workdir WORKDIR /root/TeamUltroid/ -# install main requirements. -RUN pip3 install --no-cache-dir -r requirements.txt -RUN pip3 uninstall av -y && pip3 install av --no-binary av - # start the bot CMD ["bash", "resources/startup/startup.sh"] diff --git a/README.md b/README.md index a94bc4e..0e55c50 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ ## Deploy to Heroku Get the [Necessary Variables](#Necessary-Variables) and then click the button below! -[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://dashboard.heroku.com/new?button-url=https%3A%2F%2Fgithub.com%2FNew-dev0%2FTraveliTg&template=https%3A%2F%2Fgithub.com%2FNew-dev0%2FTraveliTg) +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://dashboard.heroku.com/new?button-url=https%3A%2F%2Fgithub.com%2FNew-dev0%2FArchived&template=https%3A%2F%2Fgithub.com%2FNew-dev0%2FArchived) ## Deploy Locally - [Traditional Method](#local-deploy---traditional-method) @@ -68,6 +68,7 @@ Further, take a look at the [`docs`](https://blue-devil1134.github.io/UltroidCli `virtualenv -p /usr/bin/python3 venv` `. ./venv/bin/activate` - Install the requirements:
+`pip(3) install -U -r re*/st*/optional-requirements.txt` `pip(3) install -U -r requirements.txt` - Generate your `SESSION`: - For Linux users: @@ -89,7 +90,7 @@ Further, take a look at the [`docs`](https://blue-devil1134.github.io/UltroidCli ## Necessary Variables - `SESSION` - SessionString for your accounts login session. Get it from [here](#Session-String) - `REDIS_URI` - Redis endpoint URL, from [redislabs](http://redislabs.com/), tutorial [here.](./resources/extras/redistut.md) -- `REDIS_PASSWORD ` - Redis endpoint Password, from [redislabs](http://redislabs.com/), tutorial [here.](./resources/extras/redistut.md) +- `REDIS_PASSWORD` - Redis endpoint Password, from [redislabs](http://redislabs.com/), tutorial [here.](./resources/extras/redistut.md) ## Session String Different ways to get your `SESSION`: diff --git a/assistant/__init__.py b/assistant/__init__.py index a869538..6a9e20f 100644 --- a/assistant/__init__.py +++ b/assistant/__init__.py @@ -6,15 +6,19 @@ # . from pyUltroid import * -from pyUltroid.dB.database import Var -from pyUltroid.functions.all import * +from pyUltroid.functions.helper import * +from pyUltroid.misc import owner_and_sudos +from pyUltroid.misc._assistant import asst_cmd, callback, in_pattern from telethon import Button, custom -from strings import get_languages, get_string +from plugins import ATRA_COL +from strings import get_languages, get_string, language OWNER_NAME = ultroid_bot.me.first_name OWNER_ID = ultroid_bot.me.id +AST_PLUGINS = {} + async def setit(event, name, value): try: diff --git a/assistant/api_setter.py b/assistant/api_setter.py index b4e649b..c662560 100644 --- a/assistant/api_setter.py +++ b/assistant/api_setter.py @@ -5,14 +5,15 @@ # PLease read the GNU Affero General Public License in # . +from telethon import events + from . import * # main menu for api setting -@callback("apiset") -@owner -async def apiset(event): +@callback("apiset", owner=True) +async def apiset(event: events.CallbackQuery): await event.edit( get_string("ast_1"), buttons=[ @@ -24,9 +25,8 @@ async def apiset(event): ) -@callback("rmbg") -@owner -async def rmbgapi(event): +@callback("rmbg", owner=True) +async def rmbgapi(event: events.CallbackQuery): await event.delete() pru = event.sender_id var = "RMBG_API" @@ -48,9 +48,8 @@ async def rmbgapi(event): ) -@callback("dapi") -@owner -async def rmbgapi(event): +@callback("dapi", owner=True) +async def rmbgapi(event: events.CallbackQuery): await event.delete() pru = event.sender_id var = "DEEP_API" @@ -72,9 +71,8 @@ async def rmbgapi(event): ) -@callback("oapi") -@owner -async def rmbgapi(event): +@callback("oapi", owner=True) +async def rmbgapi(event: events.CallbackQuery): await event.delete() pru = event.sender_id var = "OCR_API" diff --git a/assistant/callbackstuffs.py b/assistant/callbackstuffs.py index ea5ee2c..970d338 100644 --- a/assistant/callbackstuffs.py +++ b/assistant/callbackstuffs.py @@ -7,17 +7,38 @@ import re import sys +from asyncio.exceptions import TimeoutError as AsyncTimeOut from os import execl, remove +from random import choice -from telegraph import Telegraph +from pyUltroid.functions.gdrive import authorize, create_token_file +from pyUltroid.functions.tools import get_paste, telegraph_client +from pyUltroid.startup.loader import Loader from telegraph import upload_file as upl +from telethon import events +from telethon.tl.types import MessageMediaWebPage +from telethon.utils import get_peer_id +try: + from carbonnow import Carbon +except ImportError: + Carbon = None from . import * # --------------------------------------------------------------------# -telegraph = Telegraph() -r = telegraph.create_account(short_name="Ultroid") -auth_url = r["auth_url"] +telegraph = telegraph_client() +# --------------------------------------------------------------------# + + +def text_to_url(event): + """function to get media url (with|without) Webpage""" + if isinstance(event.media, MessageMediaWebPage): + webpage = event.media.webpage + if webpage and webpage.type in ["photo"]: + return webpage.display_url + return event.text + + # --------------------------------------------------------------------# @@ -28,8 +49,8 @@ TOKEN_FILE = "resources/auths/auth_token.txt" re.compile( "sndplug_(.*)", ), + owner=True, ) -@owner async def send(eve): name = (eve.data_match.group(1)).decode("UTF-8") thumb = "resources/extras/inline.jpg" @@ -55,7 +76,6 @@ async def send(eve): ], [ Button.inline("« Bᴀᴄᴋ", data=data), - Button.inline("••Cʟᴏꜱᴇ••", data="close"), ], ] await eve.edit(file=plugin, thumb=thumb, buttons=buttons) @@ -64,8 +84,7 @@ async def send(eve): heroku_api, app_name = Var.HEROKU_API, Var.HEROKU_APP_NAME -@callback("updatenow") -@owner +@callback("updatenow", owner=True) async def update(eve): repo = Repo() ac_br = repo.active_branch @@ -86,9 +105,7 @@ async def update(eve): await eve.edit("`Wrong HEROKU_APP_NAME.`") repo.__del__() return - await eve.edit( - "`Userbot dyno build in progress, please wait for it to complete.`" - ) + await eve.edit(get_string("clst_1")) ups_rem.fetch(ac_br) repo.git.reset("--hard", "FETCH_HEAD") heroku_git_url = heroku_app.git_url.replace( @@ -107,22 +124,36 @@ async def update(eve): return await eve.edit("`Successfully Updated!\nRestarting, please wait...`") else: - await eve.edit( - "`Userbot dyno build in progress, please wait for it to complete.`" - ) + await eve.edit(get_string("clst_1")) call_back() await bash("git pull && pip3 install -r requirements.txt") execl(sys.executable, sys.executable, "-m", "pyUltroid") -@callback("changes") -@owner +@callback("changes", owner=True) async def changes(okk): - await okk.answer("■ Generating Changelogs...") + await okk.answer(get_string("clst_3")) repo = Repo.init() ac_br = repo.active_branch + button = (Button.inline("Update Now", data="updatenow"),) changelog, tl_chnglog = gen_chlog(repo, f"HEAD..upstream/{ac_br}") - changelog_str = changelog + "\n\nClick the below button to update!" + cli = "\n\nClick the below button to update!" + if Carbon: + try: + await okk.edit("• Writing Changelogs 📝 •") + carbon = Carbon( + base_url="https://carbonara-42.herokuapp.com/api/cook", + code=tl_chnglog, + background=choice(ATRA_COL), + language="md", + ) + img = await carbon.memorize("changelog") + return await okk.edit( + f"**• Ultroid Userbot •**{cli}", file=img, buttons=button + ) + except Exception as er: + LOGS.exception(er) + changelog_str = changelog + cli if len(changelog_str) > 1024: await okk.edit(get_string("upd_4")) await asyncio.sleep(2) @@ -137,7 +168,7 @@ async def changes(okk): return await okk.edit( changelog_str, - buttons=Button.inline("Update Now", data="updatenow"), + buttons=button, parse_mode="html", ) @@ -146,8 +177,8 @@ async def changes(okk): re.compile( "pasta-(.*)", ), + owner=True, ) -@owner async def _(e): ok = (e.data_match.group(1)).decode("UTF-8") with open(ok, "r") as hmm: @@ -156,23 +187,16 @@ async def _(e): raw = f"https://spaceb.in/api/v1/documents/{key}/raw" if not _: return await e.answer(key[:30], alert=True) - data = "buck" - if ok.startswith("plugins"): - data = "back" - buttons = [ - Button.inline("« Bᴀᴄᴋ", data=data), - Button.inline("••Cʟᴏꜱᴇ••", data="close"), - ] + data = "back" if ok.startswith("plugins") else "buck" await e.edit( f"Pasted\n👉 [Link]\n👉 [Raw Link]", - buttons=buttons, + buttons=Button.inline("« Bᴀᴄᴋ", data=data), link_preview=False, parse_mode="html", ) -@callback("authorise") -@owner +@callback("authorise", owner=True) async def _(e): if not e.is_private: return @@ -192,8 +216,7 @@ async def _(e): ) -@callback("folderid") -@owner +@callback("folderid", owner=True, func=lambda x: x.is_private) async def _(e): if not e.is_private: return @@ -216,8 +239,7 @@ async def _(e): ) -@callback("clientsec") -@owner +@callback("clientsec", owner=True) async def _(e): if not e.is_private: return @@ -232,8 +254,7 @@ async def _(e): ) -@callback("clientid") -@owner +@callback("clientid", owner=True) async def _(e): if not e.is_private: return @@ -250,8 +271,7 @@ async def _(e): ) -@callback("gdrive") -@owner +@callback("gdrive", owner=True) async def _(e): if not e.is_private: return @@ -272,8 +292,7 @@ async def _(e): ) -@callback("otvars") -@owner +@callback("otvars", owner=True) async def otvaar(event): await event.edit( "Other Variables to set for @TheUltroid:", @@ -304,8 +323,7 @@ async def otvaar(event): ) -@callback("oofdm") -@owner +@callback("oofdm", owner=True) async def euwhe(event): BT = [ [Button.inline("Dᴜᴀʟ Mᴏᴅᴇ Oɴ", "dmof")], @@ -319,8 +337,7 @@ async def euwhe(event): ) -@callback("dmof") -@owner +@callback("dmof", owner=True) async def rhwhe(e): if udB.get("DUAL_MODE"): udB.delete("DUAL_MODE") @@ -332,8 +349,7 @@ async def rhwhe(e): await e.edit(Msg, buttons=get_back_button("otvars")) -@callback("dmhn") -@owner +@callback("dmhn", owner=True) async def hndlrr(event): await event.delete() pru = event.sender_id @@ -365,8 +381,7 @@ async def hndlrr(event): ) -@callback("emoj") -@owner +@callback("emoj", owner=True) async def emoji(event): await event.delete() pru = event.sender_id @@ -395,8 +410,7 @@ async def emoji(event): ) -@callback("plg") -@owner +@callback("plg", owner=True) async def pluginch(event): await event.delete() pru = event.sender_id @@ -430,8 +444,7 @@ async def pluginch(event): ) -@callback("hhndlr") -@owner +@callback("hhndlr", owner=True) async def hndlrr(event): await event.delete() pru = event.sender_id @@ -467,8 +480,7 @@ async def hndlrr(event): ) -@callback("shndlr") -@owner +@callback("shndlr", owner=True) async def hndlrr(event): await event.delete() pru = event.sender_id @@ -505,8 +517,7 @@ async def hndlrr(event): ) -@callback("taglog") -@owner +@callback("taglog", owner=True) async def tagloggrr(e): if not udB.get("TAG_LOG"): BUTTON = [Button.inline("SET TAG LOG", data="settag")] @@ -518,15 +529,13 @@ async def tagloggrr(e): ) -@callback("deltag") -@owner -async def delfuk(e): +@callback("deltag", owner=True) +async def _(e): udB.delete("TAG_LOG") await e.answer("Done!!! TAG lOG Off") -@callback("settag") -@owner +@callback("settag", owner=True) async def taglogerr(event): await event.delete() pru = event.sender_id @@ -534,7 +543,7 @@ async def taglogerr(event): name = "Tag Log Group" async with event.client.conversation(pru) as conv: await conv.send_message( - 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.", + 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.", ) response = conv.wait_event(events.NewMessage(chats=pru)) response = await response @@ -551,8 +560,7 @@ async def taglogerr(event): ) -@callback("eaddon") -@owner +@callback("eaddon", owner=True) async def pmset(event): if not udB.get("ADDONS"): BT = [Button.inline("Aᴅᴅᴏɴs Oɴ", data="edon")] @@ -567,8 +575,7 @@ async def pmset(event): ) -@callback("edon") -@owner +@callback("edon", owner=True) async def eddon(event): var = "ADDONS" await setit(event, var, "True") @@ -578,8 +585,7 @@ async def eddon(event): ) -@callback("edof") -@owner +@callback("edof", owner=True) async def eddof(event): udB.set("ADDONS", "False") await event.edit( @@ -588,8 +594,7 @@ async def eddof(event): ) -@callback("sudo") -@owner +@callback("sudo", owner=True) async def pmset(event): if not udB.get("SUDO"): BT = [Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ Oɴ", data="onsudo")] @@ -604,8 +609,7 @@ async def pmset(event): ) -@callback("onsudo") -@owner +@callback("onsudo", owner=True) async def eddon(event): var = "SUDO" await setit(event, var, "True") @@ -615,8 +619,7 @@ async def eddon(event): ) -@callback("ofsudo") -@owner +@callback("ofsudo", owner=True) async def eddof(event): var = "SUDO" await setit(event, var, "False") @@ -626,8 +629,7 @@ async def eddof(event): ) -@callback("sfban") -@owner +@callback("sfban", owner=True) async def sfban(event): await event.edit( "SuperFban Settings:", @@ -639,8 +641,7 @@ async def sfban(event): ) -@callback("sfgrp") -@owner +@callback("sfgrp", owner=True) async def sfgrp(event): await event.delete() name = "FBan Group ID" @@ -648,7 +649,7 @@ async def sfgrp(event): pru = event.sender_id async with asst.conversation(pru) as conv: await conv.send_message( - f"Make a group, add @MissRose_Bot, send `{hndlr}id`, copy that and send it here.\nUse /cancel to go back.", + f"Make a group, add @MissRose_Bot, send `{HNDLR}id`, copy that and send it here.\nUse /cancel to go back.", ) response = conv.wait_event(events.NewMessage(chats=pru)) response = await response @@ -665,8 +666,7 @@ async def sfgrp(event): ) -@callback("sfexf") -@owner +@callback("sfexf", owner=True) async def sfexf(event): await event.delete() name = "Excluded Feds" @@ -692,8 +692,7 @@ async def sfexf(event): ) -@callback("alvcstm") -@owner +@callback("alvcstm", owner=True) async def alvcs(event): await event.edit( f"Customise your {HNDLR}alive. Choose from the below options -", @@ -706,8 +705,7 @@ async def alvcs(event): ) -@callback("alvtx") -@owner +@callback("alvtx", owner=True) async def name(event): await event.delete() pru = event.sender_id @@ -735,8 +733,7 @@ async def name(event): ) -@callback("alvmed") -@owner +@callback("alvmed", owner=True) async def media(event): await event.delete() pru = event.sender_id @@ -756,16 +753,16 @@ async def media(event): ) except BaseException: pass - media = await event.client.download_media(response, "alvpc") if ( not (response.text).startswith("/") and response.text != "" - and not response.media + and (not response.media or isinstance(response.media, MessageMediaWebPage)) ): - url = response.text + url = text_to_url(response) elif response.sticker: url = response.file.id else: + media = await event.client.download_media(response, "alvpc") try: x = upl(media) url = f"https://telegra.ph/{x[0]}" @@ -782,21 +779,21 @@ async def media(event): ) -@callback("delmed") -@owner +@callback("delmed", owner=True) async def dell(event): try: udB.delete("ALIVE_PIC") - return await event.edit("Done!", buttons=get_back_button("alvcstm")) + return await event.edit( + get_string("clst_5"), buttons=get_back_button("alvcstm") + ) except BaseException: return await event.edit( - "Something went wrong...", + get_string("clst_4"), buttons=get_back_button("alvcstm"), ) -@callback("pmcstm") -@owner +@callback("pmcstm", owner=True) async def alvcs(event): await event.edit( "Customise your PMPERMIT Settings -", @@ -819,8 +816,7 @@ async def alvcs(event): ) -@callback("pmtype") -@owner +@callback("pmtype", owner=True) async def pmtyp(event): await event.edit( "Select the type of PMPermit needed.", @@ -832,8 +828,7 @@ async def pmtyp(event): ) -@callback("inpm_in") -@owner +@callback("inpm_in", owner=True) async def inl_on(event): var = "INLINE_PM" await setit(event, var, "True") @@ -843,8 +838,7 @@ async def inl_on(event): ) -@callback("inpm_no") -@owner +@callback("inpm_no", owner=True) async def inl_on(event): var = "INLINE_PM" await setit(event, var, "False") @@ -854,8 +848,7 @@ async def inl_on(event): ) -@callback("pmtxt") -@owner +@callback("pmtxt", owner=True) async def name(event): await event.delete() pru = event.sender_id @@ -888,8 +881,7 @@ async def name(event): ) -@callback("swarn") -@owner +@callback("swarn", owner=True) async def name(event): m = range(1, 10) tultd = [Button.inline(f"{x}", data=f"wrns_{x}") for x in m] @@ -901,8 +893,7 @@ async def name(event): ) -@callback(re.compile(b"wrns_(.*)")) -@owner +@callback(re.compile(b"wrns_(.*)"), owner=True) async def set_wrns(event): value = int(event.data_match.group(1).decode("UTF-8")) dn = udB.set("PMWARNS", value) @@ -913,13 +904,12 @@ async def set_wrns(event): ) else: await event.edit( - f"Something went wrong, please check your {hndlr}logs!", + f"Something went wrong, please check your {HNDLR}logs!", buttons=get_back_button("pmcstm"), ) -@callback("pmmed") -@owner +@callback("pmmed", owner=True) async def media(event): await event.delete() pru = event.sender_id @@ -943,9 +933,9 @@ async def media(event): if ( not (response.text).startswith("/") and response.text != "" - and not response.media + and (not response.media or isinstance(response.media, MessageMediaWebPage)) ): - url = response.text + url = text_to_url(response) elif response.sticker: url = response.file.id else: @@ -965,21 +955,19 @@ async def media(event): ) -@callback("delpmmed") -@owner +@callback("delpmmed", owner=True) async def dell(event): try: udB.delete("PMPIC") - return await event.edit("Done!", buttons=get_back_button("pmcstm")) + return await event.edit(get_string("clst_5"), buttons=get_back_button("pmcstm")) except BaseException: return await event.edit( - "Something went wrong...", + get_string("clst_4"), buttons=[[Button.inline("« Sᴇᴛᴛɪɴɢs", data="setter")]], ) -@callback("apauto") -@owner +@callback("apauto", owner=True) async def apauto(event): await event.edit( "This'll auto approve on outgoing messages", @@ -991,8 +979,7 @@ async def apauto(event): ) -@callback("apon") -@owner +@callback("apon", owner=True) async def apon(event): var = "AUTOAPPROVE" await setit(event, var, "True") @@ -1002,8 +989,7 @@ async def apon(event): ) -@callback("apof") -@owner +@callback("apof", owner=True) async def apof(event): try: udB.delete("AUTOAPPROVE") @@ -1013,13 +999,12 @@ async def apof(event): ) except BaseException: return await event.edit( - "Something went wrong...", + get_string("clst_4"), buttons=[[Button.inline("« Sᴇᴛᴛɪɴɢs", data="setter")]], ) -@callback("pml") -@owner +@callback("pml", owner=True) async def alvcs(event): if not udB.get("PMLOG"): BT = [Button.inline("PMLOGGER ON", data="pmlog")] @@ -1035,8 +1020,7 @@ async def alvcs(event): ) -@callback("pmlgg") -@owner +@callback("pmlgg", owner=True) async def disus(event): await event.delete() pru = event.sender_id @@ -1062,19 +1046,16 @@ async def disus(event): ) -@callback("pmlog") -@owner +@callback("pmlog", owner=True) async def pmlog(event): - var = "PMLOG" - await setit(event, var, "True") + await setit(event, "PMLOG", "True") await event.edit( "Done!! PMLOGGER Started!!", buttons=[[Button.inline("« Bᴀᴄᴋ", data="pml")]], ) -@callback("pmlogof") -@owner +@callback("pmlogof", owner=True) async def pmlogof(event): try: udB.delete("PMLOG") @@ -1084,13 +1065,12 @@ async def pmlogof(event): ) except BaseException: return await event.edit( - "Something went wrong...", + get_string("clst_4"), buttons=[[Button.inline("« Sᴇᴛᴛɪɴɢs", data="setter")]], ) -@callback("ppmset") -@owner +@callback("ppmset", owner=True) async def pmset(event): await event.edit( "PMPermit Settings:", @@ -1103,8 +1083,7 @@ async def pmset(event): ) -@callback("pmon") -@owner +@callback("pmon", owner=True) async def pmonn(event): var = "PMSETTING" await setit(event, var, "True") @@ -1114,8 +1093,7 @@ async def pmonn(event): ) -@callback("pmoff") -@owner +@callback("pmoff", owner=True) async def pmofff(event): var = "PMSETTING" await setit(event, var, "False") @@ -1125,8 +1103,20 @@ async def pmofff(event): ) -@callback("chatbot") -@owner +@callback("botmew", owner=True) +async def hhh(e): + async with e.client.conversation(e.chat_id) as conv: + await conv.send_message("Send Any Media to keep at your Bot's welcome ") + msg = await conv.get_response() + if not msg.media or msg.text.startswith("/"): + return await conv.send_message( + "Terminated!", buttons=get_back_button("chatbot") + ) + udB.set("STARTMEDIA", msg.file.id) + await conv.send_message("Done!", buttons=get_back_button("chatbot")) + + +@callback("chatbot", owner=True) async def chbot(event): await event.edit( "From This Feature U can chat with ppls Via ur Assistant Bot.\n[More info](https://t.me/UltroidUpdates/2)", @@ -1134,14 +1124,50 @@ async def chbot(event): [Button.inline("Cʜᴀᴛ Bᴏᴛ Oɴ", data="onchbot")], [Button.inline("Cʜᴀᴛ Bᴏᴛ Oғғ", data="ofchbot")], [Button.inline("Bᴏᴛ Wᴇʟᴄᴏᴍᴇ", data="bwel")], + [Button.inline("Bᴏᴛ Wᴇʟᴄᴏᴍᴇ Mᴇᴅɪᴀ", data="botmew")], + [Button.inline("Fᴏʀᴄᴇ Sᴜʙsᴄʀɪʙᴇ", data="pmfs")], [Button.inline("« Bᴀᴄᴋ", data="setter")], ], link_preview=False, ) -@callback("bwel") -@owner +@callback("pmfs", owner=True) +async def heheh(event): + Ll = [] + err = "" + async with event.client.conversation(event.chat_id) as conv: + await conv.send_message( + "• Send The Chat Id(s), which you want user to Join Before using Chat/Pm Bot" + ) + await conv.send_message( + "Example : \n`-1001234567\n-100778888`\n\nFor Multiple Chat(s)." + ) + try: + msg = await conv.get_response() + except AsyncTimeOut: + return await conv.send_message("TimeUp!\nStart from /start back.") + if not msg.text or msg.text.startswith("/"): + return await conv.send_message( + "Cancelled!", buttons=get_back_button("chatbot") + ) + for chat in msg.message.split("\n"): + if chat.startswith("-") or chat.isdigit(): + chat = int(chat) + try: + CHSJSHS = await event.client.get_entity(chat) + Ll.append(get_peer_id(CHSJSHS)) + except Exception as er: + err += f"**{chat}** : {er}\n" + if err: + return await conv.send_message(err) + udB.set("PMBOT_FSUB", str(Ll)) + await conv.send_message( + "Done!\nRestart Your Bot.", buttons=get_back_button("chatbot") + ) + + +@callback("bwel", owner=True) async def name(event): await event.delete() pru = event.sender_id @@ -1169,30 +1195,36 @@ async def name(event): ) -@callback("onchbot") -@owner +@callback("onchbot", owner=True) async def chon(event): var = "PMBOT" await setit(event, var, "True") + Loader(path="assistant/pmbot.py", key="PM Bot").load_single() + if AST_PLUGINS.get("pmbot"): + for i, e in AST_PLUGINS["pmbot"]: + event.client.remove_event_handler(i) + for i, e in AST_PLUGINS["pmbot"]: + event.client.add_event_handler(i, events.NewMessage(**e)) await event.edit( "Done! Now u Can Chat With People Via This Bot", buttons=[Button.inline("« Bᴀᴄᴋ", data="chatbot")], ) -@callback("ofchbot") -@owner +@callback("ofchbot", owner=True) async def chon(event): var = "PMBOT" await setit(event, var, "False") + if AST_PLUGINS.get("pmbot"): + for i, e in AST_PLUGINS["pmbot"]: + event.client.remove_event_handler(i) await event.edit( "Done! Chat People Via This Bot Stopped.", buttons=[Button.inline("« Bᴀᴄᴋ", data="chatbot")], ) -@callback("vcb") -@owner +@callback("vcb", owner=True) async def vcb(event): await event.edit( "From This Feature U can play songs in group voice chat\n\n[moreinfo](https://t.me/UltroidUpdates/4)", @@ -1204,8 +1236,7 @@ async def vcb(event): ) -@callback("vcs") -@owner +@callback("vcs", owner=True) async def name(event): await event.delete() pru = event.sender_id @@ -1233,8 +1264,7 @@ async def name(event): ) -@callback("inli_pic") -@owner +@callback("inli_pic", owner=True) async def media(event): await event.delete() pru = event.sender_id @@ -1258,9 +1288,9 @@ async def media(event): if ( not (response.text).startswith("/") and response.text != "" - and not response.media + and (not response.media or isinstance(response.media, MessageMediaWebPage)) ): - url = response.text + url = text_to_url(response) else: try: x = upl(media) diff --git a/assistant/inlinestuff.py b/assistant/inlinestuff.py index bf54971..9c85bfd 100644 --- a/assistant/inlinestuff.py +++ b/assistant/inlinestuff.py @@ -9,23 +9,25 @@ import base64 from datetime import datetime from random import choice from re import compile as re_compile -from re import findall -import aiohttp import requests from bs4 import BeautifulSoup as bs -from play_scraper import search -from search_engine_parser import GoogleSearch, YahooSearch +from pyUltroid.functions.misc import google_search +from pyUltroid.functions.tools import async_searcher, dloader, get_ofox from telethon import Button from telethon.tl.types import InputWebDocument as wb -from plugins._inline import SUP_BUTTONS - from . import * +SUP_BUTTONS = [ + [ + Button.url("• Repo •", url="https://github.com/TeamUltroid/Ultroid"), + Button.url("• Support •", url="t.me/UltroidSupport"), + ], +] + ofox = "https://telegra.ph/file/231f0049fcd722824f13b.jpg" gugirl = "https://telegra.ph/file/0df54ae4541abca96aa11.jpg" -yeah = "https://telegra.ph/file/e3c67885e16a194937516.jpg" ultpic = "https://telegra.ph/file/4136aa1650bc9d4109cc5.jpg" api1 = base64.b64decode("QUl6YVN5QXlEQnNZM1dSdEI1WVBDNmFCX3c4SkF5NlpkWE5jNkZV").decode( @@ -39,8 +41,7 @@ api3 = base64.b64decode("QUl6YVN5RGRPS253blB3VklRX2xiSDVzWUU0Rm9YakFLSVFWMERR"). ) -@in_pattern("ofox") -@in_owner +@in_pattern("ofox", owner=True) async def _(e): match = None try: @@ -98,8 +99,7 @@ async def _(e): ) -@in_pattern("fl2lnk ?(.*)") -@in_owner +@in_pattern("fl2lnk ?(.*)", owner=True) async def _(e): file_path = e.pattern_match.group(1) file_name = file_path.split("/")[-1] @@ -135,8 +135,8 @@ async def _(e): re_compile( "fl(.*)", ), + owner=True, ) -@owner async def _(e): t = (e.data).decode("UTF-8") data = t[2:] @@ -147,8 +147,7 @@ async def _(e): await dloader(e, host, file) -@in_pattern("repo") -@in_owner +@in_pattern("repo", owner=True) async def repo(e): res = [ await e.builder.article( @@ -162,34 +161,21 @@ async def repo(e): await e.answer(res, switch_pm="Ultroid Repo.", switch_pm_param="start") -@in_pattern("go") -@in_owner +@in_pattern("go", owner=True) async def gsearch(q_event): try: match = q_event.text.split(" ", maxsplit=1)[1] except IndexError: - await q_event.answer( + return await q_event.answer( [], switch_pm="Google Search. Enter a query!", switch_pm_param="start" ) searcher = [] - page = findall(r"page=\d+", match) - cache = False - try: - page = page[0] - page = page.replace("page=", "") - match = match.replace("page=" + page[0], "") - except IndexError: - page = 1 - search_args = (str(match), int(page), bool(cache)) - gsearch = GoogleSearch() - gresults = await gsearch.async_search(*search_args) - msg = "" - for i in range(len(gresults["links"])): + gresults = await google_search(match) + for i in gresults: try: - title = gresults["titles"][i] - link = gresults["links"][i] - desc = gresults["descriptions"][i] - msg += f"👉[{title}]({link})\n`{desc}`\n\n" + title = i["title"] + link = i["link"] + desc = i["description"] searcher.append( await q_event.builder.article( title=title, @@ -219,115 +205,7 @@ async def gsearch(q_event): await q_event.answer(searcher, switch_pm="Google Search.", switch_pm_param="start") -@in_pattern("yahoo") -@in_owner -async def yahoosearch(q_event): - try: - match = q_event.text.split(" ", maxsplit=1)[1] - except IndexError: - await q_event.answer( - [], switch_pm="Yahoo Search. Enter a query!", switch_pm_param="start" - ) - searcher = [] - page = findall(r"page=\d+", match) - cache = False - try: - page = page[0] - page = page.replace("page=", "") - match = match.replace("page=" + page[0], "") - except IndexError: - page = 1 - search_args = (str(match), int(page), bool(cache)) - gsearch = YahooSearch() - gresults = await gsearch.async_search(*search_args) - msg = "" - for i in range(len(gresults["links"])): - try: - title = gresults["titles"][i] - link = gresults["links"][i] - desc = gresults["descriptions"][i] - msg += f"👉[{title}]({link})\n`{desc}`\n\n" - searcher.append( - await q_event.builder.article( - title=title, - description=desc, - thumb=wb(yeah, 0, "image/jpeg", []), - text=f"**Yᴀʜᴏᴏ Sᴇᴀʀᴄʜ**\n\n**••Tɪᴛʟᴇ••**\n`{title}`\n\n**••Dᴇsᴄʀɪᴘᴛɪᴏɴ••**\n`{desc}`", - link_preview=False, - buttons=[ - [Button.url("Lɪɴᴋ", url=f"{link}")], - [ - Button.switch_inline( - "Sᴇᴀʀᴄʜ Aɢᴀɪɴ", - query="yahoo ", - same_peer=True, - ), - Button.switch_inline( - "Sʜᴀʀᴇ", - query=f"yahoo {match}", - same_peer=False, - ), - ], - ], - ), - ) - except IndexError: - break - await q_event.answer(searcher, switch_pm="Yahoo Search.", switch_pm_param="start") - - -@in_pattern("app") -@in_owner -async def _(e): - try: - f = e.text.split(" ", maxsplit=1)[1] - except IndexError: - await e.answer( - [], switch_pm="App search. Enter app name!", switch_pm_param="start" - ) - foles = [] - aap = search(f) - for z in aap: - name = z["title"] - desc = z["description"] - price = z["price"] - dev = z["developer"] - icon = z["icon"] - url = z["url"] - ids = z["app_id"] - text = f"**••Aᴘᴘ Nᴀᴍᴇ••** [{name}]({icon})\n" - text += f"**••Dᴇᴠᴇʟᴏᴘᴇʀ••** `{dev}`\n" - text += f"**••Pʀɪᴄᴇ••** `{price}`\n\n" - text += f"**••Dᴇsᴄʀɪᴘᴛɪᴏɴ••**\n`{desc}`" - foles.append( - await e.builder.article( - title=name, - description=ids, - thumb=wb(icon, 0, "image/jpeg", []), - text=text, - link_preview=True, - buttons=[ - [Button.url("Lɪɴᴋ", url=f"https://play.google.com{url}")], - [ - Button.switch_inline( - "Mᴏʀᴇ Aᴘᴘs", - query="app ", - same_peer=True, - ), - Button.switch_inline( - "Sʜᴀʀᴇ", - query=f"app {f}", - same_peer=False, - ), - ], - ], - ), - ) - await e.answer(foles, switch_pm="Application Searcher.", switch_pm_param="start") - - -@in_pattern("mods") -@in_owner +@in_pattern("mods", owner=True) async def _(e): try: quer = e.text.split(" ", maxsplit=1)[1] @@ -378,20 +256,17 @@ async def _(e): # Inspired by @FindXDaBot -@in_pattern("xda") -@in_owner +@in_pattern("xda", owner=True) async def xda_dev(event): QUERY = event.text.split(" ", maxsplit=1) try: query = QUERY[1] except IndexError: return await event.answer( - [], switch_pm="Enter Query to Search", switch_pm_param="start" + [], switch_pm=get_string("instu_3"), switch_pm_param="start" ) le = "https://www.xda-developers.com/search/" + query.replace(" ", "+") - async with aiohttp.ClientSession() as requests: - async with requests.get(le) as out: - ct = await out.read() + ct = await async_searcher(le, re_content=True) ml = bs(ct, "html.parser", from_encoding="utf-8") ml = ml.find_all("div", re_compile("layout_post_"), id=re_compile("post-")) out = [] @@ -408,7 +283,123 @@ async def xda_dev(event): title=title, description=desc, url=hre, thumb=thumb, text=text ) ) - uppar = "|| XDA Search Results ||" - if not out: - uppar = "No Results Found :(" + uppar = "No Results Found :(" if not out else "|| XDA Search Results ||" await event.answer(out, switch_pm=uppar, switch_pm_param="start") + + +APP_CACHE = {} + + +@in_pattern("app", owner=True) +async def _(e): + try: + f = e.text.split(" ", maxsplit=1)[1] + except IndexError: + swa = get_string("instu_1") + res = [] + if APP_CACHE: + [res.append(APP_CACHE[a][0]) for a in APP_CACHE.keys()] + swa = get_string("instu_2") + return await e.answer(res, switch_pm=swa, switch_pm_param="start") + try: + return await e.answer( + APP_CACHE[f], switch_pm="Application Searcher.", switch_pm_param="start" + ) + except KeyError: + pass + foles = [] + base_uri = "https://play.google.com" + url = f"{base_uri}/store/search?q={f.replace(' ', '%20')}&c=apps" + aap = await async_searcher(url, re_content=True) + b_ = bs(aap, "html.parser", from_encoding="utf-8") + aap = b_.find_all("div", "Vpfmgd") + for z in aap[:10]: + url = base_uri + z.find("a")["href"] + scra = await async_searcher(url, re_content=True) + bp = bs(scra, "html.parser", from_encoding="utf-8") + name = z.find("div", "WsMG1c nnK0zc")["title"] + desc = ( + str(bp.find("div", jsname="sngebd")) + .replace('
', "") + .replace("
", "\n") + .replace("
", "")[:300] + + "..." + ) + dev = z.find("div", "KoLSrc").text + icon = z.find("img", "T75of QNCnCf")["data-src"] + text = f"**••Aᴘᴘ Nᴀᴍᴇ••** [{name}]({icon})\n" + text += f"**••Dᴇᴠᴇʟᴏᴘᴇʀ••** `{dev}`\n" + text += f"**••Dᴇsᴄʀɪᴘᴛɪᴏɴ••**\n`{desc}`" + foles.append( + await e.builder.article( + title=name, + description=dev, + thumb=wb(icon, 0, "image/jpeg", []), + text=text, + link_preview=True, + buttons=[ + [Button.url("Lɪɴᴋ", url=url)], + [ + Button.switch_inline( + "Mᴏʀᴇ Aᴘᴘs", + query="app ", + same_peer=True, + ), + Button.switch_inline( + "Sʜᴀʀᴇ", + query=f"app {f}", + same_peer=False, + ), + ], + ], + ), + ) + APP_CACHE.update({f: foles}) + await e.answer(foles, switch_pm="Application Searcher.", switch_pm_param="start") + + +PISTON_URI = "https://emkc.org/api/v2/piston/" +PISTON_LANGS = {} + + +@in_pattern("run", owner=True) +async def piston_run(event): + try: + lang = event.text.split()[1] + code = event.text.split(maxsplit=2)[2] + except IndexError: + result = await event.builder.article( + title="Bad Query", + description="Usage: [Language] [code]", + text=f'**Inline Usage**\n\n`@{asst.me.username} run python print("hello world")`\n\n[Language List](https://telegra.ph/Ultroid-09-01-6)', + ) + return await event.answer([result]) + if not PISTON_LANGS: + se = await async_searcher(PISTON_URI + "runtimes", re_json=True) + PISTON_LANGS.update({lang.pop("language"): lang for lang in se}) + if lang in PISTON_LANGS.keys(): + version = PISTON_LANGS[lang]["version"] + else: + result = await event.builder.article( + title="Unsupported Language", + description="Usage: [Language] [code]", + text=f'**Inline Usage**\n\n`@{asst.me.username} run python print("hello world")`\n\n[Language List](https://telegra.ph/Ultroid-09-01-6)', + ) + return await event.answer([result]) + output = ( + await async_searcher( + PISTON_URI + "execute", + post=True, + json={"language": lang, "version": version, "files": [{"content": code}]}, + re_json=True, + ) + )["run"]["output"] or get_string("instu_4") + if len(output) > 3000: + output = output[:3000] + "..." + result = await event.builder.article( + title="Result", + description=output, + text=f"• **Language:**\n`{lang}`\n\n• **Code:**\n`{code}`\n\n• **Result:**\n`{output}`", + buttons=Button.switch_inline("Fork", query=event.text, same_peer=True), + ) + await event.answer([result], switch_pm="• Piston •", switch_pm_param="start") diff --git a/assistant/localization.py b/assistant/localization.py index 22a17d8..0749efe 100644 --- a/assistant/localization.py +++ b/assistant/localization.py @@ -7,11 +7,10 @@ import re -from . import * +from . import Button, callback, get_back_button, get_languages, language, udB -@callback("lang") -@owner +@callback("lang", owner=True) async def setlang(event): languages = get_languages() tultd = [ @@ -28,12 +27,12 @@ async def setlang(event): await event.edit("List Of Available Languages.", buttons=buttons) -@callback(re.compile(b"set_(.*)")) -@owner +@callback(re.compile(b"set_(.*)"), owner=True) async def settt(event): lang = event.data_match.group(1).decode("UTF-8") languages = get_languages() - udB.set("language", f"{lang}") + language[0] = lang + udB.delete("language") if lang == "en" else udB.set("language", lang) await event.edit( f"Your language has been set to {languages[lang]['natively']} [{lang}].", buttons=get_back_button("lang"), diff --git a/assistant/manager/__init__.py b/assistant/manager/__init__.py index 33d345d..49ec5ba 100644 --- a/assistant/manager/__init__.py +++ b/assistant/manager/__init__.py @@ -5,5 +5,6 @@ # PLease read the GNU Affero General Public License in # . - -from plugins import * +from .. import * +from pyUltroid.misc._decorators import ultroid_cmd +from pyUltroid.functions.helper import inline_mention diff --git a/assistant/manager/_help.py b/assistant/manager/_help.py index c3b3c2c..9be1949 100644 --- a/assistant/manager/_help.py +++ b/assistant/manager/_help.py @@ -74,6 +74,7 @@ MISC = """ ✘ **Misc** ✘ • /joke : Get Random Jokes. +• /decide : Decide Something.. """ STRINGS = {"Admintools": ADMINTOOLS, "locks": LOCKS, "Utils": UTILITIES, "Misc": MISC} @@ -96,10 +97,10 @@ def get_buttons(): return BTTS -@asst_cmd("help") +@asst_cmd(pattern="help") async def helpish(event): if not event.is_private: - url = "https://t.me/" + asst.me.username + "?start=start" + url = f"https://t.me/{asst.me.username}?start=start" return await event.reply( "Contact me in PM for help!", buttons=Button.url("Click me for Help", url) ) @@ -111,8 +112,7 @@ async def helpish(event): await event.reply(START, buttons=BTTS) -@callback("mngbtn") -@owner +@callback("mngbtn", owner=True) async def ehwhshd(e): buttons = get_buttons() buttons.append([Button.inline("<< Back", "open")]) diff --git a/assistant/manager/_on_adds.py b/assistant/manager/_on_adds.py index 8c2aefd..2be0bab 100644 --- a/assistant/manager/_on_adds.py +++ b/assistant/manager/_on_adds.py @@ -6,12 +6,11 @@ # . from . import * +from telethon import events -@asst.on(events.ChatAction()) +@asst.on(events.ChatAction(func= lambda x: x.user_added)) async def dueha(e): - if not e.user_added: - return user = await e.get_user() if not user.is_self: return diff --git a/assistant/manager/misc.py b/assistant/manager/misc.py index 7e1e975..35ba54f 100644 --- a/assistant/manager/misc.py +++ b/assistant/manager/misc.py @@ -7,10 +7,20 @@ import aiohttp - +import random +from pyUltroid.dB import DEVLIST from . import * +@ultroid_cmd(pattern="decide", type="manager") +async def dheh(e): + text = ["Yes", "NoU", "Maybe", "IDK"] + text = random.choice(text) + ri = e.id + if e.is_reply: + ri = e.reply_to_msg_id + await e.client.send_message(e.chat_id, text, reply_to=ri) + @ultroid_cmd(pattern="echo ?(.*)", type=["manager"]) async def oqha(e): match = e.pattern_match.group(1) diff --git a/assistant/ping.py b/assistant/ping.py deleted file mode 100644 index 74b5274..0000000 --- a/assistant/ping.py +++ /dev/null @@ -1,18 +0,0 @@ -# Ultroid - UserBot -# Copyright (C) 2021 TeamUltroid -# -# This file is a part of < https://github.com/TeamUltroid/Ultroid/ > -# PLease read the GNU Affero General Public License in -# . - -from datetime import datetime - - -@asst_cmd("ping$") -@owner -async def _(event): - start = datetime.now() - msg = await event.reply("Pong!") - end = datetime.now() - ms = (end - start).microseconds / 1000 - await msg.edit(f"**Pong!!**\n `{ms} ms`") diff --git a/assistant/piston.py b/assistant/piston.py deleted file mode 100644 index 019361e..0000000 --- a/assistant/piston.py +++ /dev/null @@ -1,45 +0,0 @@ -# Ultroid - UserBot -# Copyright (C) 2021 TeamUltroid -# -# This file is a part of < https://github.com/TeamUltroid/Ultroid/ > -# PLease read the GNU Affero General Public License in -# . - -from pistonapi import PistonAPI - -from . import * - - -@in_pattern("run") -async def piston_run(event): - piston = PistonAPI() - version = None - try: - lang = event.text.split()[1] - code = event.text.split(maxsplit=2)[2] - except IndexError: - result = await event.builder.article( - title="Bad Query", - description="Usage: [Language] [code]", - text=f'**Inline Usage**\n\n`@{asst.me.username} run python print("hello world")`\n\n[Language List](https://telegra.ph/Ultroid-09-01-6)', - ) - return await event.answer([result]) - if lang in piston.languages.keys(): - version = piston.languages[lang]["version"] - if not version: - result = await event.builder.article( - title="Unsupported Language", - description="Usage: [Language] [code]", - text=f'**Inline Usage**\n\n`@{asst.me.username} run python print("hello world")`\n\n[Language List](https://telegra.ph/Ultroid-09-01-6)', - ) - return await event.answer([result]) - output = piston.execute(language=lang, version=version, code=code) or "Success" - if len(output) > 3000: - output = output[:3000] + "..." - result = await event.builder.article( - title="Result", - description=output, - text=f"• **Language:**\n`{lang}`\n\n• **Code:**\n`{code}`\n\n• **Result:**\n`{output}`", - buttons=Button.switch_inline("Fork", query=event.text, same_peer=True), - ) - await event.answer([result], switch_pm="• Piston •", switch_pm_param="start") diff --git a/assistant/pmbot.py b/assistant/pmbot.py new file mode 100644 index 0000000..f6b34c2 --- /dev/null +++ b/assistant/pmbot.py @@ -0,0 +1,144 @@ +# Ultroid - UserBot +# Copyright (C) 2021 TeamUltroid +# +# This file is a part of < https://github.com/TeamUltroid/Ultroid/ > +# PLease read the GNU Affero General Public License in +# . + +# https://github.com/xditya/TeleBot/blob/master/telebot/plugins/mybot/pmbot/incoming.py + +# --------------------------------------- Imports -------------------------------------------- # + +from pyUltroid.dB.asst_fns import * +from pyUltroid.dB.botchat_db import * +from pyUltroid.functions.helper import inline_mention +from pyUltroid.misc import owner_and_sudos +from telethon.errors.rpcerrorlist import UserNotParticipantError +from telethon.tl.custom import Button +from telethon.tl.functions.channels import GetFullChannelRequest +from telethon.tl.functions.messages import GetFullChatRequest +from telethon.tl.types import Channel, Chat +from telethon.utils import get_display_name + +from . import * + +FSUB = udB.get_redis("PMBOT_FSUB") +CACHE = {} +# --------------------------------------- Incoming -------------------------------------------- # + + +@asst_cmd(load=AST_PLUGINS, incoming=True, func=lambda e: e.is_private) +async def on_new_mssg(event): + who = event.sender_id + if is_blacklisted(who): + return + # doesn't reply to that user anymore + if event.text.startswith("/") or who == OWNER_ID: + return + if FSUB: + MSG = "" + BTTS = [] + for chat in FSUB: + try: + await event.client.get_permissions(chat, event.sender_id) + except UserNotParticipantError: + if not MSG: + MSG += "**You need to Join Below Chat(s) in order to Chat to my Master!\n\n**" + try: + TAHC_ = await event.client.get_entity(chat) + if hasattr(TAHC_, "username") and TAHC_.username: + uri = "t.me/" + TAHC_.username + elif CACHE.get(chat): + uri = CACHE[chat] + else: + if isinstance(TAHC_, Channel): + FUGB = await event.client(GetFullChannelRequest(chat)) + elif isinstance(TAHC_, Chat): + FUGB = await event.client(GetFullChatRequest(chat)) + else: + return + if FUGB.full_chat.exported_invite: + CACHE[chat] = FUGB.full_chat.exported_invite.link + uri = CACHE[chat] + BTTS.append(Button.url(get_display_name(TAHC_), uri)) + except Exception as er: + LOGS.exception(f"Error On PmBot Force Sub!\n - {chat} \n{er}") + if MSG and BTTS: + return await event.reply(MSG, buttons=BTTS) + xx = await event.forward_to(OWNER_ID) + if event.fwd_from: + await xx.reply(f"From {inline_mention(event.sender)} [`{event.sender_id}`]") + add_stuff(xx.id, who) + + +# --------------------------------------- Outgoing -------------------------------------------- # + + +@asst_cmd( + load=AST_PLUGINS, + from_users=[OWNER_ID], + incoming=True, + func=lambda e: e.is_private and e.is_reply, +) +async def on_out_mssg(event): + x = await event.get_reply_message() + to_user = get_who(x.id) + if event.text.startswith("/who"): + try: + k = await asst.get_entity(to_user) + return await event.reply( + f"• **Name :** {get_display_name(k)}\n• **ID :** `{k.id}`\n• **Link :** {inline_mention(k)}" + ) + except BaseException: + return + elif event.text.startswith("/"): + return + if to_user: + await asst.send_message(to_user, event.message) + + +# --------------------------------------- Ban/Unban -------------------------------------------- # + + +@asst_cmd( + pattern="ban", + load=AST_PLUGINS, + from_users=owner_and_sudos(castint=True), + func=lambda x: x.is_private, +) +async def banhammer(event): + x = await event.get_reply_message() + if not x: + return await event.reply("Please reply to someone to ban him.") + target = get_who(x.id) + if is_blacklisted(target): + return await event.reply("User is already banned!") + + blacklist_user(target) + await event.reply(f"#BAN\nUser : {target}") + await asst.send_message( + target, + "`GoodBye! You have been banned.`\n**Further messages you send will not be forwarded.**", + ) + + +@asst_cmd( + pattern="unban", + load=AST_PLUGINS, + from_users=owner_and_sudos(castint=True), + func=lambda x: x.is_private, +) +async def unbanhammer(event): + x = await event.get_reply_message() + if not x: + return await event.reply("Please reply to someone to Unban him.") + target = get_who(x.id) + if not is_blacklisted(target): + return await event.reply("User was never banned!") + + rem_blacklist(target) + await event.reply(f"#UNBAN\nUser : {target}") + await asst.send_message(target, "`Congrats! You have been unbanned.`") + + +# --------------------------------------- END -------------------------------------------- # diff --git a/assistant/pmbot/__init__.py b/assistant/pmbot/__init__.py deleted file mode 100644 index 89bc4e3..0000000 --- a/assistant/pmbot/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -from pyUltroid.functions.asst_fns import * -from pyUltroid.functions.botchat_db import * - -from .. import * - -OWNER_NAME = ultroid_bot.me.first_name -OWNER_ID = ultroid_bot.me.id diff --git a/assistant/pmbot/banuser.py b/assistant/pmbot/banuser.py deleted file mode 100644 index ca1b022..0000000 --- a/assistant/pmbot/banuser.py +++ /dev/null @@ -1,45 +0,0 @@ -# Ultroid - UserBot -# Copyright (C) 2021 TeamUltroid -# -# This file is a part of < https://github.com/TeamUltroid/Ultroid/ > -# PLease read the GNU Affero General Public License in -# . - -from . import * - - -@asst_cmd("ban") -@owner -async def banhammer(event): - if not event.is_private: - return - x = await event.get_reply_message() - if x is None: - return await event.edit("Please reply to someone to ban him.") - target = get_who(x.id) - if is_blacklisted(target): - return await asst.send_message(event.chat_id, "User is already banned!") - - blacklist_user(target) - await asst.send_message(event.chat_id, f"#BAN\nUser - {target}") - await asst.send_message( - target, - "`GoodBye! You have been banned.`\n**Further messages you send will not be forwarded.**", - ) - - -@asst_cmd("unban") -@owner -async def banhammer(event): - if not event.is_private: - return - x = await event.get_reply_message() - if x is None: - return await event.edit("Please reply to someone to ban him.") - target = get_who(x.id) - if not is_blacklisted(target): - return await asst.send_message(event.chat_id, "User was never banned!") - - rem_blacklist(target) - await asst.send_message(event.chat_id, f"#UNBAN\nUser - {target}") - await asst.send_message(target, "`Congrats! You have been unbanned.`") diff --git a/assistant/pmbot/incoming.py b/assistant/pmbot/incoming.py deleted file mode 100644 index aab122a..0000000 --- a/assistant/pmbot/incoming.py +++ /dev/null @@ -1,29 +0,0 @@ -# Ultroid - UserBot -# Copyright (C) 2021 TeamUltroid -# -# This file is a part of < https://github.com/TeamUltroid/Ultroid/ > -# PLease read the GNU Affero General Public License in -# . - -# https://github.com/xditya/TeleBot/blob/master/telebot/plugins/mybot/pmbot/incoming.py -""" -Incoming Message(s) forwarder. -""" - -from telethon import events - -from . import * - -# if incoming - - -@asst.on(events.NewMessage(incoming=True, func=lambda e: e.is_private)) -async def on_new_mssg(event): - who = event.sender_id - if is_blacklisted(who): - return - # doesn't reply to that user anymore - if event.text.startswith("/") or who == OWNER_ID: - return - xx = await event.forward_to(OWNER_ID) - add_stuff(xx.id, who) diff --git a/assistant/pmbot/outgoing.py b/assistant/pmbot/outgoing.py deleted file mode 100644 index 5bd2555..0000000 --- a/assistant/pmbot/outgoing.py +++ /dev/null @@ -1,34 +0,0 @@ -# Ultroid - UserBot -# Copyright (C) 2021 TeamUltroid -# -# This file is a part of < https://github.com/TeamUltroid/Ultroid/ > -# PLease read the GNU Affero General Public License in -# . - -# https://github.com/xditya/TeleBot/blob/master/telebot/plugins/mybot/pmbot/outgoing.py - -from telethon import events - -from . import * - -# outgoing - - -@asst.on(events.NewMessage(incoming=True, func=lambda e: e.is_private)) -async def on_out_mssg(event): - x = await event.get_reply_message() - if not x: - return - who = event.sender_id - if who == OWNER_ID: - to_user = get_who(x.id) - if event.text.startswith("/who"): - try: - k = await asst.get_entity(to_user) - return await event.reply(f"[{k.first_name}](tg://user?id={k.id})") - except BaseException: - return - elif event.text.startswith("/"): - return - if to_user: - await asst.send_message(to_user, event.message) diff --git a/assistant/start.py b/assistant/start.py index a95e748..0c9405a 100644 --- a/assistant/start.py +++ b/assistant/start.py @@ -8,23 +8,27 @@ from datetime import datetime from pytz import timezone as tz -from pyUltroid.functions.asst_fns import * +from pyUltroid.dB.asst_fns import * +from pyUltroid.functions.helper import inline_mention from pyUltroid.misc import owner_and_sudos -from telethon import events +from telethon import Button, events from telethon.utils import get_display_name -from plugins import * +from strings.strings import get_string from . import * -Owner_info_msg = f""" -Owner - {OWNER_NAME} -OwnerID - {OWNER_ID} +Owner_info_msg = ( + udB.get("BOT_INFO_START") + or f""" +**Owner** - {OWNER_NAME} +**OwnerID** - `{OWNER_ID}` -Message Forwards - {udB.get("PMBOT")} +**Message Forwards** - {udB.get("PMBOT")} -Ultroid [v{ultroid_version}], powered by @TeamUltroid +**Ultroid [v{ultroid_version}](https://github.com/TeamUltroid/Ultroid), powered by @TeamUltroid** """ +) _settings = [ [ @@ -61,7 +65,6 @@ async def own(event): Owner_info_msg, buttons=[Button.inline("Close", data="closeit")], link_preview=False, - parse_mode="html", ) @@ -70,12 +73,19 @@ async def closet(lol): await lol.delete() -@asst_cmd("start ?(.*)") +@asst_cmd(pattern="start ?(.*)", forwards=False, func=lambda x: not x.is_group) async def ultroid(event): - if event.is_group: - return if not is_added(event.sender_id) and str(event.sender_id) not in owner_and_sudos(): add_user(event.sender_id) + kak_uiw = udB.get("OFF_START_LOG") + if not kak_uiw or kak_uiw != "True": + msg = f"{inline_mention(event.sender)} `[{event.sender_id}]` started your [Assistant bot](@{asst.me.username})." + buttons = [[Button.inline("Info", "itkkstyo")]] + if event.sender.username: + buttons[0].append(Button.url("User", "t.me/" + event.sender.username)) + await event.client.send_message( + int(udB["LOG_CHANNEL"]), msg, buttons=buttons + ) if str(event.sender_id) not in owner_and_sudos(): ok = "" u = await event.client.get_entity(event.chat_id) @@ -84,13 +94,17 @@ async def ultroid(event): ok = "You can contact my master using this bot!!\n\nSend your Message, I will Deliver it To Master." await event.reply( f"Hey there [{get_display_name(u)}](tg://user?id={u.id}), this is Ultroid Assistant of [{ultroid_bot.me.first_name}](tg://user?id={ultroid_bot.uid})!\n\n{ok}", - buttons=[Button.inline("Info.", data="ownerinfo")], + file=udB.get("STARTMEDIA"), + buttons=[Button.inline("Info.", data="ownerinfo")] + if Owner_info_msg != "False" + else None, ) else: me = f"[{ultroid_bot.me.first_name}](tg://user?id={ultroid_bot.uid})" mention = f"[{get_display_name(u)}](tg://user?id={u.id})" await event.reply( - Redis("STARTMSG").format(me=me, mention=mention), + udB.get("STARTMSG").format(me=me, mention=mention), + file=udB.get("STARTMEDIA"), buttons=[Button.inline("Info.", data="ownerinfo")], ) else: @@ -107,19 +121,21 @@ async def ultroid(event): ) -@callback("mainmenu") -@owner +@callback("itkkstyo", owner=True) +async def ekekdhdb(e): + text = f"When New Visitor will visit your Assistant Bot. You will get this log message!\n\nTo Disable : {HNDLR}setredis OFF_START_LOG True" + await e.answer(text, alert=True) + + +@callback("mainmenu", owner=True, func=lambda x: not x.is_group) async def ultroid(event): - if event.is_group: - return await event.edit( get_string("ast_3").format(OWNER_NAME), buttons=_start, ) -@callback("stat") -@owner +@callback("stat", owner=True) async def botstat(event): ok = len(get_all_users()) msg = """Ultroid Assistant - Stats @@ -129,19 +145,17 @@ Total Users - {}""".format( await event.answer(msg, cache_time=0, alert=True) -@callback("bcast") -@owner +@callback("bcast", owner=True) async def bdcast(event): ok = get_all_users() - await event.edit(f"Broadcast to {len(ok)} users.") + await event.edit(f"• Broadcast to {len(ok)} users.") async with event.client.conversation(OWNER_ID) as conv: await conv.send_message( "Enter your broadcast message.\nUse /cancel to stop the broadcast.", ) response = conv.wait_event(events.NewMessage(chats=OWNER_ID)) response = await response - themssg = response.message.message - if themssg == "/cancel": + if response.message == "/cancel": return await conv.send_message("Cancelled!!") success = 0 fail = 0 @@ -149,7 +163,7 @@ async def bdcast(event): start = datetime.now() for i in ok: try: - await asst.send_message(int(i), f"{themssg}") + await asst.send_message(int(i), response.message) success += 1 except BaseException: fail += 1 @@ -157,15 +171,14 @@ async def bdcast(event): time_taken = (end - start).seconds await conv.send_message( f""" -Broadcast completed in {time_taken} seconds. +**Broadcast completed in {time_taken} seconds.** Total Users in Bot - {len(ok)} -Sent to {success} users. -Failed for {fail} user(s).""", +**Sent to** : `{success} users.` +**Failed for** : `{fail} user(s).`""", ) -@callback("setter") -@owner +@callback("setter", owner=True) async def setting(event): await event.edit( "Choose from the below options -", @@ -173,8 +186,7 @@ async def setting(event): ) -@callback("tz") -@owner +@callback("tz", owner=True) async def timezone_(event): await event.delete() pru = event.sender_id diff --git a/assistant/ytdl.py b/assistant/ytdl.py index 0047dd7..6832d21 100644 --- a/assistant/ytdl.py +++ b/assistant/ytdl.py @@ -10,19 +10,27 @@ import os import re import time -from numerize import numerize -from pyUltroid.functions.all import * +from pyUltroid.functions.helper import ( + bash, + download_file, + fast_download, + numerize, + time_formatter, + uploader, +) +from pyUltroid.functions.ytdl import dler, get_buttons, get_data from telethon import Button from telethon.tl.types import DocumentAttributeAudio, DocumentAttributeVideo from telethon.tl.types import InputWebDocument as wb from youtubesearchpython import VideosSearch +from . import callback, in_pattern + ytt = "https://telegra.ph/file/afd04510c13914a06dd03.jpg" _yt_base_url = "https://www.youtube.com/watch?v=" -@in_pattern("yt") -@in_owner +@in_pattern("yt", owner=True) async def _(event): try: string = event.text.split(" ", maxsplit=1)[1] @@ -48,9 +56,23 @@ async def _(event): link = _yt_base_url + ids title = v["title"] duration = v["duration"] + views = v["viewCount"]["short"] + publisher = v["channel"]["name"] + published_on = v["publishedTime"] + description = ( + v["descriptionSnippet"][0]["text"] + if v.get("descriptionSnippet") + and len(v["descriptionSnippet"][0]["text"]) < 500 + else "None" + ) thumb = f"https://i.ytimg.com/vi/{ids}/hqdefault.jpg" - text = f"**•Tɪᴛʟᴇ•** `{title}`\n\n**••[Lɪɴᴋ]({link})••**\n\n**••Dᴜʀᴀᴛɪᴏɴ••** `{duration}`\n\n\n" - desc = f"Title : {title}\nDuration : {duration}" + text = f"Title:- {title}\n" + text += f"Duration:- {duration}\n" + text += f"Views:- {views}\n" + text += f"Publisher:- {publisher}\n" + text += f"Published:- {published_on}\n" + text += f"Description:- {description}" + desc = f"{title}\n{duration}" file = wb(thumb, 0, "image/jpeg", []) results.append( await event.builder.article( @@ -61,6 +83,7 @@ async def _(event): content=file, text=text, include_media=True, + parse_mode="html", buttons=[ [ Button.inline("Audio", data=f"ytdl_audio_{ids}"), @@ -88,8 +111,8 @@ async def _(event): re.compile( "ytdl_(.*)", ), + owner=True, ) -@owner async def _(e): _e = e.pattern_match.group(1).decode("UTF-8") _lets_split = _e.split("_", maxsplit=1) @@ -108,8 +131,8 @@ async def _(e): re.compile( "ytdownload_(.*)", ), + owner=True, ) -@owner async def _(event): url = event.pattern_match.group(1).decode("UTF-8") lets_split = url.split("_", maxsplit=1) @@ -135,7 +158,7 @@ async def _(event): artist = ytdl_data["creator"] elif ytdl_data.get("channel"): artist = ytdl_data["channel"] - views = numerize.numerize(ytdl_data["view_count"]) + views = numerize(ytdl_data["view_count"]) await download_file( f"https://i.ytimg.com/vi/{vid_id}/hqdefault.jpg", f"{title}.jpg" ) @@ -172,7 +195,7 @@ async def _(event): artist = ytdl_data["creator"] elif ytdl_data.get("channel"): artist = ytdl_data["channel"] - views = numerize.numerize(ytdl_data["view_count"]) + views = numerize(ytdl_data["view_count"]) thumb = await fast_download( f"https://i.ytimg.com/vi/{vid_id}/hqdefault.jpg", filename=f"{title}.jpg" ) diff --git a/plugins/__init__.py b/plugins/__init__.py index 3bb9fbe..d6ba3b8 100644 --- a/plugins/__init__.py +++ b/plugins/__init__.py @@ -8,36 +8,39 @@ import asyncio import os import time +from random import choice from pyUltroid import * -from pyUltroid.dB import * -from pyUltroid.functions.all import * -from pyUltroid.functions.sudos import * -from pyUltroid.version import ultroid_version -from telethon import Button +from pyUltroid.dB import ULTROID_IMAGES +from pyUltroid.functions.helper import * +from pyUltroid.functions.info import * +from pyUltroid.functions.misc import * +from pyUltroid.functions.tools import * +from pyUltroid.misc._assistant import asst_cmd, callback, in_pattern +from pyUltroid.misc._decorators import ultroid_cmd +from pyUltroid.misc._wrappers import eod, eor +from pyUltroid.version import __version__, ultroid_version +from telethon import Button, events from telethon.tl import functions, types -from telethon.utils import get_display_name from strings import get_string -try: - import glitch_me -except ModuleNotFoundError: - os.system( - "git clone https://github.com/1Danish-00/glitch_me.git && pip install -e ./glitch_me" - ) - - -start_time = time.time() +Redis = udB.get OWNER_NAME = ultroid_bot.me.first_name OWNER_ID = ultroid_bot.me.id LOG_CHANNEL = int(udB.get("LOG_CHANNEL")) +INLINE_PIC = udB.get("INLINE_PIC") or choice(ULTROID_IMAGES) +if INLINE_PIC == "False": + INLINE_PIC = None +Telegraph = telegraph_client() List = [] Dict = {} N = 0 +STUFF = {} + # Chats, which needs to be ignore for some cases # Considerably, there can be many # Feel Free to Add Any other... @@ -62,3 +65,18 @@ KANGING_STR = [ "Imprisoning this sticker...", "Mr.Steal-Your-Sticker is stealing this sticker... ", ] + +ATRA_COL = [ + "DarkCyan", + "DeepSkyBlue", + "DarkTurquoise", + "Cyan", + "LightSkyBlue", + "Turquoise", + "MediumVioletRed", + "Aquamarine", + "Lightcyan", + "Azure", + "Moccasin", + "PowderBlue", +] diff --git a/plugins/_ChatActions.py b/plugins/_chatactions.py similarity index 68% rename from plugins/_ChatActions.py rename to plugins/_chatactions.py index c4c19d7..15e4fe2 100644 --- a/plugins/_ChatActions.py +++ b/plugins/_chatactions.py @@ -5,19 +5,24 @@ # PLease read the GNU Affero General Public License in # . +import asyncio -from pyUltroid.functions.all import get_chatbot_reply -from pyUltroid.functions.chatBot_db import chatbot_stats -from pyUltroid.functions.clean_db import * -from pyUltroid.functions.forcesub_db import * -from pyUltroid.functions.gban_mute_db import * -from pyUltroid.functions.greetings_db import * -from pyUltroid.functions.username_db import * +from pyUltroid.dB import stickers +from pyUltroid.dB.chatBot_db import chatbot_stats +from pyUltroid.dB.clean_db import is_clean_added +from pyUltroid.dB.forcesub_db import get_forcesetting +from pyUltroid.dB.gban_mute_db import is_gbanned +from pyUltroid.dB.greetings_db import get_goodbye, get_welcome, must_thank +from pyUltroid.dB.username_db import get_username, update_username +from pyUltroid.functions.helper import inline_mention +from pyUltroid.functions.tools import create_tl_btn, get_chatbot_reply +from telethon import events from telethon.errors.rpcerrorlist import UserNotParticipantError from telethon.tl.functions.channels import GetParticipantRequest from telethon.utils import get_display_name -from . import * +from . import LOG_CHANNEL, LOGS, asst, get_string, types, udB, ultroid_bot +from ._inline import something @ultroid_bot.on(events.ChatAction()) @@ -31,11 +36,11 @@ async def ChatActionsHandler(ult): # sourcery no-metrics # thank members if must_thank(ult.chat_id): - chat_count = len(await ult.client.get_participants(await ult.get_chat())) + chat_count = (await ult.client.get_participants(ult.chat_id, limit=0)).total if chat_count % 100 == 0: stik_id = chat_count / 100 - 1 sticker = stickers[stik_id] - await ultroid.send_message(ult.chat_id, file=sticker) + await ult.respond(file=sticker) # force subscribe if ( udB.get("FORCESUB") @@ -68,41 +73,43 @@ async def ChatActionsHandler(ult): # sourcery no-metrics user.id, view_messages=False, ) - gban_watch = f"#GBanned_User Joined.\n\n**User** - [{user.first_name}](tg://user?id={user.id})\n" - gban_watch += f"**Reason**: {reason}\n\n" - gban_watch += "`User Banned.`" + gban_watch = get_string("can_1").format(inline_mention(user), reason) await ult.reply(gban_watch) except Exception as er: - LOGS.info(er) + LOGS.exception(er) # greetings elif get_welcome(ult.chat_id): user = await ult.get_user() chat = await ult.get_chat() title = chat.title or "this chat" - pp = await ult.client.get_participants(chat) - count = len(pp) - mention = f"[{get_display_name(user)}](tg://user?id={user.id})" + count = (await ult.client.get_participants(chat, limit=0)).total + mention = inline_mention(user) name = user.first_name - last = user.last_name - fullname = f"{name} {last}" if last else name + fullname = get_display_name(user) uu = user.username username = f"@{uu}" if uu else mention wel = get_welcome(ult.chat_id) msgg = wel["welcome"] - med = wel["media"] + med = wel["media"] or None userid = user.id + msg = None if msgg: + msg = msgg.format( + mention=mention, + group=title, + count=count, + name=name, + fullname=fullname, + username=username, + userid=userid, + ) + if wel.get("button"): + btn = create_tl_btn(wel["button"]) + await something(ult, msg, med, btn) + elif msg: send = await ult.reply( - msgg.format( - mention=mention, - group=title, - count=count, - name=name, - fullname=fullname, - username=username, - userid=userid, - ), + msg, file=med, ) await asyncio.sleep(150) @@ -113,29 +120,33 @@ async def ChatActionsHandler(ult): # sourcery no-metrics user = await ult.get_user() chat = await ult.get_chat() title = chat.title or "this chat" - pp = await ult.client.get_participants(chat) - count = len(pp) - mention = f"[{get_display_name(user)}](tg://user?id={user.id})" + count = (await ult.client.get_participants(chat, limit=0)).total + mention = inline_mention(user) name = user.first_name - last = user.last_name - fullname = f"{name} {last}" if last else name + fullname = get_display_name(user) uu = user.username username = f"@{uu}" if uu else mention wel = get_goodbye(ult.chat_id) msgg = wel["goodbye"] med = wel["media"] userid = user.id + msg = None if msgg: + msg = msgg.format( + mention=mention, + group=title, + count=count, + name=name, + fullname=fullname, + username=username, + userid=userid, + ) + if wel.get("button"): + btn = create_tl_btn(wel["button"]) + await something(ult, msg, med, btn) + elif msg: send = await ult.reply( - msgg.format( - mention=mention, - group=title, - count=count, - name=name, - fullname=fullname, - username=username, - userid=userid, - ), + msg, file=med, ) await asyncio.sleep(150) @@ -150,7 +161,7 @@ async def chatBot_replies(e): if not isinstance(sender, types.User): return if e.text and chatbot_stats(e.chat_id, e.sender_id): - msg = get_chatbot_reply(e, e.message.message) + msg = await get_chatbot_reply(e.message.message) if msg: await e.reply(msg) chat = await e.get_chat() @@ -176,16 +187,16 @@ async def uname_stuff(id, uname, name): if old and uname: await asst.send_message( LOG_CHANNEL, - f"∆ #UsernameUpdate\n\n@{old} changed username to @{uname}", + get_string("can_2").format(old, uname), ) elif old: await asst.send_message( LOG_CHANNEL, - f"∆ #UsernameUpdate\n\n[{name}](tg://user?id={id}) removed its username. (@{old})", + get_string("can_3").format(f"[{name}](tg://user?id={id})", old), ) elif uname: await asst.send_message( LOG_CHANNEL, - f"∆ #UsernameUpdate\n\n[{name}](tg://user?id={id})'s new username --> @{uname}", + get_string("can_4").format(f"[{name}](tg://user?id={id})", uname), ) update_username(id, uname) diff --git a/plugins/_help.py b/plugins/_help.py index bebbe19..4477cd7 100644 --- a/plugins/_help.py +++ b/plugins/_help.py @@ -5,30 +5,33 @@ # PLease read the GNU Affero General Public License in # . -from pyUltroid.dB.core import * -from telethon.errors.rpcerrorlist import BotInlineDisabledError as dis -from telethon.errors.rpcerrorlist import BotMethodInvalidError -from telethon.errors.rpcerrorlist import BotResponseTimeoutError as rep + +from pyUltroid.dB._core import HELP, LIST +from telethon.errors.rpcerrorlist import ( + BotInlineDisabledError, + BotMethodInvalidError, + BotResponseTimeoutError, +) +from telethon.tl.custom import Button from . import * -C_PIC = udB.get("INLINE_PIC") -_file_to_replace = C_PIC or "resources/extras/inline.jpg" - _main_help_menu = [ [ - Button.inline("• Plugins", data="hrrrr"), - Button.inline("• Addons", data="frrr"), + Button.inline(get_string("help_4"), data="hrrrr"), + Button.inline(get_string("help_5"), data="frrr"), ], [ - Button.inline("••Voice Chat", data="vc_helper"), - Button.inline("Inline Plugins••", data="inlone"), + Button.inline(get_string("help_6"), data="vc_helper"), + Button.inline(get_string("help_7"), data="inlone"), ], [ - Button.inline("⚙️ Owner Tools", data="ownr"), - Button.url("Settings ⚙️", url=f"https://t.me/{asst.me.username}?start=set"), + Button.inline(get_string("help_8"), data="ownr"), + Button.url( + get_string("help_9"), url=f"https://t.me/{asst.me.username}?start=set" + ), ], - [Button.inline("••Cʟᴏꜱᴇ••", data="close")], + [Button.inline(get_string("help_10"), data="close")], ] @@ -37,19 +40,27 @@ async def _help(ult): plug = ult.pattern_match.group(1) if plug: try: - if plug in HELP: + if plug in HELP["Official"]: output = f"**Plugin** - `{plug}`\n" - for i in HELP[plug]: + for i in HELP["Official"][plug]: + output += i + output += "\n© @TeamUltroid" + await eor(ult, output) + elif HELP.get("Addons") and plug in HELP["Addons"]: + output = f"**Plugin** - `{plug}`\n" + for i in HELP["Addons"][plug]: + output += i + output += "\n© @TeamUltroid" + await eor(ult, output) + elif HELP.get("VCBot") and plug in HELP["VCBot"]: + output = f"**Plugin** - `{plug}`\n" + for i in HELP["VCBot"][plug]: output += i output += "\n© @TeamUltroid" await eor(ult, output) - elif plug in CMD_HELP: - kk = f"Plugin Name-{plug}\n\n✘ Commands Available -\n\n" - kk += str(CMD_HELP[plug]) - await eor(ult, kk) else: try: - x = f"Plugin Name-{plug}\n\n✘ Commands Available -\n\n" + x = get_string("help_11").format(plug) for d in LIST[plug]: x += HNDLR + d x += "\n" @@ -57,12 +68,12 @@ async def _help(ult): await eor(ult, x) except BaseException: await eor(ult, get_string("help_1").format(plug), time=5) - except BaseException: + except BaseException as er: + LOGS.exception(er) await eor(ult, "Error 🤔 occured.") else: - tgbot = asst.me.username try: - results = await ult.client.inline_query(tgbot, "ultd") + results = await ult.client.inline_query(asst.me.username, "ultd") except BotMethodInvalidError: z = [] for x in LIST.values(): @@ -74,19 +85,19 @@ async def _help(ult): return await ult.reply( get_string("inline_4").format( OWNER_NAME, - len(PLUGINS) - 5, - len(ADDONS), + len(HELP["Official"]) - 5, + len(HELP["Addons"] if "Addons" in HELP else []), cmd, ), - file=_file_to_replace, + file=INLINE_PIC, buttons=_main_help_menu, ) - except rep: + except BotResponseTimeoutError: return await eor( ult, get_string("help_2").format(HNDLR), ) - except dis: + except BotInlineDisabledError: return await eor(ult, get_string("help_3")) await results[0].click(ult.chat_id, reply_to=ult.reply_to_msg_id, hide_via=True) await ult.delete() diff --git a/plugins/_inline.py b/plugins/_inline.py index 8adbfed..0c10c3c 100644 --- a/plugins/_inline.py +++ b/plugins/_inline.py @@ -12,18 +12,21 @@ from math import ceil from os import remove from git import Repo -from pyUltroid.dB.core import * -from pyUltroid.misc import owner_and_sudos -from support import * -from telethon.tl.types import InputBotInlineResult, InputWebDocument +from pyUltroid.dB._core import HELP, LIST +from pyUltroid.functions.helper import gen_chlog, time_formatter, updater +from pyUltroid.misc import CMD_HELP, owner_and_sudos +from pyUltroid.misc._assistant import callback, in_pattern +from telethon import Button +from telethon.tl.types import InputWebDocument, Message +from telethon.utils import resolve_bot_file_id -from . import * +from . import HNDLR, INLINE_PIC, LOGS, OWNER_NAME, asst, get_string, start_time, udB from ._help import _main_help_menu # ================================================# notmine = f"This bot is for {OWNER_NAME}" -TLINK = "https://telegra.ph/file/d9c9bc13647fa1d96e764.jpg" +TLINK = INLINE_PIC or "https://telegra.ph/file/d9c9bc13647fa1d96e764.jpg" helps = get_string("inline_1") add_ons = udB.get("ADDONS") @@ -32,18 +35,10 @@ if add_ons == "True" or add_ons is None: else: zhelps = get_string("inline_3") -C_PIC = udB.get("INLINE_PIC") - -if C_PIC: - _file_to_replace = C_PIC - TLINK = C_PIC -else: - _file_to_replace = "resources/extras/inline.jpg" upage = 0 # ============================================# - # --------------------BUTTONS--------------------# SUP_BUTTONS = [ @@ -56,24 +51,18 @@ SUP_BUTTONS = [ # --------------------BUTTONS--------------------# -@inline +@in_pattern(owner=True, func=lambda x: not x.text) async def inline_alive(o): - if o.text or not str(o.sender_id) in owner_and_sudos(): - return - b = o.builder MSG = "• **Ultroid Userbot •**" WEB0 = InputWebDocument( "https://telegra.ph/file/55dd0f381c70e72557cb1.jpg", 0, "image/jpg", [] ) RES = [ - InputBotInlineResult( - str(o.id), - "photo", - send_message=await b._message( - text=MSG, - media=True, - buttons=SUP_BUTTONS, - ), + await o.builder.article( + type="photo", + text=MSG, + include_media=True, + buttons=SUP_BUTTONS, title="Ultroid Userbot", description="Userbot | Telethon", url=TLINK, @@ -84,29 +73,35 @@ async def inline_alive(o): await o.answer(RES, switch_pm="👥 ULTROID PORTAL", switch_pm_param="start") -@in_pattern("ultd") -@in_owner +@in_pattern("ultd", owner=True) async def inline_handler(event): z = [] + PLUGINS = HELP["Official"] if "Official" in HELP.keys() else [] + ADDONS = HELP["Addons"] if "Addons" in HELP.keys() else [] for x in LIST.values(): for y in x: z.append(y) - result = event.builder.photo( - file=_file_to_replace, - link_preview=False, - text=get_string("inline_4").format( - OWNER_NAME, - len(PLUGINS), - len(ADDONS), - len(z), - ), - buttons=_main_help_menu, + text = get_string("inline_4").format( + OWNER_NAME, + len(PLUGINS), + len(ADDONS), + len(z), ) + if INLINE_PIC: + result = await event.builder.photo( + file=INLINE_PIC, + link_preview=False, + text=text, + buttons=_main_help_menu, + ) + else: + result = await event.builder.article( + title="Ultroid Help Menu", text=text, buttons=_main_help_menu + ) await event.answer([result], gallery=True) -@in_pattern("pasta") -@in_owner +@in_pattern("pasta", owner=True) async def _(event): ok = event.text.split("-")[1] link = "https://spaceb.in/" + ok @@ -124,22 +119,22 @@ async def _(event): await event.answer([result]) -@callback("ownr") -@owner +@callback("ownr", owner=True) async def setting(event): z = [] + PLUGINS = HELP["Official"] if "Official" in HELP.keys() else [] + ADDONS = HELP["Addons"] if "Addons" in HELP.keys() else [] for x in LIST.values(): for y in x: z.append(y) - cmd = len(z) await event.edit( get_string("inline_4").format( OWNER_NAME, len(PLUGINS), len(ADDONS), - cmd, + len(z), ), - file=_file_to_replace, + file=INLINE_PIC, link_preview=False, buttons=[ [ @@ -147,7 +142,7 @@ async def setting(event): Button.inline("•Uᴘᴛɪᴍᴇ•", data="upp"), ], [ - Button.inline("•Rᴇsᴛᴀʀᴛ•", data="rstrt"), + Button.inline("•Stats•", data="alive"), Button.inline("•Uᴘᴅᴀᴛᴇ•", data="doupdate"), ], [Button.inline("« Bᴀᴄᴋ", data="open")], @@ -155,31 +150,26 @@ async def setting(event): ) -@callback("vc_helper") -@owner +@callback(data="vc_helper", owner=True) async def on_vc_callback_query_handler(event): - xhelps = "**Voice Chat Help Menu for {}**\n**Available Commands:** `{}`\n\n@TeamUltroid".format( - OWNER_NAME, len(VC_HELP) - ) + xhelps = get_string("inline_6").format(OWNER_NAME, len(HELP["VCBot"])) try: - buttons = page_num(0, VC_HELP, "vchelp", "vc") - except ZeroDivisionError: + buttons = page_num(0, HELP["VCBot"].keys(), "vchelp", "vc") + except (ZeroDivisionError, KeyError): return await event.answer("Vc not Active.") - await event.edit(f"{xhelps}", buttons=buttons, link_preview=False) + await event.edit(xhelps, file=INLINE_PIC, buttons=buttons, link_preview=False) -@callback("doupdate") -@owner +@callback(data="doupdate", owner=True) async def _(event): - check = updater() - if not check: - return await event.answer( - "You Are Already On Latest Version", cache_time=0, alert=True - ) + if not updater(): + return await event.answer(get_string("inline_9"), cache_time=0, alert=True) + if not INLINE_PIC: + return await event.answer(f"Do {HNDLR}update") repo = Repo.init() ac_br = repo.active_branch changelog, tl_chnglog = gen_chlog(repo, f"HEAD..upstream/{ac_br}") - changelog_str = changelog + "\n\nClick the below button to update!" + changelog_str = changelog + "\n\n" + get_string("inline_8") if len(changelog_str) > 1024: await event.edit(get_string("upd_4")) with open("ultroid_updates.txt", "w+") as file: @@ -204,7 +194,7 @@ async def _(event): ) -@callback("pkng") +@callback(data="pkng", owner=True) async def _(event): start = datetime.now() end = datetime.now() @@ -213,15 +203,14 @@ async def _(event): await event.answer(pin, cache_time=0, alert=True) -@callback("upp") +@callback(data="upp", owner=True) async def _(event): uptime = time_formatter((time.time() - start_time) * 1000) pin = f"🙋Uᴘᴛɪᴍᴇ = {uptime}" await event.answer(pin, cache_time=0, alert=True) -@callback("inlone") -@owner +@callback(data="inlone", owner=True) async def _(e): button = [ [ @@ -243,15 +232,15 @@ async def _(e): same_peer=True, ), Button.switch_inline( - "Sᴇᴀʀᴄʜ Oɴ Yᴀʜᴏᴏ", - query="yahoo TeamUltroid", + "Search on XDA", + query="xda telegram", same_peer=True, ), ], [ Button.switch_inline( "WʜɪSᴘᴇʀ", - query="msg username wspr Hello", + query="wspr @username Hello🎉", same_peer=True, ), Button.switch_inline( @@ -272,7 +261,6 @@ async def _(e): same_peer=True, ), ], - [Button.switch_inline("xda Search", query="xda telegram", same_peer=True)], [ Button.inline( "« Bᴀᴄᴋ", @@ -283,155 +271,116 @@ async def _(e): await e.edit(buttons=button, link_preview=False) -@callback("hrrrr") -@owner +@callback(data="hrrrr", owner=True) async def on_plug_in_callback_query_handler(event): - xhelps = helps.format(OWNER_NAME, len(PLUGINS)) - buttons = page_num(0, PLUGINS, "helpme", "def") + xhelps = helps.format(OWNER_NAME, len(HELP["Official"])) + buttons = page_num(0, HELP["Official"].keys(), "helpme", "def") await event.edit(f"{xhelps}", buttons=buttons, link_preview=False) -@callback("frrr") -@owner +@callback(data="frrr", owner=True) async def addon(event): - halp = zhelps.format(OWNER_NAME, len(ADDONS)) - if len(ADDONS) > 0: - buttons = page_num(0, ADDONS, "addon", "add") - await event.edit(f"{halp}", buttons=buttons, link_preview=False) + if HELP.get("Addons"): + halp = zhelps.format(OWNER_NAME, len(HELP["Addons"])) + buttons = page_num(0, HELP["Addons"].keys(), "addon", "add") + await event.edit(halp, buttons=buttons, link_preview=False) else: await event.answer( - f"• Tʏᴘᴇ `{HNDLR}setredis ADDONS True`\n Tᴏ ɢᴇᴛ ᴀᴅᴅᴏɴs ᴘʟᴜɢɪɴs", + f"• Tʏᴘᴇ {HNDLR}setredis ADDONS True\n Tᴏ ɢᴇᴛ ᴀᴅᴅᴏɴs ᴘʟᴜɢɪɴs", cache_time=0, alert=True, ) -@callback("rstrt") -@owner -async def rrst(ult): - await restart(ult) - - @callback( - re.compile( + data=re.compile( rb"helpme_next\((.+?)\)", ), + owner=True, ) -@owner async def on_plug_in_callback_query_handler(event): current_page_number = int(event.data_match.group(1).decode("UTF-8")) - buttons = page_num(current_page_number + 1, PLUGINS, "helpme", "def") + buttons = page_num( + current_page_number + 1, HELP["Official"].keys(), "helpme", "def" + ) await event.edit(buttons=buttons, link_preview=False) @callback( - re.compile( + data=re.compile( rb"helpme_prev\((.+?)\)", ), + owner=True, ) -@owner async def on_plug_in_callback_query_handler(event): current_page_number = int(event.data_match.group(1).decode("UTF-8")) - buttons = page_num(current_page_number - 1, PLUGINS, "helpme", "def") + buttons = page_num( + current_page_number - 1, list(HELP["Official"].keys()), "helpme", "def" + ) await event.edit(buttons=buttons, link_preview=False) @callback( - re.compile( - rb"vchelp_next\((.+?)\)", - ), -) -@owner -async def on_vc_callback_query_handler(event): - current_page_number = int(event.data_match.group(1).decode("UTF-8")) - buttons = page_num(current_page_number + 1, VC_HELP, "vchelp", "vc") - await event.edit(buttons=buttons, link_preview=False) - - -@callback( - re.compile( - rb"vchelp_prev\((.+?)\)", - ), -) -@owner -async def on_vc_callback_query_handler(event): - current_page_number = int(event.data_match.group(1).decode("UTF-8")) - buttons = page_num(current_page_number - 1, VC_HELP, "vchelp", "vc") - await event.edit(buttons=buttons, link_preview=False) - - -@callback( - re.compile( + data=re.compile( rb"addon_next\((.+?)\)", ), + owner=True, ) -@owner async def on_plug_in_callback_query_handler(event): current_page_number = int(event.data_match.group(1).decode("UTF-8")) - buttons = page_num(current_page_number + 1, ADDONS, "addon", "add") + buttons = page_num( + current_page_number + 1, list(HELP["Addons"].keys()), "addon", "add" + ) await event.edit(buttons=buttons, link_preview=False) @callback( - re.compile( + data=re.compile( rb"addon_prev\((.+?)\)", ), + owner=True, ) -@owner async def on_plug_in_callback_query_handler(event): current_page_number = int(event.data_match.group(1).decode("UTF-8")) - buttons = page_num(current_page_number - 1, ADDONS, "addon", "add") + buttons = page_num( + current_page_number - 1, list(HELP["Addons"].keys()), "addon", "add" + ) await event.edit(buttons=buttons, link_preview=False) -@callback("back") -@owner +@callback(data="back", owner=True) async def backr(event): - xhelps = helps.format(OWNER_NAME, len(PLUGINS)) + xhelps = helps.format(OWNER_NAME, len(HELP["Official"])) current_page_number = int(upage) - buttons = page_num(current_page_number, PLUGINS, "helpme", "def") + buttons = page_num( + current_page_number, list(HELP["Official"].keys()), "helpme", "def" + ) await event.edit( - f"{xhelps}", - file=_file_to_replace, + xhelps, + file=INLINE_PIC, buttons=buttons, link_preview=False, ) -@callback("buck") -@owner +@callback(data="buck", owner=True) async def backr(event): - xhelps = zhelps.format(OWNER_NAME, len(ADDONS)) + xhelps = zhelps.format(OWNER_NAME, len(HELP["Addons"])) current_page_number = int(upage) - buttons = page_num(current_page_number, ADDONS, "addon", "add") + buttons = page_num(current_page_number, list(HELP["Addons"].keys()), "addon", "add") await event.edit( - f"{xhelps}", - file=_file_to_replace, + xhelps, + file=INLINE_PIC, buttons=buttons, link_preview=False, ) -@callback("bvck") -@owner -async def bvckr(event): - xhelps = "**Voice Chat Help Menu for {}**\n**Available Commands:** `{}`\n\n@TeamUltroid".format( - OWNER_NAME, len(VC_HELP) - ) - current_page_number = int(upage) - buttons = page_num(current_page_number, VC_HELP, "vchelp", "vc") - await event.edit( - f"{xhelps}", - file=_file_to_replace, - buttons=buttons, - link_preview=False, - ) - - -@callback("open") -@owner +@callback(data="open", owner=True) async def opner(event): z = [] + PLUGINS = HELP["Official"] if "Official" in HELP.keys() else [] + ADDONS = HELP["Addons"] if "Addons" in HELP.keys() else [] for x in LIST.values(): for y in x: z.append(y) @@ -447,27 +396,25 @@ async def opner(event): ) -@callback("close") -@owner +@callback(data="close", owner=True) async def on_plug_in_callback_query_handler(event): await event.edit( get_string("inline_5"), - file=_file_to_replace, buttons=Button.inline("Oᴘᴇɴ Aɢᴀɪɴ", data="open"), ) @callback( - re.compile( + data=re.compile( b"def_plugin_(.*)", ), + owner=True, ) -@owner async def on_plug_in_callback_query_handler(event): plugin_name = event.data_match.group(1).decode("UTF-8") help_string = f"Plugin Name - `{plugin_name}`\n" try: - for i in HELP[plugin_name]: + for i in HELP["Official"][plugin_name]: help_string += i except BaseException: pass @@ -476,18 +423,21 @@ async def on_plug_in_callback_query_handler(event): else: reply_pop_up_alert = help_string reply_pop_up_alert += "\n© @TeamUltroid" - buttons = [ + buttons = [] + if INLINE_PIC: + buttons.append( + [ + Button.inline( + "« Sᴇɴᴅ Pʟᴜɢɪɴ »", + data=f"sndplug_{(event.data).decode('UTF-8')}", + ) + ] + ) + buttons.append( [ - Button.inline( - "« Sᴇɴᴅ Pʟᴜɢɪɴ »", - data=f"sndplug_{(event.data).decode('UTF-8')}", - ) - ], - [ - Button.inline("« Bᴀᴄᴋ", data="back"), - Button.inline("••Cʟᴏꜱᴇ••", data="close"), - ], - ] + Button.inline("« Bᴀᴄᴋ", data="buck"), + ] + ) try: if str(event.query.user_id) in owner_and_sudos(): await event.edit( @@ -498,21 +448,20 @@ async def on_plug_in_callback_query_handler(event): reply_pop_up_alert = notmine await event.answer(reply_pop_up_alert, cache_time=0) except BaseException: - halps = f"Do .help {plugin_name} to get the list of commands." - await event.edit(halps, buttons=buttons) + await event.edit(get_string("inline_7").format(plugin_name), buttons=buttons) @callback( - re.compile( + data=re.compile( b"vc_plugin_(.*)", ), + owner=True, ) -@owner async def on_vc_plg_callback_query_handler(event): plugin_name = event.data_match.group(1).decode("UTF-8") help_string = f"Plugin Name - `{plugin_name}`\n" try: - for i in VC_HELP[plugin_name]: + for i in HELP["VCBot"][plugin_name]: help_string += i except BaseException: pass @@ -521,18 +470,21 @@ async def on_vc_plg_callback_query_handler(event): else: reply_pop_up_alert = help_string reply_pop_up_alert += "\n© @TeamUltroid" - buttons = [ + buttons = [] + if INLINE_PIC: + buttons.append( + [ + Button.inline( + "« Sᴇɴᴅ Pʟᴜɢɪɴ »", + data=f"sndplug_{(event.data).decode('UTF-8')}", + ) + ] + ) + buttons.append( [ - Button.inline( - "« Sᴇɴᴅ Pʟᴜɢɪɴ »", - data=f"sndplug_{(event.data).decode('UTF-8')}", - ) - ], - [ - Button.inline("« Bᴀᴄᴋ", data="bvck"), - Button.inline("••Cʟᴏꜱᴇ••", data="close"), - ], - ] + Button.inline("« Bᴀᴄᴋ", data="vc_helper"), + ] + ) try: if str(event.query.user_id) in owner_and_sudos(): await event.edit( @@ -548,28 +500,26 @@ async def on_vc_plg_callback_query_handler(event): @callback( - re.compile( + data=re.compile( b"add_plugin_(.*)", ), + owner=True, ) -@owner async def on_plug_in_callback_query_handler(event): plugin_name = event.data_match.group(1).decode("UTF-8") help_string = "" try: - for i in HELP[plugin_name]: + for i in HELP["Addons"][plugin_name]: help_string += i except BaseException: try: for u in CMD_HELP[plugin_name]: - help_string = f"Plugin Name-{plugin_name}\n\n✘ Commands Available-\n\n" + help_string = get_string("help_11").format(plugin_name) help_string += str(CMD_HELP[plugin_name]) except BaseException: try: if plugin_name in LIST: - help_string = ( - f"Plugin Name-{plugin_name}\n\n✘ Commands Available-\n\n" - ) + help_string = get_string("help_11").format(plugin_name) for d in LIST[plugin_name]: help_string += HNDLR + d help_string += "\n" @@ -580,18 +530,21 @@ async def on_plug_in_callback_query_handler(event): else: reply_pop_up_alert = help_string reply_pop_up_alert += "\n© @TeamUltroid" - buttons = [ - [ - Button.inline( - "« Sᴇɴᴅ Pʟᴜɢɪɴ »", - data=f"sndplug_{(event.data).decode('UTF-8')}", - ) - ], + buttons = [] + if INLINE_PIC: + buttons.append( + [ + Button.inline( + "« Sᴇɴᴅ Pʟᴜɢɪɴ »", + data=f"sndplug_{(event.data).decode('UTF-8')}", + ) + ] + ) + buttons.append( [ Button.inline("« Bᴀᴄᴋ", data="buck"), - Button.inline("••Cʟᴏꜱᴇ••", data="close"), - ], - ] + ] + ) try: if str(event.query.user_id) in owner_and_sudos(): await event.edit( @@ -602,14 +555,14 @@ async def on_plug_in_callback_query_handler(event): reply_pop_up_alert = notmine await event.answer(reply_pop_up_alert, cache_time=0) except BaseException: - halps = f"Do .help {plugin_name} to get the list of commands." + halps = get_string("inline_7").format(plugin_name) await event.edit(halps, buttons=buttons) def page_num(page_number, loaded_plugins, prefix, type_): number_of_rows = 5 number_of_cols = 2 - emoji = Redis("EMOJI_IN_HELP") + emoji = udB.get("EMOJI_IN_HELP") multi = emoji or "✘" global upage upage = page_number @@ -652,3 +605,100 @@ def page_num(page_number, loaded_plugins, prefix, type_): modulo_page * number_of_rows : number_of_rows * (modulo_page + 1) ] + [(Button.inline("« Bᴀᴄᴋ »", data="open"),)] return pairs + + +# --------------------------------------------------------------------------------- # + +STUFF = {} + + +@in_pattern("stf(.*)", owner=True) +async def ibuild(e): + n = e.pattern_match.group(1) + builder = e.builder + if not (n and n.isdigit()): + return + ok = STUFF.get(int(n)) + txt = ok.get("msg") or None + pic = ok.get("media") or None + btn = ok.get("button") or None + if not (pic and txt): + txt = "Hey!" + if pic: + try: + include_media = True + mime_type, _pic = None, None + cont, results = None, None + try: + ext = str(pic).split(".")[-1].lower() + except BaseException: + ext = None + if ext in ["img", "jpg", "png"]: + _type = "photo" + mime_type = "image/jpg" + elif ext in ["mp4", "mkv", "gif"]: + mime_type = "video/mp4" + _type = "gif" + else: + try: + if "telethon.tl.types" in str(type(pic)): + _pic = pic + else: + _pic = resolve_bot_file_id(pic) + except BaseException: + pass + if _pic: + results = [ + await builder.document( + _pic, + title="Ultroid Op", + text=txt, + description="@TheUltroid", + buttons=btn, + link_preview=False, + ) + ] + else: + _type = "article" + include_media = False + if not results: + if include_media: + cont = InputWebDocument(pic, 0, mime_type, []) + results = [ + await builder.article( + title="Ultroid Op", + type=_type, + text=txt, + description="@TeamUltroid", + include_media=include_media, + buttons=btn, + thumb=cont, + content=cont, + link_preview=False, + ) + ] + return await e.answer(results) + except Exception as er: + LOGS.exception(er) + result = [ + await builder.article("Ultroid Op", text=txt, link_preview=False, buttons=btn) + ] + await e.answer(result) + + +async def something(e, msg, media, button, reply=True, chat=None): + if e.client._bot: + return await e.reply(msg, file=media, buttons=button) + num = len(STUFF) + 1 + STUFF.update({num: {"msg": msg, "media": media, "button": button}}) + try: + res = await e.client.inline_query(asst.me.username, f"stf{num}") + return await res[0].click( + chat or e.chat_id, + reply_to=bool(isinstance(e, Message) and reply), + hide_via=True, + silent=True, + ) + + except Exception as er: + LOGS.info(er) diff --git a/plugins/_ultroid.py b/plugins/_ultroid.py index 7da74fc..2a1a19f 100644 --- a/plugins/_ultroid.py +++ b/plugins/_ultroid.py @@ -11,7 +11,7 @@ from telethon.errors import ( ChatSendMediaForbiddenError, ) -from . import * +from . import LOG_CHANNEL, LOGS, Button, asst, eor, get_string, ultroid_cmd REPOMSG = """ • **ULTROID USERBOT** •\n @@ -22,7 +22,7 @@ REPOMSG = """ RP_BUTTONS = [ [ - Button.url("Repo", "https://github.com/TeamUltroid/Ultroid"), + Button.url(get_string("bot_3"), "https://github.com/TeamUltroid/Ultroid"), Button.url("Addons", "https://github.com/TeamUltroid/UltroidAddons"), ], [Button.url("Support Group", "t.me/ultroidsupport")], @@ -53,7 +53,7 @@ async def repify(e): await eor(e, REPOMSG) -@ultroid_cmd(pattern="ultroid") +@ultroid_cmd(pattern="ultroid$") async def useUltroid(rs): button = Button.inline("Start >>", "initft_2") msg = await asst.send_message( diff --git a/plugins/_userlogs.py b/plugins/_userlogs.py index 35198b3..191f435 100644 --- a/plugins/_userlogs.py +++ b/plugins/_userlogs.py @@ -8,7 +8,7 @@ import os import re -from pyUltroid.functions.botchat_db import tag_add, who_tag +from pyUltroid.dB.botchat_db import tag_add, who_tag from telethon.errors.rpcerrorlist import ( ChatWriteForbiddenError, MediaEmptyError, @@ -34,7 +34,7 @@ async def all_messages_catcher(e): try: NEEDTOLOG = int(udB.get("TAG_LOG")) except Exception: - return LOGS.info("you given Wrong Grp/Channel ID in TAG_LOG.") + return LOGS.info(get_string("userlogs_1")) x = await e.get_sender() if isinstance(x, types.User) and (x.bot or x.verified): return @@ -43,7 +43,7 @@ async def all_messages_catcher(e): who_n = get_display_name(x) where_l = e.message.message_link buttons = [[Button.url(where_n, where_l)]] - if x.username: + if hasattr(x, "username") and x.username: who_l = f"https://t.me/{x.username}" buttons.append([Button.url(who_n, who_l)]) else: @@ -67,20 +67,21 @@ async def all_messages_catcher(e): return os.remove(media) except Exception as er: LOGS.info(er) - await asst.send_message(NEEDTOLOG, "`Unsupported Media`", buttons=buttons) + await asst.send_message(NEEDTOLOG, get_string("com_4"), buttons=buttons) except (PeerIdInvalidError, ValueError): - await asst.send_message( - int(udB.get("LOG_CHANNEL")), - "The Chat Id You Set In Tag Logger Is Wrong , Please Correct It", - ) + try: + CACHE_SPAM[NEEDTOLOG] + except KeyError: + await asst.send_message( + int(udB.get("LOG_CHANNEL")), get_string("userlogs_1") + ) + CACHE_SPAM.update({NEEDTOLOG: True}) except ChatWriteForbiddenError: try: await asst.get_permissions(NEEDTOLOG, "me") - MSG = "Your Asst Cant Send Messages in Tag Log Chat." - MSG += "\n\nPlease Review the case or you can off" - MSG += "Your TagLogger, if you dont want to use it" + MSG = get_string("userlogs_4") except UserNotParticipantError: - MSG = "Add me to Your Tag Logger Chat to Log Tags" + MSG = get_string("userlogs_2") try: CACHE_SPAM[NEEDTOLOG] except KeyError: @@ -124,34 +125,39 @@ async def when_asst_added_to_chat(event): return user = await event.get_user() chat = await event.get_chat() - if chat.username: + if hasattr(chat, "username") and chat.username: chat = f"[{chat.title}](https://t.me/{chat.username}/{event.action_message.id})" else: chat = f"[{chat.title}](https://t.me/c/{chat.id}/{event.action_message.id})" - if user and user.is_self: - tmp = event.added_by - buttons = Button.inline("Leave Chat", data=f"leave_ch_{event.chat_id}|bot") - return await asst.send_message( - int(udB.get("LOG_CHANNEL")), - f"#ADD_LOG\n\n[{tmp.first_name}](tg://user?id={tmp.id}) added [{user.first_name}](tg://user?id={user.id}) to {chat}.", - buttons=buttons, - ) + if not (user and user.is_self): + return + tmp = event.added_by + buttons = Button.inline( + get_string("userlogs_3"), data=f"leave_ch_{event.chat_id}|bot" + ) + await asst.send_message( + int(udB.get("LOG_CHANNEL")), + f"#ADD_LOG\n\n[{tmp.first_name}](tg://user?id={tmp.id}) added [{user.first_name}](tg://user?id={user.id}) to {chat}.", + buttons=buttons, + ) # log for user's new joins -@ultroid.on(events.ChatAction) +@ultroid_bot.on(events.ChatAction) async def when_ultd_added_to_chat(event): user = await event.get_user() chat = await event.get_chat() if not (user and user.is_self): return - if chat.username: + if hasattr(chat, "username") and chat.username: chat = f"[{chat.title}](https://t.me/{chat.username}/{event.action_message.id})" else: chat = f"[{chat.title}](https://t.me/c/{chat.id}/{event.action_message.id})" - buttons = Button.inline("Leave Chat", data=f"leave_ch_{event.chat_id}|user") + buttons = Button.inline( + get_string("userlogs_3"), data=f"leave_ch_{event.chat_id}|user" + ) if event.user_added: tmp = event.added_by text = f"#ADD_LOG\n\n{inline_mention(tmp)} just added {inline_mention(user)} to {chat}." @@ -166,15 +172,17 @@ async def when_ultd_added_to_chat(event): re.compile( "leave_ch_(.*)", ), + owner=True, ) -@owner async def leave_ch_at(event): cht = event.data_match.group(1).decode("UTF-8") ch_id, client = cht.split("|") if client == "bot": - name = (await asst.get_entity(int(ch_id))).title - await asst.delete_dialog(int(ch_id)) + client = asst elif client == "user": - name = (await ultroid_bot.get_entity(int(ch_id))).title - await ultroid_bot.delete_dialog(int(ch_id)) - await event.edit(f"Left `{name}`") + client = ultroid_bot + else: + return + name = (await client.get_entity(int(ch_id))).title + await client.delete_dialog(int(ch_id)) + await event.edit(get_string("userlogs_5").format(name)) diff --git a/plugins/_wspr.py b/plugins/_wspr.py index b515704..170f333 100644 --- a/plugins/_wspr.py +++ b/plugins/_wspr.py @@ -21,7 +21,6 @@ from telethon.tl.types import UserStatusRecently as rec from . import * -snap = {} buddhhu = {} @@ -30,13 +29,10 @@ buddhhu = {} ) async def _(e): if e.reply_to_msg_id: - okk = (await e.get_reply_message()).sender_id - try: - put = okk - except ValueError as ex: - return await eor(e, str(ex)) - except AttributeError: - return await eor(e, "No username of replied user was found.") + okk = await e.get_reply_message() + if okk.sender.username: + put = f"@{okk.sender.username}" + put = okk.sender_id else: put = e.pattern_match.group(1) if put: @@ -50,100 +46,117 @@ async def _(e): except dis: return await eor(e, get_string("help_3")) await results[0].click(e.chat_id, reply_to=e.reply_to_msg_id, hide_via=True) - await e.delete() - else: - await eor(e, "Add some id or username too") + return await e.delete() + await eor(e, get_string("wspr_3")) -@in_pattern("msg") -@in_owner +@in_pattern("wspr", owner=True) async def _(e): - vvv = e.text - zzz = vvv.split(" ", maxsplit=1) + iuser = e.query.user_id + zzz = e.text.split(maxsplit=2) try: - ggg = zzz[1] - sed = ggg.split(" wspr ", maxsplit=1) - query = sed[0].replace(" ", "") + query = zzz[1] if query.isdigit(): query = int(query) + logi = await ultroid_bot.get_entity(query) except IndexError: - return - iuser = e.query.user_id + sur = e.builder.article( + title="Give Username", + description="You Didn't Type Username or id.", + text="You Didn't Type Username or id.", + ) + return await e.answer([sur]) + except ValueError: + sur = e.builder.article( + title="User Not Found", + description="Make sure username or id is correct.", + text="Make sure username or id is correct.", + ) + return await e.answer([sur]) try: - desc = sed[1] + desc = zzz[2] except IndexError: - desc = "Touch me" - if "wspr" not in vvv: - try: - logi = await ultroid_bot(gu(id=query)) - name = logi.user.first_name - ids = logi.user.id - username = logi.user.username - mention = f"[{name}](tg://user?id={ids})" - x = logi.user.status - bio = logi.about - if isinstance(x, on): - status = "Online" - if isinstance(x, off): - status = "Offline" - if isinstance(x, rec): - status = "Last Seen Recently" - if isinstance(x, lm): - status = "Last seen months ago" - if isinstance(x, lw): - status = "Last seen weeks ago" - if isinstance(x, mt): - status = "Can't Tell" - text = f"**Name:** `{name}`\n" - text += f"**Id:** `{ids}`\n" - if username: - text += f"**Username:** `{username}`\n" - url = f"https://t.me/{username}" - else: - text += f"**Mention:** `{mention}`\n" - url = f"tg://user?id={ids}" - text += f"**Status:** `{status}`\n" - text += f"**About:** `{bio}`" - button = [ - Button.url("Private", url=url), - Button.switch_inline( - "Secret msg", - query=f"msg {query} wspr Hello 👋", - same_peer=True, - ), - ] - sur = e.builder.article( - title=f"{name}", - description=desc, - text=text, - buttons=button, - ) - except BaseException: - name = f"User {query} Not Found\nSearch Again" - sur = e.builder.article( - title=name, - text=name, - ) - else: - try: - logi = await ultroid_bot.get_entity(query) - button = [ - Button.inline("Secret Msg", data=f"dd_{e.id}"), - Button.inline("Delete Msg", data=f"del_{e.id}"), - ] - us = logi.username - sur = e.builder.article( - title=f"{logi.first_name}", - description=desc, - text=get_string("wspr_1").format(us), - buttons=button, - ) - buddhhu.update({e.id: [logi.id, iuser]}) - snap.update({e.id: desc}) - except ValueError: - sur = e.builder.article( - title="Type ur msg", text="You Didn't Type Your Msg" - ) + sur = e.builder.article(title="Type ur msg", text="You Didn't Type Your Msg") + return await e.answer([sur]) + button = [ + Button.inline("Secret Msg", data=f"dd_{e.id}"), + Button.inline("Delete Msg", data=f"del_{e.id}"), + ] + us = logi.username or logi.first_name + sur = e.builder.article( + title=f"{logi.first_name}", + description=desc, + text=get_string("wspr_1").format(us), + buttons=button, + ) + buddhhu.update({e.id: [logi.id, iuser, desc]}) + await e.answer([sur]) + + +@in_pattern("msg", owner=True) +async def _(e): + zzz = e.text.split(maxsplit=1) + desc = "Touch me" + try: + query = zzz[1] + if query.isdigit(): + query = int(query) + logi = await ultroid_bot(gu(id=query)) + name = logi.user.first_name + ids = logi.user.id + username = logi.user.username + mention = f"[{name}](tg://user?id={ids})" + x = logi.user.status + bio = logi.about + if isinstance(x, on): + status = "Online" + if isinstance(x, off): + status = "Offline" + if isinstance(x, rec): + status = "Last Seen Recently" + if isinstance(x, lm): + status = "Last seen months ago" + if isinstance(x, lw): + status = "Last seen weeks ago" + if isinstance(x, mt): + status = "Can't Tell" + text = f"**Name:** `{name}`\n" + text += f"**Id:** `{ids}`\n" + if username: + text += f"**Username:** `{username}`\n" + url = f"https://t.me/{username}" + else: + text += f"**Mention:** `{mention}`\n" + url = f"tg://user?id={ids}" + text += f"**Status:** `{status}`\n" + text += f"**About:** `{bio}`" + button = [ + Button.url("Private", url=url), + Button.switch_inline( + "Secret msg", + query=f"wspr {query} Hello 👋", + same_peer=True, + ), + ] + sur = e.builder.article( + title=f"{name}", + description=desc, + text=text, + buttons=button, + ) + except IndexError: + sur = e.builder.article( + title="Give Username", + description="You Didn't Type Username or id.", + text="You Didn't Type Username or id.", + ) + except BaseException: + name = get_string("wspr_4").format(query) + sur = e.builder.article( + title=name, + text=name, + ) + await e.answer([sur]) @@ -156,11 +169,11 @@ async def _(e): ids = int(e.pattern_match.group(1).decode("UTF-8")) if buddhhu.get(ids): if e.sender_id in buddhhu[ids]: - await e.answer(snap[ids], alert=True) + await e.answer(buddhhu[ids][-1], alert=True) else: await e.answer("Not For You", alert=True) else: - await e.answer("Message Deleted", alert=True) + await e.answer(get_string("wspr_2"), alert=True) @callback(re.compile("del_(.*)")) @@ -169,10 +182,9 @@ async def _(e): if buddhhu.get(ids): if e.sender_id in buddhhu[ids]: buddhhu.pop(ids) - snap.pop(ids) try: await e.edit(get_string("wspr_2")) except np: pass - else: - await e.answer("You Can't do this", alert=True) + else: + await e.answer(get_string("wspr_5"), alert=True) diff --git a/plugins/admintools.py b/plugins/admintools.py index 11e93dc..8bae7fb 100644 --- a/plugins/admintools.py +++ b/plugins/admintools.py @@ -18,27 +18,19 @@ • `{i}kick ` Kick the user from the chat. -• `{i}tban