Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

New nick_lookup_h command to look up hosts associated with a nick

  • Loading branch information...
commit d99cc6629885dfc1b43020d01774c62c30811aa0 1 parent 92358da
Isaac Good authored
Showing with 33 additions and 8 deletions.
  1. +7 −2 ChangeLog
  2. +26 −6 stalker.pl
View
9 ChangeLog
@@ -1,6 +1,11 @@
+2012-11-05 .76
+ * New nick_lookup_h command that takes a nick and shows associated
+ hosts.
+ - IsaacG
+
2012-03-27 .75
- * Add database indices to speed up read accesses.
- - IsaacG
+ * Add database indices to speed up read accesses.
+ - IsaacG
2011-09-15 .74
* Merged in the testing branch to get two DB handles to avoid the parent
View
32 stalker.pl
@@ -8,7 +8,7 @@
# DBI
# DBD::SQLite
-$VERSION = '0.75';
+$VERSION = '0.76';
%IRSSI = (
authors => 'SymKat',
contact => 'symkat@symkat.com',
@@ -29,6 +29,7 @@
Irssi::command_bind( 'host_lookup', \&host_request );
Irssi::command_bind( 'nick_lookup', \&nick_request );
+Irssi::command_bind( 'nick_lookup_h', \&nick_request_hosts );
Irssi::theme_register([
$IRSSI{'name'} => '{whois stalker %|$1}',
@@ -95,15 +96,19 @@ sub whois_request {
my ( $me, $n, $u, $h ) = split(" ", $data );
$server->printformat($n,MSGLEVEL_CRAP,$IRSSI{'name'},$n,
- join( ", ", (get_records('host', $h, $server->{address}))) . "." );
+ join( ", ", (get_nick_records('host', $h, $server->{address}))) . "." );
+}
+
+sub nick_request_hosts {
+ windowPrint( join( ", ", (get_host_records('nick', $_[0], $_[1]->{address}))) . ".");
}
sub host_request {
- windowPrint( join( ", ", (get_records('host', $_[0], $_[1]->{address}))) . ".");
+ windowPrint( join( ", ", (get_nick_records('host', $_[0], $_[1]->{address}))) . ".");
}
sub nick_request {
- windowPrint( join( ", ", (get_records('nick', $_[0], $_[1]->{address}))) . ".");
+ windowPrint( join( ", ", (get_nick_records('nick', $_[0], $_[1]->{address}))) . ".");
}
# Record Adding Functions
@@ -115,7 +120,7 @@ sub nick_joined {
if ( Irssi::settings_get_bool($IRSSI{name} . "_stalk_on_join") ) {
my $window = $server->channel_find($channel);
- my @used_nicknames = get_records( 'host', $host, $server->{address} );
+ my @used_nicknames = get_nick_records( 'host', $host, $server->{address} );
$window->printformat( MSGLEVEL_JOINS, 'stalker_join',
$nick, $address, $channel, join( ", ", @used_nicknames ));
@@ -313,6 +318,7 @@ sub async_add
Irssi::signal_remove( 'pidwait', \&record_added );
Irssi::command_unbind( 'host_lookup', \&host_request );
Irssi::command_unbind( 'nick_lookup', \&nick_request );
+ Irssi::command_unbind( 'nick_lookup_h', \&nick_request_h );
# In child, do the database tasks
db_add_record(@{$_}) for (@record_list);
@@ -348,7 +354,21 @@ sub db_add_record
debugPrint( "info", "Added record for $nick!$user\@$host to $serv" );
}
-sub get_records {
+sub get_host_records {
+ my ( $type, $query, $serv, @return ) = @_;
+
+ $count = 0; %data = ( );
+ my %data = _r_search( $serv, $type, $query );
+ for my $k ( keys %data ) {
+ debugPrint( "info", "$type query for records on $query from server $serv returned: $k" );
+ push @return, $k if $data{$k} eq 'host';
+ }
+
+ # case-insensitive sort
+ return sort {uc($a) cmp uc($b)} @return;
+}
+
+sub get_nick_records {
my ( $type, $query, $serv, @return ) = @_;
$count = 0; %data = ( );
Please sign in to comment.
Something went wrong with that request. Please try again.