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+ """
2+ chatbot.py
3+
4+ Ask Cleverbot something via CloudBot!
5+
6+ Created By:
7+ - Foxlet <http://furcode.tk/>
8+
9+ License:
10+ GNU General Public License (Version 3)
11+ """
12+
13+ from cloudbot import hook
14+ import requests
15+ import urllib .parse
16+ import hashlib
17+ import collections
18+
19+ SESSION = collections .OrderedDict ()
20+ API_URL = "http://www.cleverbot.com/webservicemin/"
21+
22+ @hook .onload ()
23+ def init_vars ():
24+ SESSION ['stimulus' ] = ""
25+ SESSION ['start' ] = 'y'
26+ SESSION ['icognoid' ] = 'wsf'
27+ SESSION ['fno' ] = '0'
28+ SESSION ['sub' ] = 'Say'
29+ SESSION ['islearning' ] = '1'
30+ SESSION ['cleanslate' ] = 'false'
31+
32+ @hook .command ()
33+ def cb_think (text ):
34+ SESSION ['stimulus' ] = text
35+ payload = urllib .parse .urlencode (SESSION )
36+ digest = hashlib .md5 (payload [9 :35 ].encode ('utf-8' )).hexdigest ()
37+ target_url = "{}&icognocheck={}" .format (payload , digest )
38+ print (target_url )
39+ parsed = requests .post (API_URL , data = target_url )
40+ data = parsed .text .split ('\r ' )
41+ print (data )
You can’t perform that action at this time.
0 commit comments