Created
January 10, 2012 20:50
-
-
Save spazm/1591106 to your computer and use it in GitHub Desktop.
Bot::Backbone jabber example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
package Example::Bot::Backbone::Jabber; | |
use strict; | |
use warnings; | |
use v5.10; | |
use Bot::Backbone; | |
use DateTime; | |
#modified from Bot::Backbone synopsis | |
my $domain = 'chat.example.com'; | |
my $group_domain = 'conference.' . $domain; | |
my $username = 'guest'; | |
my $password = 'guest'; | |
my $group = 'test_room'; | |
service jabber_chat => ( | |
service => 'JabberChat', | |
domain => $domain, | |
group_domain => $group_domain, | |
username => $username, | |
password => $password, | |
); | |
service "group_\$group" => ( | |
service => 'GroupChat', | |
group => $group, | |
chat => 'jabber_chat', | |
dispatcher => 'group_chat', | |
); | |
dispatcher group_chat => as { | |
# Report the bot's time | |
command '!time' => | |
respond { DateTime->now->format_cldr('ddd, MMM d, yyyy @ hh:mm:ss') }; | |
}; | |
my $bot = Example::Bot::Backbone::Jabber->new; | |
$bot->run; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
simple Bot::Backbone jabber bot that connects to a group_chat. Replies to group message "!time" with the current time.