File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import requests
2+
3+ from cloudbot import hook
4+
5+ headers = {'User-Agent' : 'CloudBot/dev 1.0 - CloudBot Refresh by lukeroge' }
6+
7+ @hook .command
8+ def wyr (text , message ):
9+ url = "http://www.rrrather.com/botapi"
10+
11+ r = requests .get (url , headers = headers )
12+ data = r .json ()
13+ title = data ['title' ].strip ().capitalize ()
14+ title = title .rstrip ('.?' )
15+ choice1 = data ['choicea' ].strip ().lower ()
16+ choice1 = choice1 .rstrip ('.?' )
17+ choice2 = data ['choiceb' ].strip ().lower ()
18+ choice2 = choice2 .rstrip ('.?' )
19+ link = data ['link' ]
20+
21+ text = "{} {}" .format (choice1 , choice2 ).split ()
22+ text = [ word for word in text if word != "a" ]
23+
24+ title_text = title .split ()
25+
26+ #message(str(title_text))
27+ #message(str(text))
28+
29+ dupl_count = 0
30+
31+ for word in title_text :
32+ dupl_count += text .count (word )
33+
34+ #message(str(dupl_count / len(text)))
35+
36+ if title .lower () == "would u rather" :
37+ title = "Would you rather"
38+
39+ if dupl_count / len (text ) >= 0.6 :
40+ title = "Would you rather"
41+ else :
42+ pass
43+
44+ return "{}... {} \x02 OR\x02 {}? - {}" .format (title , choice1 , choice2 , link )
You can’t perform that action at this time.
0 commit comments