Update the MarkdownV2 message

This commit is contained in:
Yi Zhao 2024-03-29 23:01:34 +08:00
parent 27444d6fa1
commit 98909312f2
4 changed files with 13 additions and 16 deletions

View File

@ -20,6 +20,12 @@ T = TypeVar("T", bound=Callable)
BOT_MESSAGE_LENGTH = 4000
def bot_reply_first(message: Message, who: str, bot: TeleBot) -> Message:
""" Create the first reply message which make user feel the bot is working. """
return bot.reply_to(message,
f"**{who}** is __thinking__ \.\.\.",
parse_mode="MarkdownV2"
)
def bot_reply_markdown(reply_id: Message, who: str, text: str, bot: TeleBot) -> None:
"""
@ -144,4 +150,4 @@ def list_available_commands() -> list[str]:
# `import *` will give you these
__all__ = ["bot_reply_markdown", "extract_prompt"]
__all__ = ["bot_reply_first", "bot_reply_markdown", "extract_prompt"]

View File

@ -6,7 +6,7 @@ from anthropic import Anthropic, APITimeoutError
from telebot import TeleBot
from telebot.types import Message
from . import bot_reply_markdown
from . import *
from telegramify_markdown import convert
from telegramify_markdown.customize import markdown_symbol
@ -48,10 +48,7 @@ def claude_handler(message: Message, bot: TeleBot) -> None:
return
# show something, make it more responsible
reply_id = bot.reply_to(message,
"**Claude** is __thinking__...",
parse_mode="MarkdownV2"
)
reply_id = bot_reply_first(message, "Claude", bot)
player_message.append({"role": "user", "content": m})
# keep the last 5, every has two ask and answer.

View File

@ -6,7 +6,7 @@ from google.generativeai.types.generation_types import StopCandidateException
from telebot import TeleBot
from telebot.types import Message
from . import bot_reply_markdown
from . import *
GOOGLE_GEMINI_KEY = environ.get("GOOGLE_GEMINI_KEY")
@ -59,10 +59,7 @@ def gemini_handler(message: Message, bot: TeleBot) -> None:
return
# show something, make it more responsible
reply_id = bot.reply_to(message,
"**Gemini** is __thinking__...",
parse_mode="MarkdownV2"
)
reply_id = bot_reply_first(message, "Gemini", bot)
# keep the last 5, every has two ask and answer.
if len(player.history) > 10:

View File

@ -7,7 +7,7 @@ import requests
from telebot import TeleBot
from telebot.types import Message
from . import bot_reply_markdown
from . import *
YI_BASE_URL = environ.get("YI_BASE_URL")
YI_API_KEY = environ.get("YI_API_KEY")
@ -45,10 +45,7 @@ def yi_handler(message: Message, bot: TeleBot) -> None:
return
# show something, make it more responsible
reply_id = bot.reply_to(message,
"**Yi** is __thinking__...",
parse_mode="MarkdownV2"
)
reply_id = bot_reply_first(message, "Yi", bot)
player_message.append({"role": "user", "content": m})
# keep the last 5, every has two ask and answer.