PHP Chat Bot: Google Talk

I was wondering how to create a chatbot for Google Talk through a special client.

I know that it uses XMPP to send messages, but I do not know how to use it at all. I understand that I should be able to make a bot that chat for me when I leave, if I create my own client page that will analyze chats with my data. Where would I start if I wanted to create a custom client, and how can I get it to parse messages and auto-replies in the prescribed manner? My mission: an answering machine when I'm AFC, with a decent AI (which I can do.)

Can I use this protocol with PHP to create my bot, or should it be based on java or python?

Thanks for any help !!!

+3
source share
2 answers

The xmpphp library should help you. Take a look at the examples.

PHP is absolutely the last language I would use for something like this (well, okay, I would not do it in awk or sed), but if you use it, you can.

+7
source

Take a look at this library:

Provides you with a complete OOP API (> PHP5) for communication using this protocol.

By default, it uses TLS, so you will not have problems connecting to the google talk server.

Check out this sample code:

<?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('someguy@someserver.net', 'This is a test message!');
$conn->disconnect();
?>
+4
source

Source: https://habr.com/ru/post/1714180/


All Articles