diff --git a/.env.sample b/.env.sample
index 4fc517fc99..fb49d134fb 100644
--- a/.env.sample
+++ b/.env.sample
@@ -4,4 +4,4 @@ API_ID=
API_HASH=
SESSION=
REDIS_URI=
-REDIS_PASSWORD=
+REDIS_PASSWORD=
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
index c8e78d7838..d8c0d8797b 100644
--- a/.github/ISSUE_TEMPLATE/config.yml
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -5,4 +5,4 @@ contact_links:
about: Please drop your doubts or queries there for an immediate response.
- name: Documentation
url: https://ultroid.tech/
- about: Basic documentation for setting up.
+ about: Basic documentation for setting up.
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index a8bff80e48..485b60338d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,4 +21,4 @@ node_modules/
glitch_me/
.idea/
.vscode/
-temp/
+temp/
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
index 6ab1e3836d..2b8f39df61 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -14,6 +14,4 @@ WORKDIR /root/TeamUltroid/
RUN pip3 install --no-cache-dir -r requirements.txt
-RUN npm install -g npm@7.16.0 -g
-RUN npm install
-RUN npm run build
+CMD ["bash", "resources/startup/startup.sh"]
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 40d1685b21..0000000000
--- a/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-test:
- @pre-commit run --all-files
-
-install:
- @pip3 install --upgrade pip setuptools wheel
- @pip3 install --upgrade -r requirements.txt
-
-
-dev-install:
- @pip3 install --upgrade pip setuptools wheel
- @pip3 install --upgrade -r requirements-dev.txt
- @sleep 5
- @pre-commit
- @pre-commit install
-
-update:
- @git pull
- @pip3 install --upgrade pip setuptools wheel
- @pip3 install --upgrade -r requirements.txt
-
-ci:
- @pip3 install --upgrade pip setuptools wheel
- @pip3 install --upgrade -r requirements-dev.txt
- @pre-commit
diff --git a/README.md b/README.md
index 0227e48e4b..9fc85911d9 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@
[![Open Source Love svg2](https://badges.frapsoft.com/os/v2/open-source.svg?v=103)](https://github.com/TeamUltroid/Ultroid)
[![Contributors](https://img.shields.io/github/contributors/TeamUltroid/Ultroid?style=flat-square&color=green)](https://github.com/TeamUltroid/Ultroid/graphs/contributors)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)
-[![License](https://img.shields.io/badge/License-AGPL-blue)](https://github.com/TeamUltroid/Ultroid/blob/main/LICENSE)
+[![License](https://img.shields.io/badge/License-AGPL-blue)](https://github.com/TeamUltroid/Ultroid/blob/main/LICENSE)
[![Sparkline](https://stars.medv.io/Teamultroid/Ultroid.svg)](https://stars.medv.io/TeamUltroid/Ultroid)
----
@@ -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?template=https%3A%2F%2Fgithub.com%2F1Danish-00%2FUltroid-1)
+[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://dashboard.heroku.com/new?template=https%3A%2F%2Fgithub.com%2F1Danish-00%2FSideLoad)
## Deploy Locally
- [Traditional Method](#local-deploy---traditional-method)
@@ -45,8 +45,8 @@ Get the [Necessary Variables](#Necessary-Variables) and then click the button be
### Local Deploy - Easy Method
- Linux - `bash -c "$(curl -fsSL https://git.io/JY9UM)"`
-- Windows - `cd desktop ; wget https://del.dog/raw/ultroid-termux -o locals.py ; python locals.py`
-- Termux - `sh -c "$(curl -fsSL https://del.dog/raw/ultroid-termux-deploy)"`
+- Windows - `cd desktop ; wget https://git.io/JY9UM -o locals.py ; python locals.py`
+- Termux - `sh -c "$(curl -fsSL https://git.io/JY9UM)"`
### Local Deploy - Traditional Method
- Get your [Necessary Variables](#Necessary-Variables)
@@ -63,11 +63,11 @@ Get the [Necessary Variables](#Necessary-Variables) and then click the button be
- For Linux users:
`bash sessiongen`
or
- `bash -c "$(curl -fsSL https://del.dog/ultroid)"`
+ `bash -c "$(curl -fsSL https://git.io/JY9JI)"`
- For Termux users:
- `sh -c "$(curl -fsSL https://da.gd/termux-tel)"`
+ `sh -c "$(curl -fsSL https://git.io/JqgsR)"`
- For Windows Users:
- `cd desktop ; wget https://del.dog/ultroid -o ultroid.py ; python ultroid.py`
+ `cd desktop ; wget https://git.io/JY9JI -o ultroid.py ; python ultroid.py`
- Fill your details in a `.env` file, as given in [`.env.sample`](https://github.com/TeamUltroid/Ultroid/blob/main/.env.sample).
(You can either edit and rename the file or make a new file named `.env`.)
- Run the bot:
@@ -86,9 +86,10 @@ Get the [Necessary Variables](#Necessary-Variables) and then click the button be
## Session String
Different ways to get your `SESSION`:
* [![Run on Repl.it](https://replit.com/badge/github/TeamUltroid/Ultroid)](https://replit.com/@TeamUltroid/UltroidStringSession)
-* Linux : `bash -c "$(curl -fsSL https://del.dog/ultroid)"`
+* Linux : `bash -c "$(curl -fsSL https://git.io/JY9JI)"`
* PowerShell : `cd desktop ; wget https://git.io/JY9JI ; python ultroid.py`
* Termux : `sh -c "$(curl -fsSL https://da.gd/termux-tel)"`
+* TelegramBot : [@SessionGeneratorBot](https://t.me/SessionGeneratorBot)
Made with 💕 by [@TeamUltroid](https://t.me/TeamUltroid).
@@ -100,5 +101,6 @@ Ultroid is licensed under [GNU Affero General Public License](https://www.gnu.or
# Credits
* [![TeamUltroid-Devs](https://img.shields.io/static/v1?label=Teamultroid&message=devs&color=critical)](https://t.me/UltroidDevs)
* [Lonami](https://github.com/LonamiWebs/) for [Telethon.](https://github.com/LonamiWebs/Telethon)
-* [AndrewLaneX](https://github.com/AndrewLaneX) for [tgcalls-base.](http://github.com/tgcallsjs/tgcalls)
+* [Dan](https://github.com/delivrance) for [Pyrogram.](https://github.com/pyrogram/pyrogram)
+* [Pytgcalls](https://github.com/pytgcalls) for [PyTgCalls.](https://github.com/pytgcalls/pytgcalls)
diff --git a/assistant/othervars.py b/assistant/callbackstuffs.py
similarity index 93%
rename from assistant/othervars.py
rename to assistant/callbackstuffs.py
index 568c2f8d6e..de70389847 100644
--- a/assistant/othervars.py
+++ b/assistant/callbackstuffs.py
@@ -6,11 +6,11 @@
# .
import re
+import urllib
from glob import glob
from os import remove
from random import choices
-import requests
from telegraph import Telegraph
from telegraph import upload_file as upl
@@ -27,7 +27,33 @@
@callback(
- re.compile("sndplug_(.*)"),
+ re.compile(
+ "ebk_(.*)",
+ ),
+)
+async def eupload(event):
+ match = event.pattern_match.group(1).decode("utf-8")
+ await event.answer("Uploading..")
+ try:
+ await event.edit(
+ file=f"https://www.gutenberg.org/files/{match}/{match}-pdf.pdf"
+ )
+ except BaseException:
+ book = "Ultroid-Book.epub"
+ urllib.request.urlretrieve(
+ "https://www.gutenberg.org/ebooks/132.epub.images", book
+ )
+ fn, media, _ = await asst._file_to_media(
+ book, thumb="resources/extras/ultroid.jpg"
+ )
+ await event.edit(file=media)
+ remove(book)
+
+
+@callback(
+ re.compile(
+ "sndplug_(.*)",
+ ),
)
async def send(eve):
name = (eve.data_match.group(1)).decode("UTF-8")
@@ -133,9 +159,9 @@ async def changes(okk):
changelog_str = changelog + f"\n\nClick the below button to update!"
if len(changelog_str) > 1024:
await okk.edit(get_string("upd_4"))
- file = open(f"ultroid_updates.txt", "w+")
- file.write(tl_chnglog)
- file.close()
+ await asyncio.sleep(2)
+ with open(f"ultroid_updates.txt", "w+") as file:
+ file.write(tl_chnglog)
await okk.edit(
get_string("upd_5"),
file="ultroid_updates.txt",
@@ -159,15 +185,14 @@ async def changes(okk):
@owner
async def _(e):
ok = (e.data_match.group(1)).decode("UTF-8")
- hmm = open(ok)
- hmmm = hmm.read()
- hmm.close()
- key = (
- requests.post("https://nekobin.com/api/documents", json={"content": hmmm})
- .json()
- .get("result")
- .get("key")
- )
+ with open(ok, "r") as hmm:
+ _, key = get_paste(hmm.read())
+ if _ == "dog":
+ link = "https://del.dog/" + key
+ raw = "https://del.dog/raw/" + key
+ else:
+ link = "https://nekobin.com/" + key
+ raw = "https://nekobin.com/raw/" + key
if ok.startswith("plugins"):
buttons = [
Button.inline("« Bᴀᴄᴋ", data="back"),
@@ -179,9 +204,10 @@ async def _(e):
Button.inline("••Cʟᴏꜱᴇ••", data="close"),
]
await e.edit(
- f"Pasted to Nekobin\n 👉[Link](https://nekobin.com/{key})\n 👉[Raw Link](https://nekobin.com/raw/{key})",
+ f"Pasted\n 👉[Link]\n 👉[Raw Link]",
buttons=buttons,
link_preview=False,
+ parse_mode="html",
)
@@ -220,7 +246,7 @@ async def _(e):
+ "4. Copy link of that folder.\n"
+ "5. Send all characters which is after id= .",
)
- async with ultroid_bot.asst.conversation(e.sender_id) as conv:
+ async with asst.conversation(e.sender_id) as conv:
reply = conv.wait_event(events.NewMessage(from_users=e.sender_id))
repl = await reply
udB.set("GDRIVE_FOLDER_ID", repl.text)
@@ -236,7 +262,7 @@ async def _(e):
if not e.is_private:
return
await e.edit("Send your CLIENT SECRET")
- async with ultroid_bot.asst.conversation(e.sender_id) as conv:
+ async with asst.conversation(e.sender_id) as conv:
reply = conv.wait_event(events.NewMessage(from_users=e.sender_id))
repl = await reply
udB.set("GDRIVE_CLIENT_SECRET", repl.text)
@@ -252,7 +278,7 @@ async def _(e):
if not e.is_private:
return
await e.edit("Send your CLIENT ID ending with .com")
- async with ultroid_bot.asst.conversation(e.sender_id) as conv:
+ async with asst.conversation(e.sender_id) as conv:
reply = conv.wait_event(events.NewMessage(from_users=e.sender_id))
repl = await reply
if not repl.text.endswith(".com"):
@@ -720,11 +746,47 @@ async def alvcs(event):
Button.inline("Sᴇᴛ Wᴀʀɴs", data="swarn"),
Button.inline("Dᴇʟᴇᴛᴇ Pᴍ Mᴇᴅɪᴀ", data="delpmmed"),
],
+ [Button.inline("PMPermit Type", data="pmtype")],
[Button.inline("« Bᴀᴄᴋ", data="ppmset")],
],
)
+@callback("pmtype")
+@owner
+async def pmtyp(e):
+ await event.edit(
+ "Select the type of PMPermit needed.",
+ buttons=[
+ [Button.inline("Inline", data="inpm_in")],
+ [Button.inline("Normal", data="inpm_no")],
+ [Button.inline("« Bᴀᴄᴋ", data="pmcstm")],
+ ],
+ )
+
+
+@callback("inpm_in")
+@owner
+async def inl_on(event):
+ var = "INLINE_PM"
+ await setit(event, var, "True")
+ await event.edit(
+ f"Done!! PMPermit type has been set to inline!",
+ buttons=[[Button.inline("« Bᴀᴄᴋ", data="pmtype")]],
+ )
+
+
+@callback("inpm_no")
+@owner
+async def inl_on(event):
+ var = "INLINE_PM"
+ await setit(event, var, "False")
+ await event.edit(
+ f"Done!! PMPermit type has been set to normal!",
+ buttons=[[Button.inline("« Bᴀᴄᴋ", data="pmtype")]],
+ )
+
+
@callback("pmtxt")
@owner
async def name(event):
@@ -988,7 +1050,7 @@ async def name(event):
name = "Bot Welcome Message:"
async with event.client.conversation(pru) as conv:
await conv.send_message(
- "**BOT WELCOME MSG**\nEnter the msg which u want to show when someone start your assistant Bot.\n\nUse /cancel to terminate the operation.",
+ "**BOT WELCOME MSG**\nEnter the msg which u want to show when someone start your assistant Bot.\nYou Can use `{me}` , `{mention}` Parameters Too\nUse /cancel to terminate the operation.",
)
response = conv.wait_event(events.NewMessage(chats=pru))
response = await response
diff --git a/assistant/inlinestuff.py b/assistant/inlinestuff.py
index 6f4d6bfa7d..7088780be7 100644
--- a/assistant/inlinestuff.py
+++ b/assistant/inlinestuff.py
@@ -6,8 +6,6 @@
# .
import base64
-import os
-import urllib
from random import choice
from re import compile as re_compile
from re import findall
@@ -219,52 +217,6 @@ async def gsearch(q_event):
await q_event.answer(searcher, switch_pm="Google Search.", switch_pm_param="start")
-@in_pattern("rex")
-@in_owner
-async def rextester(event):
- builder = event.builder
- try:
- omk = event.text.split(" ", maxsplit=1)[1]
- if omk is not None:
- if "|" in omk:
- lang, codee = omk.split("|")
- else:
- lang = "python3"
- codee = omk
- if lang == "php":
- code = f""
- else:
- code = codee
- output = await rexec_aio(lang, code)
- stats = output.stats
- if output.errors is not None:
- outputt = output.errors
- resultm = builder.article(
- title="Code",
- description=f"Language-`{lang}` & Code-`{code}`",
- text=f"Language:\n`{lang}`\n\nCode:\n`{code}`\n\nErrors:\n`{outputt}`\n\nStats:\n`{stats}`",
- )
- else: # By @ProgrammingError
- outputt = output.results
- resultm = builder.article(
- title="Code", # By @ProgrammingError
- description=f"Language-`{lang}` & Code-`{code}`",
- text=f"Language:\n`{lang}`\n\nCode:\n`{code}`\n\nResult:\n`{outputt}`\n\nStats:\n`{stats}`",
- )
- await event.answer(
- [resultm], switch_pm="RexTester.", switch_pm_param="start"
- )
- except UnknownLanguage:
- resultm = builder.article(
- title="Error", # By @ProgrammingError
- description="Invalid language choosen",
- text=f"The list of valid languages are\n\n{rex_langs}\n\n\nFormat to use Rextester is `@Yourassistantusername rex langcode|code`",
- )
- await event.answer(
- [resultm], switch_pm="RexTester. Invalid Language!", switch_pm_param="start"
- )
-
-
@in_pattern("yahoo")
@in_owner
async def yahoosearch(q_event):
@@ -463,33 +415,18 @@ async def clip(e):
if "/cache/epub" in out[rs]["src"]:
link = out[rs]["src"]
num = link.split("/")[3]
+ link = "https://gutenberg.org" + link.replace("small", "medium")
+ file = wb(link, 0, "image/jpeg", [])
hm.append(
- buil.document(
+ buil.article(
title=titles[rs],
+ type="photo",
description="GutenBerg Search",
- file="https://gutenberg.org" + link.replace("small", "medium"),
+ thumb=file,
+ content=file,
+ include_media=True,
text=f"**• Ebook Search**\n\n->> `{titles[rs]}`",
buttons=Button.inline("Get as Doc", data=f"ebk_{num}"),
)
)
await e.answer(hm, switch_pm="Ebooks Search", switch_pm_param="start")
-
-
-@callback(re_compile("ebk_(.*)"))
-async def eupload(event):
- match = event.pattern_match.group(1).decode("utf-8")
- await event.answer("Uploading..")
- try:
- await event.edit(
- file=f"https://www.gutenberg.org/files/{match}/{match}-pdf.pdf"
- )
- except BaseException:
- book = "Ultroid-Book.epub"
- urllib.request.urlretrieve(
- "https://www.gutenberg.org/ebooks/132.epub.images", book
- )
- fn, media, _ = await asst._file_to_media(
- book, thumb="resources/extras/ultroid.jpg"
- )
- await event.edit(file=media)
- os.remove(book)
diff --git a/assistant/manager/__init__.py b/assistant/manager/__init__.py
new file mode 100644
index 0000000000..fc68000831
--- /dev/null
+++ b/assistant/manager/__init__.py
@@ -0,0 +1,11 @@
+# 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 plugins import *
+
+asst = asst
diff --git a/assistant/pmbot/__init__.py b/assistant/pmbot/__init__.py
index 1030b843e7..89bc4e3334 100644
--- a/assistant/pmbot/__init__.py
+++ b/assistant/pmbot/__init__.py
@@ -1,5 +1,6 @@
from pyUltroid.functions.asst_fns import *
from pyUltroid.functions.botchat_db import *
+
from .. import *
OWNER_NAME = ultroid_bot.me.first_name
diff --git a/assistant/pmbot/outgoing.py b/assistant/pmbot/outgoing.py
index 2a4e9a9b86..0a28b7b425 100644
--- a/assistant/pmbot/outgoing.py
+++ b/assistant/pmbot/outgoing.py
@@ -29,7 +29,7 @@ async def on_out_mssg(event):
except BaseException:
return
elif event.text.startswith("/"):
- return
+ return
if event.media:
if event.text:
await asst.send_file(int(to_user), event.media, caption=event.text)
diff --git a/assistant/start.py b/assistant/start.py
index b2da53260a..c02b6ac1eb 100644
--- a/assistant/start.py
+++ b/assistant/start.py
@@ -7,6 +7,7 @@
from datetime import datetime
+from pytz import timezone as tz
from pyUltroid.functions.asst_fns import *
from pyUltroid.misc import owner_and_sudos
from telethon import events
@@ -17,12 +18,12 @@
from . import *
Owner_info_msg = f"""
-**Owner** - {OWNER_NAME}
-**OwnerID** - `{OWNER_ID}`
+Owner - {OWNER_NAME}
+OwnerID - {OWNER_ID}
-**Message Forwards** - {udB.get("PMBOT")}
+Message Forwards - {udB.get("PMBOT")}
-__Ultroid {ultroid_version}, powered by @TeamUltroid__
+Ultroid [v{ultroid_version}], powered by @TeamUltroid
"""
_settings = [
@@ -48,6 +49,7 @@
Button.inline("Sᴛᴀᴛs ✨", data="stat"),
Button.inline("Bʀᴏᴀᴅᴄᴀsᴛ 📻", data="bcast"),
],
+ [Button.inline("TɪᴍᴇZᴏɴᴇ 🌎", data="tz")],
]
@@ -56,6 +58,8 @@ async def own(event):
await event.edit(
Owner_info_msg,
buttons=[Button.inline("Close", data=f"closeit")],
+ link_preview=False,
+ parse_mode="html",
)
@@ -67,15 +71,7 @@ async def closet(lol):
@asst_cmd("start ?(.*)")
async def ultroid(event):
if event.is_group:
- if str(event.sender_id) in owner_and_sudos():
- return await event.reply(
- "`I dont work in groups`",
- buttons=[
- Button.url(
- "⚙️Sᴛᴀʀᴛ⚙️", url=f"https://t.me/{asst.me.username}?start=set"
- )
- ],
- )
+ return
else:
if (
not is_added(event.sender_id)
@@ -178,3 +174,37 @@ async def setting(event):
"Choose from the below options -",
buttons=_settings,
)
+
+
+@callback("tz")
+@owner
+async def timezone_(event):
+ await event.delete()
+ pru = event.sender_id
+ var = "TIMEZONE"
+ name = "Timezone"
+ async with event.client.conversation(pru) as conv:
+ await conv.send_message(
+ "Send Your TimeZone From This List [Check From Here](http://www.timezoneconverter.com/cgi-bin/findzone.tzc)"
+ )
+ response = conv.wait_event(events.NewMessage(chats=pru))
+ response = await response
+ themssg = response.message.message
+ if themssg == "/cancel":
+ return await conv.send_message(
+ "Cancelled!!",
+ buttons=get_back_button("mainmenu"),
+ )
+ else:
+ try:
+ tz(themssg)
+ await setit(event, var, themssg)
+ await conv.send_message(
+ f"{name} changed to {themssg}\n",
+ buttons=get_back_button("mainmenu"),
+ )
+ except BaseException:
+ await conv.send_message(
+ "Wrong TimeZone, Try again",
+ buttons=get_back_button("mainmenu"),
+ )
diff --git a/assistant/ytdl.py b/assistant/ytdl.py
index c54625d3d4..2f90b70512 100644
--- a/assistant/ytdl.py
+++ b/assistant/ytdl.py
@@ -24,7 +24,6 @@
@in_pattern("yt")
-@in_owner
async def _(event):
try:
string = event.text.split(" ", maxsplit=1)[1]
@@ -50,14 +49,17 @@ async def _(event):
link = _yt_base_url + ids
title = v["title"]
duration = v["duration"]
- thumb = f"https://img.youtube.com/vi/{ids}/hqdefault.jpg"
+ 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}"
+ file = wb(thumb, 0, "image/jpeg", [])
results.append(
- await event.builder.document(
- file=thumb,
+ await event.builder.article(
+ type="photo",
title=title,
description=desc,
+ thumb=file,
+ content=file,
text=text,
include_media=True,
buttons=[
@@ -80,7 +82,7 @@ async def _(event):
],
),
)
- await event.answer(results)
+ await event.answer(results[:50])
@callback(
@@ -99,7 +101,7 @@ async def _(e):
)
_text = "`Select Your Format.`"
if not _buttons:
- _text = "`Error domwloading from YouTube.\nTry Restarting your bot.`"
+ _text = "`Error downloading from YouTube.\nTry Restarting your bot.`"
await e.edit(_text, buttons=_buttons)
@@ -191,12 +193,12 @@ async def _(event):
text = f"**Title:** `{title}`\n"
text += f"**Duration:** `{time_formatter(int(duration)*1000)}`\n"
text += f"**Views:** `{views}`\n"
- text += f"**Artist:** `{artist}`"
+ text += f"**Artist:** `{artist}`\n\n"
await event.edit(
text,
file=file,
+ buttons=Button.switch_inline("Search More", query="yt ", same_peer=True),
attributes=attributes,
thumb=thumb,
- buttons=Button.switch_inline("Search More", query="yt ", same_peer=True),
)
os.system(f'rm "{title}"*')
diff --git a/heroku.yml b/heroku.yml
index ce83d37360..06f0fb7467 100644
--- a/heroku.yml
+++ b/heroku.yml
@@ -1,5 +1,3 @@
build:
docker:
ultroid: Dockerfile
-run:
- ultroid: bash resources/startup/startup.sh
diff --git a/package.json b/package.json
deleted file mode 100644
index e9578539ef..0000000000
--- a/package.json
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- "name": "ultroid-vcbot",
- "version": "1.0.0",
- "main": "index.js",
- "scripts": {
- "start": "node build/index.js",
- "build": "tsc",
- "test": "tsc --noEmit",
- "dev": "nodemon src/index.ts"
- },
- "author": "TeamUltroid ",
- "license": "AGPL-3.0",
- "dependencies": {
- "@mapbox/node-pre-gyp": "^1.0.0",
- "@youtwitface/escape-html": "^1.0.0",
- "dotenv": "^8.2.0",
- "envalid": "^7.0.0",
- "redis": "^3.0.2",
- "telegraf": "^4.4.0",
- "tgcalls": "^0.1.2",
- "ws": "^7.4.6"
- },
- "devDependencies": {
- "@types/node": "^14.14.25",
- "@types/redis": "^2.8.28",
- "@types/ws": "^7.4.0",
- "nodemon": "^2.0.7",
- "ts-node": "^9.1.1",
- "typegram": "^3.4.0",
- "typescript": "^4.1.3"
- }
-}
diff --git a/plugins/_ChatActions.py b/plugins/_ChatActions.py
new file mode 100644
index 0000000000..c7ae840fc0
--- /dev/null
+++ b/plugins/_ChatActions.py
@@ -0,0 +1,142 @@
+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 telethon.errors.rpcerrorlist import UserNotParticipantError
+from telethon.tl.functions.channels import GetParticipantRequest
+from telethon.utils import get_display_name
+
+from . import *
+
+
+@ultroid_bot.on(events.ChatAction())
+async def ChatActionsHandler(ult): # sourcery no-metrics
+ # clean chat actions
+ if is_clean_added(ult.chat_id):
+ try:
+ await ult.delete()
+ except BaseException:
+ pass
+
+ # thank members
+ if must_thank(ult.chat_id):
+ chat_count = len(await ult.client.get_participants(await ult.get_chat()))
+ if chat_count % 100 == 0:
+ stik_id = chat_count / 100 - 1
+ sticker = stickers[stik_id]
+ await ultroid.send_message(ult.chat_id, file=sticker)
+ # force subscribe
+ if (
+ udB.get("FORCESUB")
+ and ((ult.user_joined or ult.user_added))
+ and get_forcesetting(ult.chat_id)
+ ):
+ user = await ult.get_user()
+ if not user.bot:
+ joinchat = get_forcesetting(ult.chat_id)
+ try:
+ await ultroid_bot(GetParticipantRequest(int(joinchat), user.id))
+ except UserNotParticipantError:
+ await ultroid_bot.edit_permissions(
+ ult.chat_id, user.id, send_messages=False
+ )
+ res = await ultroid_bot.inline_query(
+ asst.me.username, f"fsub {user.id}_{joinchat}"
+ )
+ await res[0].click(ult.chat_id, reply_to=ult.action_message.id)
+
+ # gban checks
+ if ult.user_joined and ult.added_by:
+ user = await ult.get_user()
+ chat = await ult.get_chat()
+ if is_gbanned(str(user.id)) and chat.admin_rights:
+ try:
+ await ultroid_bot.edit_permissions(
+ chat.id,
+ user.id,
+ view_messages=False,
+ )
+ reason = get_gban_reason(user.id)
+ gban_watch = f"#GBanned_User Joined.\n\n**User** - [{user.first_name}](tg://user?id={user.id})\n"
+ if reason is not None:
+ gban_watch += f"**Reason**: {reason}\n\n"
+ gban_watch += f"`User Banned.`"
+ await ult.reply(gban_watch)
+ except BaseException:
+ pass
+
+ # greetings
+ if 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})"
+ name = user.first_name
+ last = user.last_name
+ fullname = f"{name} {last}" if last else name
+ uu = user.username
+ username = f"@{uu}" if uu else mention
+ msgg = wel["welcome"]
+ med = wel["media"]
+ userid = user.id
+ if msgg and not is_gbanned(str(user.id)):
+ send = await ult.reply(
+ msgg.format(
+ mention=mention,
+ group=title,
+ count=count,
+ name=name,
+ fullname=fullname,
+ username=username,
+ userid=userid,
+ ),
+ file=med,
+ )
+ await asyncio.sleep(150)
+ await send.delete()
+ elif not is_gbanned(str(user.id)):
+ await ult.reply(file=med)
+ if (ult.user_left or ult.user_kicked) and get_goodbye(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})"
+ name = user.first_name
+ last = user.last_name
+ fullname = f"{name} {last}" if last else name
+ uu = user.username
+ username = f"@{uu}" if uu else mention
+ msgg = wel["goodbye"]
+ med = wel["media"]
+ userid = user.id
+ if msgg:
+ send = await ult.reply(
+ msgg.format(
+ mention=mention,
+ group=title,
+ count=count,
+ name=name,
+ fullname=fullname,
+ username=username,
+ userid=userid,
+ ),
+ file=med,
+ )
+ await asyncio.sleep(150)
+ await send.delete()
+ else:
+ await ult.reply(file=med)
+
+
+@ultroid_bot.on(events.NewMessage(incoming=True))
+async def chatBot_replies(event):
+ if event.sender_id and chatbot_stats(event.sender_id) and event.text:
+ msg = get_chatbot_reply(event, event.text)
+ if msg:
+ await event.reply(msg)
diff --git a/plugins/__init__.py b/plugins/__init__.py
index e881b50af6..0a68f2cc98 100644
--- a/plugins/__init__.py
+++ b/plugins/__init__.py
@@ -5,17 +5,14 @@
# PLease read the GNU Affero General Public License in
# .
+import asyncio
import time
+from pyUltroid import *
from pyUltroid.dB import *
-from pyUltroid.dB.core import *
from pyUltroid.functions.all import *
-from pyUltroid.functions.asstcmd_db import *
-from pyUltroid.functions.broadcast_db import *
-from pyUltroid.functions.gban_mute_db import *
-from pyUltroid.functions.nsfw_db import *
from pyUltroid.functions.sudos import *
-from pyUltroid.utils import *
+from pyUltroid.version import ultroid_version
from telethon import Button
from telethon.tl import functions, types
@@ -30,7 +27,7 @@
start_time = time.time()
-ultroid_version = "v0.0.8.1"
+
OWNER_NAME = ultroid_bot.me.first_name
OWNER_ID = ultroid_bot.me.id
@@ -38,312 +35,13 @@
Dict = {}
N = 0
-
-def grt(seconds: int) -> str:
- count = 0
- up_time = ""
- time_list = []
- time_suffix_list = ["s", "m", "h", "d"]
-
- while count < 4:
- count += 1
- if count < 3:
- remainder, result = divmod(seconds, 60)
- else:
- remainder, result = divmod(seconds, 24)
- if seconds == 0 and remainder == 0:
- break
- time_list.append(int(result))
- seconds = int(remainder)
-
- for x in range(len(time_list)):
- time_list[x] = str(time_list[x]) + time_suffix_list[x]
- if len(time_list) == 4:
- up_time += time_list.pop() + ", "
-
- time_list.reverse()
- up_time += ":".join(time_list)
-
- return up_time
-
-
-_default = [
- "a",
- "b",
- "c",
- "d",
- "e",
- "f",
- "g",
- "h",
- "i",
- "j",
- "k",
- "l",
- "m",
- "n",
- "o",
- "p",
- "q",
- "r",
- "s",
- "t",
- "u",
- "v",
- "w",
- "x",
- "y",
- "z",
- "A",
- "B",
- "C",
- "D",
- "E",
- "F",
- "G",
- "H",
- "I",
- "J",
- "K",
- "L",
- "M",
- "N",
- "O",
- "P",
- "Q",
- "R",
- "S",
- "T",
- "U",
- "V",
- "W",
- "X",
- "Y",
- "Z",
-]
-
-
-_small_caps = [
- "ᴀ",
- "ʙ",
- "ᴄ",
- "ᴅ",
- "ᴇ",
- "ғ",
- "ɢ",
- "ʜ",
- "ɪ",
- "ᴊ",
- "ᴋ",
- "ʟ",
- "ᴍ",
- "ɴ",
- "ᴏ",
- "ᴘ",
- "ϙ",
- "ʀ",
- "s",
- "ᴛ",
- "ᴜ",
- "ᴠ",
- "ᴡ",
- "x",
- "ʏ",
- "ᴢ",
- "A",
- "B",
- "C",
- "D",
- "E",
- "F",
- "G",
- "H",
- "I",
- "J",
- "K",
- "L",
- "M",
- "N",
- "O",
- "P",
- "Q",
- "R",
- "S",
- "T",
- "U",
- "V",
- "W",
- "X",
- "Y",
- "Z",
+NOSPAM_CHAT = [
+ -1001387666944, # @PyrogramChat
+ -1001109500936, # @TelethonChat
+ -1001050982793, # @Python
+ -1001256902287, # @DurovsChat
]
-_monospace = [
- "𝚊",
- "𝚋",
- "𝚌",
- "𝚍",
- "𝚎",
- "𝚏",
- "𝚐",
- "𝚑",
- "𝚒",
- "𝚓",
- "𝚔",
- "𝚕",
- "𝚖",
- "𝚗",
- "𝚘",
- "𝚙",
- "𝚚",
- "𝚛",
- "𝚜",
- "𝚝",
- "𝚞",
- "𝚟",
- "𝚠",
- "𝚡",
- "𝚢",
- "𝚣",
- "𝙰",
- "𝙱",
- "𝙲",
- "𝙳",
- "𝙴",
- "𝙵",
- "𝙶",
- "𝙷",
- "𝙸",
- "𝙹",
- "𝙺",
- "𝙻",
- "𝙼",
- "𝙽",
- "𝙾",
- "𝙿",
- "𝚀",
- "𝚁",
- "𝚂",
- "𝚃",
- "𝚄",
- "𝚅",
- "𝚆",
- "𝚇",
- "𝚈",
- "𝚉",
-]
-
-_double_stroke = [
- "𝕒",
- "𝕓",
- "𝕔",
- "𝕕",
- "𝕖",
- "𝕗",
- "𝕘",
- "𝕙",
- "𝕚",
- "𝕛",
- "𝕜",
- "𝕝",
- "𝕞",
- "𝕟",
- "𝕠",
- "𝕡",
- "𝕢",
- "𝕣",
- "𝕤",
- "𝕥",
- "𝕦",
- "𝕧",
- "𝕨",
- "𝕩",
- "𝕪",
- "𝕫",
- "𝔸",
- "𝔹",
- "ℂ",
- "𝔻",
- "𝔼",
- "𝔽",
- "𝔾",
- "ℍ",
- "𝕀",
- "𝕁",
- "𝕂",
- "𝕃",
- "𝕄",
- "ℕ",
- "𝕆",
- "ℙ",
- "ℚ",
- "ℝ",
- "𝕊",
- "𝕋",
- "𝕌",
- "𝕍",
- "𝕎",
- "𝕏",
- "𝕐",
- "ℤ",
-]
-
-_script_royal = [
- "𝒶",
- "𝒷",
- "𝒸",
- "𝒹",
- "𝑒",
- "𝒻",
- "𝑔",
- "𝒽",
- "𝒾",
- "𝒿",
- "𝓀",
- "𝓁",
- "𝓂",
- "𝓃",
- "𝑜",
- "𝓅",
- "𝓆",
- "𝓇",
- "𝓈",
- "𝓉",
- "𝓊",
- "𝓋",
- "𝓌",
- "𝓍",
- "𝓎",
- "𝓏",
- "𝒜",
- "ℬ",
- "𝒞",
- "𝒟",
- "ℰ",
- "ℱ",
- "𝒢",
- "ℋ",
- "ℐ",
- "𝒥",
- "𝒦",
- "ℒ",
- "ℳ",
- "𝒩",
- "𝒪",
- "𝒫",
- "𝒬",
- "ℛ",
- "𝒮",
- "𝒯",
- "𝒰",
- "𝒱",
- "𝒲",
- "𝒳",
- "𝒴",
- "𝒵",
-]
-
-
KANGING_STR = [
"Using Witchery to kang this sticker...",
"Plagiarising hehe...",
diff --git a/plugins/_help.py b/plugins/_help.py
index e15dafd979..d2f300718f 100644
--- a/plugins/_help.py
+++ b/plugins/_help.py
@@ -5,21 +5,17 @@
# PLease read the GNU Affero General Public License in
# .
-from support import *
+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 telethon.tl.custom import Button
from . import *
-@ultroid_cmd(
- pattern="help ?(.*)",
-)
-async def ult(ult):
+@ultroid_cmd(pattern="help ?(.*)")
+async def _help(ult):
plug = ult.pattern_match.group(1)
- tgbot = asst.me.username
if plug:
try:
if plug in HELP:
@@ -45,16 +41,16 @@ async def ult(ult):
except BaseException:
await eor(ult, "Error 🤔 occured.")
else:
+ tgbot = asst.me.username
try:
- results = await ultroid_bot.inline_query(tgbot, "ultd")
+ results = await ult.client.inline_query(tgbot, "ultd")
except BotMethodInvalidError:
z = []
for x in LIST.values():
for y in x:
z.append(y)
cmd = len(z) + 10
- bnn = asst.me.username
- return await ultroid_bot.send_message(
+ return await ult.client.send_message(
ult.chat_id,
get_string("inline_4").format(
OWNER_NAME,
@@ -71,7 +67,11 @@ async def ult(ult):
Button.inline("Oᴡɴᴇʀ•ᴛᴏᴏʟꜱ", data="ownr"),
Button.inline("Iɴʟɪɴᴇ•Pʟᴜɢɪɴs", data="inlone"),
],
- [Button.url("⚙️Sᴇᴛᴛɪɴɢs⚙️", url=f"https://t.me/{bnn}?start=set")],
+ [
+ Button.url(
+ "⚙️Sᴇᴛᴛɪɴɢs⚙️", url=f"https://t.me/{tgbot}?start=set"
+ ),
+ ],
[Button.inline("••Cʟᴏꜱᴇ••", data="close")],
],
)
diff --git a/plugins/_inline.py b/plugins/_inline.py
index 2a0cee2a5e..46bc9ff3af 100644
--- a/plugins/_inline.py
+++ b/plugins/_inline.py
@@ -12,6 +12,7 @@
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
@@ -74,7 +75,7 @@ async def inline_alive(o):
if len(o.text) == 0:
b = o.builder
MSG = "• **Ultroid Userbot •**"
- uptime = grt(time.time() - start_time)
+ uptime = time_formatter((time.time() - start_time) * 1000)
MSG += f"\n\n• **Uptime** - `{uptime}`\n"
MSG += f"• **OWNER** - `{OWNER_NAME}`"
WEB0 = InputWebDocument(
@@ -120,35 +121,17 @@ async def inline_handler(event):
await event.answer([result], gallery=True)
-@in_pattern("paste")
+@in_pattern("haste")
@in_owner
async def _(event):
ok = event.text.split(" ")[1]
- link = "https://nekobin.com/"
+ link = "https://hastebin.com/"
result = event.builder.article(
title="Paste",
- text="Pᴀsᴛᴇᴅ Tᴏ Nᴇᴋᴏʙɪɴ!",
+ text="Pᴀsᴛᴇᴅ Tᴏ Hᴀsᴛᴇʙɪɴ!",
buttons=[
[
- Button.url("NekoBin", url=f"{link}{ok}"),
- Button.url("Raw", url=f"{link}raw/{ok}"),
- ],
- ],
- )
- await event.answer([result])
-
-
-@in_pattern("dog")
-@in_owner
-async def _(event):
- ok = event.text.split(" ")[1]
- link = "https://del.dog/"
- result = event.builder.article(
- title="Paste",
- text="Pᴀsᴛᴇᴅ Tᴏ Dᴏɢʙɪɴ!",
- buttons=[
- [
- Button.url("DogBin", url=f"{link}{ok}"),
+ Button.url("HasteBin", url=f"{link}{ok}"),
Button.url("Raw", url=f"{link}raw/{ok}"),
],
],
@@ -236,7 +219,7 @@ async def _(event):
@callback("upp")
async def _(event):
- uptime = grt(time.time() - start_time)
+ uptime = time_formatter((time.time() - start_time) * 1000)
pin = f"🙋Uᴘᴛɪᴍᴇ = {uptime}"
await event.answer(pin, cache_time=0, alert=True)
diff --git a/plugins/_ultroid.py b/plugins/_ultroid.py
index 17f36c9fc7..7c9c4a2aa3 100644
--- a/plugins/_ultroid.py
+++ b/plugins/_ultroid.py
@@ -4,27 +4,25 @@
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# .
-
-
from telethon.errors import ChatSendInlineForbiddenError
from telethon.errors.rpcerrorlist import BotMethodInvalidError as bmi
from . import *
-REPOMSG = (
- "• **ULTROID USERBOT** •\n\n",
- "• Repo - [Click Here](https://github.com/TeamUltroid/Ultroid)\n",
- "• Addons - [Click Here](https://github.com/TeamUltroid/UltroidAddons)\n",
- "• Support - @UltroidSupport",
-)
+REPOMSG = """
+• **ULTROID USERBOT** •\n
+• Repo - [Click Here](https://github.com/TeamUltroid/Ultroid)
+• Addons - [Click Here](https://github.com/TeamUltroid/UltroidAddons)
+• Support - @UltroidSupport
+"""
-@ultroid_cmd(pattern="repo$")
+@ultroid_cmd(pattern="repo$", type=["official", "manager"], ignore_dualmode=True)
async def repify(e):
try:
- q = await ultroid_bot.inline_query(asst.me.username, "repo")
+ q = await e.client.inline_query(asst.me.username, "repo")
await q[0].click(e.chat_id)
- if e.sender_id == ultroid_bot.uid:
+ if e.out:
await e.delete()
except (ChatSendInlineForbiddenError, bmi):
await eor(e, REPOMSG)
diff --git a/plugins/_userlogs.py b/plugins/_userlogs.py
index 26ecaa0781..46f02cae21 100644
--- a/plugins/_userlogs.py
+++ b/plugins/_userlogs.py
@@ -26,70 +26,69 @@
),
)
async def all_messages_catcher(e):
- if udB.get("TAG_LOG"):
- try:
- NEEDTOLOG = int(udB.get("TAG_LOG"))
- except Exception:
- return LOGS.info("you given Wrong Grp/Channel ID in TAG_LOG.")
- x = e.sender
- if x.bot or x.verified:
- return
- y = e.chat
- where_n = get_display_name(y)
- who_n = get_display_name(x)
- where_l = f"https://t.me/c/{y.id}/{e.id}"
- send = await ultroid_bot.get_messages(e.chat_id, ids=e.id)
- try:
- if x.username:
- who_l = f"https://t.me/{x.username}"
- await asst.send_message(
- NEEDTOLOG,
- send,
- buttons=[
- [Button.url(who_n, who_l)],
- [Button.url(where_n, where_l)],
- ],
- )
- else:
- await asst.send_message(
- NEEDTOLOG,
- send,
- buttons=[
- [Button.inline(who_n, data=f"who{x.id}")],
- [Button.url(where_n, where_l)],
- ],
- )
- except MediaEmptyError:
- if x.username:
- who_l = f"https://t.me/{x.username}"
- await asst.send_message(
- NEEDTOLOG,
- "`Unsupported Media`",
- buttons=[
- [Button.url(who_n, who_l)],
- [Button.url(where_n, where_l)],
- ],
- )
- else:
- await asst.send_message(
- NEEDTOLOG,
- "`Unsupported Media`",
- buttons=[
- [Button.inline(who_n, data=f"who{x.id}")],
- [Button.url(where_n, where_l)],
- ],
- )
- except PeerIdInvalidError:
- await ultroid_bot.send_message(
- int(udB.get("LOG_CHANNEL")),
- "The Chat Id You Set In Tag Logger Is Wrong , Please Correct It",
- )
- except ChatWriteForbiddenError:
- await ultroid_bot.send_message(NEEDTOLOG, "Please Give Your Assistant Bot")
- except Exception as er:
- LOGS.info(str(er))
- else:
+ if not udB.get("TAG_LOG"):
return
+ try:
+ NEEDTOLOG = int(udB.get("TAG_LOG"))
+ except Exception:
+ return LOGS.info("you given Wrong Grp/Channel ID in TAG_LOG.")
+ x = e.sender
+ if x.bot or x.verified:
+ return
+ y = e.chat
+ where_n = get_display_name(y)
+ who_n = get_display_name(x)
+ where_l = f"https://t.me/c/{y.id}/{e.id}"
+ send = await ultroid_bot.get_messages(e.chat_id, ids=e.id)
+ try:
+ if x.username:
+ who_l = f"https://t.me/{x.username}"
+ await asst.send_message(
+ NEEDTOLOG,
+ send,
+ buttons=[
+ [Button.url(who_n, who_l)],
+ [Button.url(where_n, where_l)],
+ ],
+ )
+ else:
+ await asst.send_message(
+ NEEDTOLOG,
+ send,
+ buttons=[
+ [Button.inline(who_n, data=f"who{x.id}")],
+ [Button.url(where_n, where_l)],
+ ],
+ )
+ except MediaEmptyError:
+ if x.username:
+ who_l = f"https://t.me/{x.username}"
+ await asst.send_message(
+ NEEDTOLOG,
+ "`Unsupported Media`",
+ buttons=[
+ [Button.url(who_n, who_l)],
+ [Button.url(where_n, where_l)],
+ ],
+ )
+ else:
+ await asst.send_message(
+ NEEDTOLOG,
+ "`Unsupported Media`",
+ buttons=[
+ [Button.inline(who_n, data=f"who{x.id}")],
+ [Button.url(where_n, where_l)],
+ ],
+ )
+ except PeerIdInvalidError:
+ await ultroid_bot.send_message(
+ int(udB.get("LOG_CHANNEL")),
+ "The Chat Id You Set In Tag Logger Is Wrong , Please Correct It",
+ )
+ except ChatWriteForbiddenError:
+ await ultroid_bot.send_message(NEEDTOLOG, "Please Give Your Assistant Bot")
+ except Exception as er:
+ LOGS.info(str(er))
@callback(re.compile("who(.*)"))
@@ -105,21 +104,22 @@ async def _(e):
# log for assistant
@asst.on(events.ChatAction)
async def when_asst_added_to_chat(event):
- if event.user_added:
- user = await event.get_user()
- chat = await event.get_chat()
- if 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 not event.user_added:
+ return
+ user = await event.get_user()
+ chat = await event.get_chat()
+ if 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.is_self:
tmp = event.added_by
- if user.is_self:
- 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,
- )
+ 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,
+ )
# log for user's new joins
@@ -130,22 +130,22 @@ async def when_ultd_added_to_chat(event):
if event.user_added:
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})"
- tmp = event.added_by
if user.is_self:
+ tmp = event.added_by
buttons = Button.inline("Leave Chat", data=f"leave_ch_{event.chat_id}|user")
return await asst.send_message(
int(udB.get("LOG_CHANNEL")),
- f"#ADD_LOG\n\n[{tmp.first_name}](tg://user?id={tmp.id}) just added [{user.first_name}](tg://user?id={user.id}) to {chat}.",
+ f"#ADD_LOG\n\n{inline_mention(tmp)} just added {inline_mention(user)} to {chat}.",
buttons=buttons,
)
elif event.user_joined:
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})"
diff --git a/plugins/_wspr.py b/plugins/_wspr.py
index 2a4d1e0884..73e685ebbc 100644
--- a/plugins/_wspr.py
+++ b/plugins/_wspr.py
@@ -41,7 +41,7 @@ async def _(e):
put = e.pattern_match.group(1)
if put:
try:
- results = await ultroid_bot.inline_query(asst.me.username, f"msg {put}")
+ results = await e.client.inline_query(asst.me.username, f"msg {put}")
except rep:
return await eor(
e,
diff --git a/plugins/admintools.py b/plugins/admintools.py
index 1442049004..c23d588c72 100644
--- a/plugins/admintools.py
+++ b/plugins/admintools.py
@@ -4,7 +4,6 @@
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# .
-
"""
✘ Commands Available -
@@ -44,7 +43,6 @@
• `{i}purgeall`
Delete all msgs of replied user.
"""
-
import asyncio
from telethon.errors import BadRequestError
@@ -52,15 +50,16 @@
from telethon.tl.functions.channels import DeleteUserHistoryRequest, EditAdminRequest
from telethon.tl.functions.channels import ExportMessageLinkRequest as ExpLink
from telethon.tl.functions.messages import SetHistoryTTLRequest
-from telethon.tl.types import ChatAdminRights, InputMessagesFilterPinned
+from telethon.tl.types import Chat, ChatAdminRights, InputMessagesFilterPinned
from . import *
@ultroid_cmd(
pattern="promote ?(.*)",
- groups_only=True,
admins_only=True,
+ type=["official", "manager"],
+ ignore_dualmode=True,
)
async def prmte(ult):
xx = await eor(ult, get_string("com_1"))
@@ -71,7 +70,7 @@ async def prmte(ult):
if not user:
return await xx.edit("`Reply to a user to promote him!`")
try:
- await ultroid_bot(
+ await ult.client(
EditAdminRequest(
ult.chat_id,
user.id,
@@ -87,7 +86,7 @@ async def prmte(ult):
),
)
await xx.edit(
- f"[{user.first_name}](tg://user?id={user.id}) `is now an admin in {ult.chat.title} with title {rank}.`",
+ f"{inline_mention(user)} `is now an admin in {ult.chat.title} with title {rank}.`",
)
except BadRequestError:
return await xx.edit("`I don't have the right to promote you.`")
@@ -97,8 +96,9 @@ async def prmte(ult):
@ultroid_cmd(
pattern="demote ?(.*)",
- groups_only=True,
admins_only=True,
+ type=["official", "manager"],
+ ignore_dualmode=True,
)
async def dmote(ult):
xx = await eor(ult, get_string("com_1"))
@@ -109,7 +109,7 @@ async def dmote(ult):
if not user:
return await xx.edit("`Reply to a user to demote him!`")
try:
- await ultroid_bot(
+ await ult.client(
EditAdminRequest(
ult.chat_id,
user.id,
@@ -125,7 +125,7 @@ async def dmote(ult):
),
)
await xx.edit(
- f"[{user.first_name}](tg://user?id={user.id}) `is no longer an admin in {ult.chat.title}`",
+ f"{inline_mention(user)} `is no longer an admin in {ult.chat.title}`",
)
except BadRequestError:
return await xx.edit("`I don't have the right to demote you.`")
@@ -135,72 +135,71 @@ async def dmote(ult):
@ultroid_cmd(
pattern="ban ?(.*)",
- groups_only=True,
admins_only=True,
+ type=["official", "manager"],
+ ignore_dualmode=True,
)
async def bban(ult):
xx = await eor(ult, get_string("com_1"))
- await ult.get_chat()
user, reason = await get_user_info(ult)
if not user:
return await xx.edit("`Reply to a user or give username to ban him!`")
if str(user.id) in DEVLIST:
return await xx.edit(" `LoL, I can't Ban my Developer 😂`")
try:
- await ultroid_bot.edit_permissions(ult.chat_id, user.id, view_messages=False)
+ await ult.client.edit_permissions(ult.chat_id, user.id, view_messages=False)
except BadRequestError:
return await xx.edit("`I don't have the right to ban a user.`")
except UserIdInvalidError:
- await xx.edit("`I couldn't get who he is!`")
+ return await xx.edit("`I couldn't get who he is!`")
try:
reply = await ult.get_reply_message()
if reply:
await reply.delete()
except BadRequestError:
return await xx.edit(
- f"[{user.first_name}](tg://user?id={user.id}) **was banned by** [{OWNER_NAME}](tg://user?id={OWNER_ID}) **in** `{ult.chat.title}`\n**Reason**: `{reason}`\n**Messages Deleted**: `False`",
+ f"{inline_mention(user)}**was banned by** {inline_mention(ult.sender)} **in** `{ult.chat.title}`\n**Reason**: `{reason}`\n**Messages Deleted**: `False`",
)
+ userme = inline_mention(user)
+ senderme = inline_mention(ult.sender)
if reason:
await xx.edit(
- f"[{user.first_name}](tg://user?id={user.id}) **was banned by** [{OWNER_NAME}](tg://user?id={OWNER_ID}) **in** `{ult.chat.title}`\n**Reason**: `{reason}`",
+ f"{userme} **was banned by** {senderme}**in** `{ult.chat.title}`\n**Reason**: `{reason}`",
)
else:
await xx.edit(
- f"[{user.first_name}](tg://user?id={user.id}) **was banned by** [{OWNER_NAME}](tg://user?id={OWNER_ID}) **in** `{ult.chat.title}`",
+ f"{userme} **was banned by** {senderme} **in** `{ult.chat.title}`",
)
@ultroid_cmd(
pattern="unban ?(.*)",
- groups_only=True,
admins_only=True,
+ type=["official", "manager"],
+ ignore_dualmode=True,
)
async def uunban(ult):
xx = await eor(ult, get_string("com_1"))
- await ult.get_chat()
user, reason = await get_user_info(ult)
if not user:
return await xx.edit("`Reply to a user or give username to unban him!`")
try:
- await ultroid_bot.edit_permissions(ult.chat_id, user.id, view_messages=True)
+ await ult.client.edit_permissions(ult.chat_id, user.id, view_messages=True)
except BadRequestError:
return await xx.edit("`I don't have the right to unban a user.`")
except UserIdInvalidError:
await xx.edit("`I couldn't get who he is!`")
+ text = f"{inline_mention(user)} **was unbanned by** {inline_mention(ult.sender)} **in** `{ult.chat.title}`"
if reason:
- await xx.edit(
- f"[{user.first_name}](tg://user?id={user.id}) **was unbanned by** [{OWNER_NAME}](tg://user?id={OWNER_ID}) **in** `{ult.chat.title}`\n**Reason**: `{reason}`",
- )
- else:
- await xx.edit(
- f"[{user.first_name}](tg://user?id={user.id}) **was unbanned by** [{OWNER_NAME}](tg://user?id={OWNER_ID}) **in** `{ult.chat.title}`",
- )
+ text += f"\n**Reason**: `{reason}`"
+ await xx.edit(text)
@ultroid_cmd(
pattern="kick ?(.*)",
- groups_only=True,
admins_only=True,
+ type=["official", "manager"],
+ ignore_dualmode=True,
)
async def kck(ult):
if ult.text == f"{HNDLR}kickme":
@@ -212,10 +211,10 @@ async def kck(ult):
return await xx.edit("`Kick? Whom? I couldn't get his info...`")
if str(user.id) in DEVLIST:
return await xx.edit(" `Lol, I can't Kick my Developer`😂")
- if user.id == ultroid_bot.uid:
- return await xx.edit("`You Can't kick urself`")
+ if user.id in [ultroid_bot.uid, asst.me.id]:
+ return await xx.edit("`You Can't kick that powerhouse`")
try:
- await ultroid_bot.kick_participant(ult.chat_id, user.id)
+ await ult.client.kick_participant(ult.chat_id, user.id)
await asyncio.sleep(0.5)
except BadRequestError:
return await xx.edit("`I don't have the right to kick a user.`")
@@ -223,21 +222,14 @@ async def kck(ult):
return await xx.edit(
f"`I don't have the right to kick a user.`\n\n**ERROR**:\n`{str(e)}`",
)
+ text = f"{inline_mention(user)} **was kicked by** {inline_mention(ult.sender)} **in** `{ult.chat.title}`"
if reason:
- await xx.edit(
- f"[{user.first_name}](tg://user?id={user.id})` was kicked by` [{OWNER_NAME}](tg://user?id={OWNER_ID}) `in {ult.chat.title}`\n**Reason**: `{reason}`",
- )
- else:
- await xx.edit(
- f"[{user.first_name}](tg://user?id={user.id})` was kicked by` [{OWNER_NAME}](tg://user?id={OWNER_ID}) `in {ult.chat.title}`",
- )
+ text += f"\n**Reason**: `{reason}`"
+ await xx.edit(text)
-@ultroid_cmd(
- pattern="pin ?(.*)",
-)
+@ultroid_cmd(pattern="pin ?(.*)", type=["official", "manager"], ignore_dualmode=True)
async def pin(msg):
- mss = "`Pinned.`"
xx = msg.reply_to_msg_id
tt = msg.text
try:
@@ -247,35 +239,27 @@ async def pin(msg):
except BaseException:
pass
if not msg.is_reply:
- return
- if not msg.is_private:
- link = (await ultroid_bot(ExpLink(msg.chat_id, xx))).link
- mss = f"`Pinned` [This Message]({link})"
+ return await eor(msg, "Reply a Message to Pin !")
+ if not msg.client._bot and not msg.is_private and not isinstance(msg.chat, Chat):
+ link = (await msg.client(ExpLink(msg.chat_id, xx))).link
+ f"`Pinned` [This Message]({link})"
ch = msg.pattern_match.group(1)
if ch != "silent":
- slnt = True
- try:
- await ultroid_bot.pin_message(msg.chat_id, xx, notify=slnt)
- except BadRequestError:
- return await eor(msg, "`Hmm.. Guess I have no rights here!`")
- except Exception as e:
- return await eor(msg, f"**ERROR:**`{str(e)}`")
- await eor(msg, mss)
+ pass
else:
- try:
- await ultroid_bot.pin_message(msg.chat_id, xx, notify=False)
- except BadRequestError:
- return await eor(msg, "`Hmm.. Guess I have no rights here!`")
- except Exception as e:
- return await eor(msg, f"**ERROR:**`{str(e)}`")
- try:
- await msg.delete()
- except BaseException:
- pass
+ pass
+ try:
+ await msg.client.pin_message(msg.chat_id, xx, notify=False)
+ except BadRequestError:
+ return await eor(msg, "`Hmm.. Guess I have no rights here!`")
+ except Exception as e:
+ return await eor(msg, f"**ERROR:**`{str(e)}`")
+ if msg.out:
+ await msg.delete()
@ultroid_cmd(
- pattern="unpin($| (.*))",
+ pattern="unpin($| (.*))", type=["official", "manager"], ignore_dualmode=True
)
async def unp(ult):
xx = await eor(ult, get_string("com_1"))
@@ -286,14 +270,14 @@ async def unp(ult):
msg = ult.reply_to_msg_id
if msg and not ch:
try:
- await ultroid_bot.unpin_message(ult.chat_id, msg)
+ await ult.client.unpin_message(ult.chat_id, msg)
except BadRequestError:
return await xx.edit("`Hmm.. Guess I have no rights here!`")
except Exception as e:
return await xx.edit(f"**ERROR:**\n`{str(e)}`")
elif ch == "all":
try:
- await ultroid_bot.unpin_message(ult.chat_id)
+ await ult.client.unpin_message(ult.chat_id)
except BadRequestError:
return await xx.edit("`Hmm.. Guess I have no rights here!`")
except Exception as e:
@@ -305,9 +289,7 @@ async def unp(ult):
await xx.edit("`Unpinned!`")
-@ultroid_cmd(
- pattern="purge ?(.*)",
-)
+@ultroid_cmd(pattern="purge ?(.*)", type=["official", "manager"], ignore_dualmode=True)
async def fastpurger(purg):
chat = await purg.get_input_chat()
match = purg.pattern_match.group(1)
@@ -317,9 +299,13 @@ async def fastpurger(purg):
ABC = None
if ABC and purg.text[6] in ["m", "a"]:
return
+ if purg.client._bot:
+ return await purg.client.delete_messages(
+ purg.chat_id, [a for a in range(purg.reply_to_msg_id, purg.id)]
+ )
if match and not purg.is_reply:
p = 0
- async for msg in ultroid_bot.iter_messages(purg.chat_id, limit=int(match)):
+ async for msg in purg.client.iter_messages(purg.chat_id, limit=int(match)):
await msg.delete()
p += 0
return await eod(purg, f"Purged {p} Messages! ")
@@ -327,26 +313,20 @@ async def fastpurger(purg):
count = 0
if not (purg.reply_to_msg_id or match):
return await eod(purg, "`Reply to a message to purge from.`", time=10)
- async for msg in ultroid_bot.iter_messages(chat, min_id=purg.reply_to_msg_id):
+ async for msg in purg.client.iter_messages(chat, min_id=purg.reply_to_msg_id):
msgs.append(msg)
count = count + 1
msgs.append(purg.reply_to_msg_id)
if len(msgs) == 100:
- await ultroid_bot.delete_messages(chat, msgs)
+ await purg.client.delete_messages(chat, msgs)
msgs = []
if msgs:
- await ultroid_bot.delete_messages(chat, msgs)
- done = await ultroid_bot.send_message(
- purg.chat_id,
- "__Fast purge complete!__\n**Purged** `"
- + str(len(msgs))
- + "` **of** `"
- + str(count)
- + "` **messages.**",
+ await purg.client.delete_messages(chat, msgs)
+ await eod(
+ purg,
+ "__Fast purge complete!__\n**Purged** `" + str(count) + "` **messages.**",
)
- await asyncio.sleep(5)
- await done.delete()
@ultroid_cmd(
@@ -361,7 +341,7 @@ async def fastpurgerme(purg):
await eod(purg, "`Give a Valid Input.. `")
return
mp = 0
- async for mm in ultroid_bot.iter_messages(
+ async for mm in purg.client.iter_messages(
purg.chat_id, limit=nnt, from_user="me"
):
await mm.delete()
@@ -377,7 +357,7 @@ async def fastpurgerme(purg):
"`Reply to a message to purge from or use it like ``purgeme `",
time=10,
)
- async for msg in ultroid_bot.iter_messages(
+ async for msg in purg.client.iter_messages(
chat,
from_user="me",
min_id=purg.reply_to_msg_id,
@@ -390,13 +370,11 @@ async def fastpurgerme(purg):
msgs = []
if msgs:
- await ultroid_bot.delete_messages(chat, msgs)
- done = await ultroid_bot.send_message(
- purg.chat_id,
+ await purg.client.delete_messages(chat, msgs)
+ await eod(
+ purg,
"__Fast purge complete!__\n**Purged** `" + str(count) + "` **messages.**",
)
- await asyncio.sleep(5)
- await done.delete()
@ultroid_cmd(
@@ -405,54 +383,37 @@ async def fastpurgerme(purg):
async def _(e):
xx = await eor(e, get_string("com_1"))
if e.reply_to_msg_id:
- input = (await e.get_reply_message()).sender_id
- name = (await e.client.get_entity(input)).first_name
+ name = (await e.get_reply_message()).sender
try:
- await ultroid_bot(DeleteUserHistoryRequest(e.chat_id, input))
- await eod(e, f"Successfully Purged All Messages from {name}")
+ await e.client(DeleteUserHistoryRequest(e.chat_id, name.id))
+ await eod(e, f"Successfully Purged All Messages from {name.first_name}")
except Exception as er:
- return await eod(xx, str(er), time=5)
+ return await eod(xx, str(er))
else:
return await eod(
xx,
"`Reply to someone's msg to delete.`",
- time=5,
)
-@ultroid_cmd(pattern="pinned")
-async def get_pinned(event):
- x = await eor(event, get_string("com_1"))
- chat_id = (str(event.chat_id)).replace("-100", "")
- chat_name = "This Chat"
- if not event.is_private:
- chat_name = (await event.get_chat()).title
- tem = ""
- c = 0
-
- async for i in ultroid.iter_messages(
- event.chat_id, filter=InputMessagesFilterPinned
- ):
- c += 1
- tem += f"The pinned message in {chat_name} can be found here."
- if c == 1:
- return await x.edit(tem, parse_mode="html")
-
- if tem == "":
- return await eod(x, "There is no pinned message in chat!", time=5)
-
-
-@ultroid_cmd(pattern="listpinned")
+@ultroid_cmd(
+ pattern="listpinned$",
+)
async def get_all_pinned(event):
x = await eor(event, get_string("com_1"))
chat_id = (str(event.chat_id)).replace("-100", "")
chat_name = (await event.get_chat()).title
a = ""
c = 1
- async for i in ultroid.iter_messages(
+ async for i in event.client.iter_messages(
event.chat_id, filter=InputMessagesFilterPinned
):
- a += f"{c}. Go to message.\n"
+ if i.message:
+ t = " ".join(i.message.split()[0:4])
+ txt = "{}....".format(t)
+ else:
+ txt = "Go to message."
+ a += f"{c}. {txt}\n"
c += 1
if c == 1:
@@ -461,12 +422,15 @@ async def get_all_pinned(event):
m = f"List of pinned message(s) in {chat_name}:\n\n"
if a == "":
- return await eod(x, "There is no message pinned in this group!", time=5)
+ return await eod(x, "There is no message pinned in this group!")
await x.edit(m + a, parse_mode="html")
-@ultroid_cmd(pattern="autodelete ?(.*)", groups_only=True, admins_only=True)
+@ultroid_cmd(
+ pattern="autodelete ?(.*)",
+ admins_only=True,
+)
async def autodelte(ult): # Tg Feature
match = ult.pattern_match.group(1)
if not match or match not in ["24h", "7d", "off"]:
@@ -478,7 +442,7 @@ async def autodelte(ult): # Tg Feature
else:
tt = 0
try:
- await ultroid_bot(SetHistoryTTLRequest(ult.chat_id, period=tt))
+ await ult.client(SetHistoryTTLRequest(ult.chat_id, period=tt))
except ChatNotModifiedError:
return await eod(ult, f"Auto Delete Setting is Already same to `{match}`")
await eor(ult, f"Auto Delete Status Changed to {match} !")
diff --git a/plugins/afk.py b/plugins/afk.py
index 98690713e3..82d2d86e8c 100644
--- a/plugins/afk.py
+++ b/plugins/afk.py
@@ -10,6 +10,7 @@
• `{i}afk `
AFK means away from keyboard,
+
After u active this if Someone tag or msg u then It auto Reply Him/her,
(Note : By Reply To any media U can set media afk too).
@@ -160,9 +161,11 @@ async def on_afk(event):
@ultroid_cmd(pattern=r"afk ?(.*)")
async def _(event):
- if not is_fullsudo(event.sender_id):
- return await eor(event, "`This Command Is Sudo Restricted.`")
+ if not event.out and not is_fullsudo(event.sender_id):
+ return await eor(event, "`This Command Is Full Sudo Restricted.`")
reply = await event.get_reply_message()
+ if event.client._bot:
+ return await eor(event, "Master, I am a Bot, I cant go AFK..")
global USER_AFK
global afk_time
global last_afk_message
diff --git a/plugins/anime.py b/plugins/anime.py
index fa500c9bb9..60882f50b1 100644
--- a/plugins/anime.py
+++ b/plugins/anime.py
@@ -4,7 +4,6 @@
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# .
-
"""
✘ Commands Available -
@@ -17,10 +16,10 @@
• `{i}character `
Fetch anime character details.
"""
-
from os import remove
import jikanpy
+from telethon.errors.rpcerrorlist import MediaCaptionTooLongError
from . import *
@@ -47,7 +46,26 @@ async def anilist(event):
return await eod(x, "`Enter a anime name!`", time=5)
banner, title, year, episodes, info = get_anime_src_res(name)
msg = f"**{title}**\n{year} | {episodes} Episodes.\n\n{info}"
- await event.reply(msg, file=banner, link_preview=True)
+ try:
+ await event.reply(msg, file=banner, link_preview=True)
+ except MediaCaptionTooLongError:
+ nm = name.replace(" ", "_")
+ with open(f"{nm}.txt", "w") as f:
+ f.write(msg.replace("*", ""))
+ await bash(f"wget {banner} -O {nm}.jpg")
+ try:
+ await event.reply(file=f"{nm}.txt", thumb=f"{nm}.jpg")
+ except Exception as e:
+ await event.reply(file=f"{nm}.txt")
+ LOGS.warning(str(e))
+ try:
+ remove(f"{nm}.jpg")
+ except BaseException:
+ pass
+ try:
+ remove(f"{nm}.txt")
+ except BaseException:
+ pass
await x.delete()
diff --git a/plugins/antiflood.py b/plugins/antiflood.py
index 2f639fa1f5..05c5c22def 100644
--- a/plugins/antiflood.py
+++ b/plugins/antiflood.py
@@ -97,6 +97,7 @@ async def unmuting(e):
@ultroid_cmd(
pattern="setflood ?(\\d+)",
admins_only=True,
+ ignore_dualmode=True,
)
async def setflood(e):
input = e.pattern_match.group(1)
@@ -114,6 +115,7 @@ async def setflood(e):
@ultroid_cmd(
pattern="remflood$",
admins_only=True,
+ ignore_dualmode=True,
)
async def remove_flood(e):
hmm = rem_flood(e.chat_id)
@@ -129,6 +131,7 @@ async def remove_flood(e):
@ultroid_cmd(
pattern="getflood$",
admins_only=True,
+ ignore_dualmode=True,
)
async def getflood(e):
ok = get_flood_limit(e.chat_id)
diff --git a/plugins/ascii.py b/plugins/ascii.py
index b7ae9ea6e3..8da8674cc6 100644
--- a/plugins/ascii.py
+++ b/plugins/ascii.py
@@ -4,15 +4,12 @@
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# .
-
"""
✘ Commands Available -
• `{i}ascii `
Convert replied image into html.
"""
-
-
import os
from img2html.converter import Img2HTMLConverter
@@ -33,7 +30,7 @@ async def _(e):
html = converter.convert(img)
with open("html.html", "w") as t:
t.write(html)
- await e.client.send_file(e.chat_id, "html.html", reply_to=e.reply_to_msg_id)
+ await e.reply(file="html.html")
await m.delete()
os.remove(img)
os.remove("html.html")
diff --git a/plugins/asst_cmd.py b/plugins/asst_cmd.py
index 3552cb826d..f0a9d0d72f 100644
--- a/plugins/asst_cmd.py
+++ b/plugins/asst_cmd.py
@@ -4,7 +4,6 @@
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# .
-
"""
✘ Commands Available -
@@ -17,7 +16,6 @@
•`{i}listcmd`
To Get list of all your custom cmd.
"""
-
import os
from pyUltroid.functions.asstcmd_db import *
@@ -38,7 +36,7 @@ async def ac(e):
if wt and wt.media:
wut = mediainfo(wt.media)
if wut.startswith(("pic", "gif")):
- dl = await bot.download_media(wt.media)
+ dl = await e.client.download_media(wt.media)
variable = uf(dl)
os.remove(dl)
m = "https://telegra.ph" + variable[0]
@@ -46,7 +44,7 @@ async def ac(e):
if wt.media.document.size > 8 * 1000 * 1000:
return await eod(x, "`Unsupported Media`")
else:
- dl = await bot.download_media(wt.media)
+ dl = await e.client.download_media(wt.media)
variable = uf(dl)
os.remove(dl)
m = "https://telegra.ph" + variable[0]
diff --git a/plugins/autopic.py b/plugins/autopic.py
index 3410c24b04..f60b82eaa0 100644
--- a/plugins/autopic.py
+++ b/plugins/autopic.py
@@ -4,7 +4,6 @@
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# .
-
"""
✘ Commands Available -
@@ -48,9 +47,9 @@ async def autopic(e):
if not ge == "True":
return
au = "https://unsplash.com" + lie["href"]
- et = await ultroid_bot(getweb(au))
+ et = await e.client(getweb(au))
try:
- kar = await ultroid_bot.download_media(et.webpage.photo)
+ kar = await e.client.download_media(et.webpage.photo)
except AttributeError:
ct = r.get(au).content
bsc = bs(ct, "html.parser", from_encoding="utf-8")
@@ -58,8 +57,8 @@ async def autopic(e):
li = ft[0]["src"]
kar = "autopic.png"
urllib.request.urlretrieve(li, kar)
- file = await ultroid_bot.upload_file(kar)
- await ultroid_bot(UploadProfilePhotoRequest(file))
+ file = await e.client.upload_file(kar)
+ await e.client(UploadProfilePhotoRequest(file))
os.remove(kar)
await asyncio.sleep(SLEEP_TIME)
diff --git a/plugins/bot.py b/plugins/bot.py
index 1a8ba5e226..c95f6585ee 100644
--- a/plugins/bot.py
+++ b/plugins/bot.py
@@ -4,7 +4,6 @@
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# .
-
"""
✘ Commands Available
@@ -29,7 +28,6 @@
• `{i}shutdown`
Turn off your bot.
"""
-
import time
from datetime import datetime as dt
from platform import python_version as pyver
@@ -47,7 +45,7 @@
)
async def lol(ult):
pic = udB.get("ALIVE_PIC")
- uptime = grt(time.time() - start_time)
+ uptime = time_formatter((time.time() - start_time) * 1000)
header = udB.get("ALIVE_TEXT") if udB.get("ALIVE_TEXT") else "Hey, I am alive."
y = Repo().active_branch
xx = Repo().remotes[0].config_reader.get("url")
@@ -67,16 +65,14 @@ async def lol(ult):
return await eor(ult, als)
elif pic is not None and "telegra" in pic:
try:
- await ultroid_bot.send_message(
- ult.chat_id, als, file=pic, link_preview=False
- )
+ await ult.reply(als, file=pic, link_preview=False)
await ult.delete()
except ChatSendMediaForbiddenError:
await eor(ult, als, link_preview=False)
else:
try:
- await ultroid_bot.send_message(ult.chat_id, file=pic)
- await ultroid_bot.send_message(ult.chat_id, als, link_preview=False)
+ await ult.reply(file=pic)
+ await ult.reply(als, link_preview=False)
await ult.delete()
except ChatSendMediaForbiddenError:
await eor(ult, als, link_preview=False)
@@ -92,7 +88,7 @@ async def _(event):
x = await eor(event, "`Pong !`")
end = dt.now()
ms = (end - start).microseconds / 1000
- uptime = grt(time.time() - start_time)
+ uptime = time_formatter((time.time() - start_time) * 1000)
await x.edit(get_string("ping").format(ms, uptime))
@@ -116,13 +112,13 @@ async def restartbt(ult):
@ultroid_cmd(pattern="shutdown$")
async def shutdownbot(ult):
- if not ult.out:
- if not is_fullsudo(ult.sender_id):
- return await eod(ult, "`This Command Is Sudo Restricted.`")
+ if not ult.out and not is_fullsudo(ult.sender_id):
+ return await eod(ult, "`This Command Is Sudo Restricted.`")
await shutdown(ult)
@ultroid_bot.on(events.NewMessage(pattern=f"\\{HNDLR}logs ?(.*)"))
+@asst.on(events.NewMessage(pattern="^/{HNDLR}logs ?(.*)"))
async def _(event):
if event.fwd_from:
return
@@ -134,7 +130,5 @@ async def _(event):
return await def_logs(event)
if opt == "heroku":
await heroku_logs(event)
- elif opt == "sys":
- await def_logs(event)
else:
await def_logs(event)
diff --git a/plugins/botecho.py b/plugins/botecho.py
new file mode 100644
index 0000000000..7a86ffd3e0
--- /dev/null
+++ b/plugins/botecho.py
@@ -0,0 +1,60 @@
+# 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
+# .
+
+"""
+✘ Commands Available -
+
+• `{i}botecho text (optional -\n[button_text_1](https://t.me/TheUltroid)\n[button_text_2](https://t.me/TeamUltroid))`
+ Send a message from your assistant bot.
+"""
+
+import re
+
+from . import *
+
+regex = r"\[(.*)\]\((\S*)\)"
+
+
+def generate_url_button(text):
+ btns = []
+ if not text:
+ return None
+ bt_txt = re.sub(regex, "", text) or None
+ matches = re.finditer(regex, text, re.MULTILINE)
+ if not matches:
+ return None
+ for i, match in enumerate(matches):
+ if match.group(2).endswith(":same"):
+ btnurl = match.group(2)[:-5]
+ if i == 0:
+ btns.append([Button.url(text=match.group(1), url=btnurl)])
+ else:
+ btns[-1].append(Button.url(text=match.group(1), url=btnurl))
+ else:
+ btns.append([Button.url(text=match.group(1), url=match.group(2))])
+ if not btns:
+ btns = None
+ return bt_txt, btns
+
+
+@ultroid_cmd(pattern="botecho")
+async def button_parser(event):
+ try:
+ text = event.text.split(" ", 1)[1]
+ except IndexError:
+ return await eor(
+ event,
+ f"**Please give some text!**\n**Format:** `{hndlr}botecho text \n[button_text_1](https://t.me/TheUltroid)\n[button_text_2](https://t.me/TeamUltroid)`",
+ )
+ text, buttons = generate_url_button(text)
+ try:
+ if text is None:
+ return await eor(event, "`Please provide a text too!`")
+ await asst.send_message(event.chat_id, text, buttons=buttons)
+ await eor(event, "Done. Message sent.")
+ except Exception as e:
+ await eod(event, "**ERROR:**\n{}".format(str(e)), time=5)
diff --git a/plugins/broadcast.py b/plugins/broadcast.py
index 8ca5347a98..8ec4f926fc 100644
--- a/plugins/broadcast.py
+++ b/plugins/broadcast.py
@@ -4,7 +4,6 @@
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# .
-
"""
✘ Commands Available
@@ -23,10 +22,11 @@
• `{i}listchannels`
To get list of all added chats.
"""
-
import asyncio
import io
+from pyUltroid.functions.broadcast_db import *
+
from . import *
@@ -42,7 +42,7 @@ async def broadcast_adder(event):
await x.edit(get_string("bd_2"))
chats = [
e.entity
- for e in await ultroid.get_dialogs()
+ for e in await event.client.get_dialogs()
if (e.is_group or e.is_channel)
]
for i in chats:
@@ -53,10 +53,8 @@ async def broadcast_adder(event):
new += 1
cid = f"-100{i.id}"
add_channel(int(cid))
- else:
- pass
- except BaseException:
- pass
+ except Exception as Ex:
+ LOGS.info(Ex)
await x.edit(get_string("bd_3").format(get_no_channels(), new))
return
if event.reply_to_msg_id:
@@ -73,11 +71,8 @@ async def broadcast_adder(event):
await event.delete()
return
chat_id = event.chat_id
- try:
- if int(chat_id) == int(udB.get("LOG_CHANNEL")):
- return
- except BaseException:
- pass
+ if int(chat_id) == int(udB.get("LOG_CHANNEL")):
+ return
if not is_channel_added(chat_id):
xx = add_channel(chat_id)
if xx:
@@ -133,7 +128,7 @@ async def list_all(event):
for channel in channels:
name = ""
try:
- name = (await ultroid.get_entity(int(channel))).title
+ name = (await event.client.get_entity(int(channel))).title
except BaseException:
name = ""
msg += f"=> **{name}** [`{channel}`]\n"
@@ -142,13 +137,11 @@ async def list_all(event):
MSG = msg.replace("*", "").replace("`", "")
with io.BytesIO(str.encode(MSG)) as out_file:
out_file.name = "channels.txt"
- await ultroid_bot.send_file(
- event.chat_id,
- out_file,
+ await event.reply(
+ "Channels in Database",
+ file=out_file,
force_document=True,
allow_cache=False,
- caption="Channels in database",
- reply_to=event,
)
await x.delete()
else:
@@ -161,8 +154,8 @@ async def list_all(event):
)
async def forw(event):
if not event.is_reply:
- await eor(event, "Reply to a message to broadcast.")
- return
+ return await eor(event, "Reply to a message to broadcast.")
+ ultroid_bot = event.client
channels = get_channels()
x = await eor(event, "Sending...")
if get_no_channels() == 0:
@@ -185,25 +178,23 @@ async def forw(event):
int(udB.get("LOG_CHANNEL")),
f"Error in sending at {channel}.",
)
- except BaseException:
- pass
+ except Exception as Em:
+ LOGS.info(Em)
error_count += 1
await x.edit(
f"Sent : {sent_count}\nError : {error_count}\nTotal : {len(channels)}",
)
await x.edit(f"{sent_count} messages sent with {error_count} errors.")
if error_count > 0:
- try:
- await ultroid_bot.send_message(
- int(udB.get("LOG_CHANNEL")), f"{error_count} Errors"
- )
- except BaseException:
- await x.edit("Set up log channel for checking errors.")
+ await ultroid_bot.send_message(
+ int(udB.get("LOG_CHANNEL")), f"{error_count} Errors"
+ )
@ultroid_cmd(
pattern="broadcast ?(.*)",
allow_sudo=False,
+ ignore_dualmode=True,
)
async def sending(event):
x = await eor(event, "`Processing...`")
@@ -228,23 +219,18 @@ async def sending(event):
f"Sent : {sent_count}\nError : {error_count}\nTotal : {len(channels)}",
)
except Exception as error:
- try:
- await ultroid_bot.send_message(
- int(udB.get("LOG_CHANNEL")),
- f"Error in sending at {channel}.\n\n{error}",
- )
- except BaseException:
- pass
+
+ await ultroid_bot.send_message(
+ int(udB.get("LOG_CHANNEL")),
+ f"Error in sending at {channel}.\n\n{error}",
+ )
error_count += 1
await x.edit(
f"Sent : {sent_count}\nError : {error_count}\nTotal : {len(channels)}",
)
await x.edit(f"{sent_count} messages sent with {error_count} errors.")
if error_count > 0:
- try:
- await ultroid_bot.send_message(
- int(udB.get("LOG_CHANNEL")),
- f"{error_count} Errors",
- )
- except BaseException:
- pass
+ await ultroid_bot.send_message(
+ int(udB.get("LOG_CHANNEL")),
+ f"{error_count} Errors",
+ )
diff --git a/plugins/calculator.py b/plugins/calculator.py
index 3199a8d6cb..3b515d5571 100644
--- a/plugins/calculator.py
+++ b/plugins/calculator.py
@@ -4,14 +4,12 @@
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# .
-
"""
✘ Commands Available -
•`{i}calc` - Inline Calculator
"""
-
import re
from . import *
@@ -20,7 +18,7 @@
@ultroid_cmd(pattern="calc")
async def icalc(e):
udB.delete("calc")
- results = await ultroid_bot.inline_query(asst.me.username, "calc")
+ results = await e.client.inline_query(asst.me.username, "calc")
await results[0].click(e.chat_id, silent=True, hide_via=True)
await e.delete()
diff --git a/plugins/carbon.py b/plugins/carbon.py
index 3472849042..7dab031cc8 100644
--- a/plugins/carbon.py
+++ b/plugins/carbon.py
@@ -4,7 +4,6 @@
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# .
-
"""
✘ Commands Available -
@@ -14,7 +13,6 @@
• `{i}rcarbon `
Carbonise the text, with random bg colours.
"""
-
import random
import requests
@@ -182,7 +180,7 @@ async def crbn(event):
if event.reply_to_msg_id:
temp = await event.get_reply_message()
if temp.media:
- b = await ultroid_bot.download_media(temp)
+ b = await event.client.download_media(temp)
a = open(b)
code = a.read()
a.close()
@@ -199,10 +197,9 @@ async def crbn(event):
carbon = Carbon(base_url="https://carbonara.vercel.app/api/cook", code=code)
xx = await carbon.memorize("ultroid_carbon")
await xxxx.delete()
- await ultroid_bot.send_file(
- event.chat_id,
- xx,
- caption=f"Carbonised by [{OWNER_NAME}](tg://user?id={OWNER_ID})",
+ await event.reply(
+ f"Carbonised by {inline_mention(event.sender)}",
+ file=xx,
)
@@ -214,7 +211,7 @@ async def crbn(event):
if event.reply_to_msg_id:
temp = await event.get_reply_message()
if temp.media:
- b = await ultroid_bot.download_media(temp)
+ b = await event.client.download_media(temp)
a = open(b)
code = a.read()
a.close()
@@ -234,8 +231,7 @@ async def crbn(event):
)
xx = await carbon.memorize("ultroid_carbon")
await xxxx.delete()
- await ultroid_bot.send_file(
- event.chat_id,
- xx,
- caption=f"Carbonised by [{OWNER_NAME}](tg://user?id={OWNER_ID})",
+ await event.reply(
+ f"Carbonised by {inline_mention(event.sender)}",
+ file=xx,
)
diff --git a/plugins/channelhacks.py b/plugins/channelhacks.py
index 2ca35f9904..af6f04f111 100644
--- a/plugins/channelhacks.py
+++ b/plugins/channelhacks.py
@@ -73,7 +73,7 @@ async def _(e):
c = int(a)
except Exception:
try:
- c = (await ultroid_bot.get_entity(a)).id
+ c = (await e.client.get_entity(a)).id
except Exception:
await z.edit("invalid Channel given")
return
@@ -81,14 +81,14 @@ async def _(e):
d = int(b)
except Exception:
try:
- d = (await ultroid_bot.get_entity(b)).id
+ d = (await e.client.get_entity(b)).id
except Exception:
await z.edit("invalid Channel given")
return
- async for msg in ultroid_bot.iter_messages(int(c), reverse=True):
+ async for msg in e.client.iter_messages(int(c), reverse=True):
try:
await asyncio.sleep(2)
- await ultroid_bot.send_message(int(d), msg)
+ await e.client.send_message(int(d), msg)
except BaseException:
pass
await z.edit("Done")
@@ -115,7 +115,7 @@ async def source(e):
@ultroid_cmd(pattern="dsource ?(.*)")
async def dd(event):
chat_id = event.pattern_match.group(1)
- x = await eor(event, "processing")
+ x = await eor(event, "`Processing..`")
if chat_id == "all":
await x.edit("`Removing...`")
udB.delete("CH_SOURCE")
@@ -125,24 +125,18 @@ async def dd(event):
y = int(chat_id)
except Exception:
try:
- y = int((await bot.get_entity(chat_id)).id)
+ y = int((await event.client.get_entity(chat_id)).id)
except Exception as es:
print(es)
return
if is_source_channel_added(y):
rem_source_channel(y)
- await x.edit("Source removed from database")
- await asyncio.sleep(3)
- await x.delete()
+ await eod(x, "Source removed from database", time=3)
elif is_source_channel_added(y):
rem_source_channel(y)
- await x.edit("Source removed from database")
- await asyncio.sleep(3)
- await x.delete()
+ await eod(x, "Source removed from database")
elif not is_source_channel_added(y):
- await x.edit("Source channel is already removed from database. ")
- await asyncio.sleep(3)
- await x.delete()
+ await eod(x, "Source channel is already removed from database. ", time=3)
@ultroid_cmd(pattern="listsource")
@@ -156,7 +150,7 @@ async def list_all(event):
for channel in channels:
name = ""
try:
- name = (await ultroid.get_entity(int(channel))).title
+ name = (await event.client.get_entity(int(channel))).title
except BaseException:
name = ""
msg += f"=> **{name}** [`{channel}`]\n"
@@ -165,7 +159,7 @@ async def list_all(event):
MSG = msg.replace("*", "").replace("`", "")
with io.BytesIO(str.encode(MSG)) as out_file:
out_file.name = "channels.txt"
- await ultroid_bot.send_file(
+ await event.client.send_file(
event.chat_id,
out_file,
force_document=True,
@@ -185,7 +179,7 @@ async def destination(e):
y = int(x)
except Exception:
try:
- y = int((await bot.get_entity(x)).id)
+ y = int((await e.client.get_entity(x)).id)
except Exception as es:
print(es)
return
@@ -209,28 +203,23 @@ async def dd(event):
y = int(chat_id)
except Exception:
try:
- y = int((await bot.get_entity(chat_id)).id)
+ y = int((await event.client.get_entity(chat_id)).id)
except Exception as es:
print(es)
return
if is_destination_added(y):
rem_destination(y)
- await x.edit("Destination removed from database")
- await asyncio.sleep(3)
- await x.delete()
+ await eor(x, "Destination removed from database")
elif is_destination_added(y):
rem_destination(y)
- await x.edit("Destination removed from database")
- await asyncio.sleep(3)
- await x.delete()
+ await eod(x, "Destination removed from database")
elif not is_destination_added(y):
- await x.edit("Destination channel is already removed from database. ")
- await asyncio.sleep(3)
- await x.delete()
+ await eod(x, "Destination channel is already removed from database. ")
@ultroid_cmd(pattern="listdest")
async def list_all(event):
+ ultroid_bot = event.client
x = await eor(event, "`Calculating...`")
channels = get_destinations()
num = get_no_destinations()
diff --git a/plugins/chat_bot.py b/plugins/chat_bot.py
new file mode 100644
index 0000000000..0b7a660ab9
--- /dev/null
+++ b/plugins/chat_bot.py
@@ -0,0 +1,88 @@
+# Ultroid - UserBot
+# Copyright (C) 2020 TeamUltroid
+#
+# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
+# PLease read the GNU Affero General Public License in
+# .
+
+"""
+✘ Commands Available -
+
+• `{i}addai `
+ Add a AI ChatBot to reply to that user.
+
+• `{i}remai `
+ Remove the AI ChatBot.
+
+• `{i}repai `
+ Reply to the user with a message by an AI.
+
+• `{i}listai`
+ List the currently AI added users.
+"""
+
+from pyUltroid.functions.all import get_chatbot_reply
+from pyUltroid.functions.chatBot_db import *
+
+
+@ultroid_cmd(pattern="repai")
+async def im_lonely_chat_with_me(event):
+ if event.reply_to_msg_id:
+ message = (await event.get_reply_message()).message
+ else:
+ try:
+ message = event.text.split(" ", 1)[1]
+ except IndexError:
+ return await eod(
+ event, "Give a message or Reply to a User's Message.", time=10
+ )
+ reply_ = get_chatbot_reply(event, message=message)
+ await eor(event, reply_)
+
+
+@ultroid_cmd(pattern="addai")
+async def add_chatBot(event):
+ await chat_bot_fn(event, type_="add")
+
+
+@ultroid_cmd(pattern="remai")
+async def rem_chatBot(event):
+ await chat_bot_fn(event, type_="remov")
+
+
+@ultroid_cmd(pattern="listai")
+async def lister(event):
+ users = get_all_added()
+ if udB.get("CHATBOT_USERS") is None:
+ return await eod(event, "`No user has AI added.`")
+ msg = ""
+ for i in users:
+ try:
+ user = await event.client.get_entity(int(i))
+ user = inline_mention(user)
+ except BaseException:
+ user = f"`{i}`"
+ msg += "- {}\n".format(user)
+ await eor(event, msg, link_preview=False)
+
+
+async def chat_bot_fn(event, type_):
+ if event.reply_to_msg_id:
+ user = (await event.get_reply_message()).sender
+ else:
+ temp = event.text.split(" ", 1)
+ try:
+ usr = temp[1]
+ except IndexError:
+ return await eod(
+ event,
+ "Reply to a user or give me his id/username to add an AI ChatBot!",
+ )
+ user = await event.client.get_entity(usr)
+ if type_ == "add":
+ add_chatbot(user.id)
+ if type_ == "remov":
+ rem_chatbot(user.id)
+ await eor(
+ event, f"**ChatBot:**\n{type_}ed [{user.first_name}](tg://user?id={user.id})`"
+ )
diff --git a/plugins/chats.py b/plugins/chats.py
index f72d06af52..c35438f293 100644
--- a/plugins/chats.py
+++ b/plugins/chats.py
@@ -53,6 +53,8 @@ async def _(e):
@ultroid_cmd(
pattern="getlink$",
groups_only=True,
+ type=["official", "manager"],
+ ignore_dualmode=True,
)
async def _(e):
xx = await eor(e, "`Processing...`")
diff --git a/plugins/clean_action.py b/plugins/clean_action.py
index 34cbef4481..e3e8dbf65c 100644
--- a/plugins/clean_action.py
+++ b/plugins/clean_action.py
@@ -28,9 +28,6 @@
async def _(e):
add_clean(e.chat_id)
await eod(e, "Added Clean Action Setting For this Chat")
- async for x in ultroid_bot.iter_messages(e.chat_id, limit=3000):
- if x.action:
- await x.delete()
@ultroid_cmd(pattern="remclean$")
@@ -47,19 +44,10 @@ async def _(e):
o = ""
for x in k:
try:
- title = (await ultroid_bot.get_entity(int(x))).title
+ title = e.chat.title
except BaseException:
title = "`Invalid ID`"
o += x + " " + title + "\n"
await eor(e, o)
else:
await eod(e, "`No Chat Added`")
-
-
-@ultroid_bot.on(events.ChatAction())
-async def _(event):
- if is_clean_added(event.chat_id):
- try:
- await event.delete()
- except BaseException:
- pass
diff --git a/plugins/compressor.py b/plugins/compressor.py
index dcc9e4eda8..d99ccb8d0c 100644
--- a/plugins/compressor.py
+++ b/plugins/compressor.py
@@ -10,7 +10,7 @@
• `{i}compress `
optional `crf` and `stream`
- Example : `{i}compress 27 | stream` or `{i}compress 28`
+ Example : `{i}compress 27 stream` or `{i}compress 28`
Encode the replied video according to CRF value.
Less CRF == High Quality, More Size
More CRF == Low Quality, Less Size
@@ -33,12 +33,18 @@
from . import *
-@ultroid_cmd(pattern="compress ?((\\d+)(.*)|$)")
+@ultroid_cmd(pattern="compress ?(.*)")
async def _(e):
- crf = e.pattern_match.group(1)
- if not crf:
- crf = 27
- to_stream = e.pattern_match.group(2)
+ cr = e.pattern_match.group(1)
+ crf = 27
+ to_stream = False
+ if cr:
+ k = e.text.split()
+ if len(k) == 2:
+ crf = int(k[1]) if k[1].isdigit() else 27
+ elif len(k) > 2:
+ crf = int(k[1]) if k[1].isdigit() else 27
+ to_stream = True if "stream" in k[2] else False
vido = await e.get_reply_message()
if vido and vido.media:
if "video" in mediainfo(vido.media):
@@ -63,7 +69,7 @@ async def _(e):
d_time = time.time()
diff = time_formatter((d_time - c_time) * 1000)
file_name = (file.name).split("/")[-1]
- out = file_name.replace(file_name.split(".")[-1], " compressed.mkv")
+ out = file_name.replace(file_name.split(".")[-1], "compressed.mkv")
await xxx.edit(
f"`Downloaded {file.name} of {humanbytes(o_size)} in {diff}.\nNow Compressing...`"
)
@@ -93,16 +99,17 @@ async def _(e):
per = elapse * 100 / int(total_frames)
time_diff = time.time() - int(d_time)
speed = round(elapse / time_diff, 2)
- eta = time_formatter(
- ((int(total_frames) - elapse) / speed) * 1000
- )
+ some_eta = ((int(total_frames) - elapse) / speed) * 1000
text = f"`Compressing {file_name} at {crf} CRF.\n`"
progress_str = "`[{0}{1}] {2}%\n\n`".format(
"".join(["●" for i in range(math.floor(per / 5))]),
"".join(["" for i in range(20 - math.floor(per / 5))]),
round(per, 2),
)
- e_size = humanbytes(size)
+ e_size = (
+ humanbytes(size) + " of ~" + humanbytes((size / per) * 100)
+ )
+ eta = "~" + time_formatter(some_eta)
try:
await xxx.edit(
text
@@ -135,7 +142,7 @@ async def _(e):
xxx,
"Uploading " + out + "...",
)
- if to_stream and "| stream" in to_stream:
+ if to_stream:
metadata = extractMetadata(createParser(out))
duration = metadata.get("duration").seconds
hi, _ = await bash(f'mediainfo "{out}" | grep "Height"')
diff --git a/plugins/converter.py b/plugins/converter.py
index cb3e1db4dd..975f219a03 100644
--- a/plugins/converter.py
+++ b/plugins/converter.py
@@ -4,7 +4,6 @@
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# .
-
"""
✘ Commands Available -
@@ -27,7 +26,6 @@
• `{i}thumbnail `
Upload Your file with your custom thumbnail.
"""
-
import os
import time
@@ -51,10 +49,10 @@ async def _(e):
if not r:
return await eor(e, pop)
if isinstance(r.media, photu):
- dl = await ultroid_bot.download_media(r.media)
+ dl = await e.client.download_media(r.media)
elif isinstance(r.media, doc):
if r.media.document.thumbs:
- dl = await ultroid_bot.download_media(r, thumb=-1)
+ dl = await e.client.download_media(r, thumb=-1)
else:
return await eor(e, pop)
variable = uf(dl)
@@ -76,7 +74,7 @@ async def imak(event):
return
inp = event.pattern_match.group(1)
if not inp:
- await eor(event, "Give The name nd extension of file")
+ await eor(event, "Give The name and extension of file")
return
xx = await eor(event, "`Processing...`")
if reply.media:
@@ -91,13 +89,11 @@ async def imak(event):
os.rename(file, inp)
k = time.time()
xxx = await uploader(inp, inp, k, xx, "Uploading...")
- await ultroid_bot.send_file(
- event.chat_id,
- xxx,
+ await event.reply(
+ f"`{xxx.name}`",
+ file=xxx,
force_document=True,
thumb="resources/extras/ultroid.jpg",
- caption=f"`{xxx.name}`",
- reply_to=reply,
)
os.remove(inp)
await xx.delete()
@@ -112,7 +108,7 @@ async def imak(event):
await eor(event, "Reply to any media.")
return
xx = await eor(event, "`Processing...`")
- image = await ultroid_bot.download_media(reply)
+ image = await reply.download_media()
file = "ult.png"
if image.endswith((".webp", ".png")):
c = Image.open(image)
@@ -121,7 +117,7 @@ async def imak(event):
img = cv2.VideoCapture(image)
ult, roid = img.read()
cv2.imwrite(file, roid)
- await ultroid_bot.send_file(event.chat_id, file, reply_to=reply)
+ await event.reply(file=file)
await xx.delete()
os.remove(file)
os.remove(image)
@@ -136,7 +132,7 @@ async def smak(event):
await eor(event, "Reply to any media.")
return
xx = await eor(event, "`Processing...`")
- image = await ultroid_bot.download_media(reply)
+ image = await reply.download_media()
file = "ult.webp"
if image.endswith((".webp", ".png", ".jpg")):
c = Image.open(image)
@@ -145,7 +141,7 @@ async def smak(event):
img = cv2.VideoCapture(image)
ult, roid = img.read()
cv2.imwrite(file, roid)
- await ultroid_bot.send_file(event.chat_id, file, reply_to=reply)
+ await event.reply(file=file)
await xx.delete()
os.remove(file)
os.remove(image)
@@ -157,7 +153,7 @@ async def smak(event):
async def _(event):
input_str = event.pattern_match.group(1)
if not input_str:
- return await eod(event, "`Bsdk Give Name.`")
+ return await eod(event, "`Give The File Name.`")
xx = await eor(event, get_string("com_1"))
if event.reply_to_msg_id:
a = await event.get_reply_message()
@@ -168,9 +164,7 @@ async def _(event):
b.write(str(a.message))
b.close()
await xx.edit(f"**Packing into** `{input_str}`")
- await event.client.send_file(
- event.chat_id, input_str, thumb="resources/extras/ultroid.jpg"
- )
+ await event.reply(file=input_str, thumb="resources/extras/ultroid.jpg")
await xx.delete()
os.remove(input_str)
@@ -198,12 +192,8 @@ async def _(event):
await xx.edit(
f"**MESSAGE EXCEEDS TELEGRAM LIMITS**\n\nSo Pasted It On [NEKOBIN](https://nekobin.com/{key})"
)
- elif "dog" in what:
- await xx.edit(
- f"**MESSAGE EXCEEDS TELEGRAM LIMITS**\n\nSo Pasted It On [DOGBIN](https://del.dog/{key})"
- )
os.remove(b)
else:
- return await eod(xx, "`Reply to a readable file`", time=5)
+ return await eod(xx, "`Reply to a readable file`")
else:
- return await eod(xx, "`Reply to a readable file`", time=5)
+ return await eod(xx, "`Reply to a readable file`")
diff --git a/plugins/deezer.py b/plugins/deezer.py
index ac02344254..8ee9f10a24 100644
--- a/plugins/deezer.py
+++ b/plugins/deezer.py
@@ -4,7 +4,6 @@
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# .
-
"""
✘ Commands Available -
@@ -14,7 +13,6 @@
import os
import time
from json.decoder import JSONDecodeError
-from urllib.request import urlretrieve
import requests as r
from telethon.tl.types import DocumentAttributeAudio
@@ -56,8 +54,8 @@ async def siesace(e):
singers = k["artist"]["name"]
except Exception as ex:
return await eod(lol, f"`{str(ex)}`")
- urlretrieve(urrl, title + "." + quality)
- urlretrieve(img, title + ".jpg")
+ await download_file(urrl, title + "." + quality)
+ await download_file(img, title + ".jpg")
okk = await uploader(
title + "." + quality,
title + "." + quality,
@@ -65,10 +63,9 @@ async def siesace(e):
lol,
"Uploading " + title + "...",
)
- await ultroid_bot.send_file(
- e.chat_id,
- okk,
- caption="`" + title + "`" + "\n`From Deezer`",
+ await e.reply(
+ "`" + title + "`" + "\n`From Deezer`",
+ file=okk,
attributes=[
DocumentAttributeAudio(
duration=int(duration),
diff --git a/plugins/devtools.py b/plugins/devtools.py
index 8c15911222..dce9cca4ad 100644
--- a/plugins/devtools.py
+++ b/plugins/devtools.py
@@ -4,7 +4,6 @@
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# .
-
"""
✘ Commands Available -
@@ -27,6 +26,7 @@
import sys
import traceback
from os import remove
+from pprint import pprint
from carbonnow import Carbon
@@ -43,7 +43,7 @@ async def _(e):
p = (neo.read()).replace("\n\n", "")
ok = Carbon(base_url="https://carbonara.vercel.app/api/cook", code=p)
haa = await ok.save("neofetch")
- await e.client.send_file(e.chat_id, haa)
+ await e.reply(file=haa)
await xx.delete()
remove("neofetch.jpg")
remove("neo.txt")
@@ -89,7 +89,7 @@ async def _(event):
force_document=True,
thumb="resources/extras/ultroid.jpg",
allow_cache=False,
- caption=f"`{cmd}`",
+ caption=f"`{cmd}`" if (len(cmd) + 2) < 1000 else None,
reply_to=reply_to_id,
)
await xx.delete()
@@ -97,7 +97,7 @@ async def _(event):
await xx.edit(OUT)
-p = print # ignore: pylint
+p, pp = print, pprint # ignore: pylint
@ultroid_cmd(
@@ -155,7 +155,7 @@ async def _(event):
ultd = final_output.replace("`", "").replace("*", "").replace("_", "")
with io.BytesIO(str.encode(ultd)) as out_file:
out_file.name = "eval.txt"
- await ultroid_bot.send_file(
+ await event.client.send_file(
event.chat_id,
out_file,
force_document=True,
@@ -174,7 +174,7 @@ async def aexec(code, event):
f"async def __aexec(e, client): "
+ "\n message = event = e"
+ "\n reply = await event.get_reply_message()"
- + "\n chat = e.chat_id"
+ + "\n chat = (await event.get_chat()).id"
+ "".join(f"\n {l}" for l in code.split("\n")),
)
diff --git a/plugins/dm.py b/plugins/dm.py
index 8f5cf026ff..09f96b9f6a 100644
--- a/plugins/dm.py
+++ b/plugins/dm.py
@@ -10,7 +10,6 @@
• `{i}dm `
Direct Message the User.
"""
-
from . import *
@@ -26,22 +25,18 @@ async def dm(e):
try:
chat_id = await get_user_id(c[0])
except Exception as ex:
- return await eod(e, "`" + str(ex) + "`", time=5)
+ return await eod(e, "`" + str(ex) + "`")
msg = ""
masg = await e.get_reply_message()
if e.reply_to_msg_id:
- await ultroid_bot.send_message(chat_id, masg)
- await eod(e, "`⚜️Message Delivered!`", time=4)
+ await e.client.send_message(chat_id, masg)
+ await eod(e, "`⚜️Message Delivered!`")
for i in c[1:]:
msg += i + " "
if msg == "":
return
try:
- await ultroid_bot.send_message(chat_id, msg)
- await eod(e, "`⚜️Message Delivered!⚜️`", time=4)
+ await e.client.send_message(chat_id, msg)
+ await eod(e, "`⚜️Message Delivered!⚜️`")
except BaseException:
- await eod(
- e,
- "`{i}help dm`",
- time=4,
- )
+ await eod(e, f"Read Usage : `{HNDLR}help dm`")
diff --git a/plugins/download_upload.py b/plugins/download_upload.py
index a61233c1e3..7716f4b1f5 100644
--- a/plugins/download_upload.py
+++ b/plugins/download_upload.py
@@ -4,7 +4,6 @@
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# .
-
"""
✘ Commands Available -
@@ -19,7 +18,6 @@
Reply to file to download.
"""
-
import glob
import os
import time
@@ -118,39 +116,46 @@ async def download(event):
for kk in kk:
try:
try:
- res = await uploader(kk, kk, tt, xx, "Uploading...")
+ res = await uploader(kk, kk, tt, xx, "Uploading {kk}...")
except MessageNotModifiedError as err:
return await xx.edit(str(err))
title = kk.split("/")[-1]
- if title.endswith((".mp3", ".m4a", ".opus", ".ogg")):
+ if title.endswith((".mp3", ".m4a", ".opus", ".ogg", ".flac")):
hmm = " | stream"
if " | stream" in hmm:
metadata = extractMetadata(createParser(res.name))
- if not metadata:
- return await event.reply(file=res, supports_streaming=True)
wi = 512
hi = 512
duration = 0
- if metadata.has("width"):
- wi = metadata.get("width")
- if metadata.has("height"):
- hi = metadata.get("height")
- if metadata.has("duration"):
- duration = metadata.get("duration").seconds
- if metadata.has("artist"):
- artist = metadata.get("artist")
- else:
- if udB.get("artist"):
- artist = udB.get("artist")
+ artist = ""
+ try:
+ if metadata.has("width"):
+ wi = metadata.get("width")
+ if metadata.has("height"):
+ hi = metadata.get("height")
+ if metadata.has("duration"):
+ duration = metadata.get("duration").seconds
+ if metadata.has("artist"):
+ artist = metadata.get("artist")
else:
- artist = ultroid_bot.first_name
- if res.name.endswith(tuple([".mkv", ".mp4", ".avi"])):
+ if udB.get("artist"):
+ artist = udB.get("artist")
+ else:
+ artist = ultroid_bot.first_name
+ except AttributeError:
+ return await event.client.send_file(
+ event.chat_id,
+ res,
+ caption=f"`{kk}/{title}`",
+ supports_streaming=True,
+ )
+ if res.name.endswith((".mkv", ".mp4", ".avi")):
attributes = [
DocumentAttributeVideo(
w=wi, h=hi, duration=duration, supports_streaming=True
)
]
- elif res.name.endswith(tuple([".mp3", ".m4a", ".opus", ".ogg"])):
+ elif res.name.endswith((".mp3", ".m4a", ".opus", ".ogg", ".flac")):
attributes = [
DocumentAttributeAudio(
duration=duration,
@@ -161,26 +166,26 @@ async def download(event):
else:
attributes = None
try:
- x = await event.client.send_file(
+ await event.client.send_file(
event.chat_id,
res,
- caption=f"`{title}`",
+ caption=f"`{kk}`",
attributes=attributes,
supports_streaming=True,
thumb="resources/extras/ultroid.jpg",
)
except BaseException:
- x = await event.client.send_file(
+ await event.client.send_file(
event.chat_id,
res,
- caption=f"`{title}`",
+ caption=f"`{kk}`",
thumb="resources/extras/ultroid.jpg",
)
else:
- x = await event.client.send_file(
+ await event.client.send_file(
event.chat_id,
res,
- caption=f"`{title}`",
+ caption=f"`{kk}`",
force_document=True,
thumb="resources/extras/ultroid.jpg",
)
@@ -189,36 +194,45 @@ async def download(event):
else:
try:
try:
- res = await uploader(kk, kk, tt, xx, "Uploading...")
+ res = await uploader(kk, kk, tt, xx, f"Uploading {kk}...")
except MessageNotModifiedError as err:
return await xx.edit(str(err))
- if title.endswith((".mp3", ".m4a", ".opus", ".ogg")):
+ if title.endswith((".mp3", ".m4a", ".opus", ".ogg", ".flac")):
hmm = " | stream"
if " | stream" in hmm:
metadata = extractMetadata(createParser(res.name))
wi = 512
hi = 512
duration = 0
- if metadata.has("width"):
- wi = metadata.get("width")
- if metadata.has("height"):
- hi = metadata.get("height")
- if metadata.has("duration"):
- duration = metadata.get("duration").seconds
- if metadata.has("artist"):
- artist = metadata.get("artist")
- else:
- if udB.get("artist"):
- artist = udB.get("artist")
+ artist = ""
+ try:
+ if metadata.has("width"):
+ wi = metadata.get("width")
+ if metadata.has("height"):
+ hi = metadata.get("height")
+ if metadata.has("duration"):
+ duration = metadata.get("duration").seconds
+ if metadata.has("artist"):
+ artist = metadata.get("artist")
else:
- artist = ultroid_bot.first_name
- if res.name.endswith(tuple([".mkv", ".mp4", ".avi"])):
+ if udB.get("artist"):
+ artist = udB.get("artist")
+ else:
+ artist = ultroid_bot.first_name
+ except AttributeError:
+ await event.client.send_file(
+ event.chat_id,
+ res,
+ caption=f"`{title}`",
+ supports_streaming=True,
+ )
+ if res.name.endswith((".mkv", ".mp4", ".avi")):
attributes = [
DocumentAttributeVideo(
w=wi, h=hi, duration=duration, supports_streaming=True
)
]
- elif res.name.endswith(tuple([".mp3", ".m4a", ".opus", ".ogg"])):
+ elif res.name.endswith((".mp3", ".m4a", ".opus", ".ogg", ".flac")):
attributes = [
DocumentAttributeAudio(
duration=duration,
@@ -229,7 +243,7 @@ async def download(event):
else:
attributes = None
try:
- x = await event.client.send_file(
+ await event.client.send_file(
event.chat_id,
res,
caption=f"`{title}`",
@@ -238,7 +252,7 @@ async def download(event):
thumb="resources/extras/ultroid.jpg",
)
except BaseException:
- x = await event.client.send_file(
+ await event.client.send_file(
event.chat_id,
res,
caption=f"`{title}`",
@@ -246,7 +260,7 @@ async def download(event):
thumb="resources/extras/ultroid.jpg",
)
else:
- x = await event.client.send_file(
+ await event.client.send_file(
event.chat_id,
res,
caption=f"`{title}`",
@@ -266,7 +280,7 @@ async def download(event):
size += os.path.getsize(fp)
c = len(os.listdir(kk))
await xx.delete()
- await ultroid_bot.send_message(
+ await event.client.send_message(
event.chat_id,
f"Uploaded Total - `{c}` files of `{humanbytes(size)}` in `{t}`",
)
diff --git a/plugins/echo.py b/plugins/echo.py
index 2ed67357bf..c98e797d23 100644
--- a/plugins/echo.py
+++ b/plugins/echo.py
@@ -34,7 +34,7 @@ async def echo(e):
try:
user = e.text.split()[1]
if user.startswith("@"):
- ok = await ultroid_bot.get_entity(user)
+ ok = await e.client.get_entity(user)
user = ok.id
else:
user = int(user)
@@ -43,7 +43,7 @@ async def echo(e):
if check_echo(e.chat_id, user):
return await eod(e, "Echo already activated for this user.")
add_echo(e.chat_id, user)
- ok = await ultroid_bot.get_entity(user)
+ ok = await e.client.get_entity(user)
user = f"[{get_display_name(ok)}](tg://user?id={ok.id})"
await eor(e, f"Activated Echo For {user}.")
@@ -57,7 +57,7 @@ async def rm(e):
try:
user = e.text.split()[1]
if user.startswith("@"):
- ok = await ultroid_bot.get_entity(user)
+ ok = await e.client.get_entity(user)
user = ok.id
else:
user = int(user)
@@ -65,7 +65,7 @@ async def rm(e):
return await eod(e, "Reply To A User.")
if check_echo(e.chat_id, user):
rem_echo(e.chat_id, user)
- ok = await ultroid_bot.get_entity(user)
+ ok = await e.client.get_entity(user)
user = f"[{get_display_name(ok)}](tg://user?id={ok.id})"
return await eor(e, f"Deactivated Echo For {user}.")
await eor(e, "Echo not activated for this user")
@@ -75,8 +75,8 @@ async def rm(e):
async def okk(e):
if check_echo(e.chat_id, e.sender_id):
try:
- ok = await bot.get_messages(e.chat_id, ids=e.id)
- return await ultroid_bot.send_message(e.chat_id, ok)
+ ok = await e.client.get_messages(e.chat_id, ids=e.id)
+ return await e.client.send_message(e.chat_id, ok)
except Exception as er:
LOGS.info(er)
@@ -87,7 +87,7 @@ async def lstecho(e):
if k:
user = "**Activated Echo For Users:**\n\n"
for x in k:
- ok = await ultroid_bot.get_entity(int(x))
+ ok = await e.client.get_entity(int(x))
kk = f"[{get_display_name(ok)}](tg://user?id={ok.id})"
user += "•" + kk + "\n"
await eor(e, user)
diff --git a/plugins/evaljs.py b/plugins/evaljs.py
index 828c42020f..e17131a857 100644
--- a/plugins/evaljs.py
+++ b/plugins/evaljs.py
@@ -4,22 +4,20 @@
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# .
-
"""
✘ Commands Available -
• `{i}evaljs `
Evaluate JavaScript code and upload.
"""
-
# Inbuilt
import os
import time
from threading import Thread
-# Ultroid
from . import *
+# Ultroid
async def evalJs(
event,
startTime: float,
@@ -34,14 +32,14 @@ async def evalJs(
scriptFile.close()
os.system(f"node ./src/ecmaHelper/eval.d.js")
if os.path.exists("./src/ecmaHelper/evalJs.result.d.txt"):
- await ultroid_bot.send_file(
+ await event.client.send_file(
event.chat_id,
"./src/ecmaHelper/evalJs.result.d.txt",
force_document=True,
caption=f"**☞ evalJS\n\n• Command:**\n`{command}` \n\n**• TimeTaken:**\n`{time.time() - startTime:.2f}s` \n\n**• Result:**\n`[Info]: Uploaded File For Better Visualisation Of Indents.`",
)
else:
- await ultroid_bot.send_file(
+ await event.client.send_file(
event.chat_id,
"./src/ecmaHelper/evalJs.result.d.txt",
force_document=True,
diff --git a/plugins/extra.py b/plugins/extra.py
index 5f962fbbf3..1af8c0d96d 100644
--- a/plugins/extra.py
+++ b/plugins/extra.py
@@ -4,7 +4,6 @@
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# .
-
"""
✘ Commands Available -
@@ -20,7 +19,6 @@
• `{i}reply`
Reply the last sent msg to replied user.
"""
-
import asyncio
from telethon.events import NewMessage as NewMsg
@@ -51,11 +49,7 @@ async def delete_it(delme):
await msg_src.delete()
await delme.delete()
except Exception as e:
- await eod(
- delme,
- f"Couldn't delete the message.\n\n**ERROR:**\n`{str(e)}`",
- time=5,
- )
+ await eod(delme, f"Couldn't delete the message.\n\n**ERROR:**\n`{str(e)}`")
@ultroid_cmd(
@@ -68,7 +62,7 @@ async def copy(e):
await eor(e, reply.text)
else:
await reply.reply(reply)
- if e.sender_id == ultroid_bot.uid:
+ if e.out:
await e.delete()
else:
await eod(e, "`Reply To any message`")
@@ -90,7 +84,7 @@ async def editer(edit):
pass
else:
i = 1
- async for message in ultroid_bot.iter_messages(chat, ultroid_bot.uid):
+ async for message in edit.client.iter_messages(chat, ultroid_bot.uid):
if i == 2:
await message.edit(string)
await edit.delete()
diff --git a/plugins/fakeaction.py b/plugins/fakeaction.py
index e7a65d7d58..ab64e48371 100644
--- a/plugins/fakeaction.py
+++ b/plugins/fakeaction.py
@@ -19,6 +19,9 @@
• `{i}fgame