Permalink
Browse files

Added stalker_normalize_nick option.

  • Loading branch information...
1 parent 6a8743f commit 389a10dfa735255a8e1a7071076ad705cfa54a84 @symkat committed Aug 12, 2011
Showing with 29 additions and 2 deletions.
  1. +11 −1 ChangeLog
  2. +18 −1 stalker.pl
View
@@ -1,4 +1,14 @@
-2011-09-10 .60
+2011-08-12 .62
+ * Added stalker_normalize_nick option, default on.
+ When set, nicknames which contain any of '-_~^`' will not
+ be shown if a version without those exist. For example
+ results like "symkat`, symkat, sym`kat" will just be "symkat",
+ while results like "`foo bar bar`" would be "`foo bar".
+ When turned off, acts as before, listing all nicknames.
+ Inspired by VinzNL's branch on GitHub.
+ - SymKat
+
+2011-08-10 .60
* Added add_timestamp_column. This adds a "added" timestamp column to the
database which records when a record was added.
- IsaacG
View
@@ -8,7 +8,7 @@
# DBI
# DBD::SQLite
-$VERSION = '0.60';
+$VERSION = '0.62';
%IRSSI = (
authors => 'SymKat',
contact => 'symkat@symkat.com',
@@ -49,6 +49,7 @@
Irssi::settings_add_bool( 'Stalker', $IRSSI{name} . "_ignore_guest_nicks", 1 );
Irssi::settings_add_bool( 'Stalker', $IRSSI{name} . "_debug_log", 0 );
Irssi::settings_add_bool( 'Stalker', $IRSSI{name} . "_stalk_on_join", 0 );
+Irssi::settings_add_bool( 'Stalker', $IRSSI{name} . "_normalize_nicks", 1 );
my $count;
my %data;
@@ -199,6 +200,17 @@ sub create_database {
# Other Routines
+sub normalize {
+ my ( @nicks ) = @_;
+ my ( %nicks, %ret ) = map { $_, 1 } @nicks;
+
+ for my $nick ( @nicks ) {
+ (my $base = $nick ) =~ s/[\Q-_~^`\E]//g;
+ $ret{ exists $nicks{$base} ? $base : $nick }++;
+ }
+ return keys %ret;
+}
+
sub add_record {
my ( $nick, $user, $host, $serv ) = @_;
return unless ($nick and $user and $host and $serv);
@@ -280,6 +292,11 @@ sub get_records {
debugPrint( "info", "$type query for records on $query from server $serv returned: $k" );
push @return, $k if $data{$k} eq 'nick';
}
+
+ if ( Irssi::settings_get_bool($IRSSI{name} . "_normalize_nicks" ) ) {
+ return normalize(@return);
+ }
+
return @return;
}

0 comments on commit 389a10d

Please sign in to comment.