Fix parse mode default for telegram bot
All checks were successful
publish-images / build (push) Successful in 56s
All checks were successful
publish-images / build (push) Successful in 56s
This commit is contained in:
18
bot/main.py
18
bot/main.py
@@ -12,6 +12,7 @@ from telegram.ext import (
|
||||
CallbackQueryHandler,
|
||||
CommandHandler,
|
||||
ContextTypes,
|
||||
Defaults,
|
||||
)
|
||||
|
||||
from .boinc import BoincClient
|
||||
@@ -55,9 +56,7 @@ async def render_view(view: View, client: BoincClient) -> str:
|
||||
async def start_handler(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
client: BoincClient = context.bot_data["boinc_client"]
|
||||
text = await render_view("dashboard", client)
|
||||
await update.message.reply_text(
|
||||
text, reply_markup=build_keyboard(), parse_mode=ParseMode.HTML
|
||||
)
|
||||
await update.message.reply_text(text, reply_markup=build_keyboard(), parse_mode=ParseMode.HTML)
|
||||
|
||||
|
||||
async def callback_handler(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
@@ -70,9 +69,7 @@ async def callback_handler(update: Update, context: ContextTypes.DEFAULT_TYPE) -
|
||||
except Exception as exc: # broad catch to show meaningful message in chat
|
||||
logger.exception("Error rendering view %s", view)
|
||||
text = f"Не удалось получить данные: {exc}"
|
||||
await query.edit_message_text(
|
||||
text=text, reply_markup=build_keyboard(), parse_mode=ParseMode.HTML
|
||||
)
|
||||
await query.edit_message_text(text=text, reply_markup=build_keyboard(), parse_mode=ParseMode.HTML)
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
@@ -85,12 +82,8 @@ async def main() -> None:
|
||||
sample_output=settings.sample_output,
|
||||
)
|
||||
|
||||
application = (
|
||||
ApplicationBuilder()
|
||||
.token(settings.telegram_token)
|
||||
.parse_mode(ParseMode.HTML)
|
||||
.build()
|
||||
)
|
||||
defaults = Defaults(parse_mode=ParseMode.HTML)
|
||||
application = ApplicationBuilder().token(settings.telegram_token).defaults(defaults).build()
|
||||
application.bot_data["boinc_client"] = client
|
||||
|
||||
application.add_handler(CommandHandler("start", start_handler))
|
||||
@@ -103,4 +96,3 @@ async def main() -> None:
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user