From 60b9f1d485651fce46c22c17129d726cbcaa9741 Mon Sep 17 00:00:00 2001 From: onlive1337 Date: Thu, 5 Sep 2024 19:49:54 +0500 Subject: [PATCH] 0.9.3 --- CHANGELOG.md | 27 ++++----------------------- bot.py | 12 +++++++++++- config.py | 2 +- languages.py | 2 ++ 4 files changed, 18 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4132ae4..c9eeffe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,33 +1,14 @@ -[0.9.2] - 2024-09-05 +[0.9.3] - 2024-09-05 RU: -Пофикшено: - -Исчезновение криптовалюты когда идёт настройка в чате - -Изменено: - -Текст /start -И текст раздела Помощь - Добавлено: -1) Добавлены триггеры к сокращениям на русском ( сум , лир , лиры , лира , гривны , грн , тон, доллар, долларов, доллары ) -2) Добавлены триггеры к буквенным обозначениям цифр ( 1 млн сум ) и тд -3) Было добавлено предупреждение если юзер пишет неправильную валюту +Кнопка удаления как и в лс бота так и в чатах EN: -Fixed: -Disappearance of cryptocurrency when chat customization is in progress - -Modified: -/start text -And the text of the Help section - Added: -1) Added triggers to abbreviations in Russian ( сум , лир , лиры , лира , гривны , грн , тон ) -2) Added triggers for alphabetic digits ( 1 млн сум ) etc. -3) A warning was added if user writes wrong currency \ No newline at end of file + +Delete button in both bot dm and chat \ No newline at end of file diff --git a/bot.py b/bot.py index 0a7e886..2ceeebd 100644 --- a/bot.py +++ b/bot.py @@ -860,8 +860,11 @@ async def process_conversion(message: types.Message, amount: float, from_currenc response += f"{LANGUAGES[user_lang]['cryptocurrencies_output']}\n" response += "\n".join(crypto_conversions) + kb = InlineKeyboardBuilder() + kb.button(text=LANGUAGES[user_lang].get('delete_button', "Delete"), callback_data="delete_conversion") + logger.info(f"Sending conversion response for {amount} {from_currency} to user {user_id} in chat {chat_id}") - await message.answer(response) + await message.answer(response, reply_markup=kb.as_markup()) except OverflowError: await message.answer(LANGUAGES[user_lang].get('number_too_large', "The number is too large to process.")) except Exception as e: @@ -869,6 +872,9 @@ async def process_conversion(message: types.Message, amount: float, from_currenc logger.exception("Full traceback:") await message.answer(LANGUAGES[user_lang]['error']) +async def delete_conversion_message(callback_query: CallbackQuery): + await callback_query.message.delete() + await callback_query.answer() async def process_about(callback_query: CallbackQuery): user_data.update_user_data(callback_query.from_user.id) @@ -987,6 +993,9 @@ async def process_callback(callback_query: CallbackQuery, state: FSMContext): await process_about(callback_query) elif action == 'view': await view_changelog(callback_query) + elif action == 'delete': + if callback_query.data == 'delete_conversion': + await delete_conversion_message(callback_query) async def main(): bot = Bot(token=BOT_TOKEN) @@ -1020,6 +1029,7 @@ async def main(): dp.callback_query.register(save_chat_settings, F.data.startswith("save_chat_settings_")) dp.callback_query.register(back_to_settings, F.data == "back_to_settings") dp.callback_query.register(back_to_chat_settings, F.data.startswith("back_to_chat_settings_")) + dp.callback_query.register(delete_conversion_message, F.data == "delete_conversion") dp.callback_query.register(process_callback) dp.inline_query.register(inline_query_handler) diff --git a/config.py b/config.py index 629041a..517a861 100644 --- a/config.py +++ b/config.py @@ -6,7 +6,7 @@ BOT_TOKEN = os.getenv('TELEGRAM_BOT_TOKEN') ADMIN_IDS = [810587766] USER_DATA_FILE = 'user_data.json' -CURRENT_VERSION = "0.9.2" +CURRENT_VERSION = "0.9.3" CACHE_EXPIRATION_TIME = 600 diff --git a/languages.py b/languages.py index 87db06d..1cb7bfe 100644 --- a/languages.py +++ b/languages.py @@ -72,6 +72,7 @@ 'current_version': "Текущая версия:", 'view_changelog': "Посмотреть список изменений", 'invalid_currency': "Извините, я не могу распознать валюту '{currency}'. Пожалуйста, используйте стандартные коды валют, например: USD, EUR, RUB.", + 'delete_button': "Удалить", }, 'en': { 'welcome': """Hello! I'm a currency conversion bot. 🌍💱 @@ -146,5 +147,6 @@ 'current_version': "Current version:", 'view_changelog': "View changelog", 'invalid_currency': "Sorry, I can't recognize the currency '{currency}'. Please use standard currency codes, for example: USD, EUR, RUB.", + 'delete_button': "Delete", } } \ No newline at end of file