Skip to content

Commit

Permalink
Update clear_notifs.py (#40)
Browse files Browse the repository at this point in the history
* Update clear_notifs.py

* Update clear_notifs.py
  • Loading branch information
AbhiTheModder authored Dec 16, 2023
1 parent bfd4d13 commit efacd21
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions modules/clear_notifs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from pyrogram import Client
from pyrogram import enums as enums
from pyrogram import filters
from pyrogram import Client, filters, enums
from pyrogram.errors import FloodWait
from pyrogram.raw import functions, types
from pyrogram.types import Message
Expand All @@ -29,18 +27,17 @@ async def solo_mention_clear(client: Client, message: Message):
await message.delete()
peer = await client.resolve_peer(message.chat.id)
request = functions.messages.ReadMentions(peer=peer)
await client.send(request, parse_mode=enums.ParseMode.HTML)
await client.invoke(request)


@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.send(request, parse_mode=enums.ParseMode.HTML)
result = await client.invoke(request)
except FloodWait as e:
await message.edit(
f"<code>FloodWait received. Wait {e.x} seconds before trying again</code>",
parse_mode=enums.ParseMode.HTML,
await message.edit_text(
f"<b>FloodWait received. Wait {e.x} seconds before trying again</b>", parse_mode=enums.ParseMode.HTML
)
return
await message.delete()
Expand All @@ -51,26 +48,25 @@ async def global_mention_clear(client: Client, message: Message):
peer_id = int(f"-100{chat.id}")
peer = await client.resolve_peer(peer_id)
request = functions.messages.ReadMentions(peer=peer)
await client.send(request, parse_mode=enums.ParseMode.HTML)
await client.invoke(request)


@Client.on_message(filters.command(["clear_reacts"], prefix) & filters.me)
async def solo_reaction_clear(client: Client, message: Message):
await message.delete()
peer = await client.resolve_peer(message.chat.id)
request = functions.messages.ReadReactions(peer=peer)
await client.send(request, parse_mode=enums.ParseMode.HTML)
await client.invoke(request)


@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.send(request, parse_mode=enums.ParseMode.HTML)
result = await client.invoke(request)
except FloodWait as e:
await message.edit(
f"<code>FloodWait received. Wait {e.x} seconds before trying again</code>",
parse_mode=enums.ParseMode.HTML,
await message.edit_text(
f"<b>FloodWait received. Wait {e.x} seconds before trying again</b>", parse_mode=enums.ParseMode.HTML
)
return
await message.delete()
Expand All @@ -81,12 +77,12 @@ async def global_reaction_clear(client: Client, message: Message):
peer_id = int(f"-100{chat.id}")
peer = await client.resolve_peer(peer_id)
request = functions.messages.ReadReactions(peer=peer)
await client.send(request, parse_mode=enums.ParseMode.HTML)
await client.invoke(request)


modules_help["clear_notifs"] = {
"clear_@": "clear all mentions in this chat",
"clear_all_@": "clear all mentions in all chats",
"clear_reacts": "clear all reactions in this chat",
"clear_all_reacts": "clear all reactions in all chats (except private chats)",
}
}

0 comments on commit efacd21

Please sign in to comment.