mirror of
https://github.com/nexus-stc/hyperboria
synced 2024-12-12 04:37:50 +01:00
43be16e4bc
- [nexus] Remove outdated protos - [nexus] Development - [nexus] Development - [nexus] Development - [nexus] Development - [nexus] Development - [nexus] Refactor views - [nexus] Update aiosumma - [nexus] Add tags - [nexus] Development - [nexus] Update repository - [nexus] Update repository - [nexus] Update dependencies - [nexus] Update dependencies - [nexus] Fixes for MetaAPI - [nexus] Support for new queries - [nexus] Adopt new versions of search - [nexus] Improving Nexus - [nexus] Various fixes - [nexus] Add profile - [nexus] Fixes for ingestion - [nexus] Refactorings and bugfixes - [idm] Add profile methods - [nexus] Fix stalled nexus-meta bugs - [nexus] Various bugfixes - [nexus] Restore IDM API functionality GitOrigin-RevId: a0842345a6dde5b321279ab5510a50c0def0e71a
56 lines
2.0 KiB
Python
56 lines
2.0 KiB
Python
import asyncio
|
|
|
|
from library.telegram.base import RequestContext
|
|
from nexus.translations import t
|
|
from nexus.views.telegram.common import (
|
|
DecodeDeepQueryError,
|
|
decode_deep_query,
|
|
)
|
|
from telethon import events
|
|
|
|
from .search import BaseSearchHandler
|
|
|
|
|
|
class StartHandler(BaseSearchHandler):
|
|
should_reset_last_widget = False
|
|
filter = events.NewMessage(incoming=True, pattern='^/start\\s?(.*)?')
|
|
|
|
async def handler(self, event: events.ChatAction, request_context: RequestContext):
|
|
raw_query = event.pattern_match.group(1)
|
|
query = None
|
|
|
|
request_context.statbox(action='start', mode='start')
|
|
|
|
try:
|
|
query = decode_deep_query(raw_query)
|
|
except DecodeDeepQueryError as e:
|
|
request_context.error_log(e, mode='start', raw_query=raw_query)
|
|
|
|
if query:
|
|
request_context.statbox(action='query', mode='start', query=query)
|
|
request_message = await self.application.telegram_client.send_message(event.chat, query)
|
|
prefetch_message = await request_message.reply(
|
|
t("SEARCHING", request_context.chat.language),
|
|
)
|
|
self.application.user_manager.last_widget[request_context.chat.chat_id] = prefetch_message.id
|
|
text, buttons = await self.setup_widget(
|
|
request_context=request_context,
|
|
prefetch_message=prefetch_message,
|
|
query=query,
|
|
is_shortpath_enabled=True,
|
|
)
|
|
edit_action = self.application.telegram_client.edit_message(
|
|
request_context.chat.chat_id,
|
|
prefetch_message.id,
|
|
text,
|
|
buttons=buttons,
|
|
link_preview=False,
|
|
)
|
|
await asyncio.gather(
|
|
event.delete(),
|
|
edit_action,
|
|
)
|
|
else:
|
|
request_context.statbox(action='show', mode='start')
|
|
await event.reply(t('HELP', request_context.chat.language))
|