mirror of
https://github.com/Balshgit/gpt_chat_bot.git
synced 2026-02-04 16:50:38 +03:00
add bug report action (#71)
* add bug report * add admin section to env
This commit is contained in:
@@ -6,7 +6,8 @@ from loguru import logger
|
||||
from telegram import InlineKeyboardMarkup, Update
|
||||
from telegram.ext import ContextTypes
|
||||
|
||||
from constants import BotEntryPoints
|
||||
from constants import BotCommands, BotEntryPoints
|
||||
from core.bot.app import get_bot
|
||||
from core.bot.keyboards import main_keyboard
|
||||
from core.bot.services import ChatGptService, SpeechToTextService
|
||||
from settings.config import settings
|
||||
@@ -36,9 +37,7 @@ async def about_bot(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
chatgpt_service = ChatGptService.build()
|
||||
model = await chatgpt_service.get_current_chatgpt_model()
|
||||
await update.effective_message.reply_text(
|
||||
f"Бот использует бесплатную модель *{model}* для ответов на вопросы.\nПринимает запросы на разных языках."
|
||||
f"\n\nБот так же умеет переводить русские голосовые сообщения в текст. Просто пришлите или перешлите "
|
||||
f"голосовуху боту и получите поток сознания в виде текста, но без знаков препинания.",
|
||||
f"Бот использует бесплатную модель *{model}* для ответов на вопросы.\nПринимает запросы на разных языках.",
|
||||
parse_mode="Markdown",
|
||||
)
|
||||
|
||||
@@ -64,6 +63,20 @@ async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
|
||||
)
|
||||
|
||||
|
||||
async def bug_report(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
"""Send a message when the command /bug-report is issued."""
|
||||
|
||||
if not update.effective_message:
|
||||
return
|
||||
async with get_bot(settings.TELEGRAM_API_TOKEN) as bot:
|
||||
await bot.send_message(chat_id=settings.ADMIN_CHAT_ID, text=f"Bug report from user: {update.effective_user}")
|
||||
await update.effective_message.reply_text(
|
||||
f"Спасибо за баг репорт.\n"
|
||||
f"Можете попробовать воспользоваться веб версией /{BotCommands.website}, выбрав различные GPT модели",
|
||||
parse_mode="Markdown",
|
||||
)
|
||||
|
||||
|
||||
async def github(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
"""Send a message when the command /help is issued."""
|
||||
|
||||
@@ -79,7 +92,11 @@ async def ask_question(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
|
||||
if not update.message:
|
||||
return
|
||||
|
||||
await update.message.reply_text("Пожалуйста, подождите, ответ в среднем занимает 10-15 секунд")
|
||||
await update.message.reply_text(
|
||||
f"Ответ в среднем занимает 10-15 секунд.\n"
|
||||
f"- Список команд: /{BotCommands.help}\n"
|
||||
f"- Сообщить об ошибке: /{BotCommands.bug_report}",
|
||||
)
|
||||
|
||||
chatgpt_service = ChatGptService.build()
|
||||
logger.warning("question asked", user=update.message.from_user, question=update.message.text)
|
||||
|
||||
@@ -9,11 +9,12 @@ from telegram.ext import (
|
||||
filters,
|
||||
)
|
||||
|
||||
from constants import BotEntryPoints, BotStagesEnum
|
||||
from constants import BotCommands, BotEntryPoints, BotStagesEnum
|
||||
from core.bot.commands import (
|
||||
about_bot,
|
||||
about_me,
|
||||
ask_question,
|
||||
bug_report,
|
||||
github,
|
||||
help_command,
|
||||
start_command,
|
||||
@@ -32,7 +33,10 @@ class BotEventHandlers:
|
||||
|
||||
bot_event_handlers = BotEventHandlers()
|
||||
|
||||
bot_event_handlers.add_handler(CommandHandler("help", help_command))
|
||||
bot_event_handlers.add_handler(CommandHandler(BotCommands.help, help_command))
|
||||
bot_event_handlers.add_handler(CommandHandler(BotCommands.website, website))
|
||||
bot_event_handlers.add_handler(CommandHandler(BotCommands.bug_report, bug_report))
|
||||
|
||||
bot_event_handlers.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, ask_question))
|
||||
bot_event_handlers.add_handler(MessageHandler(filters.VOICE | filters.AUDIO, voice_recognize))
|
||||
bot_event_handlers.add_handler(
|
||||
|
||||
Reference in New Issue
Block a user