From 0b720ef770b5c9091039ebbf3cefa9b3aab4f36f Mon Sep 17 00:00:00 2001 From: profitroll Date: Wed, 30 Aug 2023 12:52:31 +0200 Subject: [PATCH 1/8] OperationFailure handling added --- plugins/commands/upcoming.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/plugins/commands/upcoming.py b/plugins/commands/upcoming.py index 262e53b..b96665f 100644 --- a/plugins/commands/upcoming.py +++ b/plugins/commands/upcoming.py @@ -1,5 +1,6 @@ from datetime import datetime, timedelta, timezone +from pymongo.errors import OperationFailure from pyrogram import filters from pyrogram.types import Message from pytz import timezone as pytz_timezone @@ -33,15 +34,23 @@ async def command_upcoming(app: PyroClient, message: Message): + timedelta(days=30) ).replace(tzinfo=timezone.utc) - entries = [ - await GarbageEntry.from_record(entry) - async for entry in col_entries.find( - { - "location": {"$in": user.location.id}, - "date": {"$gte": date_min, "$lte": date_max}, - } + try: + entries = [ + await GarbageEntry.from_record(entry) + async for entry in col_entries.find( + { + "location": {"$in": user.location.id}, + "date": {"$gte": date_min, "$lte": date_max}, + } + ) + ] + except OperationFailure: + await message.reply_text( + app._("upcoming_empty", "messages", locale=user.locale).format( + name=user.location.name + ) ) - ] + return entries_text = "\n\n".join( [ From c303f620050b9685eb40520230db695de085fc92 Mon Sep 17 00:00:00 2001 From: profitroll Date: Wed, 30 Aug 2023 12:56:20 +0200 Subject: [PATCH 2/8] Fixed "location" instead of "locations" --- modules/reminder.py | 2 +- plugins/commands/upcoming.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/reminder.py b/modules/reminder.py index b845303..134b0e2 100644 --- a/modules/reminder.py +++ b/modules/reminder.py @@ -39,7 +39,7 @@ async def remind(app: PyroClient) -> None: entries = await col_entries.find( { - "location": {"$in": location.id}, + "locations": {"$in": location.id}, "date": user_date.replace(hour=0, minute=0), } ).to_list() diff --git a/plugins/commands/upcoming.py b/plugins/commands/upcoming.py index b96665f..c5866c5 100644 --- a/plugins/commands/upcoming.py +++ b/plugins/commands/upcoming.py @@ -39,7 +39,7 @@ async def command_upcoming(app: PyroClient, message: Message): await GarbageEntry.from_record(entry) async for entry in col_entries.find( { - "location": {"$in": user.location.id}, + "locations": {"$in": user.location.id}, "date": {"$gte": date_min, "$lte": date_max}, } ) From 42ca71aa3e1d6e16a68b8f3c4a99b5a349cfd94d Mon Sep 17 00:00:00 2001 From: profitroll Date: Wed, 30 Aug 2023 13:00:21 +0200 Subject: [PATCH 3/8] Fixed wrong $in usage --- modules/reminder.py | 2 +- plugins/commands/upcoming.py | 24 ++++++++---------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/modules/reminder.py b/modules/reminder.py index 134b0e2..cf2b939 100644 --- a/modules/reminder.py +++ b/modules/reminder.py @@ -39,7 +39,7 @@ async def remind(app: PyroClient) -> None: entries = await col_entries.find( { - "locations": {"$in": location.id}, + "locations": location.id, "date": user_date.replace(hour=0, minute=0), } ).to_list() diff --git a/plugins/commands/upcoming.py b/plugins/commands/upcoming.py index c5866c5..ac29e63 100644 --- a/plugins/commands/upcoming.py +++ b/plugins/commands/upcoming.py @@ -34,23 +34,15 @@ async def command_upcoming(app: PyroClient, message: Message): + timedelta(days=30) ).replace(tzinfo=timezone.utc) - try: - entries = [ - await GarbageEntry.from_record(entry) - async for entry in col_entries.find( - { - "locations": {"$in": user.location.id}, - "date": {"$gte": date_min, "$lte": date_max}, - } - ) - ] - except OperationFailure: - await message.reply_text( - app._("upcoming_empty", "messages", locale=user.locale).format( - name=user.location.name - ) + entries = [ + await GarbageEntry.from_record(entry) + async for entry in col_entries.find( + { + "locations": user.location.id, + "date": {"$gte": date_min, "$lte": date_max}, + } ) - return + ] entries_text = "\n\n".join( [ From 1248efd20fcf1c4c3e45a133ae8f4191e873d260 Mon Sep 17 00:00:00 2001 From: profitroll Date: Wed, 30 Aug 2023 14:01:30 +0200 Subject: [PATCH 4/8] Fixed results order --- modules/search_name.py | 2 +- modules/search_nearby.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/search_name.py b/modules/search_name.py index 1f3caf7..7c918c4 100644 --- a/modules/search_name.py +++ b/modules/search_name.py @@ -46,7 +46,7 @@ async def search_name(app: PyroClient, message: Message) -> Union[Location, None query = {"$text": {"$search": answer.text}} - locations = await col_locations.find(query).limit(6).to_list() + locations = (await col_locations.find(query).limit(6).to_list()).reverse() if len(locations) == 0: await message.reply_text( diff --git a/modules/search_nearby.py b/modules/search_nearby.py index be94d8e..332a9ea 100644 --- a/modules/search_nearby.py +++ b/modules/search_nearby.py @@ -24,7 +24,7 @@ async def search_nearby(app: PyroClient, message: Message) -> Union[Location, No } } - locations = await col_locations.find(query).limit(6).to_list() + locations = (await col_locations.find(query).limit(6).to_list()).reverse() if len(locations) == 0: await message.reply_text( From 0006703daf114b5eafd71684ed6812a3cee314ba Mon Sep 17 00:00:00 2001 From: profitroll Date: Wed, 30 Aug 2023 14:03:08 +0200 Subject: [PATCH 5/8] Fixed stupid mistake of using an empty list --- modules/search_name.py | 4 +++- modules/search_nearby.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/search_name.py b/modules/search_name.py index 7c918c4..3377021 100644 --- a/modules/search_name.py +++ b/modules/search_name.py @@ -46,7 +46,7 @@ async def search_name(app: PyroClient, message: Message) -> Union[Location, None query = {"$text": {"$search": answer.text}} - locations = (await col_locations.find(query).limit(6).to_list()).reverse() + locations = await col_locations.find(query).limit(6).to_list() if len(locations) == 0: await message.reply_text( @@ -61,6 +61,8 @@ async def search_name(app: PyroClient, message: Message) -> Union[Location, None ) continue + locations = locations.reverse() + keyboard = ReplyKeyboard(resize_keyboard=True, row_width=2) keyboard.add(*[ReplyButton(db_record["name"]) for db_record in locations]) diff --git a/modules/search_nearby.py b/modules/search_nearby.py index 332a9ea..30af99b 100644 --- a/modules/search_nearby.py +++ b/modules/search_nearby.py @@ -24,7 +24,7 @@ async def search_nearby(app: PyroClient, message: Message) -> Union[Location, No } } - locations = (await col_locations.find(query).limit(6).to_list()).reverse() + locations = await col_locations.find(query).limit(6).to_list() if len(locations) == 0: await message.reply_text( @@ -32,6 +32,8 @@ async def search_nearby(app: PyroClient, message: Message) -> Union[Location, No ) return await search_name(app, message) + locations = locations.reverse() + keyboard = ReplyKeyboard(resize_keyboard=True, row_width=2) keyboard.add(*[ReplyButton(db_record["name"]) for db_record in locations]) From a9a92257dc8dbaa48726b4fd581875467118f338 Mon Sep 17 00:00:00 2001 From: profitroll Date: Wed, 30 Aug 2023 14:04:36 +0200 Subject: [PATCH 6/8] None check added --- modules/search_name.py | 2 +- modules/search_nearby.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/search_name.py b/modules/search_name.py index 3377021..9f0ad2e 100644 --- a/modules/search_name.py +++ b/modules/search_name.py @@ -48,7 +48,7 @@ async def search_name(app: PyroClient, message: Message) -> Union[Location, None locations = await col_locations.find(query).limit(6).to_list() - if len(locations) == 0: + if len(locations) == 0 or locations is None: await message.reply_text( app._("location_name_empty", "messages", locale=user.locale).format( cancel_notice=app._("cancel", "messages", locale=user.locale) diff --git a/modules/search_nearby.py b/modules/search_nearby.py index 30af99b..7b95d00 100644 --- a/modules/search_nearby.py +++ b/modules/search_nearby.py @@ -26,7 +26,7 @@ async def search_nearby(app: PyroClient, message: Message) -> Union[Location, No locations = await col_locations.find(query).limit(6).to_list() - if len(locations) == 0: + if len(locations) == 0 or locations is None: await message.reply_text( app._("search_nearby_empty", "messages", locale=user.locale) ) From c91d7f3afa19d384ac188f1bb1b8203274d62e53 Mon Sep 17 00:00:00 2001 From: profitroll Date: Wed, 30 Aug 2023 14:06:46 +0200 Subject: [PATCH 7/8] Fixed reverse assignation and stopped commit-tests --- modules/search_name.py | 2 +- modules/search_nearby.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/search_name.py b/modules/search_name.py index 9f0ad2e..f569407 100644 --- a/modules/search_name.py +++ b/modules/search_name.py @@ -61,7 +61,7 @@ async def search_name(app: PyroClient, message: Message) -> Union[Location, None ) continue - locations = locations.reverse() + locations.reverse() keyboard = ReplyKeyboard(resize_keyboard=True, row_width=2) keyboard.add(*[ReplyButton(db_record["name"]) for db_record in locations]) diff --git a/modules/search_nearby.py b/modules/search_nearby.py index 7b95d00..1681995 100644 --- a/modules/search_nearby.py +++ b/modules/search_nearby.py @@ -26,13 +26,13 @@ async def search_nearby(app: PyroClient, message: Message) -> Union[Location, No locations = await col_locations.find(query).limit(6).to_list() - if len(locations) == 0 or locations is None: + if len(locations) == 0: await message.reply_text( app._("search_nearby_empty", "messages", locale=user.locale) ) return await search_name(app, message) - locations = locations.reverse() + locations.reverse() keyboard = ReplyKeyboard(resize_keyboard=True, row_width=2) keyboard.add(*[ReplyButton(db_record["name"]) for db_record in locations]) From 57ff7b67652873137f1d6fcaa6a803f130498437 Mon Sep 17 00:00:00 2001 From: profitroll Date: Wed, 30 Aug 2023 14:41:34 +0200 Subject: [PATCH 8/8] Context handling implemented --- classes/pyroclient.py | 1 + modules/custom_filters.py | 5 +++++ modules/search_name.py | 4 ++++ modules/search_nearby.py | 3 +++ plugins/commands/checkout.py | 7 ++++++- plugins/commands/help.py | 3 ++- plugins/commands/import.py | 8 ++++++-- plugins/commands/remove_commands.py | 3 ++- plugins/commands/set_offset.py | 5 ++++- plugins/commands/set_time.py | 5 ++++- plugins/commands/setup.py | 5 ++++- plugins/commands/shutdown.py | 4 +++- plugins/commands/start.py | 5 ++++- plugins/commands/toggle.py | 3 ++- plugins/commands/upcoming.py | 4 ++-- plugins/language.py | 3 ++- 16 files changed, 54 insertions(+), 14 deletions(-) diff --git a/classes/pyroclient.py b/classes/pyroclient.py index f4b5ebc..db580c8 100644 --- a/classes/pyroclient.py +++ b/classes/pyroclient.py @@ -18,6 +18,7 @@ class PyroClient(LibPyroClient): self.scheduler.add_job( remind, CronTrigger.from_crontab("* * * * *"), args=(self,) ) + self.contexts = [] async def start(self, **kwargs): await col_locations.create_index( diff --git a/modules/custom_filters.py b/modules/custom_filters.py index 37b019e..4b3c709 100644 --- a/modules/custom_filters.py +++ b/modules/custom_filters.py @@ -10,4 +10,9 @@ async def _owner_func(_, __: PyroClient, message: Message): return False if message.from_user is None else __.owner == message.from_user.id +async def _context_func(_, __: PyroClient, message: Message): + return message.from_user.id in __.contexts + + owner = filters.create(_owner_func) +context = filters.create(_context_func) diff --git a/modules/search_name.py b/modules/search_name.py index f569407..5fae746 100644 --- a/modules/search_name.py +++ b/modules/search_name.py @@ -22,7 +22,9 @@ async def search_name(app: PyroClient, message: Message) -> Union[Location, None ) while location is None: + app.contexts.append(message.from_user.id) answer = await listen_message(app, message.chat.id, 300) + app.contexts.remove(message.from_user.id) if answer is None or answer.text == "/cancel": await message.reply_text( @@ -72,7 +74,9 @@ async def search_name(app: PyroClient, message: Message) -> Union[Location, None ) while True: + app.contexts.append(message.from_user.id) answer = await listen_message(app, message.chat.id, 300) + app.contexts.remove(message.from_user.id) if answer is None or answer.text == "/cancel": await message.reply_text( diff --git a/modules/search_nearby.py b/modules/search_nearby.py index 1681995..32def59 100644 --- a/modules/search_nearby.py +++ b/modules/search_nearby.py @@ -43,7 +43,10 @@ async def search_nearby(app: PyroClient, message: Message) -> Union[Location, No ) while True: + app.contexts.append(message.from_user.id) answer = await listen_message(app, message.chat.id, 300) + app.contexts.remove(message.from_user.id) + location: Union[Location, None] = None if answer is None or answer.text == "/cancel": diff --git a/plugins/commands/checkout.py b/plugins/commands/checkout.py index e5d2528..20210c5 100644 --- a/plugins/commands/checkout.py +++ b/plugins/commands/checkout.py @@ -8,12 +8,13 @@ from pyrogram.types import Message, ReplyKeyboardRemove from ujson import dumps from classes.pyroclient import PyroClient +from modules import custom_filters logger = logging.getLogger(__name__) @PyroClient.on_message( - ~filters.scheduled & filters.private & filters.command(["checkout"], prefixes=["/"]) # type: ignore + ~filters.scheduled & filters.private & filters.command(["checkout"], prefixes=["/"]) & ~custom_filters.context # type: ignore ) async def command_checkout(app: PyroClient, message: Message): user = await app.find_user(message.from_user) @@ -42,7 +43,9 @@ async def command_checkout(app: PyroClient, message: Message): ) while True: + app.contexts.append(message.from_user.id) answer_delete = await listen_message(app, message.chat.id, 300) + app.contexts.remove(message.from_user.id) if answer_delete is None or answer_delete.text == "/cancel": await message.reply_text( @@ -84,7 +87,9 @@ async def command_checkout(app: PyroClient, message: Message): ) while True: + app.contexts.append(message.from_user.id) answer_confirm = await listen_message(app, message.chat.id, 300) + app.contexts.remove(message.from_user.id) if answer_confirm is None or answer_confirm.text == "/cancel": await message.reply_text( diff --git a/plugins/commands/help.py b/plugins/commands/help.py index 6e211e9..f96f56d 100644 --- a/plugins/commands/help.py +++ b/plugins/commands/help.py @@ -2,10 +2,11 @@ from pyrogram import filters from pyrogram.types import Message from classes.pyroclient import PyroClient +from modules import custom_filters @PyroClient.on_message( - ~filters.scheduled & filters.private & filters.command(["help"], prefixes=["/"]) # type: ignore + ~filters.scheduled & filters.private & filters.command(["help"], prefixes=["/"]) & ~custom_filters.context # type: ignore ) async def command_help(app: PyroClient, message: Message): user = await app.find_user(message.from_user) diff --git a/plugins/commands/import.py b/plugins/commands/import.py index df32cb2..64c38e1 100644 --- a/plugins/commands/import.py +++ b/plugins/commands/import.py @@ -12,18 +12,22 @@ from modules.database import col_entries @PyroClient.on_message( - ~filters.scheduled & filters.private & custom_filters.owner & filters.command(["import"], prefixes=["/"]) # type: ignore + ~filters.scheduled & filters.private & custom_filters.owner & filters.command(["import"], prefixes=["/"]) & ~custom_filters.context # type: ignore ) async def command_import(app: PyroClient, message: Message): user = await app.find_user(message.from_user) await message.reply_text( app._("import", "messages", locale=user.locale), - reply_markup=ForceReply(placeholder=""), + reply_markup=ForceReply( + placeholder=app._("import", "force_replies", locale=user.locale) + ), ) while True: + app.contexts.append(message.from_user.id) answer = await listen_message(app, message.chat.id, 300) + app.contexts.remove(message.from_user.id) if answer is None or answer.text == "/cancel": await message.reply_text( diff --git a/plugins/commands/remove_commands.py b/plugins/commands/remove_commands.py index e15ebd7..5541d3e 100644 --- a/plugins/commands/remove_commands.py +++ b/plugins/commands/remove_commands.py @@ -2,10 +2,11 @@ from pyrogram import filters from pyrogram.types import Message from classes.pyroclient import PyroClient +from modules import custom_filters @PyroClient.on_message( - ~filters.scheduled & filters.private & filters.command(["remove_commands"], prefixes=["/"]) # type: ignore + ~filters.scheduled & filters.private & filters.command(["remove_commands"], prefixes=["/"]) & ~custom_filters.context # type: ignore ) async def command_remove_commands(app: PyroClient, message: Message): user = await app.find_user(message.from_user) diff --git a/plugins/commands/set_offset.py b/plugins/commands/set_offset.py index 042c32c..c0981de 100644 --- a/plugins/commands/set_offset.py +++ b/plugins/commands/set_offset.py @@ -6,12 +6,13 @@ from pyrogram import filters from pyrogram.types import ForceReply, Message, ReplyKeyboardRemove from classes.pyroclient import PyroClient +from modules import custom_filters logger = logging.getLogger(__name__) @PyroClient.on_message( - ~filters.scheduled & filters.private & filters.command(["set_offset"], prefixes=["/"]) # type: ignore + ~filters.scheduled & filters.private & filters.command(["set_offset"], prefixes=["/"]) & ~custom_filters.context # type: ignore ) async def command_set_offset(app: PyroClient, message: Message): user = await app.find_user(message.from_user) @@ -24,7 +25,9 @@ async def command_set_offset(app: PyroClient, message: Message): ) while True: + app.contexts.append(message.from_user.id) answer = await listen_message(app, message.chat.id, 300) + app.contexts.remove(message.from_user.id) if answer is None or answer.text == "/cancel": await message.reply_text( diff --git a/plugins/commands/set_time.py b/plugins/commands/set_time.py index b4c6e49..fbee4fb 100644 --- a/plugins/commands/set_time.py +++ b/plugins/commands/set_time.py @@ -6,12 +6,13 @@ from pyrogram import filters from pyrogram.types import ForceReply, Message, ReplyKeyboardRemove from classes.pyroclient import PyroClient +from modules import custom_filters logger = logging.getLogger(__name__) @PyroClient.on_message( - ~filters.scheduled & filters.private & filters.command(["set_time"], prefixes=["/"]) # type: ignore + ~filters.scheduled & filters.private & filters.command(["set_time"], prefixes=["/"]) & ~custom_filters.context # type: ignore ) async def command_set_time(app: PyroClient, message: Message): user = await app.find_user(message.from_user) @@ -24,7 +25,9 @@ async def command_set_time(app: PyroClient, message: Message): ) while True: + app.contexts.append(message.from_user.id) answer = await listen_message(app, message.chat.id, 300) + app.contexts.remove(message.from_user.id) if answer is None or answer.text == "/cancel": await message.reply_text( diff --git a/plugins/commands/setup.py b/plugins/commands/setup.py index a82acf8..5bebffe 100644 --- a/plugins/commands/setup.py +++ b/plugins/commands/setup.py @@ -8,6 +8,7 @@ from pyrogram import filters from pyrogram.types import Message, ReplyKeyboardRemove from classes.pyroclient import PyroClient +from modules import custom_filters from modules.search_name import search_name from modules.search_nearby import search_nearby @@ -15,7 +16,7 @@ logger = logging.getLogger(__name__) @PyroClient.on_message( - ~filters.scheduled & filters.private & filters.command(["setup"] + i18n.sync.in_all_locales("start_configure", "buttons"), prefixes=["/", ""]) # type: ignore + ~filters.scheduled & filters.private & filters.command(["setup"] + i18n.sync.in_all_locales("start_configure", "buttons"), prefixes=["/", ""]) & ~custom_filters.context # type: ignore ) async def command_setup(app: PyroClient, message: Message): user = await app.find_user(message.from_user) @@ -34,7 +35,9 @@ async def command_setup(app: PyroClient, message: Message): ) while True: + app.contexts.append(message.from_user.id) answer_type = await listen_message(app, message.chat.id, 300) + app.contexts.remove(message.from_user.id) if answer_type is None or answer_type.text == "/cancel": await message.reply_text( diff --git a/plugins/commands/shutdown.py b/plugins/commands/shutdown.py index aa971c5..470241c 100644 --- a/plugins/commands/shutdown.py +++ b/plugins/commands/shutdown.py @@ -4,12 +4,14 @@ from pyrogram import filters from pyrogram.types import Message from classes.pyroclient import PyroClient +from modules import custom_filters @PyroClient.on_message( ~filters.scheduled & filters.private - & filters.command(["shutdown", "reboot", "restart"], prefixes=["/"]) # type: ignore + & filters.command(["shutdown", "reboot", "restart"], prefixes=["/"]) + & ~custom_filters.context # type: ignore ) async def command_shutdown(app: PyroClient, msg: Message): if msg.from_user.id == app.owner: diff --git a/plugins/commands/start.py b/plugins/commands/start.py index cb5ee98..3df7e34 100644 --- a/plugins/commands/start.py +++ b/plugins/commands/start.py @@ -10,10 +10,11 @@ from pyrogram.types import ( ) from classes.pyroclient import PyroClient +from modules import custom_filters @PyroClient.on_message( - ~filters.scheduled & filters.private & filters.command(["start"], prefixes=["/"]) # type: ignore + ~filters.scheduled & filters.private & filters.command(["start"], prefixes=["/"]) & ~custom_filters.context # type: ignore ) async def command_start(app: PyroClient, message: Message): user = await app.find_user(message.from_user) @@ -52,7 +53,9 @@ async def command_start(app: PyroClient, message: Message): ) while True: + app.contexts.append(message.from_user.id) answer = await listen_message(app, message.chat.id, 300) + app.contexts.remove(message.from_user.id) if answer is None or answer.text == "/cancel": await message.reply_text( diff --git a/plugins/commands/toggle.py b/plugins/commands/toggle.py index 91263e0..ac97f2b 100644 --- a/plugins/commands/toggle.py +++ b/plugins/commands/toggle.py @@ -4,10 +4,11 @@ from pyrogram import filters from pyrogram.types import Message from classes.pyroclient import PyroClient +from modules import custom_filters @PyroClient.on_message( - ~filters.scheduled & filters.private & filters.command(["toggle"], prefixes=["/"]) # type: ignore + ~filters.scheduled & filters.private & filters.command(["toggle"], prefixes=["/"]) & ~custom_filters.context # type: ignore ) async def command_toggle(app: PyroClient, message: Message): user = await app.find_user(message.from_user) diff --git a/plugins/commands/upcoming.py b/plugins/commands/upcoming.py index ac29e63..d468b0d 100644 --- a/plugins/commands/upcoming.py +++ b/plugins/commands/upcoming.py @@ -1,17 +1,17 @@ from datetime import datetime, timedelta, timezone -from pymongo.errors import OperationFailure from pyrogram import filters from pyrogram.types import Message from pytz import timezone as pytz_timezone from classes.garbage_entry import GarbageEntry from classes.pyroclient import PyroClient +from modules import custom_filters from modules.database import col_entries @PyroClient.on_message( - ~filters.scheduled & filters.private & filters.command(["upcoming"], prefixes=["/"]) # type: ignore + ~filters.scheduled & filters.private & filters.command(["upcoming"], prefixes=["/"]) & ~custom_filters.context # type: ignore ) async def command_upcoming(app: PyroClient, message: Message): user = await app.find_user(message.from_user) diff --git a/plugins/language.py b/plugins/language.py index 673b72b..54ac366 100644 --- a/plugins/language.py +++ b/plugins/language.py @@ -6,10 +6,11 @@ from pyrogram.types import CallbackQuery, Message from classes.callbacks import CallbackLanguage from classes.pyroclient import PyroClient +from modules import custom_filters @PyroClient.on_message( - ~filters.scheduled & filters.private & filters.command(["language"], prefixes=["/"]) # type: ignore + ~filters.scheduled & filters.private & filters.command(["language"], prefixes=["/"]) & ~custom_filters.context # type: ignore ) async def command_language(app: PyroClient, message: Message): user = await app.find_user(message.from_user)