Bot::Backbone::Service::JabberChat - Connect and chat with a Jabber server
service jabber_chat => ( service => 'JabberChat', username => 'bot', domain => 'example.com', resource => 'coolbot', password => 'secret', );
Connects to and chats directly with other users and chat groups using a Jabber (XMPP) server.
This is the username (or localpart in XMPP parlance) to use when connecting to the Jabber server. E.g., if your bot's login name is
firstname.lastname@example.org, the username is "bot".
This is the domain (or domainpart) to use when connecting to the Jabber server. E.g., f your bot's login mame is
email@example.com, the domain is "example.com".
This is the domain to contact for group chats. Normally, this is the same as "domain", but with "conference." tacked on at the front.
This is a the resourcepart of your login name. You may not really care what this is set to, but it shows up in some chat clients. By default it will be set to "backbone-bot", but you can set it something else, if you like.
This is the password to use when logging in to the Jabber server.
This is the host to contact to login. If not set, the "domain" will be used.
If you run your bot on Google Talk, you will probably want this set to talk.google.com.
This is the port to connect. If you do not set it to anything, the default of 5222 will be used.
These are additional connection arguments to pass to the XMPP connector. See AnyEvent::XMPP::Connection for a list of available options.
This is the XMPP client object for organizing connections.
This is the XMPP discovery extension helper.
This is the XMPP multi-user chat extension helper.
Once the connection has been made and is ready to start sending and receiving messages, this will be set to true.
This is a list of multi-user chat groups the bot has joined or intends to join once "session_ready" becomes true.
my $group_jid = $chat->group_jid('bar');
Given a short group name, returns the bare JID for that group.
Returns the XMPP account object.
Returns teh XMPP connection object.
my $xmpp_room = $chat->xmpp_room('qux');
Returns the XMPP room object for the named room.
my $xmpp_contact = $chat->xmpp_contact('firstname.lastname@example.org/blah');
Given a JID, returns the XMPP contact object for that user.
Connects to the Jabber server and registers the events for receiving messages from it.
Asks to join the named multi-user chat groups on the Jabber server. If "session_ready" is false, the chat service will only record a desire to join the group. No actual join will take place. Once the session becomes ready, all pending groups will be joined.
If the session is ready already, then the group will be joined immediately.
Whenever someone sends the bot a direct message throught eh Jabber server, this handler is called. It builds a Bot::Backbone::Message and then passes that message on the associated chat consumers and the dispatcher.
my $bool = $self->is_to_me($user, \$text);
Given the user that identifies the bot in a group chat and text that was just sent to the chat, this detects if the message was directed at the bot. Normally, this includes messages that start with the following:
nick: ... nick, ... nick- ...
It also includes suffix references like this:
..., nick. ..., nick
and infix references like this:
..., nick, ...
If you want something different, you may subclass service and override this method.
Note that the text is sent as a reference and can be modified, usually to remove the nick from the message so the bot does not have to worry about that.
Whenever someone posts to a conference room that the bot has joined, this method will be called to create a Bot::Backbone::Message and pass that message on to chat consumers and the dispatcher.
Sends a message to the Jabber server for a direct chat or group.
Andrew Sterling Hanenkamp <email@example.com>
This software is copyright (c) 2014 by Qubling Software LLC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.