Skip to content

Commit

Permalink
fixed error when attempting to retrieve last uri for Twitter lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
myano committed Dec 17, 2016
1 parent 83fa290 commit 0f44e1b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions modules/cleverbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"""

#import cookielib
import collections
import hashlib
import requests
Expand All @@ -33,14 +32,13 @@
entity_parser = parser.HTMLParser()


class Cleverbot:
"""
Wrapper over the Cleverbot API.
class Cleverbot(object):
"""Handles a conversation with Cleverbot.
"""
HOST = "www.cleverbot.com"
PROTOCOL = "http://"
RESOURCE = "/webservicemin?uc=165&"
RESOURCE = "/webservicemin?uc=321&"
API_URL = PROTOCOL + HOST + RESOURCE

headers = {
Expand Down Expand Up @@ -92,7 +90,7 @@ def __init__(self):
# the log of our conversation with Cleverbot
self.conversation = []

# get the main page to get a cookie (see bug #13)
# get the main page to get a cookie (see bug #13)
self.session = requests.Session()
self.session.get(Cleverbot.PROTOCOL + Cleverbot.HOST)

Expand Down Expand Up @@ -124,7 +122,7 @@ def ask(self, question):
# Add Cleverbot's reply to the conversation log
self.conversation.append(parsed['answer'])

return parsed['answer']
return parsed['answer'].encode('latin-1').decode('utf-8')

def _send(self):
"""POST the user's question and all required information to the
Expand Down
4 changes: 2 additions & 2 deletions modules/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ def twitter(jenni, input):
arg = input.group(2)

if not arg:
if hasattr(jenni, 'last_seen_uri') and input.sender in jenni.bot.last_seen_uri:
temp = jenni.bot.last_seen_uri[input.sender]
if hasattr(jenni, 'last_seen_uri') and input.sender in jenni.last_seen_uri:
temp = jenni.last_seen_uri[input.sender]
if '//twitter.com' in temp:
arg = temp
else:
Expand Down

0 comments on commit 0f44e1b

Please sign in to comment.