edwardslabs / cleverwrap.py Goto Github PK
View Code? Open in Web Editor NEWA wrapper for the official http://www.cleverbot.com API.
License: Other
A wrapper for the official http://www.cleverbot.com API.
License: Other
Cleverbot, when used through the web interface, responds to Japanese text with a message made in Japanese. When used through this library, however, Cleverbot responds in English, leading me to believe that the message is not getting sent correctly.
from cleverwrap import CleverWrap
cw = CleverWrap("token")
print(cw.say("こにちわ? なまいわ"))
Results in Cleverbot responding with an english phrase such as "Oh... Hi John!"
After cw.say("Hello CleverBot.") the script doesnt print me the answer
Which variable contain answer value?
Hi Again,
I'm sorry to be here again, but the problem seems not fixed totally, so before coming i looked a bit in your code, and i edit those lines(87 & 88 - the lines that cause the error):
self.time_taken = int(reply.get("time_taken", None))
self.time_elapsed = int(reply.get("time_elapsed", None))
in:
time_taken_var = reply.get("time_taken", None)
time_elapsed_var = reply.get("time_elapsed", None)
try:
self.time_taken = int(time_taken_var)
self.time_elapsed = int(time_elapsed_var)
except ValueError:
print("TIME TAKEN:" + str(time_taken_var))
print("TIME ELAPSED:" + str(time_elapsed_var))
this try-except avoids the old error (ValueError) but then i noticed that when the error happens the clever doesn't give a reply, and return an empty string, this is why i tried:
while reply == "":
reply = cw.say(nuovoMessaggio)
print("Cleverbot Reply:" + reply)
print("Reply:" + reply)
with this little control the error seems to never happens (try to yourself maybe?) so... maybe you should check if there is a reply and, if no, ask the cleverbot again? Something like that?
I'm not sure how your code works so it's just an idea...
Thanks for your support.
Bye
you can now also pass in cb_settings_tweak1, cb_settings_tweak2 or cb_settings_tweak3 to vary how Cleverbot will respond
When using the example code, the following error is thrown:
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
cw.say("Hello CleverBot.")
File "C:\Users\Piero\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cleverwrap\cleverwrap.py", line 61, in say
self._process_reply(reply)
File "C:\Users\Piero\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cleverwrap\cleverwrap.py", line 84, in _process_reply
self.count = int(reply.get("interaction_count", None))
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
I'm using python 3, and I've set it to use my api key. Any idea what this is?
What could cause this error?
It started happening like a day ago and can't understand the cause
Ignoring exception in on_message
Traceback (most recent call last):
File "[...]\Python\Python35\lib\site-packages\discord\client.py", line 307, in _run_event
yield from getattr(self, event)(*args, **kwargs)
File "[...]/botLite.py", line 115, in on_message
reply = cw.say(userMessage)
File "[...]\Python\Python35\lib\site-packages\cleverwrap\cleverwrap.py", line 61, in say
self._process_reply(reply)
File "[...]\Python\Python35\lib\site-packages\cleverwrap\cleverwrap.py", line 83, in _process_reply
self.count = int(reply.get("interaction_count", None))
ValueError: invalid literal for int() with base 10: ''
Hi! When I write something in Russian to the bot like "привет" and it replies in Russian I get
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-3: ordinal not in range(256)
Old cleverbot package could work just fine with non-latin alphabets.
Thank you.
Hi there, I wrote https://pypi.python.org/pypi/cleverbot back when there was no official API. Would you be interested in taking over the cleverbot
package name on pypi with your API wrapper?
Hello again,
There is a way to change the language ? (because it's only english for the moment)
Maybe with an initial word such as "Holà" to enable Spanish or "привет" to enable Russian.
Any idea ?
Hey,
How can we chat with multiple bot at the same time ?
Hi there, I recent just encountered a strange error when calling the say()
function.
CleverWrap(bot.cleverbot_key).say(msg)
However it gaves us an error related to JSON. The backtrace is like:
/cleverwrap/cleverwrap.py, line 60, in say
reply = self._send(params)
/cleverwrap/cleverwrap.py, line 77, in_send
return r.json()
...(skipped)
builtins.ValueError: Invalid control character at: line 1 column number (char that number-1)
The skipped part if you are interested:
python3/dist-packages/requests/models.py, line 793 in json
return json.loads(self.text, **kwargs)
python3.4/json/__init__.py, line 318, in loads
return _default_decoder.decode(s)
python3.4/json/decoder.py
obj, end = self.raw_decode(s, idx=w(s, 0).end())
python3.4/json/decoder.py, line 359, in raw_decode
obj, end = self.scan_once(s, idx)
We don't see that error after restarting our app.
Also, unfortunately we can't see the JSON response when that error occurred.
Any ideas about this error?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.