-
Notifications
You must be signed in to change notification settings - Fork 5
/
transfer_additional_tokens.py
75 lines (67 loc) · 2.88 KB
/
transfer_additional_tokens.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from telebot.apihelper import ApiTelegramException
from src.bash_utils import transfer_tokens
from config import BASE_AFTER_SIGN_UP_KEYBOARD, db_worker, bot, TOKEN_NAME
MESSAGE_TEXT_NEW_USER = f'''
@cyberdBot additionally transferred <b>7.5 M{TOKEN_NAME}</b> to you.
If you create <b>10 links</b> with the bot, another <b>90 M{TOKEN_NAME}</b> will be transferred.
Remember, {TOKEN_NAME} tokens will not be migrated to the production network.
On the other hand, you can participate in the <b>Relevance</b> section of the <b>Game of Links</b>
and get your share of the prize <b>500 GCYB ~ 230 ETH</b>.
Go for it!'''
MESSAGE_TEXT_LEADER = f'''
@cyberdBot additionally transferred <b>90 M{TOKEN_NAME}</b> to you.
Remember, {TOKEN_NAME} tokens will not be migrated to the production network.
On the other hand, you can participate in the <b>Relevance</b> section of the <b>Game of Links</b>
and get your share of the prize <b>500 GCYB ~ 230 ETH</b>.
Your bandwidth is enough to generate at least <b>100 links per day</b>.
Go for it!'''
TRANSFER_VALUE_NEW_USERS = 7_500_000
TRANSFER_VALUE_LEADERS = 90_000_000
def get_users_and_links():
return db_worker.get_df(
query='''
SELECT
acc.user_id,
links.cyberlink_count,
acc.account_address
FROM (
SELECT
user_id,
account_address
FROM accounts
) as acc
LEFT JOIN (
SELECT
user_id,
count() as cyberlink_count
FROM cyberlinks
GROUP BY user_id
) as links
ON links.user_id = acc.user_id''',
columns=['user_id', 'number_of_cyberlinks', 'address']).fillna(0)
if __name__ == '__main__':
users_and_links_df = get_users_and_links()
for df_index in users_and_links_df.index:
row = users_and_links_df.iloc[df_index].copy()
if row.number_of_cyberlinks >= 10:
message_text = MESSAGE_TEXT_LEADER
transfer_value = TRANSFER_VALUE_LEADERS
else:
message_text = MESSAGE_TEXT_NEW_USER
transfer_value = TRANSFER_VALUE_NEW_USERS
print(row.user_id, row.number_of_cyberlinks, row.address, transfer_value)
transfer_success, transfer_error = \
transfer_tokens(
account_address=row.address,
value=transfer_value)
if transfer_success:
try:
bot.send_message(
chat_id=row.user_id,
text=message_text,
parse_mode='HTML',
reply_markup=BASE_AFTER_SIGN_UP_KEYBOARD)
except ApiTelegramException:
print('Chat not found')
else:
print(f'Unsuccessful transfer {transfer_value} {TOKEN_NAME} to {row.address}, user id {row.user_id}')