-
Notifications
You must be signed in to change notification settings - Fork 4
/
hook.py
53 lines (37 loc) · 1.36 KB
/
hook.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
import os
import json, requests
import telebot
bot = telebot.TeleBot("")
def checkrep(address):
url = 'https://raw.githubusercontent.com/exorde-labs/TestnetProtocol/main/Stats/leaderboard.json'
resp = requests.get(url)
loaded = json.loads(resp.text)
sumrep = 0
defa = 0
realrep = 0
for iterator in loaded:
sumrep += loaded[iterator]
for iterator in loaded:
if str(iterator) == str(address):
defa = ((loaded[iterator]/sumrep)*100)
realrep = loaded[iterator]
break
textrep = "Reputatuon Detail:\n Total Rep in this iteration: "+str(sumrep)+" \n Your Rep: "+str(realrep)+" \n Percentage: "+str(defa)
return textrep
@bot.message_handler(commands=['start', 'hello'])
def send_welcome(message):
bot.reply_to(message, "Welcome to Exorde Bot")
@bot.message_handler(commands=['checkrep'])
def sign_handler(message):
text = "Please input your address:"
sent_msg = bot.send_message(message.chat.id, text, parse_mode="Markdown")
bot.register_next_step_handler(sent_msg, day_handler)
def day_handler(message):
sign = message.text
text = checkrep(sign)
sent_msg = bot.send_message(
message.chat.id, text, parse_mode="Markdown")
@bot.message_handler(func=lambda msg: True)
def echo_all(message):
bot.reply_to(message, message.text)
bot.infinity_polling()