View ¡m../sdba/bin/commands.pl¡n
################################ # WIRED BOTS # # commands($victim‚$msg); # # desc: This sub decides whether a message is a command or not. # It first grabs $victim and $msg. # Then it opens the commands dir, checks the file names and sees # if there is a match. # If it is a command, goto that command to recieve a reply. # Otherwise, return with 'notcommand' and $command equal to 0. # recv: $victim‚$msg # sends: $command,$reply ################################ sub commands { #Get the victim and his message. $victim = shift; $msg = shift; #Set the default values. $reply = ""; $command = 0; #Check the message against the list of commands. opendir(DIR, "./commands"); foreach $file (sort(grep(!/^\./, readdir(DIR)))) { $file =~ s/\.(.*)//g; if ($command == 0) { if ($msg =~ /^\/$file/i) { $command = 1; $reply = &{$file}($victim,$msg); } } } closedir(DIR); #If the reply hasn't been set from a command, it isn't a command. if ($reply eq "") { $reply = "notcommand"; } #Give back a boolean and the reply. return $command,$reply; } 1;