pierredavidbelanger / chatter-bot-api Goto Github PK
View Code? Open in Web Editor NEWA Mono/.NET, JAVA, Python and PHP chatter bot API that supports Cleverbot, JabberWacky and Pandorabots.
A Mono/.NET, JAVA, Python and PHP chatter bot API that supports Cleverbot, JabberWacky and Pandorabots.
Hi, so... the PHP version is not in the Packagist repository. I know it's not a big deal, but is it ever going to happen? Seeing that there's a composer.json
file I thought there would be an entry already.
Hello,
today the bot cannot connect to the web api;
http://pastebin.com/kgerBVhV that's the error.
This used to work yesterday...
If i tries to connect to that link it gives a 404 not found.
Any fix? I don't think code is needed
not support chinese question?
[Fatal Error] 👎-1: Premature end of file.
org.xml.sax.SAXParseException; Premature end of file.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121)
at com.google.code.chatterbotapi.Utils.xPathSearch(Utils.java:143)
at com.google.code.chatterbotapi.Pandorabots$Session.think(Pandorabots.java:53)
at com.google.code.chatterbotapi.Pandorabots$Session.think(Pandorabots.java:61)
I tried adding header
Accept-Language:
to fopen, but it doesnt work.
Got that error on cleverbot. Pandora is working great.
I don't know what I'm doing wrong this is my code
from chatterbotapi import ChatterBotFactory, ChatterBotType
factory = ChatterBotFactory()
bot1 = factory.create(ChatterBotType.CLEVERBOT)
bot1session = bot1.create_session()
bot2 = factory.create(ChatterBotType.CLEVERBOT)
bot2session = bot2.create_session()
s = 'Hi'
while (1):
print ('bot1> ' + s)
s = bot2session.think(s);
print ('bot2> ' + s)
s = bot1session.think(s);
and here is the output
bot1> Hi
bot2> b'Ja jestem ch\xc5\x82opakiem palancie.
bot1> b"That's not english.
bot2> b'Yash, it is.
bot1> b"Your last message was, but not the one before.
bot2> b'What are you doing?
bot1> b"Talking to you. What are you doing?
bot2> b'Talking with you. I think.
bot1> b"Ohhh, that was suprising.
The PHP example is not working on my machine. On the PHP error log:
[Wed Jun 03 16:33:37 2015] [error] PHP Warning: fopen(http://www.cleverbot.com/webservicemin): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found\r\n in files/cleverbot/chatterbotapi.php on line 255
[Wed Jun 03 16:33:37 2015] [error] PHP Warning: stream_get_contents() expects parameter 1 to be resource, boolean given in files/cleverbot/chatterbotapi.php on line 256
[Wed Jun 03 16:33:37 2015] [error] PHP Warning: fclose() expects parameter 1 to be resource, boolean given in files/cleverbot/chatterbotapi.php on line 257
There is something wrong on the Cleverbot side?
Hello,
After the bot has been running for some time, I suddenly get these errors:
[Sun Jan 03 06:13:00.457780 2016] [:error] [pid 12008] [client 149.154.167.200:49441] PHP Warning: fopen(http://www.cleverbot.com/webservicemin): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden\r\n in /root/Projects/CleverRobot-Telegram-Bot/chatter-bot-api/php/chatterbotapi.php on line 306
[Sun Jan 03 06:13:00.458017 2016] [:error] [pid 12008] [client 149.154.167.200:49441] PHP Warning: stream_get_contents() expects parameter 1 to be resource, boolean given in /root/Projects/CleverRobot-Telegram-Bot/chatter-bot-api/php/chatterbotapi.php on line 307
[Sun Jan 03 06:13:00.458108 2016] [:error] [pid 12008] [client 149.154.167.200:49441] PHP Warning: fclose() expects parameter 1 to be resource, boolean given in /root/Projects/CleverRobot-Telegram-Bot/chatter-bot-api/php/chatterbotapi.php on line 318
[Sun Jan 03 06:13:00.591509 2016] [:error] [pid 12008] [client 149.154.167.200:49441] PHP Warning: file_get_contents(https://api.telegram.org/bot123456789:XXXXXXXXXXXXXXXXXXXXXXXXX/sendMessage?chat_id=125874268&text=&parse_mode=Markdown): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request\r\n in /root/Projects/CleverRobot-Telegram-Bot/bot.php on line 223
Is it because I (might have) sent too many requests?
Seems like the UC variable changed because it doesn't seem to work.
Error 404
bot1> "Te|017C nie wiesz?" should: "Też nie wiesz?"
bot2> "Ty lepiej jed|017A na PGA." should: "Ty lepiej jedź na PGA."
bot2> "W jakim mie|015Bcie?" should: "W jakim mieście?"
How to fix encodnig?
Never mind.
Hi..
i tested on my localhost.. chatterbotapitest.php.. but its not working... no reply form the bot..
Then, i modified the function to see the response form fopen...
$context = stream_context_create($contextParams);
$fp = fopen($url, 'rb', false, $context);
$response = stream_get_contents($fp);
echo $response;
i got the following response:
"DENIED +3000_cbfull"
Im currently using the newest version in my java application but since 1 week pandorabots is not working anymore. It seems like they moved their bot site to a different domain.
it is possible for cookies for separate user in Cleverbot?
eg: user1_cookie.txt, user2_cookie.txt, user3_cookie.txt
I am getting this error when I am trying to do a simple session.think(str)
:
java.io.FileNotFoundException: http://www.cleverbot.com/webservicemin
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1625)
at com.google.code.chatterbotapi.Utils.post(Utils.java:71)
at com.google.code.chatterbotapi.Cleverbot$Session.think(Cleverbot.java:59)
at com.google.code.chatterbotapi.Cleverbot$Session.think(Cleverbot.java:99)
This is the script:
ChatterBotFactory factory = new ChatterBotFactory();
try
{
ChatterBot bot = factory.create(ChatterBotType.CLEVERBOT);
ChatterBotSession session = bot.createSession();
LogHelper.info("Me > bot: Hi");
LogHelper.info("Bot > me: " + session.think("Hi"));
}
catch (Exception e)
{
e.printStackTrace();
}
I saw that you mentioned in #15 that the site now requires cookies, and I am mistaking that the java version isn't up to date. Not sure tho.
I got the chatter-bot-api
via maven so maybe that's not up to date...?
Hi guys,
Today suddenly Pandora bot didn't give any response in its python code.
Btw, cleverbot works well in python.
Thanks in advance!
Kahn
Any plans on fixing the keys or finding a way around them? The java source isn't wanting to work for me (even version 2.0)
C#, .NET 4.5, VS 2015
The url http://www.cleverbot.com/webservicemin 404'd for me, so it raised an exception:
System.Net.WebException: The remote server returned an error: (404) Not Found.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at ChatterBotAPI.Utils.<Post>d__2.MoveNext()
in Utils.Post(string url, IDictionary<string, string> parameters)
Creating two or more cleverbot sessions will make the first one never answer any requests and freeze that thread (then the POST request times out)
ChatterBotFactory factory = new ChatterBotFactory();
ChatterBot bot1 = factory.create(ChatterBotType.CLEVERBOT);
ChatterBotSession bot1session = bot1.createSession(new Locale.Builder().setLanguage("en").setRegion("US").build());
I'm using it, but the answers are not coming out in English and in other languages.
It is possible to change the language of the answers?
Looks like they've changed the webservice link for Cleverbot again, its now returning a 404 error.
Any idea what the new one is?
I believe Chatterbot class should throw exception
code with error:
ChatterBotFactory factory = new ChatterBotFactory();
ChatterBot cleverbot = factory.create(ChatterBotType.CLEVERBOT);
the second line.
Hi all,
In the old days, it worked very very well but since yesterday it seemed that every version failed.
As Python version an example, the output will be:
D:\Projects\chatter-bot-api-master\python>python chatterbotapitest.py
bot1> Hi
bot2> Hi there! What is your name?
Traceback (most recent call last):
File "chatterbotapitest.py", line 37, in <module>
s = bot1session.think(s);
File "D:\Projects\5.7\chatter-bot-api-master\python\chatterbotapi.py", line 72, in think
return self.think_thought(thought).text
File "D:\Projects\5.7\chatter-bot-api-master\python\chatterbotapi.py", line 113, in think_thought
url_response = self.opener.open(self.bot.serviceUrl, data.encode('utf-8'))
File "D:\Python27\lib\urllib2.py", line 437, in open
response = meth(req, response)
File "D:\Python27\lib\urllib2.py", line 550, in http_response
'http', request, response, code, msg, hdrs)
File "D:\Python27\lib\urllib2.py", line 475, in error
return self._call_chain(*args)
File "D:\Python27\lib\urllib2.py", line 409, in _call_chain
result = func(*args)
File "D:\Python27\lib\urllib2.py", line 558, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 400: BAD REQUEST
Could anyone help me solve this?
Thanks in advance!
Kahn
Hello,
With this code:
ChatterBotFactory factory = new ChatterBotFactory();
try {
ChatterBot bot = factory.create(ChatterBotType.JABBERWACKY, null);
ChatterBotSession botSession = bot.createSession();
String ans = botSession.think("something");
} catch (Exception e) {}
String ans always is:
"if(ob== null||cc==0) return true;if(cc==13||cc==3){uniEsc1();ob.form.submit()};return true;}"
Debugging the code the problem is on Cleverbot.class:97, that is:
responseThought.setText(Utils.stringAtIndex(responseValues, 16));
It can be solved changing the text set to:
UtilsBotURL.stringAtIndex(responseValues, 50).replaceAll("\\<[^<>]*\\>", "")
However, this is an ugly solution.
I hope your answers.
Greetings!
You're doing networking on the main thread with at least the Java version of Cleverbot, which means if you want to integrate this into an Android project, it will crash when being called.
I was at a hackathon the other day, and got around this by spawning a new thread, firing off an event using the greenrobot eventbus, and receiving the event on the main thread.
You can see the modified Cleverbot.java here: https://github.com/IntelliDrive/IntelliDrive-Android/blob/master/app/src/main/java/com/dglasser/intellidrive/CleverBotInterface/Cleverbot.java
And the event listener here: https://github.com/IntelliDrive/IntelliDrive-Android/blob/master/app/src/main/java/com/dglasser/intellidrive/MainActivity.java#L276
While this works, it really feels like a hack. Properly making a new thread, and then having a callback is probably the best way to do this. And even outside of Android, blocking the main thread with networking isn't very good practice.
Hi guys. Using Java, receive 401 response from Cleverbot.
http://pastebin.com/XQjQPued
Any thoughts?
Hello,
I am hereby inform you that, this A.P.I. was working greatly however, Suddenly after today's evening when I executed the code I noticed this exception ->
[Fatal Error] :6:3: The element type "hr" must be terminated by the matching end-tag "</hr>". [20:21:53] [DiscLoader/SEVERE]: org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 3; The element type "hr" must be terminated by the matching end-tag "</hr>". [20:21:53] [DiscLoader/SEVERE]: at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257) [20:21:53] [DiscLoader/SEVERE]: at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339) [20:21:53] [DiscLoader/SEVERE]: at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121) [20:21:53] [DiscLoader/SEVERE]: at com.google.code.chatterbotapi.Utils.xPathSearch(Utils.java:143) [20:21:53] [DiscLoader/SEVERE]: at com.google.code.chatterbotapi.Pandorabots$Session.think(Pandorabots.java:53) [20:21:53] [DiscLoader/SEVERE]: at com.google.code.chatterbotapi.Pandorabots$Session.think(Pandorabots.java:61)
Its my first time experiencing this kind of exception with chatter-bot-api.
This is my code ->
try { message.channel.sendMessage(bot1session.think(a));/*a is never empty or null. Its a proper English sentence.*/ }catch (Exception e1){ e1.printStackTrace(); }
Furthermore, I am using pandorabots bot.
bot1 = factory.create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477");//Code from examples.
I hope you find this report valuable and fix this exception.
Thank you
Seems like Cleverbot screwed with the API again and broke it. All requests returning 404. Just letting you know.
Today I downloaded the latest PHP version and Cleverbot does not work again. Is anyone having the same problem?
Thanks
Hi. I have been using your code for quite awhile and now when I updated to v2 everything just hangs on startup. Code is below.. I am unsure why this happens.
static ChatterBotSession botSession;
ChatterBotFactory factory = new ChatterBotFactory();
ChatterBot bot = factory.create(ChatterBotType.CLEVERBOT, (API KEY HERE));
botSession = bot.createSession();
log:
C:\Users\vipaggar\Documents\code\GangsterBot\chatter-bot-api\python>python chatterbotapitest.py
bot1> Hi
bot2> Hi! Can I ask you a question?
Traceback (most recent call last):
File "chatterbotapitest.py", line 37, in
s = bot1session.think(s);
File "C:\Users\vipaggar\Documents\code\GangsterBot\chatter-bot-api\python\chatterbotapi.py", line 74, in think
return self.think_thought(thought).text
File "C:\Users\vipaggar\Documents\code\GangsterBot\chatter-bot-api\python\chatterbotapi.py", line 116, in think_thought
url_response = self.opener.open(self.bot.serviceUrl, data.encode('utf-8'))
File "C:\Users\vipaggar\AppData\Local\Continuum\Anaconda2\lib\urllib2.py", line 435, in open
response = meth(req, response)
File "C:\Users\vipaggar\AppData\Local\Continuum\Anaconda2\lib\urllib2.py", line 548, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Users\vipaggar\AppData\Local\Continuum\Anaconda2\lib\urllib2.py", line 473, in error
return self._call_chain(*args)
File "C:\Users\vipaggar\AppData\Local\Continuum\Anaconda2\lib\urllib2.py", line 407, in _call_chain
result = func(*args)
File "C:\Users\vipaggar\AppData\Local\Continuum\Anaconda2\lib\urllib2.py", line 556, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 401: Unauthorized
I keep getting this:
Warning: fopen(http://www.cleverbot.com/webservicemin?uc=777&botapi=chatterbotapi): failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized
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.