xmpp
xmpp copied to clipboard
Example of echo bot
As said in #10 we need example of code for message receiving.
I tried to add event listener for {http://etherx.jabber.org/streams}message
and for {jabber:client}message
with no result. Callback just didn't calling.
Also I want to understand how client can be used in cycle for processing incoming messages in real-time.
I was trying to debug EventManager::trigger()
and found that only two events are fired on incoming messages: {jabber:client}message
and {jabber:client}body
. I was able to set event listener after small fix of my error.
But both events seems not to be usable for message processing.
{jabber:client}message
contains unwanted data with message text.
{jabber:client}body
does not.
But both have no information about sender or other helpful metadata.
I Really Really Really need to see an example of Echo bot... I don't see anything that works here! @fabiang please help!
$client->getConnection()->getInputStream()->getEventManager()->attach('{http://etherx.jabber.org/streams}message', function() use ($client) {
// send a message to the above channel
$message = new Message;
$message->setMessage('test')
->setTo($channel.'@'.$server)
->setType(Message::TYPE_GROUPCHAT);
$client->send($message);
});
This does not work!
I also don't understand how to implement echo bot