|
5 | 5 | # @Software: PyCharm
|
6 | 6 | from typing import Optional, Union, List
|
7 | 7 |
|
| 8 | +import telegramify_markdown |
8 | 9 | from loguru import logger
|
9 | 10 | from telebot import formatting, util
|
10 | 11 | from telebot import types
|
11 | 12 | from telebot.async_telebot import AsyncTeleBot
|
12 | 13 | from telebot.asyncio_storage import StateMemoryStorage
|
13 |
| -from telebot.formatting import escape_markdown |
14 | 14 | from telegramify_markdown import convert
|
15 | 15 |
|
16 | 16 | from app.sender.util_func import (
|
|
23 | 23 | TimerObjectContainer,
|
24 | 24 | dict2markdown,
|
25 | 25 | learn_instruction,
|
| 26 | + logout, |
26 | 27 | )
|
27 | 28 | from app.setting.telegram import BotSetting
|
28 | 29 | from llmkira.kv_manager.env import EnvManager
|
@@ -69,7 +70,15 @@ async def transcribe(
|
69 | 70 | event_messages = []
|
70 | 71 | files = [file for file in files if file] # No None
|
71 | 72 | for index, message in enumerate(messages):
|
72 |
| - message_text = getattr(message, "text", "empty") |
| 73 | + message_text = ( |
| 74 | + ( |
| 75 | + getattr(message, "text", None) |
| 76 | + or getattr(message, "caption", None) |
| 77 | + or "empty" |
| 78 | + ) |
| 79 | + if message is not None |
| 80 | + else "empty" |
| 81 | + ) |
73 | 82 | event_messages.append(
|
74 | 83 | EventMessage(
|
75 | 84 | chat_id=str(message.chat.id),
|
@@ -251,6 +260,17 @@ async def listen_login_command(message: types.Message):
|
251 | 260 | parse_mode="MarkdownV2",
|
252 | 261 | )
|
253 | 262 |
|
| 263 | + @bot.message_handler(commands="logout", chat_types=["private"]) |
| 264 | + async def listen_logout_command(message: types.Message): |
| 265 | + logger.debug("Debug:logout command") |
| 266 | + _cmd, _arg = parse_command(command=message.text) |
| 267 | + reply = await logout(uid=uid_make(__sender__, message.from_user.id)) |
| 268 | + await bot.reply_to( |
| 269 | + message, |
| 270 | + text=reply, |
| 271 | + parse_mode="MarkdownV2", |
| 272 | + ) |
| 273 | + |
254 | 274 | @bot.message_handler(commands="env", chat_types=["private"])
|
255 | 275 | async def listen_env_command(message: types.Message):
|
256 | 276 | _cmd, _arg = parse_command(command=message.text)
|
@@ -299,8 +319,7 @@ async def listen_help_command(message: types.Message):
|
299 | 319 | _message = await bot.reply_to(
|
300 | 320 | message,
|
301 | 321 | text=formatting.format_text(
|
302 |
| - formatting.mbold("🥕 Help"), |
303 |
| - escape_markdown(help_message()), |
| 322 | + telegramify_markdown.convert(help_message()), |
304 | 323 | separator="\n",
|
305 | 324 | ),
|
306 | 325 | parse_mode="MarkdownV2",
|
|
0 commit comments