Net::Jabber::Bot(3pm) | User Contributed Perl Documentation | Net::Jabber::Bot(3pm) |
Net::Jabber::Bot - Automated Bot creation with safeties
Version 2.1.7
Program design: This is a Moose based Class.
The idea behind the module is that someone creating a bot should not really have to know a whole lot about how the Jabber protocol works in order to use it. It also allows us to abstract away all the things that can get a bot maker into trouble. Essentially the object helps protect the coders from their own mistakes.
All someone should have to know and define in the program away from the object is:
The object at present has the following enforced safeties as long as you do not override safety mode:
my $bot = Net::Jabber::Bot->new( server => 'host.domain.com', # Name of server when sending messages internally. conference_server => 'conference.host.domain.com', port => 522, username => 'username', password => 'pasword', safety_mode => 1, message_function => \&new_bot_message, background_function => \&background_checks, forums_and_responses => \%forum_list );
All options:
my $bot = Net::Jabber::Bot->new( server => 'host.domain.com', # Name of server when sending messages internally. conference_server => 'conference.host.domain.com', server_host => 'talk.domain.com', # used to specify what jabber server to connect to on connect? tls => 0, # set to 1 for google ssl_ca_path => '', # path to your CA cert bundle ssl_verify => 0, # for testing and for self-signed certificates connection_type => 'tcpip', port => 522, username => 'username', password => 'pasword', alias => 'cpan_bot', message_function => \&new_bot_message, background_function => \&background_checks, loop_sleep_time => 15, process_timeout => 5, forums_and_responses => \%forum_list, ignore_server_messages => 1, ignore_self_messages => 1, out_messages_per_second => 4, max_message_size => 1000, max_messages_per_hour => 100 );
Set up the object and connect to the server. Hash values are passed to new as a hash.
The following initialization variables can be passed. Only marked variables are required (TODO)
safety_mode = (1,0)
Determines if the bot safety features are turned on and enforced. This mode is on by default. Many of the safety features are here to assure you do not crash your favorite jabber server with floods, etc. DO NOT turn it off unless you're sure you know what you're doing (not just Sledge Hammer ceratin)
The found 'response string' is assumed to be at the beginning of the message. The message_funtion function will be called with the modified string.
alias = jbot:, attention:
example1:
message: 'jbot: help' passed to callback: 'help'
BE CAREFUL if you turn this on!!! Turning this on risks potentially endless loops. If you're going to do this, please be sure safety is turned on at least initially.
default: 5
safety: 5
default: 1,000,000
safety: 1,000
default: 125
safety: 166
NOTE: No error detection for join failure is present at the moment. (TODO)
Internal process:
1. Disconnects 3. Re-initializes
$bot->get_ident($forum_name);
Returns the array of messages we are monitoring for in supplied forum or replies with undef.
$bot->respond_to_self_messages($value = 1);
Tells the bot to start reacting to it\'s own messages if non-zero is passed. Default is 1.
$bot->get_messages_this_hour();
replys with number of messages sent so far this hour.
$bot->SendGroupMessage($name, $message);
Tells the bot to send a message to the recipient room name
$bot->SendPersonalMessage($recipient, $message);
How to send an individual message to someone.
$recipient must read as user@server/Resource or it will not send.
$bot->SendJabberMessage($recipient, $message, $message_type, $subject);
The master subroutine to send a message. Called either by the user, SendPersonalMessage, or SendGroupMessage. Sometimes there is call to call it directly when you do not feel like figuring you messaged you. Assures message size does not exceed a limit and chops it into pieces if need be.
NOTE: non-printable characters (unicode included) will be
stripped before sending to the server via:
s/[^[:print:]]+/./xmsg
$bot->SetForumSubject($recipient, $subject);
Sets the subject of a forum
$bot->ChangeStatus($presence_mode, $status_string);
Sets the Bot's presence status. $presence mode could be something like: (Chat, Available, Away, Ext. Away, Do Not Disturb). $status_string is an optional comment to go with your presence mode. It is not required.
$bot->GetRoster();
Returns a list of the people logged into the server. I suspect we really want to know who is in a paticular forum right? In which case we need another sub for this.
Todd Rinaldo "<perl-net-jabber-bot@googlegroups.com) >"
Please report any bugs or feature requests to "perl-net-jabber-bot@googlegroups.com", or through the web interface at <http://code.google.com/p/perl-net-jabber-bot/issues/entry>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc Net::Jabber::Bot
You can also look for information at:
<http://annocpan.org/dist/Net-Jabber-Bot>
<http://cpanratings.perl.org/d/Net-Jabber-Bot>
<https://metacpan.org/pod/Net::Jabber::Bot>
<https://github.com/toddr/perl-net-jabber-bot>
Copyright 2007 Todd E Rinaldo, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2022-05-28 | perl v5.34.0 |