#!/usr/local/bin/perl

# This module will give voice to people who enter the channel and have identified with NickServ.
# This module was written for UnrealIRCd with Anope services. Different IRCd's and different services may require different commands or generate different responses.

# 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] = first argument given in IRC
# $_[8] = second argument given in IRC etc.

# The package name must match the filename + .pm, so this file should be called "identified.pm".
package identified;

my $channel = "#hackerthreads";
my $mode = "+v"; # This is the mode to be set when identification is completed.

sub join {
	if("$_[4]" eq "$channel") {
		# Check with nickserv for ident status
		nanobot::msg("NickServ", "status $_[1]");
	}
}


sub notice {
	if($_[1] eq "NickServ") {
		my ($ignore,$user,$status) = split(/ /, $_[7]);
		if($status eq "3") {
			nanobot::snd("MODE $channel $mode $user");
		}
	}
}

# 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");
}


# 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::ntc("$_[1]", "This module gives voice to users who have identified with nickserv.");
}

# A module must always end with the line "1;", Perl demands it.
1;
