Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add menu button in telegram bot #58

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion notify/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import os
from datetime import datetime
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup, BotCommand
from telegram.ext import Application, CommandHandler, CallbackQueryHandler, ContextTypes
from dotenv import load_dotenv

Expand Down Expand Up @@ -384,6 +384,17 @@ async def set_bot_description(application) -> None:
)
await application.bot.set_my_description(description)

async def set_bot_commands(application) -> None:
commands = [
BotCommand("start", "Iniciar el bot y añadir nuevas preferencias"),
BotCommand("check", "Listar tus preferencias actuales"),
BotCommand("delete", "Eliminar una preferencia específica"),
BotCommand("clean", "Eliminar todas tus preferencias"),
BotCommand("about", "Mostrar información sobre el bot"),
BotCommand("help", "Mostrar este mensaje de ayuda")
]
await application.bot.set_my_commands(commands)

# MAIN Function
def main() -> None:
telegram_token = os.getenv("TELEGRAM_TOKEN")
Expand All @@ -406,6 +417,9 @@ def main() -> None:
# Establecer la descripción del bot
application.job_queue.run_once(set_bot_description, 0)

# Establecer los comandos del bot
application.job_queue.run_once(set_bot_commands, 0)

application.run_polling()

if __name__ == '__main__':
Expand Down
Loading