Skip to content

Commit

Permalink
select main currency
Browse files Browse the repository at this point in the history
  • Loading branch information
XigmaDev committed Dec 28, 2024
1 parent 41089b9 commit 2e91838
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,22 @@ def format_data_for_telegram(data):
# Add more currencies and their Persian names as needed
}

currencies_to_send = ['usd', 'eur', 'gbp', 'chf', 'jpy', 'try', 'cny', 'rub', 'aed', 'emami1', 'azadi1g', 'azadi1', 'azadi12', 'azadi14', 'mithqal', 'gol18', 'ounce', 'bitcoin']

formatted_lines = []
for key, values in data.items():
flag = currency_flags.get(key.lower(), '')
name_persian = currency_names_persian.get(key.lower(), key.upper())

if key.lower() not in ['bitcoin', 'ounce']:
sell_price = f"{int(values['sell']):,} تومن"
buy_price = f"{int(values['buy']):,} تومن"
else:
sell_price = f"{values['sell']} دلار"
buy_price = f"{values['buy']} دلار"

formatted_lines.append(f"{flag}{name_persian}: \n - فروش: {sell_price} \n - خرید: {buy_price}")
if key.lower() in currencies_to_send:
flag = currency_flags.get(key.lower(), '')
name_persian = currency_names_persian.get(key.lower(), key.upper())

if key.lower() not in ['bitcoin', 'ounce']:
sell_price = f"{int(values['sell']):,} تومن"
buy_price = f"{int(values['buy']):,} تومن"
else:
sell_price = f"{values['sell']} دلار"
buy_price = f"{values['buy']} دلار"

formatted_lines.append(f"{flag}{name_persian}: \n - فروش: {sell_price} \n - خرید: {buy_price}")

formatted_message = "\n\n".join(formatted_lines)

Expand All @@ -71,7 +74,6 @@ def format_data_for_telegram(data):

return formatted_message


def send_to_telegram(message):
telegram_url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage"
payload = {"chat_id": TELEGRAM_CHAT_ID, "text": f"\u200F{message}", "parse_mode": "Markdown"}
Expand Down

0 comments on commit 2e91838

Please sign in to comment.