#!/usr/local/bin/perl

# Module to allow bot admins to log in with a password when at a remote location
# Will add their current hostname to the admin list

# 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.

package login;

my $password = "my_password";

# Public command
sub public {
	@public = ("help", "password");
}


# 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, password");
	nanobot::snd("NOTICE $_[1] :!login.password yourpass");
	nanobot::snd("NOTICE $_[1] :Will add your current hostmask to the admin list");
}

# Every subroutine is a function that can be called from IRC.
sub password {
	if($_[7] eq $password) {
		nanobot::snd("NOTICE $_[1] :Logged in with $_[3]");
		push(@nanobot::opers,$_[3]);
	} else {
		nanobot::snd("NOTICE $_[1] :Login failed: wrong password");
	}
}

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