-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcryptobalance.py
More file actions
52 lines (40 loc) · 1.9 KB
/
cryptobalance.py
File metadata and controls
52 lines (40 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from telethon import events
from userbot import client
info = {'category': 'tools', 'pattern': 'wallet', 'description': 'Посмотреть баланс в CryptoBot'}
EMOJI_MAP = {
"USDT": "<emoji id=6032709766881479783>💵</emoji>",
"TON": "<emoji id=6032804204622384196>💵</emoji>",
"BTC": "<emoji id=6032744483102133873>💵</emoji>",
"ETH": "<emoji id=6032967271645711263>💵</emoji>",
"BNB": "<emoji id=6032733926072520137>💵</emoji>",
"BUSD": "<emoji id=6033097439219551284>💵</emoji>",
"USDC": "<emoji id=6030553792083135328>💵</emoji>",
}
@client.on(events.NewMessage(pattern=r'[.!/].*wallet'))
async def wallet_command(event):
async with event.client.conversation("https://t.me/CryptoBot") as conv:
m = await conv.send_message("/wallet")
r = await conv.get_response()
await event.client.delete_messages(event.chat_id, m)
button = None
for row in r.reply_markup.rows:
for btn in row.buttons:
if btn.text == "Show Small Balances":
button = btn
break
if button:
break
if button:
await event.click(button=button)
r = await event.client.get_messages(event.chat_id, ids=r.id)
await r[0].click(0)
balance_info = "\n\n".join(
f"{next((emoji for trigger, emoji in EMOJI_MAP.items() if trigger in line), '<emoji id=5471952986970267163>💎</emoji>')} <b>{line.split(maxsplit=1)[1]}</b>"
for line in r.text.splitlines()
if line.startswith("·") and ": 0 " not in line
)
if balance_info:
response = f"{balance_info}"
else:
response = "Empty balance"
await client.edit_message(event.message, f"👛 Твой <a href='https://t.me/CryptoBot'>CryptoBot</a> кошелёк:\n\n{response}", link_preview=False)