1# hideauth.pl
2#
3# Stops eggdrop passwords from showing up in e.g. /msg botnick op password [#channel]
4#
5# Settings:
6#		hideauth_commands: space-delimited case-insensitive list of eggdrop commands to filter (e.g. "op voice ident") (can be regexps)
7#		hideauth_botsonly: if 1/ON, only hideauth for nicks in the bots list (because "op" is common Dutch word :)
8#		hideauth_bots: space-delimited case-insensitive list of botnicks (can be regexps) (e.g. "notopic monicaoff")
9#
10#		You can also change the "bot_command" format item:
11#			$0 = command (op, ident, etc)
12#			$1 = (optional) channel (from "op password #channel")
13#			$2 = nick command is sent to
14#			My default format is (in case you break it): 'eggdrop command {reason $0 %K****%n$1} sent to {channick_hilight $2}'
15#
16# Thanks to Joost "Garion" Vunderink for advice and testing ^_^
17#
18
19use strict;
20use vars qw($VERSION %IRSSI);
21
22use Irssi qw(signal_add_first settings_get_str settings_get_bool settings_add_str settings_add_bool signal_stop theme_register);
23
24$VERSION = '1.01';
25%IRSSI = (
26    authors	=> 'JamesOff',
27    contact	=> 'james@jamesoff.net',
28    name	=> 'hideauth',
29    description	=> 'Stops eggdrop passwords showing up',
30    license	=> 'Public Domain',
31    url		=> 'http://www.jamesoff.net',
32    changed	=> '04 June 2002 20:56:00',
33);
34
35theme_register([
36  'bot_command', 'eggdrop command {reason $0 %K****%n$1} sent to {channick_hilight $2}'
37]);
38
39
40sub intercept_message {
41	my ($server, $message, $target, $orig_target) = @_;
42	my $commands = settings_get_str('hideauth_commands');
43	my $botsOnly = settings_get_bool('hideauth_botsonly');
44	my $bots = settings_get_str('hideauth_bots');
45	$bots =~ tr/ /|/;
46
47	#check for bots only and compare target nick
48	return if (($botsOnly == 1) && ($target !~ /($bots)/i));
49
50	#check the first word to see if it's a command
51	$commands =~ tr/ /|/;
52	if ($message =~ /^($commands) \w+( .+)?/i) {
53		#it's a match, it's handle it :)
54		my ($command, $dest) = ($1, $2);
55		$server->printformat($target, MSGLEVEL_CRAP, 'bot_command', $command, $dest, $target);
56		signal_stop();
57	}
58}
59
60signal_add_first('message own_private', 'intercept_message');
61settings_add_str('misc','hideauth_commands','op voice auth ident pass newpass rehash');
62settings_add_bool('misc','hideauth_botsonly',0);
63settings_add_str('misc','hideauth_bots','');
64