diff --git a/.github/ISSUE_TEMPLATE/bug-reports.yml b/.github/ISSUE_TEMPLATE/bug-reports.yml index 9bdd4b8586a32b3753d25d70854aa7d78545d55d..b409115d4cd27cb1fdc136eece241b9b43f76b8f 100644 --- a/.github/ISSUE_TEMPLATE/bug-reports.yml +++ b/.github/ISSUE_TEMPLATE/bug-reports.yml @@ -30,18 +30,18 @@ body: label: Version description: What version of Ultroid are you running? options: - - 0.3 - - 0.2 - - 0.1 - - 0.0.9 - - 0.0.8 (or lesser) + - "0.5" + - "0.6" + - "0.7" + - "> 0.7" + validations: required: true - type: dropdown id: hosted attributes: label: Hosted On - description: You Hosted Ultroid In Which Platform? + description: You are hosting Ultroid on Which Platform? options: - Vps - Heroku @@ -65,4 +65,4 @@ body: description: By submitting this issue, you agree that you have read the [docs](https://ultroid.tech) and gone through the [deploy tutorial](https://www.youtube.com/watch?v=9wF7k9qA0Q4) at first. options: - label: I have followed all of the above steps. - required: true \ No newline at end of file + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 734deb175073c6406a252e363996f918ff6eb461..3e8e5c23e326cad9f61db10524b1147bfe77a247 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,8 +1,8 @@ blank_issues_enabled: true contact_links: - name: Ultroid Support - url: https://t.me/UltroidSupport + url: https://t.me/UltroidSupportChat about: Please drop your doubts or queries there for an immediate response. - name: Documentation url: https://ultroid.tech/ - about: Basic documentation for setting up. \ No newline at end of file + about: Basic documentation for setting up. diff --git a/.github/workflows/autotranslate.yml b/.github/workflows/autotranslate.yml new file mode 100644 index 0000000000000000000000000000000000000000..58de97e1f8b8c850372fa49efa4b3cab417d3c88 --- /dev/null +++ b/.github/workflows/autotranslate.yml @@ -0,0 +1,33 @@ +name: Strings Translation + +on: + workflow_dispatch: + push: + branches: [ dev ] + paths: + - strings/strings/en.yml + +env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + analyze: + name: Checkout Strings + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.9.x + - name: Update Translations + run: | + git config --global user.email "newdev0@outlook.com" + git config --global user.name "New-Dev0" + git branch translation && git checkout translation + pip install pyyaml requests telethon + wget -O run.py https://gist.githubusercontent.com/New-dev0/c7d0d1eb514d311e8e3b687ae5cbe5f3/raw/350cc6d451a02a4b07d0f9bbc27b0e7c9465d3d4/updater.py + python3 run.py + rm run.py + git add . && git commit -m "[Auto] Translate" && git push --set-upstream origin translation + gh pr create --title "[Auto] Translation" -B dev --body "Update Translation" diff --git a/.github/workflows/pylint.yaml b/.github/workflows/pylint.yaml new file mode 100644 index 0000000000000000000000000000000000000000..23fcec8a249e81ff4260550f5b17560f074b6551 --- /dev/null +++ b/.github/workflows/pylint.yaml @@ -0,0 +1,44 @@ +name: PyLint +on: + push: + branches: [ dev ] + paths: + - "**.py" +jobs: + PEP8: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - name: Install Python lint libraries + run: pip install autopep8 autoflake isort black + - name: Check for showstoppers + run: | + autopep8 --verbose --in-place --recursive --aggressive --aggressive assistant/*.py + autopep8 --verbose --in-place --recursive --aggressive --aggressive assistant/manager/*.py + autopep8 --verbose --in-place --recursive --aggressive --aggressive plugins/*.py + - name: Remove unused imports and variables + run: | + autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports assistant/*.py + autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports assistant/manager/*.py + autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports plugins/*.py + - name: lint with isort and black + run: | + isort assistant/*.py + isort assistant/manager/*.py + black --fast assistant/*.py + black assistant/manager/*.py + isort plugins/*.py + black --fast plugins/*.py + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: 'pylint: auto fixes' + commit_options: '--no-verify' + repository: . + commit_user_name: buddhhu + commit_user_email: 48654350+buddhhu@users.noreply.github.com + commit_author: Amit Sharma <48654350+buddhhu@users.noreply.github.com> + diff --git a/.github/workflows/stringanalysis.yml b/.github/workflows/stringanalysis.yml new file mode 100644 index 0000000000000000000000000000000000000000..538436660072a08b10ec67b6ae254f7cfdad4b8c --- /dev/null +++ b/.github/workflows/stringanalysis.yml @@ -0,0 +1,33 @@ +name: Strings Analysis + +on: + pull_request: + push: + branches: dev + paths: strings/strings/* + workflow_dispatch: + +jobs: + analyze: + name: Checkout Strings + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.9.x + - name: Install Stuff + run: pip install pyyaml + - name: dl stuff + run: wget -O stringizer.py https://gist.githubusercontent.com/New-dev0/6dfc8a177418565a776167764b2fe0e4/raw/f515e9892a331110c1565eb109eb712eb64423bd/stringzer.py + - name: do stuff + run: python stringizer.py && rm stringizer.py + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: 'Strings: Auto Count' + commit_options: '--no-verify' + repository: . + commit_user_name: TeamUltroid + commit_user_email: 48654350+buddhhu@users.noreply.github.com + commit_author: Amit Sharma <48654350+buddhhu@users.noreply.github.com> diff --git a/.gitignore b/.gitignore index 66593fc4e58a36d1ba8fb0fedd4ef07861fb8db9..26e851a55c3b07d4f024517eaf496d9540692971 100644 --- a/.gitignore +++ b/.gitignore @@ -14,10 +14,11 @@ test* *.log target/npmlist.json package-lock.json +resources/extras/thumbnail.jpg # Directories addons/ -pyUltroid/ +vcbot/ __pycache__/ venv/ node_modules/ @@ -38,5 +39,6 @@ bin-release/ # temporary files *.raw -tplugins -tassistant + +# fly.io configs +fly.toml \ No newline at end of file diff --git a/README.md b/README.md index 405571294ceda547315e182bba1fed5eef5f1554..1488acf7885596685daac61575940019eb8b83c3 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A stable pluggable Telegram userbot + Voice & Video Call music bot, based on Telethon. -[![](https://img.shields.io/badge/Ultroid-v0.6-darkblue)](#) +[![](https://img.shields.io/badge/Ultroid-v0.7-darkgreen)](#) [![Stars](https://img.shields.io/github/stars/TeamUltroid/Ultroid?style=flat-square&color=yellow)](https://github.com/TeamUltroid/Ultroid/stargazers) [![Forks](https://img.shields.io/github/forks/TeamUltroid/Ultroid?style=flat-square&color=orange)](https://github.com/TeamUltroid/Ultroid/fork) [![Size](https://img.shields.io/github/repo-size/TeamUltroid/Ultroid?style=flat-square&color=green)](https://github.com/TeamUltroid/Ultroid/) @@ -84,8 +84,9 @@ Get the [Necessary Variables](#Necessary-Variables) and then click the button be `bash startup` - Windows Users: `python(3) -m pyUltroid` +
+

[OUTDATED] Ultroid CLI

-### Ultroid CLI [Ultroid CLI](https://github.com/BLUE-DEVIL1134/UltroidCli) is a command-line interface for deploying Ultroid. - **Installing** - @@ -96,6 +97,7 @@ Go to [UltroidCli](https://github.com/BLUE-DEVIL1134/UltroidCli) and install the - **Documentation** - Take a look at the [`docs`](https://blue-devil1134.github.io/UltroidCli/) for more detailed information. +
--- ## Necessary Variables diff --git a/app.json b/app.json index 885b2c6e673e3e8e94c527552ddb8b18679e7a30..155e90e3935896f9d94d9ae3373bd5b9506aed5a 100644 --- a/app.json +++ b/app.json @@ -1,7 +1,7 @@ { "name": "Ultroid UserBot", "description": "Pluggable telegram userbot, made in python using Telethon.", - "logo": "https://telegra.ph/file/031957757a4f6a5191040.jpg", + "logo": "https://graph.org/file/031957757a4f6a5191040.jpg", "keywords": [ "Telethon", "telegram", @@ -11,7 +11,7 @@ ], "repository": "https://github.com/TeamUltroid/Ultroid", "website": "https://ultroid.tech", - "success_url": "https://t.me/TheUltroid", + "success_url": "https://t.me/TeamUltroid", "stack": "container", "env": { "API_ID": { diff --git a/assistant/__init__.py b/assistant/__init__.py index dda3e546fb25ddd53cf973f0baf870de3dd60f16..d4d248aed02561e0e9d5ce286c6c488f700c6ba8 100644 --- a/assistant/__init__.py +++ b/assistant/__init__.py @@ -5,16 +5,16 @@ # PLease read the GNU Affero General Public License in # . +from telethon import Button, custom + +from plugins import ATRA_COL, InlinePlugin from pyUltroid import * from pyUltroid import _ult_cache from pyUltroid._misc import owner_and_sudos from pyUltroid._misc._assistant import asst_cmd, callback, in_pattern -from pyUltroid.functions.helper import * -from pyUltroid.functions.tools import get_stored_file -from telethon import Button, custom - -from plugins import ATRA_COL -from strings import get_languages, get_string, language +from pyUltroid.fns.helper import * +from pyUltroid.fns.tools import get_stored_file +from strings import get_languages, get_string OWNER_NAME = ultroid_bot.full_name OWNER_ID = ultroid_bot.uid diff --git a/assistant/callbackstuffs.py b/assistant/callbackstuffs.py index 1e64f0220ff49d174b5da0f477b9a8f78a081fc3..2209972f209de497f833de675e29d95cb93ffeb5 100644 --- a/assistant/callbackstuffs.py +++ b/assistant/callbackstuffs.py @@ -17,22 +17,18 @@ from random import choice from bs4 import BeautifulSoup as bs try: - from pyUltroid.functions.gDrive import GDriveManager + from pyUltroid.fns.gDrive import GDriveManager except ImportError: GDriveManager = None -from pyUltroid.functions.helper import fast_download, progress -from pyUltroid.functions.tools import ( - Carbon, - async_searcher, - get_paste, - telegraph_client, -) -from pyUltroid.startup.loader import Loader from telegraph import upload_file as upl from telethon import Button, events from telethon.tl.types import MessageMediaWebPage from telethon.utils import get_peer_id +from pyUltroid.fns.helper import fast_download, progress +from pyUltroid.fns.tools import Carbon, async_searcher, get_paste, telegraph_client +from pyUltroid.startup.loader import Loader + from . import * # --------------------------------------------------------------------# @@ -54,7 +50,7 @@ def text_to_url(event): _buttons = { "otvars": { - "text": "Other Variables to set for @TheUltroid:", + "text": "Other Variables to set for @TeamUltroid:", "buttons": [ [ Button.inline("Tᴀɢ Lᴏɢɢᴇʀ", data="taglog"), @@ -306,8 +302,9 @@ async def update(eve): ups_rem.fetch(ac_br) repo.git.reset("--hard", "FETCH_HEAD") heroku_git_url = heroku_app.git_url.replace( - "https://", "https://api:" + heroku_api + "@" + "https://", f"https://api:{heroku_api}@" ) + if "heroku" in repo.remotes: remote = repo.remote("heroku") remote.set_url(heroku_git_url) @@ -340,7 +337,7 @@ async def changes(okk): if not match: try: if len(tl_chnglog) > 700: - tl_chnglog = tl_chnglog[:700] + "..." + tl_chnglog = f"{tl_chnglog[:700]}..." button.append([Button.inline("View Complete", "changesall")]) await okk.edit("• Writing Changelogs 📝 •") img = await Carbon( @@ -387,7 +384,7 @@ async def _(e): ok, index = ok.split("|") with open(ok, "r") as hmm: _, key = await get_paste(hmm.read()) - link = "https://spaceb.in/" + key + link = f"https://spaceb.in/{key}" raw = f"https://spaceb.in/api/v1/documents/{key}/raw" if not _: return await e.answer(key[:30], alert=True) @@ -512,7 +509,7 @@ async def rhwhe(e): else: udB.set_key("DUAL_MODE", "True") key = "On" - Msg = "Dual Mode : " + key + Msg = f"Dual Mode : {key}" await e.edit(Msg, buttons=get_back_button("cbs_otvars")) @@ -603,10 +600,7 @@ async def pluginch(event): else: await setit(event, var, themssg) await conv.send_message( - "{} changed to {}\n After Setting All Things Do Restart".format( - name, - themssg, - ), + f"{name} changed to {themssg}\n After Setting All Things Do Restart", buttons=get_back_button("cbs_otvars"), ) @@ -705,10 +699,12 @@ async def _(e): @callback("eaddon", owner=True) async def pmset(event): - if not udB.get_key("ADDONS"): - BT = [Button.inline("Aᴅᴅᴏɴs Oɴ", data="edon")] - else: - BT = [Button.inline("Aᴅᴅᴏɴs Oғғ", data="edof")] + BT = ( + [Button.inline("Aᴅᴅᴏɴs Oғғ", data="edof")] + if udB.get_key("ADDONS") + else [Button.inline("Aᴅᴅᴏɴs Oɴ", data="edon")] + ) + await event.edit( "ADDONS~ Extra Plugins:", buttons=[ @@ -739,10 +735,12 @@ async def eddof(event): @callback("sudo", owner=True) async def pmset(event): - if not udB.get_key("SUDO"): - BT = [Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ Oɴ", data="onsudo")] - else: - BT = [Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ Oғғ", data="ofsudo")] + BT = ( + [Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ Oғғ", data="ofsudo")] + if udB.get_key("SUDO") + else [Button.inline("Sᴜᴅᴏ Mᴏᴅᴇ Oɴ", data="onsudo")] + ) + await event.edit( f"SUDO MODE ~ Some peoples can use ur Bot which u selected. To know More use `{HNDLR}help sudo`", buttons=[ @@ -829,7 +827,7 @@ async def media(event): media = await event.client.download_media(response, "alvpc") try: x = upl(media) - url = f"https://telegra.ph/{x[0]}" + url = f"https://graph.org/{x[0]}" remove(media) except BaseException: return await conv.send_message( @@ -902,10 +900,7 @@ async def name(event): ) await setit(event, var, themssg) await conv.send_message( - "{} changed to {}\n\nAfter Setting All Things Do restart".format( - name, - themssg, - ), + f"{name} changed to {themssg}\n\nAfter Setting All Things Do restart", buttons=get_back_button("cbs_pmcstm"), ) @@ -925,8 +920,7 @@ async def name(event): @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_key("PMWARNS", value) - if dn: + if dn := udB.set_key("PMWARNS", value): await event.edit( f"PM Warns Set to {value}.\nNew users will have {value} chances in PMs before getting banned.", buttons=get_back_button("cbs_pmcstm"), @@ -970,7 +964,7 @@ async def media(event): else: try: x = upl(media) - url = f"https://telegra.ph/{x[0]}" + url = f"https://graph.org/{x[0]}" remove(media) except BaseException: return await conv.send_message( @@ -1025,10 +1019,12 @@ async def apof(event): @callback("pml", owner=True) async def l_vcs(event): - if not udB.get_key("PMLOG"): - BT = [Button.inline("PMLOGGER ON", data="pmlog")] - else: - BT = [Button.inline("PMLOGGER OFF", data="pmlogof")] + BT = ( + [Button.inline("PMLOGGER OFF", data="pmlogof")] + if udB.get_key("PMLOG") + else [Button.inline("PMLOGGER ON", data="pmlog")] + ) + await event.edit( "PMLOGGER This Will Forward Ur Pm to Ur Private Group -", buttons=[ @@ -1170,10 +1166,7 @@ async def name(event): ) await setit(event, var, themssg) await conv.send_message( - "{} changed to {}".format( - name, - themssg, - ), + f"{name} changed to {themssg}", buttons=get_back_button("cbs_chatbot"), ) @@ -1237,7 +1230,7 @@ async def media(event): else: try: x = upl(media) - url = f"https://telegra.ph/{x[0]}" + url = f"https://graph.org/{x[0]}" remove(media) except BaseException: return await conv.send_message( @@ -1268,12 +1261,12 @@ async def fdroid_dler(event): title = BSC.find("h3", "package-name").text.strip() thumb = BSC.find("img", "package-icon")["src"] if thumb.startswith("/"): - thumb = "https://f-droid.org" + thumb - thumb, _ = await fast_download(thumb, filename=uri + ".png") + thumb = f"https://f-droid.org{thumb}" + thumb, _ = await fast_download(thumb, filename=f"{uri}.png") s_time = time.time() file, _ = await fast_download( dl_, - filename=title + ".apk", + filename=f"{title}.apk", progress_callback=lambda d, t: asyncio.get_event_loop().create_task( progress( d, @@ -1284,6 +1277,7 @@ async def fdroid_dler(event): ) ), ) + time.time() n_file = await event.client.fast_uploader( file, show_progress=True, event=event, message="Uploading...", to_delete=True diff --git a/assistant/games.py b/assistant/games.py index 5f7029e3e643ba0f3569fc7a1ad4581b25cd8153..2e730bfc4738d7e9a1161b1349a38c5100257683 100644 --- a/assistant/games.py +++ b/assistant/games.py @@ -28,9 +28,6 @@ except ImportError: akinator = None LOGS.error("'akinator' not installed.") -from pyUltroid._misc._decorators import ultroid_cmd -from pyUltroid.functions.helper import inline_mention -from pyUltroid.functions.tools import async_searcher from telethon.errors.rpcerrorlist import ( BotMethodInvalidError, ChatSendStickersForbiddenError, @@ -38,12 +35,16 @@ from telethon.errors.rpcerrorlist import ( from telethon.events import Raw from telethon.tl.types import InputMediaPoll, Poll, PollAnswer, UpdateMessagePollVote +from pyUltroid._misc._decorators import ultroid_cmd +from pyUltroid.fns.helper import inline_mention +from pyUltroid.fns.tools import async_searcher + from . import * # -------------------------- Akinator ----------------------- # games = {} -aki_photo = "https://telegra.ph/file/3cc8825c029fd0cab9edc.jpg" +aki_photo = "https://graph.org/file/3cc8825c029fd0cab9edc.jpg" @ultroid_cmd(pattern="akinator") @@ -89,7 +90,7 @@ async def doai(e): bts = [bts, cts] # ignored Back Button since it makes the Pagination looks Bad - await e.edit("Q. " + qu, buttons=bts) + await e.edit(f"Q. {qu}", buttons=bts) @callback(re.compile("aka_(.*)"), owner=True) @@ -138,6 +139,11 @@ async def eiagx(e): # ----------------------- Main Command ------------------- # +GIMAGES = [ + "https://graph.org/file/1c51015bae5205a65fd69.jpg", + "https://imgwhale.xyz/3xyr322l64j9590", +] + @asst_cmd(pattern="startgame", owner=True) async def magic(event): @@ -147,7 +153,7 @@ async def magic(event): ] await event.reply( get_string("games_1"), - file="https://telegra.ph/file/1c51015bae5205a65fd69.jpg", + file=choice(GIMAGES), buttons=buttons, ) @@ -261,7 +267,7 @@ async def choose_cata(event): close_period=int(in_), ), correct_answers=[ansi], - solution="Join @TheUltroid", + solution="Join @TeamUltroid", solution_entities=[], ) m_ = await event.client.send_message(chat, file=poll) diff --git a/assistant/initial.py b/assistant/initial.py index a857dc047071e1ad83f53383c3833a5ea5446c79..f61223b47f92465ac2cbcd893db076a17f72cf89 100644 --- a/assistant/initial.py +++ b/assistant/initial.py @@ -32,7 +32,7 @@ STRINGS = { -> [Also Check](https://t.me/UltroidUpdates/14) **• To Know About Updates** - - Join @TheUltroid.""", + - Join @TeamUltroid.""", 4: f"""• `To Know All Available Commands` - `{HNDLR}help` @@ -50,14 +50,15 @@ async def init_depl(e): if CURRENT == 5: return await e.edit( STRINGS[5], - buttons=Button.inline("<< Back", "initbk_" + str(4)), + buttons=Button.inline("<< Back", "initbk_4"), link_preview=False, ) + await e.edit( STRINGS[CURRENT], buttons=[ - Button.inline("<<", "initbk_" + str(CURRENT - 1)), - Button.inline(">>", "initft_" + str(CURRENT + 1)), + Button.inline("<<", f"initbk_{str(CURRENT - 1)}"), + Button.inline(">>", f"initft_{str(CURRENT + 1)}"), ], link_preview=False, ) @@ -69,14 +70,15 @@ async def ineiq(e): if CURRENT == 1: return await e.edit( STRINGS[1], - buttons=Button.inline("Start Back >>", "initft_" + str(2)), + buttons=Button.inline("Start Back >>", "initft_2"), link_preview=False, ) + await e.edit( STRINGS[CURRENT], buttons=[ - Button.inline("<<", "initbk_" + str(CURRENT - 1)), - Button.inline(">>", "initft_" + str(CURRENT + 1)), + Button.inline("<<", f"initbk_{str(CURRENT - 1)}"), + Button.inline(">>", f"initft_{str(CURRENT + 1)}"), ], link_preview=False, ) diff --git a/assistant/inlinestuff.py b/assistant/inlinestuff.py index 4e3b3eca6b832a79e7aa75e643ec75cc7fe2d3c4..97797aa33089d56909b62f7e16d07ec6b569f15f 100644 --- a/assistant/inlinestuff.py +++ b/assistant/inlinestuff.py @@ -8,22 +8,24 @@ import base64 import inspect from datetime import datetime +from html import unescape from random import choice from re import compile as re_compile from bs4 import BeautifulSoup as bs -from pyUltroid.functions.misc import google_search -from pyUltroid.functions.tools import ( +from telethon import Button +from telethon.tl.alltlobjects import LAYER, tlobjects +from telethon.tl.types import DocumentAttributeAudio as Audio +from telethon.tl.types import InputWebDocument as wb + +from pyUltroid.fns.misc import google_search +from pyUltroid.fns.tools import ( _webupload_cache, async_searcher, get_ofox, saavn_search, webuploader, ) -from telethon import Button -from telethon.tl.alltlobjects import LAYER, tlobjects -from telethon.tl.types import DocumentAttributeAudio as Audio -from telethon.tl.types import InputWebDocument as wb from . import * from . import _ult_cache @@ -31,13 +33,13 @@ from . import _ult_cache SUP_BUTTONS = [ [ Button.url("• Repo •", url="https://github.com/TeamUltroid/Ultroid"), - Button.url("• Support •", url="t.me/ultroidsupportchat"), + Button.url("• Support •", url="t.me/UltroidSupportChat"), ], ] -ofox = "https://telegra.ph/file/231f0049fcd722824f13b.jpg" -gugirl = "https://telegra.ph/file/0df54ae4541abca96aa11.jpg" -ultpic = "https://telegra.ph/file/4136aa1650bc9d4109cc5.jpg" +ofox = "https://graph.org/file/231f0049fcd722824f13b.jpg" +gugirl = "https://graph.org/file/0df54ae4541abca96aa11.jpg" +ultpic = "https://graph.org/file/4136aa1650bc9d4109cc5.jpg" apis = [ "QUl6YVN5QXlEQnNZM1dSdEI1WVBDNmFCX3c4SkF5NlpkWE5jNkZV", @@ -229,12 +231,11 @@ async def _(e): return await e.answer( [], switch_pm="Mod Apps Search. Enter app name!", switch_pm_param="start" ) - page = 1 - start = (page - 1) * 3 + 1 + start = 0 * 3 + 1 da = base64.b64decode(choice(apis)).decode("ascii") url = f"https://www.googleapis.com/customsearch/v1?key={da}&cx=25b3b50edb928435b&q={quer}&start={start}" data = await async_searcher(url, re_json=True) - search_items = data.get("items") + search_items = data.get("items", []) modss = [] for a in search_items: title = a.get("title") @@ -268,55 +269,22 @@ async def _(e): await e.answer(modss, switch_pm="Search Mod Applications.", switch_pm_param="start") -# Inspired by @FindXDaBot - - -@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=get_string("instu_3"), switch_pm_param="start" - ) - le = "https://www.xda-developers.com/search/" + query.replace(" ", "+") - 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 = [] - for on in ml: - data = on.find_all("img", "xda_image")[0] - title = data["alt"] - thumb = data["src"] - hre = on.find_all("div", "item_content")[0].find("h4").find("a")["href"] - desc = on.find_all("div", "item_meta clearfix")[0].text - thumb = wb(thumb, 0, "image/jpeg", []) - text = f"[{title}]({hre})" - out.append( - await event.builder.article( - title=title, description=desc, url=hre, thumb=thumb, text=text - ) - ) - uppar = "No Results Found :(" if not out else "|| XDA Search Results ||" - await event.answer(out, switch_pm=uppar, switch_pm_param="start") - - APP_CACHE = {} RECENTS = {} +PLAY_API = "https://googleplay.onrender.com/api/apps?q=" @in_pattern("app", owner=True) async def _(e): try: - f = e.text.split(" ", maxsplit=1)[1].lower() + f = e.text.split(maxsplit=1)[1].lower() except IndexError: get_string("instu_1") res = [] if APP_CACHE and RECENTS.get(e.sender_id): - for a in RECENTS[e.sender_id]: - if APP_CACHE.get(a): - res.append(APP_CACHE[a][0]) + res.extend( + APP_CACHE[a][0] for a in RECENTS[e.sender_id] if APP_CACHE.get(a) + ) return await e.answer( res, switch_pm=get_string("instu_2"), switch_pm_param="start" ) @@ -327,33 +295,21 @@ async def _(e): 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" + url = PLAY_API + f.replace(" ", "+") + aap = await async_searcher(url, re_json=True) + for z in aap["results"][:50]: + url = "https://play.google.com/store/apps/details?id=" + z["appId"] + name = z["title"] + desc = unescape(z["summary"])[:300].replace("
", "\n") + "..." + dev = z["developer"]["devId"] + text = f"**••Aᴘᴘ Nᴀᴍᴇ••** [{name}]({url})\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", []), + thumb=wb(z["icon"], 0, "image/jpeg", []), text=text, link_preview=True, buttons=[ @@ -395,13 +351,13 @@ async def piston_run(event): title="Bad Query", description="Usage: [Language] [code]", thumb=wb( - "https://telegra.ph/file/e33c57fc5f1044547e4d8.jpg", 0, "image/jpeg", [] + "https://graph.org/file/e33c57fc5f1044547e4d8.jpg", 0, "image/jpeg", [] ), - 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)', + text=f'**Inline Usage**\n\n`@{asst.me.username} run python print("hello world")`\n\n[Language List](https://graph.org/Ultroid-09-01-6)', ) return await event.answer([result]) if not PISTON_LANGS: - se = await async_searcher(PISTON_URI + "runtimes", re_json=True) + se = await async_searcher(f"{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"] @@ -410,26 +366,31 @@ async def piston_run(event): title="Unsupported Language", description="Usage: [Language] [code]", thumb=wb( - "https://telegra.ph/file/e33c57fc5f1044547e4d8.jpg", 0, "image/jpeg", [] + "https://graph.org/file/e33c57fc5f1044547e4d8.jpg", 0, "image/jpeg", [] ), - 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)', + text=f'**Inline Usage**\n\n`@{asst.me.username} run python print("hello world")`\n\n[Language List](https://graph.org/Ultroid-09-01-6)', ) return await event.answer([result]) output = await async_searcher( - PISTON_URI + "execute", + f"{PISTON_URI}execute", post=True, - json={"language": lang, "version": version, "files": [{"content": code}]}, + json={ + "language": lang, + "version": version, + "files": [{"content": code}], + }, re_json=True, ) + output = output["run"]["output"] or get_string("instu_4") if len(output) > 3000: - output = output[:3000] + "..." + output = f"{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}`", thumb=wb( - "https://telegra.ph/file/871ee4a481f58117dccc4.jpg", 0, "image/jpeg", [] + "https://graph.org/file/871ee4a481f58117dccc4.jpg", 0, "image/jpeg", [] ), buttons=Button.switch_inline("Fork", query=event.text, same_peer=True), ) @@ -458,7 +419,7 @@ async def do_magic(event): for dat in BSC.find_all("a", "package-header")[:10]: image = dat.find("img", "package-icon")["src"] if image.endswith("/"): - image = "https://telegra.ph/file/a8dd4a92c5a53a89d0eff.jpg" + image = "https://graph.org/file/a8dd4a92c5a53a89d0eff.jpg" title = dat.find("h4", "package-name").text.strip() desc = dat.find("span", "package-summary").text.strip() text = f"• **Name :** `{title}`\n\n" @@ -487,96 +448,6 @@ async def do_magic(event): await event.answer(ress, switch_pm=msg, switch_pm_param="start") -_koo_ = {} - - -@in_pattern("koo", owner=True) -async def koo_search(ult): - """Search Users on koo with API""" - try: - match = ult.text.split(maxsplit=1)[1].lower() - match_ = match - except IndexError: - return await ult.answer( - [], switch_pm="Enter Query to Search..", switch_pm_param="start" - ) - if _koo_.get(match): - return await ult.answer( - _koo_[match], switch_pm="• Koo Search •", switch_pm_param="start" - ) - res = [] - se_ = None - key_count = None - if " | " in match: - match = match.split(" | ", maxsplit=1) - try: - key_count = int(match[1]) - except ValueError: - pass - match = match[0] - match = match.replace(" ", "+") - req = await async_searcher( - f"https://www.kooapp.com/apiV1/search?query={match}&searchType=EXPLORE", - re_json=True, - ) - if key_count: - try: - se_ = [req["feed"][key_count - 1]] - except KeyError: - pass - if not se_: - se_ = req["feed"] - for count, feed in enumerate(se_[:10]): - if feed["uiItemType"] == "search_profile": - count += 1 - item = feed["items"][0] - profileImage = ( - item["profileImageBaseUrl"] - if item.get("profileImageBaseUrl") - else "https://telegra.ph/file/dc28e69bd7ea2c0f25329.jpg" - ) - extra = await async_searcher( - "https://www.kooapp.com/apiV1/users/handle/" + item["userHandle"], - re_json=True, - ) - img = wb(profileImage, 0, "image/jpeg", []) - text = f"‣ **Name :** `{item['name']}`" - if extra.get("title"): - text += f"\n‣ **Title :** `{extra['title']}`" - text += f"\n‣ **Username :** `@{item['userHandle']}`" - if extra.get("description"): - text += f"\n‣ **Description :** `{extra['description']}`" - text += f"\n‣ **Followers :** `{extra['followerCount']}` ‣ **Following :** {extra['followingCount']}" - if extra.get("socialProfile") and extra["socialProfile"].get("website"): - text += f"\n‣ **Website :** {extra['socialProfile']['website']}" - res.append( - await ult.builder.article( - title=item["name"], - description=item.get("title") or f"@{item['userHandle']}", - type="photo", - content=img, - thumb=img, - include_media=True, - text=text, - buttons=[ - Button.url( - "View", "https://kooapp.com/profile/" + item["userHandle"] - ), - Button.switch_inline( - "• Share •", - query=ult.text if key_count else ult.text + f" | {count}", - ), - ], - ) - ) - if not res: - switch = "No Results Found :(" - else: - _koo_.update({match_: res}) - switch = f"Showing {len(res)} Results!" - await ult.answer(res, switch_pm=switch, switch_pm_param="start") - - # Thanks to OpenSource _bearer_collected = [ "AAAAAAAAAAAAAAAAAAAAALIKKgEAAAAA1DRuS%2BI7ZRKiagD6KHYmreaXomo%3DP5Vaje4UTtEkODg0fX7nCh5laSrchhtLxeyEqxXpv0w9ZKspLD", @@ -601,7 +472,7 @@ async def twitter_search(event): ) except KeyError: pass - headers = {"Authorization": "bearer " + choice(_bearer_collected)} + headers = {"Authorization": f"bearer {choice(_bearer_collected)}"} res = await async_searcher( f"https://api.twitter.com/1.1/users/search.json?q={match}", headers=headers, @@ -629,7 +500,7 @@ async def twitter_search(event): thumb=thumb, ) ) - swi_ = "No User Found :(" if not reso else f"🐦 Showing {len(reso)} Results!" + swi_ = f"🐦 Showing {len(reso)} Results!" if reso else "No User Found :(" await event.answer(reso, switch_pm=swi_, switch_pm_param="start") if _ult_cache.get("twitter"): _ult_cache["twitter"].update({match: reso}) @@ -655,18 +526,19 @@ async def savn_s(event): switch_pm_param="start", ) results = await saavn_search(query) - swi = "No Results Found!" if not results else "🎵 Saavn Search" + swi = "🎵 Saavn Search" if results else "No Results Found!" res = [] for song in results: thumb = wb(song["image"], 0, "image/jpeg", []) - text = f"• **Title :** {song['song']}" + text = f"• **Title :** {song['title']}" text += f"\n• **Year :** {song['year']}" text += f"\n• **Lang :** {song['language']}" - text += f"\n• **Artist :** {song['primary_artists']}" + text += f"\n• **Artist :** {song['artists']}" text += f"\n• **Release Date :** {song['release_date']}" res.append( await event.builder.article( - title=song["song"], + title=song["title"], + description=song["artists"], type="audio", text=text, include_media=True, @@ -675,14 +547,14 @@ async def savn_s(event): ), thumb=thumb, content=wb( - song["media_url"], + song["url"], 0, "audio/mp4", [ Audio( - title=song["song"], + title=song["title"], duration=int(song["duration"]), - performer=song["primary_artists"], + performer=song["artists"], ) ], ), @@ -692,58 +564,6 @@ async def savn_s(event): _savn_cache.update({query: res}) -_OMG = {} - - -@in_pattern("omgu", owner=True) -async def omgubuntu(ult): - try: - match = ult.text.split(maxsplit=1)[1].lower() - except IndexError: - return await ult.answer( - [], switch_pm="Enter Query to search...", switch_pm_param="start" - ) - if _OMG.get(match): - return await ult.answer( - _OMG[match], switch_pm="OMG Ubuntu Search :]", switch_pm_param="start" - ) - get_web = "https://www.omgubuntu.co.uk/?s=" + match.replace(" ", "+") - get_ = await async_searcher(get_web, re_content=True) - BSC = bs(get_, "html.parser", from_encoding="utf-8") - res = [] - for cont in BSC.find_all("div", "sbs-layout__item"): - img = cont.find("div", "sbs-layout__image") - url = img.find("a")["href"] - src = img.find("img")["src"] - con = cont.find("div", "sbs-layout__content") - tit = con.find("a", "layout__title-link") - title = tit.text.strip() - desc = con.find("p", "layout__description").text.strip() - text = f"[{title.strip()}]({url})\n\n{desc}" - img = wb(src, 0, "image/jpeg", []) - res.append( - await ult.builder.article( - title=title, - type="photo", - description=desc, - url=url, - text=text, - buttons=Button.switch_inline( - "Search Again", query=ult.text, same_peer=True - ), - include_media=True, - content=img, - thumb=img, - ) - ) - await ult.answer( - res, - switch_pm=f"Showing {len(res)} results!" if res else "No Results Found :[", - switch_pm_param="start", - ) - _OMG[match] = res - - @in_pattern("tl", owner=True) async def inline_tl(ult): try: @@ -755,7 +575,7 @@ async def inline_tl(ult): await ult.builder.article( title="How to Use?", description="Tl Searcher by Ultroid", - url="https://t.me/TheUltroid", + url="https://t.me/TeamUltroid", text=text, ) ], @@ -769,8 +589,7 @@ async def inline_tl(ult): text = f"**Name:** `{key.__name__}`\n" text += f"**Category:** `{tyyp}`\n" text += f"\n`from {key.__module__} import {key.__name__}`\n\n" - args = str(inspect.signature(key))[1:][:-1] - if args: + if args := str(inspect.signature(key))[1:][:-1]: text += "**Parameter:**\n" for para in args.split(","): text += " " * 4 + "`" + para + "`\n" @@ -779,108 +598,26 @@ async def inline_tl(ult): await ult.builder.article( title=key.__name__, description=tyyp, - url="https://t.me/TheUltroid", + url="https://t.me/TeamUltroid", text=text[:4000], ) ) - if not res: - mo = f"No Results for {match}!" - else: - mo = f"Showing {len(res)} results!" + mo = f"Showing {len(res)} results!" if res else f"No Results for {match}!" await ult.answer(res[:50], switch_pm=mo, switch_pm_param="start") -@in_pattern("gh", owner=True) -async def gh_feeds(ult): - try: - username = ult.text.split(maxsplit=1)[1] - except IndexError: - return await ult.answer( - [], - switch_pm="Enter Github Username to see feeds...", - switch_pm_param="start", - ) - if not username.endswith("."): - return await ult.answer( - [], switch_pm="End your query with . to search...", switch_pm_param="start" - ) - username = username[:-1] - data = await async_searcher( - f"https://api.github.com/users/{username}/events", re_json=True - ) - if not isinstance(data, list): - msg = "" - for ak in list(data.keys()): - msg += ak + ": `" + data[ak] + "`\n" - return await ult.answer( - [ - await ult.builder.article( - title=data["message"], text=msg, link_preview=False - ) - ], - cache_time=300, - switch_pm="Error!!!", - switch_pm_param="start", - ) - res = [] - res_ids = [] - for cont in data[:50]: - text = f"@{username}" - title = f"@{username}" - extra = None - if cont["type"] == "PushEvent": - text += " pushed in" - title += " pushed in" - dt = cont["payload"]["commits"][-1] - url = "https://github.com/" + dt["url"].split("/repos/")[-1] - extra = f"\n-> message: {dt['message']}" - elif cont["type"] == "IssueCommentEvent": - title += " commented at" - text += " commented at" - url = cont["payload"]["comment"]["html_url"] - elif cont["type"] == "CreateEvent": - title += " created" - text += " created" - url = "https://github.com/" + cont["repo"]["name"] - elif cont["type"] == "PullRequestEvent": - if ( - cont["payload"]["pull_request"].get("user", {}).get("login") - != username.lower() - ): - continue - url = cont["payload"]["pull_request"]["html_url"] - text += " created a pull request in" - title += " created a pull request in" - elif cont["type"] == "ForkEvent": - text += " forked" - title += " forked" - url = cont["payload"]["forkee"]["html_url"] - else: - continue - repo = cont["repo"]["name"] - repo_url = "https://github.com/" + repo - title += " " + repo - text += f" {repo}" - if extra: - text += extra - thumb = wb(cont["actor"]["avatar_url"], 0, "image/jpeg", []) - article = await ult.builder.article( - title=title, - text=text, - url=repo_url, - parse_mode="html", - link_preview=False, - thumb=thumb, - buttons=[ - Button.url("View", url), - Button.switch_inline("Search again", query=ult.text, same_peer=True), - ], - ) - if article.id not in res_ids: - res_ids.append(article.id) - res.append(article) - if res: - msg = f"Showing {len(res)} feeds!" - else: - msg = "Nothing Found" - await ult.answer(res, cache_time=5000, switch_pm=msg, switch_pm_param="start") +InlinePlugin.update( + { + "Pʟᴀʏ Sᴛᴏʀᴇ Aᴘᴘs": "app telegram", + "Mᴏᴅᴅᴇᴅ Aᴘᴘs": "mods minecraft", + "Sᴇᴀʀᴄʜ Oɴ Gᴏᴏɢʟᴇ": "go TeamUltroid", + "WʜɪSᴘᴇʀ": "wspr @username Hello🎉", + "YᴏᴜTᴜʙᴇ Dᴏᴡɴʟᴏᴀᴅᴇʀ": "yt Ed Sheeran Perfect", + "Piston Eval": "run javascript console.log('Hello Ultroid')", + "OʀᴀɴɢᴇFᴏx🦊": "ofox beryllium", + "Tᴡɪᴛᴛᴇʀ Usᴇʀ": "twitter theultroid", + "Fᴅʀᴏɪᴅ Sᴇᴀʀᴄʜ": "fdroid telegram", + "Sᴀᴀᴠɴ sᴇᴀʀᴄʜ": "saavn", + "Tʟ Sᴇᴀʀᴄʜ": "tl", + } +) diff --git a/assistant/localization.py b/assistant/localization.py index b5fdd5cca58fbfe9aa4aaaddfc172c9be7513026..549ee6aa67d0d9f7a7cefa79822a574ff97d27e1 100644 --- a/assistant/localization.py +++ b/assistant/localization.py @@ -7,7 +7,15 @@ import re -from . import Button, callback, get_back_button, get_languages, language, udB +from . import ( + Button, + ULTConfig, + callback, + get_back_button, + get_languages, + get_string, + udB, +) @callback("lang", owner=True) @@ -24,14 +32,14 @@ async def setlang(event): if len(tultd) % 2 == 1: buttons.append((tultd[-1],)) buttons.append([Button.inline("« Back", data="mainmenu")]) - await event.edit("List Of Available Languages.", buttons=buttons) + await event.edit(get_string("ast_4"), buttons=buttons) @callback(re.compile(b"set_(.*)"), owner=True) async def settt(event): lang = event.data_match.group(1).decode("UTF-8") languages = get_languages() - language[0] = lang + ULTConfig.lang = lang udB.del_key("language") if lang == "en" else udB.set_key("language", lang) await event.edit( f"Your language has been set to {languages[lang]['natively']} [{lang}].", diff --git a/assistant/manager/__init__.py b/assistant/manager/__init__.py index b09a5ac0852e0278720ccb00b871c12f9cfe1348..e0aa0a0051cabcdefe89c5d06e1f90b0ecc0cd15 100644 --- a/assistant/manager/__init__.py +++ b/assistant/manager/__init__.py @@ -6,6 +6,6 @@ # . from pyUltroid._misc._decorators import ultroid_cmd -from pyUltroid.functions.helper import inline_mention +from pyUltroid.fns.helper import inline_mention from .. import * diff --git a/assistant/manager/_help.py b/assistant/manager/_help.py index 8169270fa5573c6086c0b686321d1fbf5b3bcbc1..3c7ab38ed9a66337bf713791f6fba973f687205a 100644 --- a/assistant/manager/_help.py +++ b/assistant/manager/_help.py @@ -14,7 +14,7 @@ START = """ ✘ /help : Get This Message. ✘ /repo : Get Bot's Repo.. -🧑‍💻 Join **@TheUltroid** +🧑‍💻 Join **@TeamUltroid** """ ADMINTOOLS = """✘ **AdminTools** ✘ @@ -93,11 +93,11 @@ def get_buttons(): while keys: BT = [] for i in list(keys)[:2]: - text = MNGE + " " + i + " " + MNGE - BT.append(Button.inline(text, "hlp_" + i)) + text = f"{MNGE} {i} {MNGE}" + BT.append(Button.inline(text, f"hlp_{i}")) del keys[i] BTTS.append(BT) - url = "https://t.me/" + asst.me.username + "?startgroup=true" + url = f"https://t.me/{asst.me.username}?startgroup=true" BTTS.append([Button.url("Add me to Group", url)]) return BTTS diff --git a/assistant/manager/admins.py b/assistant/manager/admins.py index a96169d3ca8b9dd962aef976bb71a8d085b7dac9..a8e1ebd154272f3b9c9750c8d4e2e1dbaded9fe0 100644 --- a/assistant/manager/admins.py +++ b/assistant/manager/admins.py @@ -7,9 +7,10 @@ import re -from pyUltroid import _ult_cache from telethon.errors.rpcerrorlist import UserNotParticipantError +from pyUltroid import _ult_cache + from . import * diff --git a/assistant/manager/afk.py b/assistant/manager/afk.py index bb17160ced5df78765471d5eec87a8611f79a6ac..659561146e9c08972ea47bbaeb935a3b4250fd44 100644 --- a/assistant/manager/afk.py +++ b/assistant/manager/afk.py @@ -7,7 +7,6 @@ from datetime import datetime as dt -from pyUltroid.functions.helper import inline_mention, time_formatter from telethon.events import NewMessage from telethon.tl.types import ( Message, @@ -17,6 +16,8 @@ from telethon.tl.types import ( ) from telethon.utils import get_display_name +from pyUltroid.fns.helper import inline_mention, time_formatter + from . import asst, asst_cmd AFK = {} diff --git a/assistant/manager/misc.py b/assistant/manager/misc.py index c411a354c2cdd35754ae9c7e8cb7a2e3af288404..ff721c7d5a9b795faaadaa239b13898f8c87147f 100644 --- a/assistant/manager/misc.py +++ b/assistant/manager/misc.py @@ -9,8 +9,9 @@ import random import aiohttp + from pyUltroid.dB import DEVLIST -from pyUltroid.functions.admins import admin_check +from pyUltroid.fns.admins import admin_check from . import * @@ -27,8 +28,7 @@ async def dheh(e): async def oqha(e): if not await admin_check(e): return - match = e.pattern_match.group(1).strip() - if match: + if match := e.pattern_match.group(1).strip(): text = match reply_to = e elif e.is_reply: diff --git a/assistant/manager/stickermanager.py b/assistant/manager/stickermanager.py index 2b4a83af20c98bff6331fc24f257ded49b351c89..a88c018a3c946df92562e6446170ad9045e9ac93 100644 --- a/assistant/manager/stickermanager.py +++ b/assistant/manager/stickermanager.py @@ -7,8 +7,6 @@ import random -from pyUltroid.functions.misc import Quotly -from pyUltroid.functions.tools import TgConverter from telethon import errors from telethon.errors.rpcerrorlist import StickersetInvalidError from telethon.tl.functions.messages import GetStickerSetRequest as GetSticker @@ -20,6 +18,9 @@ from telethon.tl.types import InputStickerSetItem as SetItem from telethon.tl.types import InputStickerSetShortName, User from telethon.utils import get_display_name, get_input_document +from pyUltroid.fns.misc import Quotly +from pyUltroid.fns.tools import TgConverter + from . import LOGS, asst, asst_cmd, udB @@ -37,7 +38,7 @@ async def kang_cmd(ult): pre = sender.username[:4] else: pre = random.random_string(length=3) - animated, dl = None, None + animated, dl, video = None, None, None try: emoji = ult.text.split(maxsplit=1)[1] except IndexError: @@ -45,9 +46,13 @@ async def kang_cmd(ult): if reply.sticker: file = get_input_document(reply.sticker) emoji = emoji or reply.file.emoji - if reply.file.name.endswith(".tgs"): + name = reply.file.name + if name.endswith(".tgs"): animated = True dl = await reply.download_media() + elif name.endswith(".webm"): + video = True + dl = await reply.download_media() elif reply.photo: dl = await reply.download_media() name = "sticker.webp" @@ -65,7 +70,7 @@ async def kang_cmd(ult): await ult.client(UploadMediaRequest(InputPeerSelf(), upl)) ) get_ = udB.get_key("STICKERS") or {} - type_ = "static" if not animated else "anim" + type_ = "anim" if animated else "static" if not get_.get(ult.sender_id) or not get_.get(ult.sender_id, {}).get(type_): sn = f"{pre}_{ult.sender_id}" title = f"{get_display_name(sender)}'s Kang Pack" @@ -73,6 +78,10 @@ async def kang_cmd(ult): type_ = "anim" sn += "_anim" title += " (Animated)" + elif video: + type_ = "vid" + sn += "_vid" + title += " (Video)" sn += f"_by_{asst.me.username}" try: await asst(GetSticker(InputStickerSetShortName(sn), hash=0)) @@ -86,7 +95,9 @@ async def kang_cmd(ult): title=title, short_name=sn, stickers=[SetItem(file, emoji=emoji)], + videos=video, animated=animated, + software="@TeamUltroid", ) ) except Exception as er: @@ -115,6 +126,9 @@ async def kang_cmd(ult): if animated: sn += "_anim" title += " (Animated)" + elif video: + sn += "_vid" + title += "(Video)" sn += f"_by_{asst.me.username}" try: pack = await ult.client( @@ -148,10 +162,8 @@ async def do_magic(ult): return await ult.reply("No Sticker Pack Found!") al_ = [] ul = ko[ult.sender_id] - if ul.get("static"): - al_.extend(ul["static"]) - if ul.get("anim"): - al_.extend(ul["anim"]) + for _ in ul.keys(): + al_.extend(ul[_]) msg = "• **Stickers Owned by You!**\n\n" for _ in al_: try: @@ -160,7 +172,9 @@ async def do_magic(ult): except StickerSetInvalidError: if ul.get("anim") and _ in ul["anim"]: ul["anim"].remove(_) + elif ul.get("vid") and _ in ul["vid"]: + ul["vid"].remove(_) else: ul["static"].remove(_) - udB.set_key("STICKERS", ko) + udB.set_key("STICKERS", ko) await ult.reply(msg) diff --git a/assistant/pmbot.py b/assistant/pmbot.py index 425fafd4287907770451d773255f11b44709bb73..b591adaf7aff461f676c2f276e37cb2395ecee03 100644 --- a/assistant/pmbot.py +++ b/assistant/pmbot.py @@ -11,9 +11,6 @@ import os -from pyUltroid.dB.asst_fns import * -from pyUltroid.dB.botchat_db import * -from pyUltroid.functions.helper import inline_mention from telethon.errors.rpcerrorlist import UserNotParticipantError from telethon.tl.custom import Button from telethon.tl.functions.channels import GetFullChannelRequest @@ -21,6 +18,10 @@ from telethon.tl.functions.messages import GetFullChatRequest from telethon.tl.types import Channel, Chat from telethon.utils import get_display_name +from pyUltroid.dB.asst_fns import * +from pyUltroid.dB.botchat_db import * +from pyUltroid.fns.helper import inline_mention + from . import * FSUB = udB.get_key("PMBOT_FSUB") @@ -50,7 +51,7 @@ async def on_new_mssg(event): try: TAHC_ = await event.client.get_entity(chat) if hasattr(TAHC_, "username") and TAHC_.username: - uri = "t.me/" + TAHC_.username + uri = f"t.me/{TAHC_.username}" elif CACHE.get(chat): uri = CACHE[chat] else: @@ -98,7 +99,7 @@ async def on_out_mssg(event): os.remove(photu) return except BaseException as er: - return await event.reply("**ERROR : **" + str(er)) + return await event.reply(f"**ERROR : **{str(er)}") elif event.text.startswith("/"): return if to_user: diff --git a/assistant/start.py b/assistant/start.py index bc82cfa52b7b844f660c9501c07b6f4b79fa61dc..cc224f6c6dbb22b0cbfc671262fcf574fd7f79f8 100644 --- a/assistant/start.py +++ b/assistant/start.py @@ -8,14 +8,14 @@ from datetime import datetime from pytz import timezone as tz -from pyUltroid._misc import SUDO_M, owner_and_sudos -from pyUltroid.dB.asst_fns import * -from pyUltroid.functions.helper import inline_mention from telethon import Button, events from telethon.errors.rpcerrorlist import MessageDeleteForbiddenError from telethon.utils import get_display_name -from strings.strings import get_string +from pyUltroid._misc import SUDO_M, owner_and_sudos +from pyUltroid.dB.asst_fns import * +from pyUltroid.fns.helper import inline_mention +from strings import get_string from . import * @@ -68,7 +68,7 @@ async def own(event): mention=event.sender.mention, me=inline_mention(ultroid_bot.me) ) if custom_info: - msg += "\n\n• Powered by **@TheUltroid**" + msg += "\n\n• Powered by **@TeamUltroid**" await event.edit( msg, buttons=[Button.inline("Close", data="closeit")], diff --git a/assistant/ytdl.py b/assistant/ytdl.py index acd54532fb12870525acb5f8639b3ca0a27048eb..8b1c8a9ade25764b3d447e2795685823740be1c9 100644 --- a/assistant/ytdl.py +++ b/assistant/ytdl.py @@ -13,18 +13,19 @@ try: from PIL import Image except ImportError: Image = None -from pyUltroid.functions.helper import ( +from telethon import Button +from telethon.errors.rpcerrorlist import FilePartLengthInvalidError, MediaEmptyError +from telethon.tl.types import DocumentAttributeAudio, DocumentAttributeVideo +from telethon.tl.types import InputWebDocument as wb + +from pyUltroid.fns.helper import ( bash, fast_download, humanbytes, numerize, time_formatter, ) -from pyUltroid.functions.ytdl import dler, get_buttons, get_formats -from telethon import Button -from telethon.errors.rpcerrorlist import FilePartLengthInvalidError, MediaEmptyError -from telethon.tl.types import DocumentAttributeAudio, DocumentAttributeVideo -from telethon.tl.types import InputWebDocument as wb +from pyUltroid.fns.ytdl import dler, get_buttons, get_formats from . import LOGS, asst, callback, in_pattern, udB @@ -35,7 +36,7 @@ except ImportError: VideosSearch = None -ytt = "https://telegra.ph/file/afd04510c13914a06dd03.jpg" +ytt = "https://graph.org/file/afd04510c13914a06dd03.jpg" _yt_base_url = "https://www.youtube.com/watch?v=" BACK_BUTTON = {} @@ -130,9 +131,12 @@ async def _(e): _ytdl_data = await dler(e, _yt_base_url + _lets_split[1]) _data = get_formats(_lets_split[0], _lets_split[1], _ytdl_data) _buttons = get_buttons(_data) - _text = "`Select Your Format.`" - if not _buttons: - _text = "`Error downloading from YouTube.\nTry Restarting your bot.`" + _text = ( + "`Select Your Format.`" + if _buttons + else "`Error downloading from YouTube.\nTry Restarting your bot.`" + ) + await e.edit(_text, buttons=_buttons) @@ -159,7 +163,7 @@ async def _(event): "key": "FFmpegMetadata", "prefer_ffmpeg": True, "geo_bypass": True, - "outtmpl": "%(id)s." + ext, + "outtmpl": f"%(id)s.{ext}", "logtostderr": False, "postprocessors": [ { @@ -170,6 +174,7 @@ async def _(event): {"key": "FFmpegMetadata"}, ], } + ytdl_data = await dler(event, link, opts, True) title = ytdl_data["title"] if ytdl_data.get("artist"): @@ -179,7 +184,8 @@ async def _(event): elif ytdl_data.get("channel"): artist = ytdl_data["channel"] views = numerize(ytdl_data.get("view_count")) or 0 - thumb, _ = await fast_download(ytdl_data["thumbnail"], filename=vid_id + ".jpg") + thumb, _ = await fast_download(ytdl_data["thumbnail"], filename=f"{vid_id}.jpg") + likes = numerize(ytdl_data.get("like_count")) or 0 duration = ytdl_data.get("duration") or 0 description = ( @@ -188,17 +194,18 @@ async def _(event): else ytdl_data["description"][:100] ) description = description or "None" - filepath = vid_id + f".{ext}" + filepath = f"{vid_id}.{ext}" if not os.path.exists(filepath): - filepath = filepath + f".{ext}" + filepath = f"{filepath}.{ext}" size = os.path.getsize(filepath) file, _ = await event.client.fast_uploader( filepath, - filename=title + "." + ext, + filename=f"{title}.{ext}", show_progress=True, event=event, to_delete=True, ) + attributes = [ DocumentAttributeAudio( duration=int(duration), @@ -213,10 +220,11 @@ async def _(event): "key": "FFmpegMetadata", "prefer_ffmpeg": True, "geo_bypass": True, - "outtmpl": "%(id)s." + ext, + "outtmpl": f"%(id)s.{ext}", "logtostderr": False, "postprocessors": [{"key": "FFmpegMetadata"}], } + ytdl_data = await dler(event, link, opts, True) title = ytdl_data["title"] if ytdl_data.get("artist"): @@ -226,7 +234,8 @@ async def _(event): elif ytdl_data.get("channel"): artist = ytdl_data["channel"] views = numerize(ytdl_data.get("view_count")) or 0 - thumb, _ = await fast_download(ytdl_data["thumbnail"], filename=vid_id + ".jpg") + thumb, _ = await fast_download(ytdl_data["thumbnail"], filename=f"{vid_id}.jpg") + try: Image.open(thumb).save(thumb, "JPEG") except Exception as er: @@ -240,17 +249,18 @@ async def _(event): likes = numerize(ytdl_data.get("like_count")) or 0 hi, wi = ytdl_data.get("height") or 720, ytdl_data.get("width") or 1280 duration = ytdl_data.get("duration") or 0 - filepath = vid_id + ".mkv" + filepath = f"{vid_id}.mkv" if not os.path.exists(filepath): - filepath = filepath + ".webm" + filepath = f"{filepath}.webm" size = os.path.getsize(filepath) file, _ = await event.client.fast_uploader( filepath, - filename=title + ".mkv", + filename=f"{title}.mkv", show_progress=True, event=event, to_delete=True, ) + attributes = [ DocumentAttributeVideo( duration=int(duration), diff --git a/installer.sh b/installer.sh index c783c74918caaceb94dddc008d100a9f871b037d..cdd1617839c3a5aaf5de7dda403c38055d09141e 100644 --- a/installer.sh +++ b/installer.sh @@ -19,29 +19,71 @@ clone_repo(){ if [ ! $BRANCH ] then export BRANCH="main" fi - echo -e "\n\nCloning Ultroid ${BRANCH}... " + if [ -d $DIR ] + then + echo -e $DIR "Already exists.." + cd $DIR + git pull + currentbranch="$(git rev-parse --abbrev-ref HEAD)" + if [ currentbranch != $BRANCH ] + then + git checkout $BRANCH + fi + if [ -d "addons" ] + then + cd addons + git pull + fi + return + fi + echo -e "Cloning Ultroid ${BRANCH}... " git clone -b $BRANCH $REPO $DIR } install_requirements(){ echo -e "\n\nInstalling requirements... " - pip3 install -q --no-cache-dir -r $DIR/requirements.txt && pip3 install av -q --no-binary av + pip3 install -q --no-cache-dir -r $DIR/requirements.txt pip3 install -q -r $DIR/resources/startup/optional-requirements.txt } railways_dep(){ if [ $RAILWAY_STATIC_URL ] then - echo -e "\n\nInstalling YouTube dependency... " - pip3 install -q --no-cache-dir yt-dlp + echo -e "Installing YouTube dependency... " + pip3 install -q yt-dlp fi } -install_okteto_cli(){ +misc_install(){ if [ $OKTETO_TOKEN ] then - echo -e "\n\nInstalling Okteto-CLI... " + echo -e "Installing Okteto-CLI... " curl https://get.okteto.com -sSfL | sh + elif [ $VCBOT ] + then + if [ -d $DIR/vcbot ] + then + cd $DIR/vcbot + git pull + else + echo -e "Cloning VCBOT.." + git clone https://github.com/TeamUltroid/VcBot $DIR/vcbot + fi + pip3 install pytgcalls>=3.0.0.dev21 && pip3 install av -q --no-binary av + fi +} + +dep_install(){ + echo -e "\n\nInstalling DB Requirement..." + if [ $MONGO_URI ] + then + pip3 install -q pymongo[srv] + elif [ $DATABASE_URL ] + then + pip3 install -q psycopg2-binary + elif [ $REDIS_URI ] + then + pip3 install -q redis hiredis fi } @@ -49,7 +91,8 @@ main(){ (clone_repo) (install_requirements) (railways_dep) - (install_okteto_cli) + (dep_install) + (misc_install) } main diff --git a/plugins/__init__.py b/plugins/__init__.py index dfd1e36a55e8cee075e0f2b30ecfb31f7b3b8a37..66476549322bb360f568caf640a5a229c6b6ad84 100644 --- a/plugins/__init__.py +++ b/plugins/__init__.py @@ -11,20 +11,20 @@ import time from random import choice import requests +from telethon import Button, events +from telethon.tl import functions, types # pylint:ignore + from pyUltroid 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.dB import DEVLIST, ULTROID_IMAGES -from pyUltroid.functions.helper import * -from pyUltroid.functions.info import * -from pyUltroid.functions.misc import * -from pyUltroid.functions.tools import * +from pyUltroid.fns.helper import * +from pyUltroid.fns.info import * +from pyUltroid.fns.misc import * +from pyUltroid.fns.tools import * from pyUltroid.version import __version__, ultroid_version -from telethon import Button, events -from telethon.tl import functions, types - -from strings import get_string +from strings import get_help, get_string Redis = udB.get_key con = TgConverter @@ -34,19 +34,23 @@ OWNER_ID = ultroid_bot.uid LOG_CHANNEL = udB.get_key("LOG_CHANNEL") -INLINE_PIC = udB.get_key("INLINE_PIC") -if INLINE_PIC is None: - INLINE_PIC = choice(ULTROID_IMAGES) -elif INLINE_PIC == False: - INLINE_PIC = None +def inline_pic(): + INLINE_PIC = udB.get_key("INLINE_PIC") + if INLINE_PIC is None: + INLINE_PIC = choice(ULTROID_IMAGES) + elif INLINE_PIC == False: + INLINE_PIC = None + return INLINE_PIC + Telegraph = telegraph_client() List = [] Dict = {} +InlinePlugin = {} N = 0 - +cmd = ultroid_cmd STUFF = {} # Chats, which needs to be ignore for some cases diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py index 7048e3ec97f0c3138a97824cdde7dda8284f718a..255650e86f54515eeef7692db14b5c592e1573c4 100644 --- a/plugins/_chatactions.py +++ b/plugins/_chatactions.py @@ -7,17 +7,18 @@ import asyncio +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 pyUltroid.dB import stickers 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.nsfw_db import is_profan -from pyUltroid.functions.helper import inline_mention -from pyUltroid.functions.tools import async_searcher, 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 pyUltroid.fns.helper import inline_mention +from pyUltroid.fns.tools import async_searcher, create_tl_btn, get_chatbot_reply try: from ProfanityDetector import detector @@ -91,11 +92,9 @@ async def DummyHandler(ult): ) await ult.client.send_message( chat.id, - "**@UltroidBans:** Banned user detected and banned!\n`{}`.\nBan reason: {}".format( - str(is_banned), - is_banned["reason"], - ), + f'**@UltroidBans:** Banned user detected and banned!\n`{str(is_banned)}`.\nBan reason: {is_banned["reason"]}', ) + except BaseException: pass reason = is_gbanned(user.id) diff --git a/plugins/_help.py b/plugins/_help.py index 06fcc3bbf08d3f9004f78d4c984bcb41cd23a1de..9d7d0aaa01ce1bb653fd8363d2eae4bc9dd82d0f 100644 --- a/plugins/_help.py +++ b/plugins/_help.py @@ -5,12 +5,6 @@ # PLease read the GNU Affero General Public License in # . -try: - from fuzzywuzzy.process import extractOne -except ImportError: - extractOne = None -from pyUltroid.dB._core import HELP, LIST -from pyUltroid.functions.tools import cmd_regex_replace from telethon.errors.rpcerrorlist import ( BotInlineDisabledError, BotMethodInvalidError, @@ -18,7 +12,10 @@ from telethon.errors.rpcerrorlist import ( ) from telethon.tl.custom import Button -from . import HNDLR, INLINE_PIC, LOGS, OWNER_NAME, asst, get_string, udB, ultroid_cmd +from pyUltroid.dB._core import HELP, LIST +from pyUltroid.fns.tools import cmd_regex_replace + +from . import HNDLR, LOGS, OWNER_NAME, asst, get_string, inline_pic, udB, ultroid_cmd _main_help_menu = [ [ @@ -86,9 +83,13 @@ async def _help(ult): if not file: # the enter command/plugin name is not found text = f"`{plug}` is not a valid plugin!" - if extractOne: - best_match = extractOne(plug, compare_strings) - text += "\nDid you mean `{}`?".format(best_match[0]) + best_match = None + for _ in compare_strings: + if plug in _ and not _.startswith("_"): + best_match = _ + break + if best_match: + text += f"\nDid you mean `{best_match}`?" return await ult.eor(text) output = f"**Command** `{plug}` **found in plugin** - `{file}`\n" if file in HELP["Official"]: @@ -122,7 +123,7 @@ async def _help(ult): len(HELP["Addons"] if "Addons" in HELP else []), cmd, ), - file=INLINE_PIC, + file=inline_pic(), buttons=_main_help_menu, ) except BotResponseTimeoutError: diff --git a/plugins/_inline.py b/plugins/_inline.py index e4e0808d8796b4fd1e565a844d223499caf82190..0a75219ddf47e96ef2524d68522cfb388375df10 100644 --- a/plugins/_inline.py +++ b/plugins/_inline.py @@ -11,21 +11,23 @@ from datetime import datetime from os import remove from git import Repo -from pyUltroid._misc._assistant import callback, in_pattern -from pyUltroid.dB._core import HELP, LIST -from pyUltroid.functions.helper import gen_chlog, time_formatter, updater -from pyUltroid.functions.misc import split_list from telethon import Button from telethon.tl.types import InputWebDocument, Message from telethon.utils import resolve_bot_file_id +from pyUltroid._misc._assistant import callback, in_pattern +from pyUltroid.dB._core import HELP, LIST +from pyUltroid.fns.helper import gen_chlog, time_formatter, updater +from pyUltroid.fns.misc import split_list + from . import ( HNDLR, - INLINE_PIC, LOGS, OWNER_NAME, + InlinePlugin, asst, get_string, + inline_pic, split_list, start_time, udB, @@ -34,16 +36,11 @@ from ._help import _main_help_menu # ================================================# -TLINK = INLINE_PIC or "https://telegra.ph/file/74d6259983e0642923fdb.jpg" helps = get_string("inline_1") add_ons = udB.get_key("ADDONS") -if add_ons is not False: - zhelps = get_string("inline_2") -else: - zhelps = get_string("inline_3") - +zhelps = get_string("inline_3") if add_ons is False else get_string("inline_2") PLUGINS = HELP.get("Official", []) ADDONS = HELP.get("Addons", []) upage = 0 @@ -54,7 +51,7 @@ upage = 0 SUP_BUTTONS = [ [ Button.url("• Repo •", url="https://github.com/TeamUltroid/Ultroid"), - Button.url("• Support •", url="t.me/ultroidsupportchat"), + Button.url("• Support •", url="t.me/UltroidSupportChat"), ], ] @@ -63,9 +60,10 @@ SUP_BUTTONS = [ @in_pattern(owner=True, func=lambda x: not x.text) async def inline_alive(o): + TLINK = inline_pic() or "https://graph.org/file/74d6259983e0642923fdb.jpg" MSG = "• **Ultroid Userbot •**" WEB0 = InputWebDocument( - "https://telegra.ph/file/acd4f5d61369f74c5e7a7.jpg", 0, "image/jpg", [] + "https://graph.org/file/acd4f5d61369f74c5e7a7.jpg", 0, "image/jpg", [] ) RES = [ await o.builder.article( @@ -100,9 +98,9 @@ async def inline_handler(event): len(HELP.get("Addons", [])), len(z), ) - if INLINE_PIC: + if inline_pic(): result = await event.builder.photo( - file=INLINE_PIC, + file=inline_pic(), link_preview=False, text=text, buttons=_main_help_menu, @@ -117,7 +115,7 @@ async def inline_handler(event): @in_pattern("pasta", owner=True) async def _(event): ok = event.text.split("-")[1] - link = "https://spaceb.in/" + ok + link = f"https://spaceb.in/{ok}" raw = f"https://spaceb.in/api/v1/documents/{ok}/raw" result = await event.builder.article( title="Paste", @@ -144,7 +142,7 @@ async def setting(event): len(HELP.get("Addons", [])), len(z), ), - file=INLINE_PIC, + file=inline_pic(), link_preview=False, buttons=[ [ @@ -172,11 +170,9 @@ async def help_func(ult): return await ult.answer(get_string("help_13").format(HNDLR), alert=True) if "|" in count: _, count = count.split("|") - count = 0 if not count else int(count) + count = int(count) if count else 0 text = _strings.get(key, "").format(OWNER_NAME, len(HELP.get(key))) - await ult.edit( - text, file=INLINE_PIC, buttons=page_num(count, key), link_preview=False - ) + await ult.edit(text, buttons=page_num(count, key), link_preview=False) @callback(re.compile("uplugin_(.*)"), owner=True) @@ -201,7 +197,7 @@ async def uptd_plugin(event): help_ = f"{file} has no Detailed Help!" help_ += "\n© @TeamUltroid" buttons = [] - if INLINE_PIC: + if inline_pic(): data = f"sndplug_{key}_{file}" if index is not None: data += f"|{index}" @@ -233,7 +229,7 @@ async def uptd_plugin(event): async def _(event): if not await updater(): return await event.answer(get_string("inline_9"), cache_time=0, alert=True) - if not INLINE_PIC: + if not inline_pic(): return await event.answer(f"Do '{HNDLR}update' to update..") repo = Repo.init() changelog, tl_chnglog = await gen_chlog( @@ -280,36 +276,18 @@ async def _(event): await event.answer(pin, cache_time=0, alert=True) -InPlugin = { - "Pʟᴀʏ Sᴛᴏʀᴇ Aᴘᴘs": "app telegram", - "Mᴏᴅᴅᴇᴅ Aᴘᴘs": "mods minecraft", - "Sᴇᴀʀᴄʜ Oɴ Gᴏᴏɢʟᴇ": "go TeamUltroid", - "Search on XDA": "xda telegram", - "WʜɪSᴘᴇʀ": "wspr @username Hello🎉", - "YᴏᴜTᴜʙᴇ Dᴏᴡɴʟᴏᴀᴅᴇʀ": "yt Ed Sheeran Perfect", - "Piston Eval": "run javascript console.log('Hello Ultroid')", - "OʀᴀɴɢᴇFᴏx🦊": "ofox beryllium", - "Tᴡɪᴛᴛᴇʀ Usᴇʀ": "twitter theultroid", - "Kᴏᴏ Sᴇᴀʀᴄʜ": "koo @__kumar__amit", - "Fᴅʀᴏɪᴅ Sᴇᴀʀᴄʜ": "fdroid telegram", - "Sᴀᴀᴠɴ sᴇᴀʀᴄʜ": "saavn", - "Tʟ Sᴇᴀʀᴄʜ": "tl", - "GɪᴛHᴜʙ ғᴇᴇᴅs": "gh", - "OᴍɢUʙᴜɴᴛᴜ": "omgu cutefish", -} -_InButtons = [Button.switch_inline(_, query=InPlugin[_]) for _ in list(InPlugin.keys())] -InButtons = split_list(_InButtons, 2) - - @callback(data="inlone", owner=True) async def _(e): + _InButtons = [ + Button.switch_inline(_, query=InlinePlugin[_], same_peer=True) + for _ in list(InlinePlugin.keys()) + ] + InButtons = split_list(_InButtons, 2) + button = InButtons.copy() button.append( [ - Button.inline( - "« Bᴀᴄᴋ", - data="open", - ), + Button.inline("« Bᴀᴄᴋ", data="open"), ], ) await e.edit(buttons=button, link_preview=False) @@ -422,7 +400,7 @@ async def ibuild(e): _pic, title="Ultroid Op", text=txt, - description="@TheUltroid", + description="@TeamUltroid", buttons=btn, link_preview=False, ) diff --git a/plugins/_ultroid.py b/plugins/_ultroid.py index f1f32a24eec56cd5a3c420c59e616ce74eb63c46..d2cd7bc6c2cda3ee88f784935967d2d25438a9b9 100644 --- a/plugins/_ultroid.py +++ b/plugins/_ultroid.py @@ -25,7 +25,7 @@ RP_BUTTONS = [ 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/ultroidsupportchat")], + [Button.url("Support Group", "t.me/UltroidSupportChat")], ] ULTSTRING = """🎇 **Thanks for Deploying Ultroid Userbot!** @@ -49,7 +49,7 @@ async def repify(e): ): pass except Exception as er: - LOGS.info("Error while repo command : " + str(er)) + LOGS.info(f"Error while repo command : {str(er)}") await e.eor(REPOMSG) @@ -59,7 +59,7 @@ async def useUltroid(rs): msg = await asst.send_message( LOG_CHANNEL, ULTSTRING, - file="https://telegra.ph/file/54a917cc9dbb94733ea5f.jpg", + file="https://graph.org/file/54a917cc9dbb94733ea5f.jpg", buttons=button, ) if not (rs.chat_id == LOG_CHANNEL and rs.client._bot): diff --git a/plugins/_userlogs.py b/plugins/_userlogs.py index 7ade4c38323d5458518800ad21ffe3c1a68b3752..d2fcdde1ce7d52bb03129843e41c19e7cb0182fb 100644 --- a/plugins/_userlogs.py +++ b/plugins/_userlogs.py @@ -8,7 +8,6 @@ import os import re -from pyUltroid.dB.botchat_db import tag_add, who_tag from telethon.errors.rpcerrorlist import ( ChannelPrivateError, ChatWriteForbiddenError, @@ -21,6 +20,8 @@ from telethon.errors.rpcerrorlist import ( from telethon.tl.types import MessageEntityMention, MessageEntityMentionName, User from telethon.utils import get_display_name +from pyUltroid.dB.botchat_db import tag_add, who_tag + from . import ( LOG_CHANNEL, LOGS, @@ -123,8 +124,7 @@ if udB.get_key("TAG_LOG"): return if event.is_private: return - entities = event.get_entities_text() - if entities: + if entities := event.get_entities_text(): is_self = False username = event.client.me.username if username: @@ -235,7 +235,6 @@ ultroid_bot.add_event_handler( when_added_or_joined, events.ChatAction(func=lambda x: x.user_added or x.user_joined), ) - _client = {"bot": asst, "user": ultroid_bot} diff --git a/plugins/_wspr.py b/plugins/_wspr.py index 795df7c43669feae6ec53963f5d7854dfbb88d43..d30da90c12c3170a30311c4fe430aafdfc8d2923 100644 --- a/plugins/_wspr.py +++ b/plugins/_wspr.py @@ -37,10 +37,7 @@ buddhhu = {} async def _(e): if e.reply_to_msg_id: okk = await e.get_reply_message() - if okk.sender.username: - put = f"@{okk.sender.username}" - else: - put = okk.sender_id + put = f"@{okk.sender.username}" if okk.sender.username else okk.sender_id else: put = e.pattern_match.group(1).strip() if put: @@ -66,6 +63,8 @@ async def _(e): if query.isdigit(): query = int(query) logi = await ultroid_bot.get_entity(query) + if not isinstance(logi, types.User): + raise ValueError("Invalid Username.") except IndexError: sur = e.builder.article( title="Give Username", diff --git a/plugins/admintools.py b/plugins/admintools.py index a7dccd773a9915a83e38a3a1f47aeeb5412062c9..0ff267ab6cfdb070eff5aba704e7953b3652416d 100644 --- a/plugins/admintools.py +++ b/plugins/admintools.py @@ -4,48 +4,13 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # . -""" -✘ Commands Available - -• `{i}promote ` -• `{i}demote` - Promote/Demote the user in the chat. +from . import get_help -• `{i}ban ` -• `{i}unban` - Ban/Unban the user from the chat. - -• `{i}kick ` - Kick the user from the chat. - -• `{i}pin ` - Pin the message in the chat -• `{i}tpin