added start command

This commit is contained in:
Louis Heredero 2024-09-17 18:28:41 +02:00
parent c9c95350a8
commit d890215b12
Signed by: HEL
GPG Key ID: 8D83DE470F8544E7
2 changed files with 13 additions and 3 deletions

View File

@ -12,6 +12,7 @@ import aiohttp
import telegram.constants import telegram.constants
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from telegram import Update, InlineKeyboardMarkup, InlineKeyboardButton from telegram import Update, InlineKeyboardMarkup, InlineKeyboardButton
from telegram.constants import ParseMode
from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes, CallbackQueryHandler, Application from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes, CallbackQueryHandler, Application
log_dir = os.getenv("BEEBOT_LOGS") log_dir = os.getenv("BEEBOT_LOGS")
@ -96,6 +97,7 @@ class BeeBot:
self.load_i18n() self.load_i18n()
self.tg_app = ApplicationBuilder().token(self.tg_token).build() self.tg_app = ApplicationBuilder().token(self.tg_token).build()
self.tg_app.add_handler(CommandHandler("start", self.cmd_start))
self.tg_app.add_handler(CommandHandler("week", self.cmd_week)) self.tg_app.add_handler(CommandHandler("week", self.cmd_week))
self.tg_app.add_handler(CommandHandler("today", self.cmd_today)) self.tg_app.add_handler(CommandHandler("today", self.cmd_today))
self.tg_app.add_handler(CommandHandler("settings", self.cmd_settings)) self.tg_app.add_handler(CommandHandler("settings", self.cmd_settings))
@ -115,6 +117,11 @@ class BeeBot:
return f"[{key}]" return f"[{key}]"
return self.langs[lang][key] return self.langs[lang][key]
async def cmd_start(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
logger.debug("Received /start")
lang = self.get_user_pref(update, context)["lang"]
await update.effective_chat.send_message(text=self.i18n(lang, "notif.start"), parse_mode=ParseMode.HTML)
async def cmd_week(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: async def cmd_week(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
logger.debug("Received /week") logger.debug("Received /week")
await self.request_menu(update, context, False) await self.request_menu(update, context, False)

View File

@ -11,7 +11,8 @@
"setting.language": "Langue: {}", "setting.language": "Langue: {}",
"setting.categories": "Catégories: {}", "setting.categories": "Catégories: {}",
"notif.wait_updating": "Le menu est en train d'être mis à jour, veuillez patienter...", "notif.wait_updating": "Le menu est en train d'être mis à jour, veuillez patienter...",
"notif.unavailable": "Il semblerait que le menu ne soit actuellement pas disponible" "notif.unavailable": "Il semblerait que le menu ne soit actuellement pas disponible",
"notif.start": "<b>Salut, je suis BeeBot 🐝, le robot des menus de la cafétéria de l'HEI !</b>\n<i>(changer la langue / change language / Sprache ändern: /settings)</i>\n\nPour voir les menus de la <u>semaine</u>, utilisez la commande /week\nPour voir les menus du <u>jour</u>, utilisez /today\n\nSi vous souhaitez changer la <u>langue</u> dans laquelle je parle ou les <u>catégories de prix</u> affichées dans les menus, utilisez la commande /settings\n\n<b>Merci de ne pas spammer</b> afin de ne pas impacter l'utilisation de ce service par les autres personnes\n\n<b>Bon appétit ! 🍽</b>"
}, },
"en": { "en": {
"category.student": "Student", "category.student": "Student",
@ -25,7 +26,8 @@
"setting.language": "Language: {}", "setting.language": "Language: {}",
"setting.categories": "Categories: {}", "setting.categories": "Categories: {}",
"notif.wait_updating": "The menu is being updated, please wait...", "notif.wait_updating": "The menu is being updated, please wait...",
"notif.unavailable": "It seems that the menu is currently unavailable" "notif.unavailable": "It seems that the menu is currently unavailable",
"notif.start": "<b>Hi, I'm BeeBot 🐝, the HEI cafeteria menu robot !</b>\n<i>(changer la langue / change language / Sprache ändern: /settings)</i>\n\nTo see the menus for the <u>week</u>, use the command /week\nTo see <u>today</u>'s menus, use /today\n\nIf you want to change the <u>language</u> I speak or the <u>price categories</u> displayed in the menus, use the command /settings\n\n<b>Please do not spam</b> to avoid affecting other people's use of this service\n\n<b>Enjoy your meal ! 🍽</b>"
}, },
"de": { "de": {
"category.student": "Student", "category.student": "Student",
@ -39,6 +41,7 @@
"setting.language": "Sprache: {}", "setting.language": "Sprache: {}",
"setting.categories": "Kategorien: {}", "setting.categories": "Kategorien: {}",
"notif.wait_updating": "Das Menü wird gerade aktualisiert, bitte warten Sie...", "notif.wait_updating": "Das Menü wird gerade aktualisiert, bitte warten Sie...",
"notif.unavailable": "Es scheint, dass das Menü derzeit nicht verfügbar ist" "notif.unavailable": "Es scheint, dass das Menü derzeit nicht verfügbar ist",
"notif.start": "<b>Hallo, ich bin BeeBot 🐝, der Menüroboter der Cafeteria der HEI !</b>\n<i>(changer la langue / change language / Sprache ändern: /settings)</i>\n\nUm die Menüs der <u>Woche</u> zu sehen, verwende den Befehl /week\nUm die Menüs des <u>Tages</u> zu sehen, verwenden Sie /today\n\nWenn Sie die <u>Sprache</u>, in der ich spreche, oder die <u>Preiskategorien</u>, die in den Menüs angezeigt werden, ändern möchten, verwenden Sie den Befehl /settings\n\n<b>Bitte spammen Sie nicht</b>, um die Nutzung dieses Dienstes durch andere Personen nicht zu beeinträchtigen\n\n<b>Guten Appetit ! 🍽</b>"
} }
} }