1010 GNU General Public License (Version 3)
1111"""
1212
13- from cloudbot import hook
14- import requests
1513import urllib .parse
1614import hashlib
1715import collections
1816import html
1917
18+ import requests
19+
20+ from cloudbot import hook
21+
22+
2023SESSION = collections .OrderedDict ()
2124API_URL = "http://www.cleverbot.com/webservicemin/"
2225
2326HEADERS = {
24- 'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ,
25- 'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.7' ,
26- 'Accept-Language' : 'en-us;q=0.8,en;q=0.5' ,
27- 'Pragma' : 'no-cache' ,
28- 'Referer' : 'http://www.cleverbot.com' ,
29- 'User-Agent' : 'Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19' ,
30- 'X-Moz' : 'prefetch'
31- }
27+ 'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ,
28+ 'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.7' ,
29+ 'Accept-Language' : 'en-us;q=0.8,en;q=0.5' ,
30+ 'Pragma' : 'no-cache' ,
31+ 'Referer' : 'http://www.cleverbot.com' ,
32+ 'User-Agent' : 'Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like '
33+ 'Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19' ,
34+ 'X-Moz' : 'prefetch'
35+ }
36+
3237
3338@hook .on_start ()
3439def init_vars ():
@@ -41,6 +46,7 @@ def init_vars():
4146 SESSION ['islearning' ] = '1'
4247 SESSION ['cleanslate' ] = 'false'
4348
49+
4450def cb_think (text ):
4551 SESSION ['stimulus' ] = text
4652 payload = urllib .parse .urlencode (SESSION )
@@ -51,6 +57,7 @@ def cb_think(text):
5157 SESSION ['sessionid' ] = data [1 ]
5258 return html .unescape (str (data [0 ]))
5359
60+
5461@hook .command ("ask" , "cleverbot" , "cb" )
5562def ask (text ):
5663 """ <question> -- Asks Cleverbot <question> """
0 commit comments