#!/usr/local/bin/perl
 
# These are the variables passed to each function call.
#
# $_[0] = name for this module (surely you already know this, but still)
# $_[1] = sending nickname
# $_[2] = sending username
# $_[3] = sending hostmask
# $_[4] = sending channel (or botnick in case of PM)
# $_[5] = current value for $modchan
# $_[6] = current value for $botnick
# $_[7] = arguments given in IRC
 
# The package name must match the filename + .pm, so this file should be called "demo.pm".
package demo;
 
if ( $firstcall == 0 ) {
	# Here is some code that is executed when the module is loaded and when a function is called.
	nanobot::snd("PRIVMSG #bot :Demo module was loaded!");
	$firstcall == 1;
}
 
# sub join {} is a special name, if you implement this you will receive JOIN info trough this subroutine
# Implementing the join subroutine is optional.
 
# Example implemetation of join:
sub join {
	nanobot::snd("PRIVMSG $_[4] :Hello $_[1], welcome to $_[4]!");
}
 
 
# sub mesg {} is a special name, if you implement this you will receive all messages that don't start with ! (since these are bot commands)
# Implementing the mesg subroutine is optional.
 
 
# sub notice {} is a special name, if you implement this you will receive notices to the bot.
# Implementing the notice subroutine is optional.
 
 
# sub raw {} is a special name, if you implement this you will receive all the raw data the bot receives.
# This is all raw IRC data, so the normal variables will not be available, this means you'll have to parse this data yourself!
# The raw data will be available in the subroutine in the variable $_
# Use this function with caution.
# Implementing the raw subroutine is optional.
 
 
# sub public {} is a special name, this function should contain an array of publicly available function names.
# When this subroutine is not implemented, all functions will only be available to bot opers.
sub public {
	@public = ("help", "function");
}
 
 
# sub help {} is a special name, if you implement this subroutine it will be called when your module is called with no parameters.
# Implementing the mesg subroutine is optional, but highly reckomended.
sub help {
	nanobot::snd("NOTICE $_[1] :Commands: help, function, listargs");
}
 
# Every subroutine is a function that can be called from IRC.
sub function {
	# You can use nanobot::function to use the functions from nanobot. (obviously)
	nanobot::snd("PRIVMSG $_[4] :Message from demo module!");
}
 
# This command is only available to bot opers or when pubmods is set.
sub listargs {
	nanobot::snd("PRIVMSG $_[4] :@_");
}
 
# A module must always end with the line "1;", Perl demands it.
1;