From ff74b7a412dc79c6bcc137b7809b2207bc9ad5f9 Mon Sep 17 00:00:00 2001 From: William Heimbigner Date: Wed, 17 Feb 2016 11:44:00 -0700 Subject: Add a ;nicks command to track down known nicks, searching by host. Incomplete / much more work to be done. --- lib/ASM/Commander.pm | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/ASM/Commander.pm b/lib/ASM/Commander.pm index a0a5179..b9c8e28 100644 --- a/lib/ASM/Commander.pm +++ b/lib/ASM/Commander.pm @@ -143,6 +143,9 @@ my $cmdtbl = { '^;falsematch\b' => { 'flag' => 's', 'cmd' => \&cmd_falsematch }, + '^;nicks (?\S+)\s*$' => { + 'flag' => 's', + 'cmd' => \&cmd_nicks }, }; sub new { @@ -1037,4 +1040,30 @@ sub cmd_falsematch { $conn->privmsg($event->replyto, 'To whitelist false matches for the impersonation check, have someone with the "a" flag run ";restrict nick LegitimateNickGoesHere +nonickbl_impersonate". Contact ilbelkyr if this issue reoccurs.'); } + +sub cmd_nicks { + my ($conn, $event) = @_; + my $nick = $+{nick}; + if (!defined $::db) { + $conn->privmsg($event->replyto, "I am set to run without a database, fool."); + return; + } + my $DB = $::db->{DBH_LOG}; + my $doit = sprintf ("select distinct nick from joins as v1 + inner join ( + select distinct host from joins where nick=%s + and host not like %s + and host <> %s + ) as v2 + on v1.host = v2.host + where v1.nick not like %s + ", + $DB->quote($nick), + $DB->quote('gateway/%/session'), + $DB->quote('127.0.0.1'), + $DB->quote('guest%') + ); + my $result = $DB->selectcol_arrayref( $doit ); + $conn->privmsg($event->replyto, "Results for $nick: " . ASM::Util->commaAndify(sort @$result)); +} # vim: ts=8:sts=8:sw=8:noexpandtab -- cgit v1.2.3