Bot::BasicBot::Pluggable::Module

Bot::BasicBot::Pluggable::Module is a Perl module for all Bot::BasicBot::Pluggable modules.
Download

Bot::BasicBot::Pluggable::Module Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Tom Insam
  • Publisher web site:
  • http://search.cpan.org/~tomi/URI-Find-Simple-1/lib/URI/Find/Simple.pm

Bot::BasicBot::Pluggable::Module Tags


Bot::BasicBot::Pluggable::Module Description

Bot::BasicBot::Pluggable::Module is a Perl module for all Bot::BasicBot::Pluggable modules. Bot::BasicBot::Pluggable::Module is a Perl module for all Bot::BasicBot::Pluggable modules. Inherit from this to get all sorts of exciting things.IRC INTERFACEThere isn't one - the 'real' modules inherit from this one.MODULE INTERFACEYou MUST override the 'said' and the 'help' methods. help() MUST return the help text for the module.You MAY override the 'chanjoin', 'chanpart', and 'tick' methods. the said() method MAY return a response to the event.OBJECT STOREEvery pluggable module gets an object store to save variables in. Access this store using the seg() and set() accessors, ie my $count = $self->get("count"); $self->set( count => $count + 1 );Do not access the store through any other means - the location of the store, and it's method of storage, may change at any time.Keys that begin "user_" should be considered _USER_ variables, and can be changed be people with admin access in the IRC channel, using Bot::BasicBot::Pluggable::Module::Vars. Don't use them as unchecked input data.Implementation detail - TODO - describe this. Fast summary - try not to put things that aren't scalars in the object store.METHODSnew()Standard new method, blesses a hash into the right class and puts any key/value pairs passed to it into the blessed hash. Calls load() to load any internal variables, then init(), which you should override in your module.bot()returns the Bot::BasicBot::Pluggable bot we're running understore()returns the Bot::BasicBot::Pluggable::Store subclass that the bot is using to store it's variables.var( name, )get or set a local variable from the module storeset( name => value )set a local variable into the object store.get( name )returns the value of a local variable from the object store.unset(var)unsets a local variable - removes it from the store, not just undefs it.store_keys()returns a list of all keys in the object storesay(message)passing through to the underlying Bot::BasicBot object, this method lets you send messages without replying to a said() call, eg: $self->say({ who => 'tom', body => 'boo', channel => 'msg' });reply(message, body)replies to the given message with the given text. Another passthrough to the Bot::BasicBot object. The message is used to pre-populate the reply, so it'll be in the same channel as the question, directed to the right user, etc.tell(nick / channel, message)convenience method to send a message to the given nick or channel, will send a privmsg if a nick is given, or a public for a channel. $self->tell('tom', "hello there, fool");or $self->tell('#sailors', "hello there, sailor");said(message, priority)This is the method to override. It's called when the bot sees something said. The first parameter is a Bot::BasicBot 'message' object, as passed to it's 'said' function - see the Bot::BasicBot docs for details. The second parameter is the priority of the message - all modules will have the 'said' function called up to 4 times, with a priority of 0, then 1, then 2, then 3. The first module to return a non-null value 'claims' the message, and the bot will reply to it with the value returned.The exception to this is the '0' priority, which a module MUST NOT respond to. This is so that all modules will at least see all messages.I suggest a method like: sub said { my ($self, $mess, $pri) = @_; my $body = $mess->{body}; return unless ($pri == 2); # most common my ($command, $param) = split(/s+/, $body, 2); $command = lc($command); # do something here return; }Optionally, you can not override this method, and override one of the seperate seen(), admin(), told() and fallback() methods, corresponding to priorities 0, 1, 2 and 3 in order - this is much preferred, and will lead to nicer code. It's very new, though, which is why it's not used in most of the shipped moduels yet. It will eventually become the only thing to do, and I will deprecate said()seen(mess)Like said(), called if you don't override said, but only for priority 0.admin(mess)Like said(), called if you don't override said, but only for priority 1.seen(mess)Like said(), called if you don't override said, but only for priority 2.fallback(mess)Like said(), called if you don't override said, but only for priority 3.connectedcalled when the bot connects to the server. The return value is meaningless.initcalled when the module is created, and after the settings are loaded. This may or may not be after the bot has connected to the server - make no assumptions.helpCalled when a user asks for help on a topic. Should return some useful help text. For Bot::BasicBot::Pluggable, when a user asks the bot 'help', the bot will return a list of modules. Asking the bot 'help ' will call the help function of that module, passing in the first parameter the message object that represents the question.emoted($mess, $priority)called when a user emotes something in channel. Params are the same as those passed to said(), and the semantics as regards returning are identical as well.tick()the tick event. The method is called every 5 seconds. It's probably worth having a counter and not responding to every single one, assuming you want to respond to it at all. The return value is ignored.chanjoin($mess)called when a user joins a channel. $mess is the event described in Bot::BasicBot, it's a hashref, the important keys are:whothe nick of the joining userchannelthe channel they joinedchanpart($mess)called when a user leaves a channel. Passed the same structure as the chanjoin method is.Requirements:· Perl Requirements: · Perl


Bot::BasicBot::Pluggable::Module Related Software