Net::Ewtoo::Bot

Net::Ewtoo::Bot is a talker robot client module.
Download

Net::Ewtoo::Bot Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Gavin Brown
  • Publisher web site:
  • http://search.cpan.org/~gbrown/Net-Ewtoo-Bot-0.16/Bot.pm

Net::Ewtoo::Bot Tags


Net::Ewtoo::Bot Description

Net::Ewtoo::Bot is a talker robot client module. Net::Ewtoo::Bot is a Ewtoo-compatible talker robot client module.SYNOPSIS use Net::Ewtoo::Bot; my $NAME = 'jodbot'; my $bot = new Net::Ewtoo::Bot; $bot->add_trigger("(.+?) says '$NAME, (.+?)'", &handle_say); $bot->set_delay('range', 0, 5); $bot->login($host, $port, $user, $pass); $bot->say("Hi! I'm the $NAME robot!"); $bot->listen(); $bot->logout(); exit; sub handle_say { my ($sayer, $said) = @_; if ($said eq 'hello') { $bot->say("Why hello $sayer!"); } elsif ($said eq 'please go away') { $bot->say("OK, bye!"); $bot->logout(); } return; }METHODS $bot->login($host, $port, $user, $pass);This logs the bot into the $host:$port talker using $user and $pass. The bot will send extra carriage returns to bypass MOTDs and saved messages.Any defined login subroutines are executed at this point. $bot->logout($message);Sends the "QUIT" command (in capitals for compatability with MBA4), and closes the socket. Any defined logout subroutines are executed beforehand. If $message is defined, the bot calls the "mquit" command with $message as its argument. $bot->set_delay($type, $lower, $upper);This method sets the delay between between the calling of a method and its execution. This is useful for adding a realistic delay during communications with another user. $type can be either 'fixed', in which case the delay is always $lower (in seconds) and $upper is ignored, or 'range', in which case the delay will be a random number of seconds between $lower and $upper. $bot->add_trigger($pattern, $callback);This method adds a trigger used by the listen() method. When a line of input is received that matches $pattern, $callback is executed. The arguments to $callback are any captured substrings you define in your pattern, which is a regular perl regexp (without the trailing and leading slashes). $bot->delete_trigger($pattern);Removes the trigger associated with $pattern from the trigger list. $bot->def_login($callback);Specifies a subroutine with $callback that will be executed after the bot logs in. $bot->def_logout($callback);Specifies a subroutine with $callback that will be executed before the bot logs out. $bot->listen($verbose);listen() reads input from the talker and executes triggers as necessary. If $verbose is set to 1, then any input received is printed to STDOUT. $bot->break();$break() sets a flag that tells the listen() method to finish and return. $bot->say($str);A convenience function that makes the bot say $str. $bot->think($str);A convenience function that makes the bot think $str. $bot->shout($str);A convenience function that makes the bot shout $str. $bot->tell($user, $str);A convenience function that makes the bot tell $str to $user. $bot->command($cmd);Allows the calling of an arbitrary talker command. $bot->getline();Reads a single line of input from the talker. Requirements: · Perl


Net::Ewtoo::Bot Related Software