mirror of
https://github.com/nexus-stc/hyperboria
synced 2024-12-04 17:02:53 +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
26 lines
901 B
Python
26 lines
901 B
Python
from library.telegram.base import RequestContext
|
|
from nexus.translations import t
|
|
from nexus.views.telegram.common import (
|
|
TooLongQueryError,
|
|
encode_query_to_deep_link,
|
|
)
|
|
from telethon import events
|
|
|
|
from .base import BaseHandler
|
|
|
|
|
|
class ShortlinkHandler(BaseHandler):
|
|
filter = events.NewMessage(incoming=True, pattern='^/shortlink\\s?(.*)?')
|
|
|
|
async def handler(self, event: events.ChatAction, request_context: RequestContext):
|
|
query = event.pattern_match.group(1)
|
|
request_context.statbox(action='start', mode='shortlink', query=query)
|
|
|
|
try:
|
|
bot_name = self.application.config['telegram']['bot_name']
|
|
text = encode_query_to_deep_link(query, bot_name)
|
|
except TooLongQueryError:
|
|
text = t('TOO_LONG_QUERY_FOR_SHORTLINK', request_context.chat.language)
|
|
|
|
return await event.reply(f'`{text}`', link_preview=False)
|