-
Notifications
You must be signed in to change notification settings - Fork 0
/
stopstalk.py
40 lines (38 loc) · 1016 Bytes
/
stopstalk.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
import requests
url = 'https://www.stopstalk.com/leaderboard.json?q=National+Institute+of+Technology%2C+Durgapur'
res=requests.get(url).json()
def RepresentsInt(s):
try:
int(s)
return True
except ValueError:
return False
def text(input_text):
coders = res['users']
rep=''
space=' '
if(RepresentsInt(input_text)):
if(int(input_text)<=200):
nxt=7
else:
nxt=3
elif(space in input_text):
nxt=0
else:
nxt=1
if(input_text!='All'):
for coder in coders:
if(str(coder[nxt])==input_text):
rep=str(coder[7])+' '+coder[0]+' '+str(coder[3])+'\n'
if(coder[3]==0):
break
elif(input_text=='All'):
count=0
for coder in coders:
if(count>=75):
break
count+=1
rep+=str(coder[7])+' '+coder[0]+' '+str(coder[3])+'\n'
if(rep==''):
return 'Command not Found'
return rep