diff --git a/Dockerfile b/Dockerfile
index 1551f040c5105df7f433f26bd3ba68d88abf7f03..b0d5e862b10b80f605b143800edc23da98fcf97d 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -14,6 +14,9 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
&& pip3 install --no-cache-dir -r root/TeamUltroid/requirements.txt \
&& pip3 install av --no-binary av
+# Railway's banned dependency
+RUN if [ ! $RAILWAY_STATIC_URL ]; then pip3 install --no-cache-dir yt-dlp; fi
+
# changing workdir
WORKDIR /root/TeamUltroid/
diff --git a/README.md b/README.md
index bde616148b8264162a99088359e9f3c91668b080..ff133fae3aa548fb32e532e6cc631d19beb18a8a 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@
[](https://github.com/TeamUltroid/Ultroid/stargazers)
[](https://github.com/TeamUltroid/Ultroid/fork)
[](https://github.com/TeamUltroid/Ultroid/)
-[](https://www.python.org/)
+[](https://www.python.org/)
[](https://www.codefactor.io/repository/github/teamultroid/ultroid/overview/main)
[](https://github.com/TeamUltroid/Ultroid/graphs/commit-activity)
[](https://img.shields.io/docker/pulls/theteamultroid/ultroid?style=flat-square)
@@ -46,9 +46,9 @@ Get the [Necessary Variables](#Necessary-Variables) and then click the button be
- [Ultroid CLI](#Ultroid-CLI)
### Local Deploy - Easy Method
-- Linux - `bash -c "$(curl -fsSL https://git.io/JY9UM)"`
+- Linux - `wget -O locals.py https://git.io/JY9UM && python3 locals.py`
- Windows - `cd desktop ; wget https://git.io/JY9UM -o locals.py ; python locals.py`
-- Termux - `sh -c "$(curl -fsSL https://git.io/JY9UM)"`
+- Termux - `wget -O locals.py https://git.io/JY9UM && python locals.py`
### Local Deploy - Traditional Method
- Get your [Necessary Variables](#Necessary-Variables)
@@ -66,9 +66,9 @@ Get the [Necessary Variables](#Necessary-Variables) and then click the button be
- For Linux users:
`bash sessiongen`
or
- `bash -c "$(curl -fsSL https://git.io/JY9JI)"`
+ `wget -O session.py https://git.io/JY9JI && python3 session.py`
- For Termux users:
- `sh -c "$(curl -fsSL https://git.io/JqgsR)"`
+ `wget -O session.py https://git.io/JY9JI && python session.py`
- For Windows Users:
`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).
@@ -94,15 +94,22 @@ Take a look at the [`docs`](https://blue-devil1134.github.io/UltroidCli/) for mo
---
## Necessary Variables
- `SESSION` - SessionString for your accounts login session. Get it from [here](#Session-String)
-- `REDIS_URI` - Redis endpoint URL, from [redislabs](http://redislabs.com/), tutorial [here.](./resources/extras/redistut.md)
-- `REDIS_PASSWORD` - Redis endpoint Password, from [redislabs](http://redislabs.com/), tutorial [here.](./resources/extras/redistut.md)
+
+One of the following databases:
+- For **Redis** (tutorial [here](./resources/extras/redistut.md))
+ - `REDIS_URI` - Redis endpoint URL, from [redislabs](http://redislabs.com/).
+ - `REDIS_PASSWORD` - Redis endpoint Password, from [redislabs](http://redislabs.com/).
+- For **MONGODB**
+ - `MONGO_URI` - Get it from [mongodb](https://mongodb.com/atlas).
+- For **SQLDB**
+ - `DATABASE_URL`- Get it from [elephantsql](https://elephantsql.com).
## Session String
Different ways to get your `SESSION`:
* [](https://replit.com/@TeamUltroid/UltroidStringSession)
-* Linux : `bash -c "$(curl -fsSL https://git.io/JY9JI)"`
+* Linux : `wget -O session.py https://git.io/JY9JI && python3 session.py`
* PowerShell : `cd desktop ; wget https://git.io/JY9JI ; python ultroid.py`
-* Termux : `sh -c "$(curl -fsSL https://da.gd/termux-tel)"`
+* Termux : `wget -O session.py https://git.io/JY9JI && python session.py`
* TelegramBot : [@SessionGeneratorBot](https://t.me/SessionGeneratorBot)
---
diff --git a/assistant/callbackstuffs.py b/assistant/callbackstuffs.py
index 247954e5376e9e203c2b19ec1507093a3a3bc296..8a46411e2e3e8d6a90141155a645d03c83dbbb31 100644
--- a/assistant/callbackstuffs.py
+++ b/assistant/callbackstuffs.py
@@ -92,7 +92,7 @@ _buttons = {
[Button.inline("« Bᴀᴄᴋ", data="cbs_pmcstm")],
],
},
- "alabs_vcstm": {
+ "alvcstm": {
"text": f"Customise your {HNDLR}alive. Choose from the below options -",
"buttons": [
[Button.inline("Aʟɪᴠᴇ Tᴇxᴛ", data="abs_alvtx")],
diff --git a/assistant/games.py b/assistant/games.py
index 44cc823e42de67a4ded367d345726fa1356d7e00..1d140a4037316e52e8de3d7dcb6056209eb263f5 100644
--- a/assistant/games.py
+++ b/assistant/games.py
@@ -65,7 +65,7 @@ async def _akokk(e):
@callback(re.compile("aki_(.*)"), owner=True)
async def doai(e):
- adt = e.pattern_match.group(1).decode("utf-8")
+ adt = e.pattern_match.group(1).strip().decode("utf-8")
dt = adt.split("_")
ch = int(dt[0])
mid = int(dt[1])
@@ -156,10 +156,11 @@ CONGO_STICKER = [
"CAADAgADjAADECECEFZM-SrKO9GgAg",
"CAADAgADSwIAAj-VzArAzNCDiGWAHAI",
"CAADAgADhQADwZxgDIuMHR9IU10iAg",
+ "CAADAgADiwMAAsSraAuoe2BwYu1sdQI",
]
-@callback("delit")
+@callback("delit", owner=True)
async def delete_it(event):
await event.delete()
diff --git a/assistant/inlinestuff.py b/assistant/inlinestuff.py
index 0924203e4415a6367134716a43aea08c8df5e372..04e44aee2dc20aa1eb1ca6407d5773a6c05ca71f 100644
--- a/assistant/inlinestuff.py
+++ b/assistant/inlinestuff.py
@@ -124,17 +124,22 @@ async def _(e):
],
]
try:
- lnk = e.builder.article(
- title=f"Upload {filename}",
- text=f"**File:**\n{filename}",
- buttons=buttons,
- )
- except BaseException:
- lnk = e.builder.article(
- title="fl2lnk",
- text="File not found",
- )
- await e.answer([lnk], switch_pm="File to Link.", switch_pm_param="start")
+ lnk = [
+ await e.builder.article(
+ title=f"Upload {filename}",
+ text=f"**File:**\n{filename}",
+ buttons=buttons,
+ )
+ ]
+ except BaseException as er:
+ LOGS.exception(er)
+ lnk = [
+ await e.builder.article(
+ title="fl2lnk",
+ text="File not found",
+ )
+ ]
+ await e.answer(lnk, switch_pm="File to Link.", switch_pm_param="start")
@callback(
diff --git a/assistant/manager/_help.py b/assistant/manager/_help.py
index 3c127df7246b8e54bc8ced52d0f54b936d7adaa5..8169270fa5573c6086c0b686321d1fbf5b3bcbc1 100644
--- a/assistant/manager/_help.py
+++ b/assistant/manager/_help.py
@@ -130,5 +130,5 @@ async def home_aja(e):
@callback(re.compile("hlp_(.*)"))
async def do_something(event):
- match = event.pattern_match.group(1).decode("utf-8")
+ match = event.pattern_match.group(1).strip().decode("utf-8")
await event.edit(STRINGS[match], buttons=Button.inline("<< Back", "mnghome"))
diff --git a/assistant/manager/admins.py b/assistant/manager/admins.py
index c9a2dbdff961c63b4de375c3c432a922e03b7556..a96169d3ca8b9dd962aef976bb71a8d085b7dac9 100644
--- a/assistant/manager/admins.py
+++ b/assistant/manager/admins.py
@@ -22,7 +22,7 @@ async def dowj(e):
return await e.eor("Reply to a message...")
try:
await replied.delete()
- if e.pattern_match.group(1) == "kick":
+ if e.pattern_match.group(1).strip() == "kick":
await e.client.kick_participant(e.chat_id, user)
te = "Kicked"
else:
diff --git a/assistant/manager/misc.py b/assistant/manager/misc.py
index 24a44a5b7670e02cd3918df64fdf6322843da0d3..c36929a39e42034050a07bc255050ecf2a218b8a 100644
--- a/assistant/manager/misc.py
+++ b/assistant/manager/misc.py
@@ -22,9 +22,9 @@ async def dheh(e):
await e.client.send_message(e.chat_id, text, reply_to=ri)
-@asst_cmd(pattern="echo ?(.*)")
+@asst_cmd(pattern="echo( (.*)|$)")
async def oqha(e):
- match = e.pattern_match.group(1)
+ match = e.pattern_match.group(1).strip()
if match:
text = match
reply_to = e
diff --git a/assistant/manager/stickermanager.py b/assistant/manager/stickermanager.py
index 0e7f3d8885b43eaab30a9572ebb73f14c2d70c27..1a8995bee53f6342c69c318056fbd1b28b8edc32 100644
--- a/assistant/manager/stickermanager.py
+++ b/assistant/manager/stickermanager.py
@@ -8,7 +8,7 @@
import random
from pyUltroid.functions.misc import create_quotly
-from pyUltroid.functions.tools import resize_photo
+from pyUltroid.functions.tools import TgConverter
from telethon import errors
from telethon.errors.rpcerrorlist import StickersetInvalidError
from telethon.tl.functions.messages import GetStickerSetRequest as GetSticker
@@ -51,7 +51,7 @@ async def kang_cmd(ult):
elif reply.photo:
dl = await reply.download_media()
name = "sticker.webp"
- image = resize_photo(dl)
+ image = TgConverter.resize_photo_sticker(dl)
image.save(name, "WEBP")
elif reply.text:
dl = await create_quotly(reply)
diff --git a/assistant/start.py b/assistant/start.py
index 65d4650659f0587f50780d6c58efd0e0ab3c7097..d89bfad02aff74aec21317f9ab17aa03bfdc3c33 100644
--- a/assistant/start.py
+++ b/assistant/start.py
@@ -12,6 +12,7 @@ from pyUltroid.dB.asst_fns import *
from pyUltroid.functions.helper import inline_mention
from pyUltroid.misc import SUDO_M, owner_and_sudos
from telethon import Button, events
+from telethon.errors.rpcerrorlist import MessageDeleteForbiddenError
from telethon.utils import get_display_name
from strings.strings import get_string
@@ -77,12 +78,15 @@ async def own(event):
@callback("closeit")
async def closet(lol):
- await lol.delete()
+ try:
+ await lol.delete()
+ except MessageDeleteForbiddenError:
+ await lol.answer("MESSAGE_TOO_OLD", alert=True)
-@asst_cmd(pattern="start ?(.*)", forwards=False, func=lambda x: not x.is_group)
+@asst_cmd(pattern="start( (.*)|$)", forwards=False, func=lambda x: not x.is_group)
async def ultroid(event):
- args = event.pattern_match.group(1)
+ args = event.pattern_match.group(1).strip()
if not is_added(event.sender_id) and event.sender_id not in owner_and_sudos():
add_user(event.sender_id)
kak_uiw = udB.get_key("OFF_START_LOG")
diff --git a/assistant/ytdl.py b/assistant/ytdl.py
index 95ddf2ff57940039e15e6afec193074230850d59..acd54532fb12870525acb5f8639b3ca0a27048eb 100644
--- a/assistant/ytdl.py
+++ b/assistant/ytdl.py
@@ -13,7 +13,13 @@ try:
from PIL import Image
except ImportError:
Image = None
-from pyUltroid.functions.helper import bash, fast_download, numerize, time_formatter
+from pyUltroid.functions.helper import (
+ bash,
+ fast_download,
+ humanbytes,
+ numerize,
+ time_formatter,
+)
from pyUltroid.functions.ytdl import dler, get_buttons, get_formats
from telethon import Button
from telethon.errors.rpcerrorlist import FilePartLengthInvalidError, MediaEmptyError
@@ -52,7 +58,7 @@ async def _(event):
await event.answer([fuk])
return
results = []
- search = VideosSearch(string, limit=10)
+ search = VideosSearch(string, limit=50)
nub = search.result()
nibba = nub["result"]
for v in nibba:
@@ -70,12 +76,12 @@ async def _(event):
else "None"
)
thumb = f"https://i.ytimg.com/vi/{ids}/hqdefault.jpg"
- text = f"Title:- {title}\n"
- text += f"⏳ Duration:- {duration}
\n"
- text += f"👀 Views:- {views}
\n"
- text += f"🎙️ Publisher:- {publisher}
\n"
- text += f"🗓️ Published on:- {published_on}
\n"
- text += f"📝 Description:- {description}
"
+ text = f"**Title: [{title}]({link})**\n\n"
+ text += f"`Description: {description}\n\n"
+ text += f"「 Duration: {duration} 」\n"
+ text += f"「 Views: {views} 」\n"
+ text += f"「 Publisher: {publisher} 」\n"
+ text += f"「 Published on: {published_on} 」`"
desc = f"{title}\n{duration}"
file = wb(thumb, 0, "image/jpeg", [])
buttons = [
@@ -96,9 +102,7 @@ async def _(event):
),
],
]
- BACK_BUTTON.update(
- {ids: {"text": text, "buttons": buttons, "parse_mode": "html"}}
- )
+ BACK_BUTTON.update({ids: {"text": text, "buttons": buttons}})
results.append(
await event.builder.article(
type="photo",
@@ -108,7 +112,6 @@ async def _(event):
content=file,
text=text,
include_media=True,
- parse_mode="html",
buttons=buttons,
),
)
@@ -122,7 +125,7 @@ async def _(event):
owner=True,
)
async def _(e):
- _e = e.pattern_match.group(1).decode("UTF-8")
+ _e = e.pattern_match.group(1).strip().decode("UTF-8")
_lets_split = _e.split(":")
_ytdl_data = await dler(e, _yt_base_url + _lets_split[1])
_data = get_formats(_lets_split[0], _lets_split[1], _ytdl_data)
@@ -140,7 +143,7 @@ async def _(e):
owner=True,
)
async def _(event):
- url = event.pattern_match.group(1).decode("UTF-8")
+ url = event.pattern_match.group(1).strip().decode("UTF-8")
lets_split = url.split(":")
vid_id = lets_split[2]
link = _yt_base_url + vid_id
@@ -151,6 +154,7 @@ async def _(event):
ext = "mp3"
if lets_split[0] == "audio":
opts = {
+ "format": "bestaudio",
"addmetadata": True,
"key": "FFmpegMetadata",
"prefer_ffmpeg": True,
@@ -184,8 +188,12 @@ async def _(event):
else ytdl_data["description"][:100]
)
description = description or "None"
+ filepath = vid_id + f".{ext}"
+ if not os.path.exists(filepath):
+ filepath = filepath + f".{ext}"
+ size = os.path.getsize(filepath)
file, _ = await event.client.fast_uploader(
- vid_id + f".{ext}" * 2,
+ filepath,
filename=title + "." + ext,
show_progress=True,
event=event,
@@ -235,6 +243,7 @@ async def _(event):
filepath = vid_id + ".mkv"
if not os.path.exists(filepath):
filepath = filepath + ".webm"
+ size = os.path.getsize(filepath)
file, _ = await event.client.fast_uploader(
filepath,
filename=title + ".mkv",
@@ -250,12 +259,14 @@ async def _(event):
supports_streaming=True,
),
]
- text = f"**Title:** `{title}`\n\n"
- text += f"`📝 Description:` `{description}`\n\n"
- text += f"`⏳ Duration:` `{time_formatter(int(duration)*1000)}`\n"
- text += f"`🎤 Artist:` `{artist}`\n"
- text += f"`👀 Views`: `{views}`\n"
- text += f"`👍 Likes`: `{likes}`\n"
+ description = description if description != "" else "None"
+ text = f"**Title: [{title}]({_yt_base_url}{vid_id})**\n\n"
+ text += f"`📝 Description: {description}\n\n"
+ text += f"「 Duration: {time_formatter(int(duration)*1000)} 」\n"
+ text += f"「 Artist: {artist} 」\n"
+ text += f"「 Views: {views} 」\n"
+ text += f"「 Likes: {likes} 」\n"
+ text += f"「 Size: {humanbytes(size)} 」`"
button = Button.switch_inline("Search More", query="yt ", same_peer=True)
try:
await event.edit(
diff --git a/plugins/__init__.py b/plugins/__init__.py
index f4a10101f18f9e13743a2f53f9835bd3a0fba812..5f62f35c1a1bdb9add65c94a9c3952342e1991d1 100644
--- a/plugins/__init__.py
+++ b/plugins/__init__.py
@@ -5,6 +5,7 @@
# PLease read the GNU Affero General Public License in
# .
+
import asyncio
import os
import time
@@ -26,7 +27,7 @@ from telethon.tl import functions, types
from strings import get_string
Redis = udB.get_key
-
+con = TgConverter
OWNER_NAME = ultroid_bot.full_name
OWNER_ID = ultroid_bot.uid
diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py
index 2cc519255abc39d579fd749bf3e07d5004102081..e9466455b15f885b62c5f401fc3a69a587fb8cbf 100644
--- a/plugins/_chatactions.py
+++ b/plugins/_chatactions.py
@@ -13,7 +13,7 @@ from pyUltroid.dB.gban_mute_db import is_gbanned
from pyUltroid.dB.greetings_db import get_goodbye, get_welcome, must_thank
from pyUltroid.dB.nsfw_db import is_profan
from pyUltroid.functions.helper import inline_mention
-from pyUltroid.functions.tools import create_tl_btn, get_chatbot_reply
+from pyUltroid.functions.tools import async_searcher, create_tl_btn, get_chatbot_reply
from telethon import events
from telethon.errors.rpcerrorlist import UserNotParticipantError
from telethon.tl.functions.channels import GetParticipantRequest
@@ -64,10 +64,33 @@ async def ChatActionsHandler(ult): # sourcery no-metrics
)
await res[0].click(ult.chat_id, reply_to=ult.action_message.id)
- # gban checks
if ult.user_joined or ult.added_by:
user = await ult.get_user()
chat = await ult.get_chat()
+ # gbans and @UltroidBans checks
+ if udB.get_key("ULTROID_BANS"):
+ try:
+ is_banned = await async_searcher(
+ "https://bans.ultroid.tech/api/status",
+ json={"userId": user.id},
+ post=True,
+ re_json=True,
+ )
+ if is_banned["is_banned"]:
+ await ult.client.edit_permissions(
+ chat.id,
+ user.id,
+ view_messages=False,
+ )
+ await ult.client.send_message(
+ chat.id,
+ "**@UltroidBans:** Banned user detected and banned!\n`{}`.\nBan reason: {}".format(
+ str(is_banned),
+ is_banned["reason"],
+ ),
+ )
+ except BaseException:
+ pass
reason = is_gbanned(user.id)
if reason and chat.admin_rights:
try:
diff --git a/plugins/_help.py b/plugins/_help.py
index a30a92de0cd1029449e5c53092c14ad9671680af..d4637d5d149743b0818c4357f765d05ee797accd 100644
--- a/plugins/_help.py
+++ b/plugins/_help.py
@@ -6,7 +6,9 @@
# .
+from fuzzywuzzy.process import extractOne
from pyUltroid.dB._core import HELP, LIST
+from pyUltroid.functions.tools import cmd_regex_replace
from telethon.errors.rpcerrorlist import (
BotInlineDisabledError,
BotMethodInvalidError,
@@ -35,9 +37,9 @@ _main_help_menu = [
]
-@ultroid_cmd(pattern="help ?(.*)")
+@ultroid_cmd(pattern="help( (.*)|$)")
async def _help(ult):
- plug = ult.pattern_match.group(1)
+ plug = ult.pattern_match.group(1).strip()
chat = await ult.get_chat()
if plug:
try:
@@ -68,7 +70,37 @@ async def _help(ult):
x += "\n© @TeamUltroid"
await ult.eor(x)
except BaseException:
- await ult.eor(get_string("help_1").format(plug), time=5)
+ file = None
+ compare_strings = []
+ for file_name in LIST:
+ compare_strings.append(file_name)
+ value = LIST[file_name]
+ for j in value:
+ j = cmd_regex_replace(j)
+ compare_strings.append(j)
+ if j.strip() == plug:
+ file = file_name
+ break
+ if not file:
+ # the enter command/plugin name is not found
+ best_match = extractOne(plug, compare_strings)
+ return await ult.eor(
+ "`{}` is not a valid plugin!\nDid you mean `{}`?".format(
+ plug, best_match[0]
+ ),
+ )
+ output = f"**Command** `{plug}` **found in plugin** - `{file}`\n"
+ if file in HELP["Official"]:
+ for i in HELP["Official"][file]:
+ output += i
+ elif HELP.get("Addons") and file in HELP["Addons"]:
+ for i in HELP["Addons"][file]:
+ output += i
+ elif HELP.get("VCBot") and file in HELP["VCBot"]:
+ for i in HELP["VCBot"][file]:
+ output += i
+ output += "\n© @TeamUltroid"
+ await ult.eor(output)
except BaseException as er:
LOGS.exception(er)
await ult.eor("Error 🤔 occured.")
diff --git a/plugins/_inline.py b/plugins/_inline.py
index aa0d6b3f6ef79a1bf7fc7171bfd397ee02f8f47f..c9900214bf90ab2e065b9ce8c4bb048ac21799a3 100644
--- a/plugins/_inline.py
+++ b/plugins/_inline.py
@@ -70,7 +70,13 @@ async def inline_alive(o):
content=InputWebDocument(TLINK, 0, "image/jpg", []),
)
]
- await o.answer(RES, switch_pm="👥 ULTROID PORTAL", switch_pm_param="start")
+ await o.answer(
+ RES,
+ private=True,
+ cache_time=300,
+ switch_pm="👥 ULTROID PORTAL",
+ switch_pm_param="start",
+ )
@in_pattern("ultd", owner=True)
@@ -95,7 +101,7 @@ async def inline_handler(event):
result = await event.builder.article(
title="Ultroid Help Menu", text=text, buttons=_main_help_menu
)
- await event.answer([result], gallery=True)
+ await event.answer([result], private=True, cache_time=300, gallery=True)
@in_pattern("pasta", owner=True)
@@ -183,7 +189,7 @@ async def uptd_plugin(event):
help_ += "\n"
if not help_:
help_ = f"{file} has no Detailed Help!"
- help_ += "\n© Join @TeamUltroid"
+ help_ += "\n© @TeamUltroid"
buttons = []
if INLINE_PIC:
data = f"sndplug_{key}_{file}"
@@ -328,6 +334,7 @@ async def _(e):
"Fᴅʀᴏɪᴅ Sᴇᴀʀᴄʜ", query="fdroid telegram", same_peer=True
)
],
+ [Button.switch_inline("Sᴀᴀᴠɴ sᴇᴀʀᴄʜ", query="saavn", same_peer=True)],
[
Button.inline(
"« Bᴀᴄᴋ",
@@ -406,7 +413,7 @@ STUFF = {}
@in_pattern("stf(.*)", owner=True)
async def ibuild(e):
- n = e.pattern_match.group(1)
+ n = e.pattern_match.group(1).strip()
builder = e.builder
if not (n and n.isdigit()):
return
diff --git a/plugins/_ultroid.py b/plugins/_ultroid.py
index 71cf2c9ecfc5da10536ad19c085e9126eb5cc27c..31d61a76f4d5feb67dd205a6dbb628253ef916f3 100644
--- a/plugins/_ultroid.py
+++ b/plugins/_ultroid.py
@@ -62,4 +62,5 @@ async def useUltroid(rs):
file="https://telegra.ph/file/54a917cc9dbb94733ea5f.jpg",
buttons=button,
)
- await eor(rs, f"**[Click Here]({msg.message_link})**")
+ if not (rs.chat_id == LOG_CHANNEL and rs.client._bot):
+ await eor(rs, f"**[Click Here]({msg.message_link})**")
diff --git a/plugins/_userlogs.py b/plugins/_userlogs.py
index 9b43324e0db27688c2e25bf5587c84e182f14327..ddb94bf7bb6615e2af86981bc8e8d0690f769d3d 100644
--- a/plugins/_userlogs.py
+++ b/plugins/_userlogs.py
@@ -10,6 +10,7 @@ import re
from pyUltroid.dB.botchat_db import tag_add, who_tag
from telethon.errors.rpcerrorlist import (
+ ChannelPrivateError,
ChatWriteForbiddenError,
MediaCaptionTooLongError,
MediaEmptyError,
@@ -46,18 +47,18 @@ async def all_messages_catcher(e):
try:
sent = await asst.send_message(NEEDTOLOG, e.message, buttons=buttons)
if TAG_EDITS.get(e.chat_id):
- TAG_EDITS[e.chat_id].update({e.id: {"id": sent.id}})
+ TAG_EDITS[e.chat_id].update({e.id: {"id": sent.id, "msg": e}})
else:
- TAG_EDITS.update({e.chat_id: {e.id: {"id": sent.id}}})
+ TAG_EDITS.update({e.chat_id: {e.id: {"id": sent.id, "msg": e}}})
tag_add(sent.id, e.chat_id, e.id)
except MediaEmptyError:
try:
msg = await asst.get_messages(e.chat_id, ids=e.id)
sent = await asst.send_message(NEEDTOLOG, msg, buttons=buttons)
if TAG_EDITS.get(e.chat_id):
- TAG_EDITS[e.chat_id].update({e.id: {"id": sent.id}})
+ TAG_EDITS[e.chat_id].update({e.id: {"id": sent.id, "msg": e}})
else:
- TAG_EDITS.update({e.chat_id: {e.id: {"id": sent.id}}})
+ TAG_EDITS.update({e.chat_id: {e.id: {"id": sent.id, "msg": e}}})
tag_add(sent.id, e.chat_id, e.id)
except Exception as me:
if not isinstance(me, (PeerIdInvalidError, ValueError)):
@@ -69,9 +70,9 @@ async def all_messages_catcher(e):
NEEDTOLOG, e.message.text, file=media, buttons=buttons
)
if TAG_EDITS.get(e.chat_id):
- TAG_EDITS[e.chat_id].update({e.id: {"id": sent.id}})
+ TAG_EDITS[e.chat_id].update({e.id: {"id": sent.id, "msg": e}})
else:
- TAG_EDITS.update({e.chat_id: {e.id: {"id": sent.id}}})
+ TAG_EDITS.update({e.chat_id: {e.id: {"id": sent.id, "msg": e}}})
return os.remove(media)
except Exception as er:
LOGS.exception(er)
@@ -141,6 +142,8 @@ if udB.get_key("TAG_LOG"):
if not d_.get(event.id):
return
d_ = d_[event.id]
+ if d_["msg"].text == event.text:
+ return
msg = None
if d_.get("count"):
d_["count"] += 1
@@ -164,7 +167,8 @@ if udB.get_key("TAG_LOG"):
if d_["count"] == 10:
TEXT += "\n\n• __Only the first 10 Edits are shown.__"
try:
- await MSG.edit(TEXT, buttons=await parse_buttons(event))
+ msg = await MSG.edit(TEXT, buttons=await parse_buttons(event))
+ d_["msg"] = msg
except (MessageTooLongError, MediaCaptionTooLongError):
del TAG_EDITS[event.chat_id][event.id]
except Exception as er:
@@ -237,8 +241,18 @@ async def leave_ch_at(event):
client = _client[client]
except KeyError:
return
- name = (await client.get_entity(int(ch_id))).title
- await client.delete_dialog(int(ch_id))
+ try:
+ name = (await client.get_entity(int(ch_id))).title
+ await client.delete_dialog(int(ch_id))
+ except UserNotParticipantError:
+ pass
+ except ChannelPrivateError:
+ return await event.edit(
+ "`[CANT_ACCESS_CHAT]` `Maybe already left or got banned.`"
+ )
+ except Exception as er:
+ LOGS.exception(er)
+ return await event.answer(str(er))
await event.edit(get_string("userlogs_5").format(name))
diff --git a/plugins/_wspr.py b/plugins/_wspr.py
index 4fc3d973bd9937d8ceb788d3c88d665801cfc691..2e938d6b4de7db089dbeb0877841eb389937fd74 100644
--- a/plugins/_wspr.py
+++ b/plugins/_wspr.py
@@ -32,7 +32,7 @@ buddhhu = {}
@ultroid_cmd(
- pattern="wspr ?(.*)",
+ pattern="wspr( (.*)|$)",
)
async def _(e):
if e.reply_to_msg_id:
@@ -41,7 +41,7 @@ async def _(e):
put = f"@{okk.sender.username}"
put = okk.sender_id
else:
- put = e.pattern_match.group(1)
+ put = e.pattern_match.group(1).strip()
if put:
try:
results = await e.client.inline_query(asst.me.username, f"msg {put}")
@@ -170,7 +170,7 @@ async def _(e):
),
)
async def _(e):
- ids = int(e.pattern_match.group(1).decode("UTF-8"))
+ ids = int(e.pattern_match.group(1).strip().decode("UTF-8"))
if buddhhu.get(ids):
if e.sender_id in buddhhu[ids]:
await e.answer(buddhhu[ids][-1], alert=True)
@@ -182,7 +182,7 @@ async def _(e):
@callback(re.compile("del_(.*)"))
async def _(e):
- ids = int(e.pattern_match.group(1).decode("UTF-8"))
+ ids = int(e.pattern_match.group(1).strip().decode("UTF-8"))
if buddhhu.get(ids):
if e.sender_id in buddhhu[ids]:
buddhhu.pop(ids)
diff --git a/plugins/admintools.py b/plugins/admintools.py
index d8e033f3f4fdea8e4932256c42e44edbd2650ca1..189103d15239adf202c71dbcc9a74db179495f06 100644
--- a/plugins/admintools.py
+++ b/plugins/admintools.py
@@ -20,6 +20,7 @@
• `{i}pin `
Pin the message in the chat
+• `{i}tpin