Skip to content
15 changes: 10 additions & 5 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from models.user import UserAdmin
from processing.processing import processing_router
from repositories.button_media import ButtonMediaRepository
from services.media import MediaService
from services.notification import NotificationService
from services.wallet import WalletService
from utils.utils import validate_i18n
Expand Down Expand Up @@ -91,16 +92,20 @@ async def on_startup():
if photos.total_count == 0:
photo_id_list = []
for admin_id in config.ADMIN_ID_LIST:
msg = await bot.send_photo(chat_id=admin_id,
photo=URLInputFile(url="https://i.imgur.com/CxWRPwY.png",
filename="no_image.png"))
bot_photo_id = msg.photo[-1].file_id
photo_id_list.append(bot_photo_id)
try:
msg = await bot.send_photo(chat_id=admin_id,
photo=URLInputFile(url="https://img.freepik.com/premium-vector/no-photo-available-vector-icon-default-image-symbol-picture-coming-soon-web-site-mobile-app_87543-18055.jpg",
filename="no_image.png"))
bot_photo_id = msg.photo[-1].file_id
photo_id_list.append(bot_photo_id)
except Exception as _:
pass
bot_photo_id = photo_id_list[0]
else:
bot_photo_id = photos.photos[0][-1].file_id
with open("static/no_image.jpeg", "w") as f:
f.write(bot_photo_id)
await MediaService.update_inaccessible_media(bot)
validate_i18n()
await ButtonMediaRepository.init_buttons_media()
if config.CRYPTO_FORWARDING_MODE:
Expand Down
6 changes: 3 additions & 3 deletions crypto_api/CryptoApiWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ async def fetch_api_request(url: str, params: dict | None = None, method: str =
async def get_crypto_prices() -> dict:
url = f"https://api.coingecko.com/api/v3/simple/price"
params = {
"ids": "bitcoin,litecoin,solana,ethereum,binancecoin",
"ids": "bitcoin,litecoin,solana,ethereum,binancecoin,tether,usd-coin",
"vs_currencies": "usd,eur,gbp,jpy,cad"
}
return await CryptoApiWrapper.fetch_api_request(url, params)

@staticmethod
async def get_wallet_balance() -> dict:
async def get_wallet_balance() -> dict[Cryptocurrency, float]:
url = f"{config.KRYPTO_EXPRESS_API_URL}/wallet"
headers = {
"X-Api-Key": config.KRYPTO_EXPRESS_API_KEY
Expand All @@ -35,7 +35,7 @@ async def get_wallet_balance() -> dict:
url,
headers=headers
)
return {k: v for k, v in response.items() if v > 0}
return {Cryptocurrency(k): v for k, v in response.items()}

@staticmethod
async def withdrawal(cryptocurrency: Cryptocurrency,
Expand Down
8 changes: 2 additions & 6 deletions handlers/admin/announcement.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,8 @@ async def send_confirmation(**kwargs):
callback_data: AnnouncementCallback = kwargs.get("callback_data")
session: AsyncSession = kwargs.get("session")
language: Language = kwargs.get("language")
msg = await AnnouncementService.send_announcement(callback, callback_data, session, language)
if callback.message.caption:
await callback.message.delete()
await callback.message.answer(text=msg)
elif callback.message.text:
await callback.message.edit_text(text=msg)
await AnnouncementService.send_announcement(callback, callback_data, session, language)
await callback.message.delete()


@announcement_router.callback_query(AdminIdFilter(), AnnouncementCallback.filter())
Expand Down
12 changes: 8 additions & 4 deletions i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@
"credit_management_request_user_entity": "👤 <b>Sende die Telegram-ID oder den Benutzernamen des Nutzers:</b>",
"credit_management_user_not_found": "⚠️ <b>Nutzer nicht gefunden.</b>",
"crypto_withdraw": "👛 Wallet",
"crypto_wallet": "\n\n<b>🤖 Bot-Guthaben\n\n⚖️ BTC-Saldo: <code>{btc_balance}</code> BTC\n⚖️ LTC-Saldo: <code>{ltc_balance}</code> LTC\n⚖️ ETH-Saldo: <code>{eth_balance}</code> ETH\n⚖️ SOL-Saldo: <code>{sol_balance}</code> SOL\n⚖️ BNB-Saldo: <code>{bnb_balance}</code> BNB</b>",
"current_stock_header": "🗂️ Aktueller Lagerbestand\n",
"deposits_statistics": "📊 Einzahlungsstatistik",
"deposits_statistics_msg": "📊 <b>Einzahlungsstatistiken der letzten {timedelta}.\n\n💸 Gesamteinzahlungen: {deposits_count}\n\n💰 BTC-Einzahlungen in Höhe von: {btc_amount} BTC\n💰 LTC-Einzahlungen in Höhe von: {ltc_amount} LTC\n💰 SOL-Einzahlungen in Höhe von: {sol_amount} SOL\n💰 ETH-Einzahlungen in Höhe von: {eth_amount} ETH\n💰 BNB-Einzahlungen in Höhe von: {bnb_amount} BNB\n\n💼 Gesamtbetrag in Fiat: {fiat_amount:.2f} {currency_text}</b>",
"delete_entity": "🗑️ {entity} löschen",
"delete_entity_confirmation": "❓ <b>Möchtest du {entity} mit dem Namen <u>{entity_name}</u> wirklich löschen?</b>",
"get_database_file": "💾 Datenbankdatei herunterladen",
Expand All @@ -55,7 +53,6 @@
"restocking_message_header": "🆕 Neue Lagerbestände! 🆕\n",
"sales_statistics": "📊 <b>Verkaufsstatistiken der letzten {timedelta}.\n💰 Gesamtgewinn: {currency_sym}{total_profit:.2f}\n🛍️ Verkaufte Artikel: {items_sold}\n💼 Gesamtkäufe: {buys_count}</b>",
"send_everyone": "📢 An alle senden",
"sending_result": "✅ <b>Nachricht an {counter} von {len} aktiven Nutzern gesendet.\nGesamtzahl der Nutzer: {users_count}</b>",
"sending_started": "🚀 Versand gestartet",
"stock": "📦 Vollständige Lagerbestandsmeldung",
"statistics": "📊 Analytik und Berichte",
Expand Down Expand Up @@ -135,7 +132,14 @@
"remove_review_image_confirmation": "❓ <b>Sind Sie sicher, dass Sie das Bewertungsbild entfernen möchten?</b>",
"reviews_management": "⭐ Bewertungsverwaltung",
"notification_new_deposit_id": "💰 Neue Einzahlung von Benutzer mit ID {telegram_id} für {currency_sym}{deposit_amount_fiat:.2f} mit 💰 {value} {crypto_name}\n💰 Empfehlungsbonus: {currency_sym}{referral_bonus:.2f}\n💰 Empfehlerbonus: {currency_sym}{referrer_bonus:.2f}",
"notification_new_deposit_username": "💰 Neue Einzahlung von Benutzer mit Benutzername @{username} für {currency_sym}{deposit_amount_fiat:.2f} mit 💰 {value} {crypto_name}\n💰 Empfehlungsbonus: {currency_sym}{referral_bonus:.2f}\n💰 Empfehlerbonus: {currency_sym}{referrer_bonus:.2f}"
"notification_new_deposit_username": "💰 Neue Einzahlung von Benutzer mit Benutzername @{username} für {currency_sym}{deposit_amount_fiat:.2f} mit 💰 {value} {crypto_name}\n💰 Empfehlungsbonus: {currency_sym}{referral_bonus:.2f}\n💰 Empfehlerbonus: {currency_sym}{referrer_bonus:.2f}",
"crypto_wallet": "\n\n<b>🤖 Bot-Guthaben\n\n{wallet_content}</b>",
"crypto_wallet_line": "⚖️ {crypto_name} Guthaben: <code>{crypto_balance:.8f}</code> {crypto_name}",
"deposits_statistics_msg": "📊 <b>Einzahlungsstatistiken der letzten {timedelta}.\n\n💰 Gesamteinzahlungen: {deposits_count}\n\n{deposits_content}\n\n💼 Gesamte Kryptowährungseinzahlungen im Wert: {fiat_amount:.2f} {currency_text}</b>",
"deposits_statistics_line": "💰 Gesamte {crypto_name}-Einzahlungen im Wert: {crypto_amount:.8f} {crypto_name}",
"sending_result": "✅ <b>Nachricht an {counter} von {len} aktiven Benutzern gesendet.\n👤 Benutzer insgesamt: {users_count}\nStatus: {status}</b>",
"in_progress": "🟡 In Bearbeitung...",
"finished": "🟢 Abgeschlossen."
},
"common": {
"back_button": "⬅️ Zurück",
Expand Down
12 changes: 8 additions & 4 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@
"credit_management_request_user_entity": "👤 <b>Send the user's telegram id or their telegram username:</b>",
"credit_management_user_not_found": "⚠️ <b>The user with this data is not found in the database.</b>",
"crypto_withdraw": "👛 Wallet",
"crypto_wallet": "\n\n<b>\uD83E\uDD16 Bot balances\n\n⚖\uFE0F BTC Balance: <code>{btc_balance}</code> BTC\n⚖\uFE0F LTC Balance: <code>{ltc_balance}</code> LTC\n⚖\uFE0F ETH Balance: <code>{eth_balance}</code> ETH\n⚖\uFE0F SOL Balance: <code>{sol_balance}</code> SOL\n⚖\uFE0F BNB Balance: <code>{bnb_balance}</code> BNB</b>",
"current_stock_header": "🗂️ Current Stock\n",
"deposits_statistics": "📊 Deposits statistics",
"deposits_statistics_msg": "📊 <b>Deposit statistics for the last {timedelta}.\n\n\uD83D\uDCB8 Total deposits: {deposits_count}\n\n\uD83D\uDCB0 Total BTC deposits for the amount: {btc_amount} BTC\n\uD83D\uDCB0 Total LTC deposits for the amount: {ltc_amount} LTC\n\uD83D\uDCB0 Total SOL deposits for the amount: {sol_amount} SOL\n\uD83D\uDCB0 Total ETH deposits in amount: {eth_amount} ETH\n\uD83D\uDCB0 Total BNB deposits in amount: {bnb_amount} BNB\n\n\uD83D\uDCBC Total cryptocurrency deposits for the amount: {fiat_amount:.2f} {currency_text}</b>",
"delete_entity": "🗑️ Delete {entity}",
"delete_entity_confirmation": "❓ <b>Do you really want to delete the {entity} with name <u>{entity_name}</u>?</b>",
"get_database_file": "💾 Get database file",
Expand All @@ -55,7 +53,6 @@
"restocking_message_header": "🆕 New Stock Alert! 🆕\n",
"sales_statistics": "📊 <b>Sales statistics for the last {timedelta}.\n\uD83D\uDCB0 Total profit: {currency_sym}{total_profit:.2f}\n\uD83D\uDECD\uFE0F Items sold: {items_sold}\n\uD83D\uDCBC Total buys: {buys_count}</b>",
"send_everyone": "📢 Send to Everyone",
"sending_result": "✅ <b>Message sent to {counter} out of {len} active users.\nTotal users:{users_count}</b>",
"sending_started": "🚀 Sending started",
"stock": "📦 Full Inventory Message",
"statistics": "📊 Analytics & Reports ",
Expand Down Expand Up @@ -135,7 +132,14 @@
"remove_review_image_confirmation": "❓ <b>Are you sure you want to remove the review image?</b>",
"reviews_management": "⭐ Reviews Management",
"notification_new_deposit_id": "💰 New deposit by user with ID {telegram_id} for {currency_sym}{deposit_amount_fiat:.2f} with \uD83D\uDCB0 {value} {crypto_name}\n💰 Referral bonus: {currency_sym}{referral_bonus:.2f}\n💰 Referrer bonus: {currency_sym}{referrer_bonus:.2f}",
"notification_new_deposit_username": "💰 New deposit by user with username @{username} for {currency_sym}{deposit_amount_fiat:.2f} with \uD83D\uDCB0 {value} {crypto_name}\n💰 Referral bonus: {currency_sym}{referral_bonus:.2f}\n💰 Referrer bonus: {currency_sym}{referrer_bonus:.2f}"
"notification_new_deposit_username": "💰 New deposit by user with username @{username} for {currency_sym}{deposit_amount_fiat:.2f} with \uD83D\uDCB0 {value} {crypto_name}\n💰 Referral bonus: {currency_sym}{referral_bonus:.2f}\n💰 Referrer bonus: {currency_sym}{referrer_bonus:.2f}",
"crypto_wallet": "\n\n<b>\uD83E\uDD16 Bot balances\n\n{wallet_content}</b>",
"crypto_wallet_line": "⚖\uFE0F {crypto_name} Balance: <code>{crypto_balance:.8f}</code> {crypto_name}",
"deposits_statistics_msg": "📊 <b>Deposit statistics for the last {timedelta}.\n\n\uD83D\uDCB8 Total deposits: {deposits_count}\n\n{deposits_content}\n\n\uD83D\uDCBC Total cryptocurrency deposits for the amount: {fiat_amount:.2f} {currency_text}</b>",
"deposits_statistics_line": "💰 Total {crypto_name} deposits for the amount: {crypto_amount:.8f} {crypto_name}",
"sending_result": "✅ <b>Message sent to {counter} out of {len} active users.\n\uD83D\uDC64 Total users:{users_count}\nStatus: {status}</b>",
"in_progress": "🟡 In progress...",
"finished": "🟢 Finished."
},
"common": {
"back_button": "⬅️ Back",
Expand Down
12 changes: 8 additions & 4 deletions i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@
"credit_management_request_user_entity": "👤 <b>Envía el telegram id del usuario o su nombre de usuario:</b>",
"credit_management_user_not_found": "⚠️ <b>No se encontró al usuario con estos datos.</b>",
"crypto_withdraw": "👛 Billetera",
"crypto_wallet": "\n\n<b>🤖 Saldos del bot\n\n⚖️ Saldo BTC: <code>{btc_balance}</code> BTC\n⚖️ Saldo LTC: <code>{ltc_balance}</code> LTC\n⚖️ Saldo ETH: <code>{eth_balance}</code> ETH\n⚖️ Saldo SOL: <code>{sol_balance}</code> SOL\n⚖️ Saldo BNB: <code>{bnb_balance}</code> BNB</b>",
"current_stock_header": "🗂️ Inventario actual\n",
"deposits_statistics": "📊 Estadísticas de depósitos",
"deposits_statistics_msg": "📊 <b>Estadísticas de depósitos de los últimos {timedelta}.\n\n💸 Depósitos totales: {deposits_count}\n\n💰 Depósitos BTC por un monto de: {btc_amount} BTC\n💰 Depósitos LTC por un monto de: {ltc_amount} LTC\n💰 Depósitos SOL por un monto de: {sol_amount} SOL\n💰 Depósitos ETH por un monto de: {eth_amount} ETH\n💰 Depósitos BNB por un monto de: {bnb_amount} BNB\n\n💼 Total en moneda fiduciaria: {fiat_amount:.2f} {currency_text}</b>",
"delete_entity": "🗑️ Eliminar {entity}",
"delete_entity_confirmation": "❓ <b>¿Realmente deseas eliminar {entity} con el nombre <u>{entity_name}</u>?</b>",
"get_database_file": "💾 Obtener archivo de base de datos",
Expand All @@ -55,7 +53,6 @@
"restocking_message_header": "🆕 ¡Nueva llegada de stock! 🆕\n",
"sales_statistics": "📊 <b>Estadísticas de ventas de los últimos {timedelta}.\n💰 Beneficio total: {currency_sym}{total_profit:.2f}\n🛍️ Artículos vendidos: {items_sold}\n💼 Total de compras: {buys_count}</b>",
"send_everyone": "📢 Enviar a todos",
"sending_result": "✅ <b>Mensaje enviado a {counter} de {len} usuarios activos.\nUsuarios totales: {users_count}</b>",
"sending_started": "🚀 Envío iniciado",
"stock": "📦 Mensaje de inventario completo",
"statistics": "📊 Analítica y reportes",
Expand Down Expand Up @@ -135,7 +132,14 @@
"remove_review_image_confirmation": "❓ <b>¿Estás seguro de que quieres eliminar la imagen de la reseña?</b>",
"reviews_management": "⭐ Gestión de reseñas",
"notification_new_deposit_id": "💰 Nuevo depósito del usuario con ID {telegram_id} por {currency_sym}{deposit_amount_fiat:.2f} con 💰 {value} {crypto_name}\n💰 Bono por referido: {currency_sym}{referral_bonus:.2f}\n💰 Bono del referidor: {currency_sym}{referrer_bonus:.2f}",
"notification_new_deposit_username": "💰 Nuevo depósito del usuario con nombre de usuario @{username} por {currency_sym}{deposit_amount_fiat:.2f} con 💰 {value} {crypto_name}\n💰 Bono por referido: {currency_sym}{referral_bonus:.2f}\n💰 Bono del referidor: {currency_sym}{referrer_bonus:.2f}"
"notification_new_deposit_username": "💰 Nuevo depósito del usuario con nombre de usuario @{username} por {currency_sym}{deposit_amount_fiat:.2f} con 💰 {value} {crypto_name}\n💰 Bono por referido: {currency_sym}{referral_bonus:.2f}\n💰 Bono del referidor: {currency_sym}{referrer_bonus:.2f}",
"crypto_wallet": "\n\n<b>🤖 Saldos del Bot\n\n{wallet_content}</b>",
"crypto_wallet_line": "⚖️ Saldo de {crypto_name}: <code>{crypto_balance:.8f}</code> {crypto_name}",
"deposits_statistics_msg": "📊 <b>Estadísticas de depósitos de los últimos {timedelta}.\n\n💰 Depósitos totales: {deposits_count}\n\n{deposits_content}\n\n💼 Depósitos totales de criptomonedas por valor: {fiat_amount:.2f} {currency_text}</b>",
"deposits_statistics_line": "💰 Depósitos totales de {crypto_name} por valor: {crypto_amount:.8f} {crypto_name}",
"sending_result": "✅ <b>Mensaje enviado a {counter} de {len} usuarios activos.\n👤 Usuarios totales: {users_count}\nEstado: {status}</b>",
"in_progress": "🟡 En progreso...",
"finished": "🟢 Finalizado."
},
"common": {
"back_button": "⬅️ Atrás",
Expand Down
12 changes: 8 additions & 4 deletions i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@
"credit_management_request_user_entity": "👤 <b>Envoyez l’ID Telegram ou le nom d’utilisateur :</b>",
"credit_management_user_not_found": "⚠️ <b>Aucun utilisateur trouvé.</b>",
"crypto_withdraw": "👛 Portefeuille",
"crypto_wallet": "\n\n<b>🤖 Soldes du bot\n\n⚖️ Solde BTC : <code>{btc_balance}</code> BTC\n⚖️ Solde LTC : <code>{ltc_balance}</code> LTC\n⚖️ Solde ETH : <code>{eth_balance}</code> ETH\n⚖️ Solde SOL : <code>{sol_balance}</code> SOL\n⚖️ Solde BNB : <code>{bnb_balance}</code> BNB</b>",
"current_stock_header": "🗂️ Stock actuel\n",
"deposits_statistics": "📊 Statistiques de dépôts",
"deposits_statistics_msg": "📊 <b>Statistiques des dépôts pour les {timedelta} derniers jours.\n\n💸 Nombre total de dépôts : {deposits_count}\n\n💰 Dépôts BTC pour un montant de : {btc_amount} BTC\n💰 Dépôts LTC pour un montant de : {ltc_amount} LTC\n💰 Dépôts SOL pour un montant de : {sol_amount} SOL\n💰 Dépôts ETH pour un montant de : {eth_amount} ETH\n💰 Dépôts BNB pour un montant de : {bnb_amount} BNB\n\n💼 Total en monnaie fiduciaire : {fiat_amount:.2f} {currency_text}</b>",
"delete_entity": "🗑️ Supprimer {entity}",
"delete_entity_confirmation": "❓ <b>Voulez-vous vraiment supprimer {entity} nommé <u>{entity_name}</u> ?</b>",
"get_database_file": "💾 Télécharger la base de données",
Expand All @@ -55,7 +53,6 @@
"restocking_message_header": "🆕 Nouveau stock disponible ! 🆕\n",
"sales_statistics": "📊 <b>Statistiques des ventes des {timedelta} derniers jours.\n💰 Profit total : {currency_sym}{total_profit:.2f}\n🛍️ Articles vendus : {items_sold}\n💼 Nombre total d’achats : {buys_count}</b>",
"send_everyone": "📢 Envoyer à tout le monde",
"sending_result": "✅ <b>Message envoyé à {counter} sur {len} utilisateurs actifs.\nTotal des utilisateurs : {users_count}</b>",
"sending_started": "🚀 Envoi lancé",
"stock": "📦 Annonce complète du stock",
"statistics": "📊 Analyses et rapports",
Expand Down Expand Up @@ -135,7 +132,14 @@
"remove_review_image_confirmation": "❓ <b>Êtes-vous sûr de vouloir supprimer l'image de l'avis?</b>",
"reviews_management": "⭐ Gestion des avis",
"notification_new_deposit_id": "💰 Nouveau dépôt de l'utilisateur avec ID {telegram_id} pour {currency_sym}{deposit_amount_fiat:.2f} avec 💰 {value} {crypto_name}\n💰 Bonus parrainé: {currency_sym}{referral_bonus:.2f}\n💰 Bonus parrain: {currency_sym}{referrer_bonus:.2f}",
"notification_new_deposit_username": "💰 Nouveau dépôt de l'utilisateur avec nom d'utilisateur @{username} pour {currency_sym}{deposit_amount_fiat:.2f} avec 💰 {value} {crypto_name}\n💰 Bonus parrainé: {currency_sym}{referral_bonus:.2f}\n💰 Bonus parrain: {currency_sym}{referrer_bonus:.2f}"
"notification_new_deposit_username": "💰 Nouveau dépôt de l'utilisateur avec nom d'utilisateur @{username} pour {currency_sym}{deposit_amount_fiat:.2f} avec 💰 {value} {crypto_name}\n💰 Bonus parrainé: {currency_sym}{referral_bonus:.2f}\n💰 Bonus parrain: {currency_sym}{referrer_bonus:.2f}",
"crypto_wallet": "\n\n<b>🤖 Soldes du Bot\n\n{wallet_content}</b>",
"crypto_wallet_line": "⚖️ Solde {crypto_name}: <code>{crypto_balance:.8f}</code> {crypto_name}",
"deposits_statistics_msg": "📊 <b>Statistiques des dépôts des derniers {timedelta}.\n\n💰 Dépôts totaux: {deposits_count}\n\n{deposits_content}\n\n💼 Dépôts totaux de cryptomonnaies d'une valeur de: {fiat_amount:.2f} {currency_text}</b>",
"deposits_statistics_line": "💰 Dépôts totaux de {crypto_name} d'une valeur de: {crypto_amount:.8f} {crypto_name}",
"sending_result": "✅ <b>Message envoyé à {counter} sur {len} utilisateurs actifs.\n👤 Utilisateurs totaux: {users_count}\nStatut: {status}</b>",
"in_progress": "🟡 En cours...",
"finished": "🟢 Terminé."
},
"common": {
"back_button": "⬅️ Retour",
Expand Down
Loading
Loading