small bug fixes
* GetAllChats has been removed from TG raw api * fix reply to message webshot plugin
This commit is contained in:
@@ -32,23 +32,19 @@ async def solo_mention_clear(client: Client, message: Message):
|
||||
|
||||
@Client.on_message(filters.command(["clear_all_@"], prefix) & filters.me)
|
||||
async def global_mention_clear(client: Client, message: Message):
|
||||
request = functions.messages.GetAllChats(except_ids=[])
|
||||
try:
|
||||
result = await client.invoke(request)
|
||||
except FloodWait as e:
|
||||
await message.edit_text(
|
||||
f"<b>FloodWait received. Wait {e.x} seconds before trying again</b>"
|
||||
)
|
||||
return
|
||||
await message.delete()
|
||||
for chat in result.chats:
|
||||
if type(chat) is types.Chat:
|
||||
peer_id = -chat.id
|
||||
elif type(chat) is types.Channel:
|
||||
peer_id = int(f"-100{chat.id}")
|
||||
peer = await client.resolve_peer(peer_id)
|
||||
counter: int = 0
|
||||
await message.edit_text(
|
||||
f"<b>Clearing all mentions...</b>\n\n<b>Cleared:</b> <code>{counter}</code> chats"
|
||||
)
|
||||
async for dialog in client.get_dialogs():
|
||||
peer = await client.resolve_peer(dialog.chat.id)
|
||||
request = functions.messages.ReadMentions(peer=peer)
|
||||
await client.invoke(request)
|
||||
counter += 1
|
||||
await message.edit_text(
|
||||
f"<b>Clearing all mentions...</b>\n\n<b>Cleared:</b> <code>{counter}</code> chats"
|
||||
)
|
||||
await message.delete()
|
||||
|
||||
|
||||
@Client.on_message(filters.command(["clear_reacts"], prefix) & filters.me)
|
||||
@@ -61,23 +57,19 @@ async def solo_reaction_clear(client: Client, message: Message):
|
||||
|
||||
@Client.on_message(filters.command(["clear_all_reacts"], prefix) & filters.me)
|
||||
async def global_reaction_clear(client: Client, message: Message):
|
||||
request = functions.messages.GetAllChats(except_ids=[])
|
||||
try:
|
||||
result = await client.invoke(request)
|
||||
except FloodWait as e:
|
||||
await message.edit_text(
|
||||
f"<b>FloodWait received. Wait {e.x} seconds before trying again</b>"
|
||||
)
|
||||
return
|
||||
await message.delete()
|
||||
for chat in result.chats:
|
||||
if type(chat) is types.Chat:
|
||||
peer_id = -chat.id
|
||||
elif type(chat) is types.Channel:
|
||||
peer_id = int(f"-100{chat.id}")
|
||||
peer = await client.resolve_peer(peer_id)
|
||||
counter: int = 0
|
||||
await message.edit_text(
|
||||
f"<b>Clearing all reactions...</b>\n\n<b>Cleared:</b> <code>{counter}</code> chats"
|
||||
)
|
||||
async for dialog in client.get_dialogs():
|
||||
peer = await client.resolve_peer(dialog.chat.id)
|
||||
request = functions.messages.ReadReactions(peer=peer)
|
||||
await client.invoke(request)
|
||||
counter += 1
|
||||
await message.edit_text(
|
||||
f"<b>Clearing all reactions...</b>\n\n<b>Cleared:</b> <code>{counter}</code> chats"
|
||||
)
|
||||
await message.delete()
|
||||
|
||||
|
||||
modules_help["clear_notifs"] = {
|
||||
|
||||
@@ -31,7 +31,7 @@ from utils.scripts import format_exc
|
||||
@Client.on_message(
|
||||
filters.command(["ex", "exec", "py", "exnoedit"], prefix) & filters.me
|
||||
)
|
||||
async def user_exec(client: Client, message: Message):
|
||||
async def user_exec(_: Client, message: Message):
|
||||
if len(message.command) == 1:
|
||||
await message.edit("<b>Code to execute isn't provided</b>")
|
||||
return
|
||||
@@ -43,7 +43,7 @@ async def user_exec(client: Client, message: Message):
|
||||
|
||||
try:
|
||||
with redirect_stdout(stdout):
|
||||
exec(code) # skipcq
|
||||
exec(code) # skipcq
|
||||
text = (
|
||||
"<b>Code:</b>\n"
|
||||
f"<code>{code}</code>\n\n"
|
||||
@@ -68,7 +68,7 @@ async def user_eval(client: Client, message: Message):
|
||||
code = message.text.split(maxsplit=1)[1]
|
||||
|
||||
try:
|
||||
result = eval(code) # skipcq
|
||||
result = eval(code) # skipcq
|
||||
await message.edit(
|
||||
"<b>Expression:</b>\n"
|
||||
f"<code>{code}</code>\n\n"
|
||||
|
||||
@@ -235,7 +235,7 @@ async def upload_cmd(_, message: Message):
|
||||
)
|
||||
else:
|
||||
await message.edit(
|
||||
f"<b>API returned an error!\n" f"{response.text}\n Not allowed</b>"
|
||||
f"<b>API returned an error!\n{response.text}\n Not allowed</b>"
|
||||
)
|
||||
print(response.text)
|
||||
if os.path.exists(file_name):
|
||||
@@ -251,7 +251,7 @@ async def webshot(client: Client, message: Message):
|
||||
elif message.reply_to_message:
|
||||
url = message.reply_to_message.text
|
||||
if not url.startswith("https://"):
|
||||
url = "https://" + message.text.split(maxsplit=1)[1]
|
||||
url = "https://" + url
|
||||
else:
|
||||
await message.edit_text(
|
||||
f"<b>Usage: </b><code>{prefix}webshot/{prefix}ws [url/reply to url]</code>"
|
||||
@@ -269,11 +269,11 @@ async def webshot(client: Client, message: Message):
|
||||
chat_id, screenshot_data, caption=f"Screenshot of <code>{url}</code>"
|
||||
)
|
||||
else:
|
||||
await message.reply_text(
|
||||
await message.edit_text(
|
||||
"<code>Failed to generate screenshot...\nMake sure url is correct</code>"
|
||||
)
|
||||
except Exception as e:
|
||||
await message.reply_text(f"An error occurred: {format_exc(e)}")
|
||||
await message.edit_text(f"An error occurred: {format_exc(e)}")
|
||||
|
||||
|
||||
modules_help["url"] = {
|
||||
|
||||
Reference in New Issue
Block a user