Reputation: 18295
I was wondering how to create a chat bot for Google Talk via special client.
I know it uses XMPP to send messages, but I do not know how to use this at all. It is my understanding that I should be able to make a bot which chats for me when I am away if I were to create my own client page, which would parse the chats with my data. Where would I begin if I wanted to create a custom client, and how could I make it parse messages and autorespond in a set manner? My intended usage: autoresponder for when I am AFK, with a decent AI (which I can make.)
Can I use this protocol with PHP to make my bot, or must it be java or python based?
Thanks for any and all help!!!
Upvotes: 3
Views: 14603
Reputation: 827326
Give a look to this library:
Gives you a fully OOP API (> PHP5) to communicate using this protocol.
By default it uses TLS so you will not have any problems connecting to the talk google server.
Check this code example:
<?php
include("xmpp.php");
$conn = new XMPP('talk.google.com', 5222, 'username', 'password', 'xmpphp',
'gmail.com', $printlog=False, $loglevel=LOGGING_INFO);
$conn->connect();
$conn->processUntil('session_start');
$conn->message('[email protected]', 'This is a test message!');
$conn->disconnect();
?>
Upvotes: 4
Reputation: 4921
The xmpphp library should help you. Have a look at the examples.
PHP is absolutely the last language I would use for something like this (well, okay, I wouldn't do it in awk or sed either), but if you're set on using it, you can.
Upvotes: 7