From d3f02e4c993a08826236af7e921891697d424b84 Mon Sep 17 00:00:00 2001 From: William Heimbigner Date: Tue, 12 Jan 2016 15:57:02 -0700 Subject: Use named capture groups in anticipation of a smarter help function, and allow users with 's' to check on monitor and silence flags, while only allowing admins to modify those flags --- config-default/commands.xml | 88 +++++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 38 deletions(-) (limited to 'config-default') diff --git a/config-default/commands.xml b/config-default/commands.xml index 68ec222..1aa99ba 100644 --- a/config-default/commands.xml +++ b/config-default/commands.xml @@ -1,5 +1,5 @@ - + {channel}}) { @@ -15,9 +15,9 @@ print Dumper(\@chans); ]]> - + {to}->[0] =~ /^#/) { $conn->privmsg($event->replyto, "This command must be used in PM. Try again WITH A DIFFERENT PASSWORD!"); return; @@ -34,9 +34,9 @@ $conn->privmsg($event->replyto, "Added $user to the list of authorized web users.") ]]> - + $::settings->{web}->{userfile}, UseMD5 => 1}); my $o_Htgroup = new Apache::Htgroup($::settings->{web}->{groupfile}); @@ -46,9 +46,9 @@ $conn->privmsg($event->replyto, "Removed $user from the list of authorized web users.") ]]> - + privmsg($event->replyto, "This is not a teredo-tunnelled IP."); @@ -102,9 +102,9 @@ ", has sent $tx of data, and received $rx of data."); ]]> - + {to}->[0] =~ /^#/) { $conn->privmsg($event->replyto, $nick . " is on: " . ASM::Util->commaAndify(sort(grep { not grep { /^s$/ } @{$::sc{$_}{modes}} } @{$::sn{lc $nick}->{mship}}))); @@ -121,7 +121,7 @@ $conn->privmsg($event->replyto, "source is at https://gitlab.devlabs.linuxassist.net/asm/antispammeta/"); ]]> - + privmsg($event->replyto, "I am set to run without a database, fool."); @@ -129,43 +129,55 @@ } my $dbh = $::db->{DBH}; - if ($1 eq 'log') { + if ($+{db} eq 'log') { $dbh = $::db->{DBH_LOG}; } - $::db->raw($conn, $event->{to}->[0], $dbh, $2); + $::db->raw($conn, $event->{to}->[0], $dbh, $+{string}); ]]> - + getLink(lc $chan); - if ( lc $link ne lc $chan ) { - $conn->privmsg($event->replyto, "Error: $chan is linked to $link - use $link instead."); - return; - } - if (defined($2)) { - my $switch = lc $2; - $::channels->{channel}->{$chan}->{monitor} = $switch; - ASM::XML->writeChannels(); - $conn->privmsg($event->replyto, "Monitor flag for $chan set to $switch"); - } else { - my $switch = $::channels->{channel}->{$chan}->{monitor} // 'yes'; - $conn->privmsg($event->replyto, "Monitor flag for $chan is currently set to $switch"); - } + my $chan = lc $+{chan}; + my $switch = lc $+{switch}; + $::channels->{channel}->{$chan}->{monitor} = $switch; + ASM::XML->writeChannels(); + $conn->privmsg($event->replyto, "Monitor flag for $chan set to $switch"); + ]]> + + + {channel}->{$chan}->{monitor} // 'yes'; + $conn->privmsg($event->replyto, "Monitor flag for $chan is currently set to $switch"); ]]> - + {channel}->{$chan}->{silence} = $switch; + my $old = $::channels->{channel}->{$chan}->{monitor}; + $::channels->{channel}->{$chan}->{monitor} = "no"; + $conn->schedule(30*60, sub { + $::channels->{channel}->{$chan}->{monitor} = $old; + $conn->privmsg($event->replyto, "Unsuppressed $chan"); ASM::XML->writeChannels(); - $conn->privmsg($event->replyto, "Silence flag for $chan set to $switch"); - } else { - my $switch = $::channels->{channel}->{$chan}->{silence} // 'no'; - $conn->privmsg($event->replyto, "Silence flag for $chan is currently set to $switch"); - } + }); + $conn->privmsg($event->replyto, "Suppressing alerts from $chan for 30 minutes. If the bot restarts or the config is changed, you will need to do ;monitor $chan to check the status of the monitor flag"); + ]]> + + + {channel}->{$chan}->{silence} // 'no'; + $conn->privmsg($event->replyto, "Silence flag for $chan is currently set to $switch"); + ]]> + + + {channel}->{$chan}->{silence} = $switch; + ASM::XML->writeChannels(); + $conn->privmsg($event->replyto, "Silence flag for $chan set to $switch"); ]]> @@ -319,7 +331,7 @@ {account})) && ( lc $::sn{$nick}->{account} ne $nick ) ) { + if ( defined($::sn{$nick}) && (defined($::sn{$nick}->{account})) && ( lc $::sn{$nick}->{account} ne $nick ) ) { $conn->privmsg($event->replyto, "I'm assuming you mean " . $nick . "'s nickserv account, " . lc $::sn{$nick}->{account} . '.'); $nick = lc $::sn{$nick}->{account}; } -- cgit v1.2.3