using right chat id for callback message
Signed-off-by: klux2 <k.lux.gm@gmail.com>
This commit is contained in:
parent
c98619a524
commit
2c7337f0e0
1 changed files with 20 additions and 14 deletions
|
@ -70,11 +70,6 @@ class EnumEncode(json.JSONEncoder):
|
||||||
|
|
||||||
|
|
||||||
class HSMensaW(telepot.aio.helper.ChatHandler):
|
class HSMensaW(telepot.aio.helper.ChatHandler):
|
||||||
keyboard = InlineKeyboardMarkup(inline_keyboard=[
|
|
||||||
[InlineKeyboardButton(text="Deutsch", callback_data=Language.GERMAN.value)],
|
|
||||||
[InlineKeyboardButton(text="English", callback_data=Language.ENGLISH.value)],
|
|
||||||
[InlineKeyboardButton(text="Deutsch + English", callback_data=Language.GERMAN_ENGLISH.value)],
|
|
||||||
])
|
|
||||||
|
|
||||||
async def on_chat_message(self, msg: dict) -> None:
|
async def on_chat_message(self, msg: dict) -> None:
|
||||||
global config, essen, status, var, logging_enabled
|
global config, essen, status, var, logging_enabled
|
||||||
|
@ -137,9 +132,15 @@ class HSMensaW(telepot.aio.helper.ChatHandler):
|
||||||
|
|
||||||
elif text.startswith("/settings"):
|
elif text.startswith("/settings"):
|
||||||
if chat_id in ids:
|
if chat_id in ids:
|
||||||
await send_message(bot_obj=bot, chat_id=chat_id,
|
callback_chat_id = "::" + str(chat_id)
|
||||||
msg="Bitte Sprache(n) auswählen/Please select language(s)",
|
keyboard = InlineKeyboardMarkup(inline_keyboard=[
|
||||||
reply_markup=self.keyboard)
|
[InlineKeyboardButton(text="Deutsch", callback_data=Language.GERMAN.value + callback_chat_id)],
|
||||||
|
[InlineKeyboardButton(text="English", callback_data=Language.ENGLISH.value + callback_chat_id)],
|
||||||
|
[InlineKeyboardButton(text="Deutsch + English",
|
||||||
|
callback_data=Language.GERMAN_ENGLISH.value + callback_chat_id)],
|
||||||
|
])
|
||||||
|
await send_message(bot_obj=bot, chat_id=chat_id, msg="Bitte Sprache(n) auswählen/Please select "
|
||||||
|
"language(s)", reply_markup=keyboard)
|
||||||
else:
|
else:
|
||||||
await send_message(bot_obj=bot, chat_id=chat_id,
|
await send_message(bot_obj=bot, chat_id=chat_id,
|
||||||
msg="Bitte starten Sie zuerst den Bot/Please start the bot first.\n/start")
|
msg="Bitte starten Sie zuerst den Bot/Please start the bot first.\n/start")
|
||||||
|
@ -176,20 +177,25 @@ class HSMensaW(telepot.aio.helper.ChatHandler):
|
||||||
global config, ids
|
global config, ids
|
||||||
query_id, from_id, query_data = telepot.glance(msg, flavor='callback_query')
|
query_id, from_id, query_data = telepot.glance(msg, flavor='callback_query')
|
||||||
|
|
||||||
|
lang = query_data[:query_data.index("::")]
|
||||||
|
chat_id = int(query_data[query_data.index("::") + 2:])
|
||||||
|
|
||||||
message = "Fehler beim Setzen der Sprache"
|
message = "Fehler beim Setzen der Sprache"
|
||||||
if query_data == Language.GERMAN.value:
|
if lang == Language.GERMAN.value:
|
||||||
message = "Sprache geändert nach _deutsch_."
|
message = "Sprache geändert nach _deutsch_."
|
||||||
elif query_data == Language.ENGLISH.value:
|
elif lang == Language.ENGLISH.value:
|
||||||
message = "Changed language to _english_."
|
message = "Changed language to _english_."
|
||||||
elif query_data == Language.GERMAN_ENGLISH.value:
|
elif lang == Language.GERMAN_ENGLISH.value:
|
||||||
message = "Sprache geändert nach _deutsch + englisch_. Changed language to _german + english_."
|
message = "Sprache geändert nach _deutsch + englisch_. Changed language to _german + english_."
|
||||||
|
|
||||||
if from_id in ids:
|
if chat_id in ids:
|
||||||
ids[from_id] = Language(query_data)
|
ids[chat_id] = Language(lang)
|
||||||
config['ids'] = ids
|
config['ids'] = ids
|
||||||
write_config()
|
write_config()
|
||||||
|
else:
|
||||||
|
message = "Fehler: Bot nicht aktiviert für diesen Chat!"
|
||||||
|
|
||||||
await send_message(bot_obj=bot, chat_id=from_id, msg=message, parse_mode="markdown")
|
await send_message(bot_obj=bot, chat_id=chat_id, msg=message, parse_mode="markdown")
|
||||||
|
|
||||||
|
|
||||||
async def send_essen(chat_id: int, sprache: Language = Language.GERMAN) -> None:
|
async def send_essen(chat_id: int, sprache: Language = Language.GERMAN) -> None:
|
||||||
|
|
Loading…
Reference in a new issue