Context handling implemented
This commit is contained in:
@@ -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)
|
||||
|
@@ -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(
|
||||
|
@@ -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":
|
||||
|
Reference in New Issue
Block a user