Skip to content

Commit

Permalink
0.9.5
Browse files Browse the repository at this point in the history
  • Loading branch information
onlive1337 committed Sep 7, 2024
1 parent a6fd7dc commit 5ee2df4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
9 changes: 4 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@


[0.9.4] - 2024-09-05
[0.9.5] - 2024-09-05
RU:

Исправлено:

Тригер бота на сообщения по типу "10 денег"
Вывод бота спустя время ломался

EN:

Fixed:
Bot Trigger on “10 money” type messages

The output of the bot would break after a while
29 changes: 15 additions & 14 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,31 +829,32 @@ async def process_conversion(message: types.Message, amount: float, from_currenc
if not user_crypto:
user_crypto = CRYPTO_CURRENCIES[:5]

all_user_currencies = user_currencies + user_crypto

response = f"{format_large_number(amount)} {ALL_CURRENCIES.get(from_currency, '')} {from_currency}\n\n"

fiat_conversions = []
crypto_conversions = []

for to_cur in all_user_currencies:
for to_cur in user_currencies:
if to_cur != from_currency:
try:
converted = convert_currency(amount, from_currency, to_cur, rates)
conversion_line = f"{format_large_number(converted)} {ALL_CURRENCIES.get(to_cur, '')} {to_cur}"
fiat_conversions.append(conversion_line)
except KeyError:
logger.warning(f"Conversion failed for {to_cur}. It might not be in the rates.")
except OverflowError:
fiat_conversions.append(f"Overflow {ALL_CURRENCIES.get(to_cur, '')} {to_cur}")

for to_cur in user_crypto:
if to_cur != from_currency:
try:
converted = convert_currency(amount, from_currency, to_cur, rates)
is_crypto = to_cur in CRYPTO_CURRENCIES
conversion_line = f"{format_large_number(converted, is_crypto)} {ALL_CURRENCIES.get(to_cur, '')} {to_cur}"
if is_crypto:
crypto_conversions.append(conversion_line)
else:
fiat_conversions.append(conversion_line)
conversion_line = f"{format_large_number(converted, True)} {ALL_CURRENCIES.get(to_cur, '')} {to_cur}"
crypto_conversions.append(conversion_line)
except KeyError:
logger.warning(f"Conversion failed for {to_cur}. It might not be in the rates.")
except OverflowError:
conversion_line = f"Overflow {ALL_CURRENCIES.get(to_cur, '')} {to_cur}"
if to_cur in CRYPTO_CURRENCIES:
crypto_conversions.append(conversion_line)
else:
fiat_conversions.append(conversion_line)
crypto_conversions.append(f"Overflow {ALL_CURRENCIES.get(to_cur, '')} {to_cur}")

if fiat_conversions:
response += f"{LANGUAGES[user_lang]['fiat_currencies']}\n"
Expand Down
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
BOT_TOKEN = os.getenv('TELEGRAM_BOT_TOKEN')
ADMIN_IDS = [810587766]
USER_DATA_FILE = 'user_data.json'
CURRENT_VERSION = "0.9.4"
CURRENT_VERSION = "0.9.5"

CACHE_EXPIRATION_TIME = 600

Expand Down

0 comments on commit 5ee2df4

Please sign in to comment.