]> git.donarmstrong.com Git - infobot.git/blobdiff - src/UserExtra.pl
factoids -> Factoids
[infobot.git] / src / UserExtra.pl
index c8ec404a33f616fec281f4354006e8483eda552a..96165ddf8f7b9c57f70a3609b5b1806dd3d93f3d 100644 (file)
@@ -17,11 +17,12 @@ use vars qw(%channels %chanstats %cmdstats %count %ircstats %param
 
 &addCmdHook("main", 'chan(stats|info)', ('CODEREF' => 'chaninfo', ) );
 &addCmdHook("main", 'cmd(stats|info)', ('CODEREF' => 'cmdstats', ) );
+&addCmdHook("main", 'sched(stats|info)', ('CODEREF' => 'scheduleList', ) );
 &addCmdHook("main", 'factinfo', ('CODEREF' => 'factinfo',
-       'Cmdstats' => 'Factoid Info', Module => 'factoids', ) );
+       'Cmdstats' => 'Factoid Info', Module => 'Factoids', ) );
 &addCmdHook("main", 'factstats?', ('CODEREF' => 'factstats',
        'Cmdstats' => 'Factoid Stats', Help => "factstats",
-       Forker => 1, 'Identifier' => 'factoids', ) );
+       Forker => 1, 'Identifier' => 'Factoids', ) );
 &addCmdHook("main", 'help', ('CODEREF' => 'help',
        'Cmdstats' => 'Help', ) );
 &addCmdHook("main", 'karma', ('CODEREF' => 'karma', ) );
@@ -166,7 +167,7 @@ sub chaninfo {
     }
 
     # TODO: show top 3 with percentages?
-    my($count) = (sort { $new{$a} <=> $new{$b} } keys %new)[0];
+    my($count) = (sort { $new{$b} <=> $new{$a} } keys %new)[0];
     if ($count) {
        $reply .= ".  \002$count\002 has said the most with a total of \002$new{$count}\002 messages";
     }
@@ -237,8 +238,21 @@ sub karma {
 
 sub ispell {
     my $query = shift;
+    my $binary;
+    my @binaries = (
+       '/usr/bin/aspell',
+       '/usr/bin/ispell',
+       '/usr/bin/spell'
+    );
+
+    foreach (@binaries) {
+       if (-x $_) {
+           $binary=$_;
+           last;
+       }
+    }
 
-    if (! -x "/usr/bin/ispell") {
+    if (!$binary) {
        &msg($who, "no binary found.");
        return;
     }
@@ -250,7 +264,7 @@ sub ispell {
 
     my $reply = "I can't find alternate spellings for '$query'";
 
-    foreach (`/bin/echo '$query' | /usr/bin/ispell -a -S`) {
+    foreach (`/bin/echo '$query' | $binary -a -S`) {
        chop;
        last if !length;                # end of query.
 
@@ -536,7 +550,7 @@ sub userCommands {
            }
        }
 
-       &performReply( sprintf("'%s' is ascii %s", $arg, ord $1) );
+       &performReply( sprintf("'%s' is ascii %s", $arg, ord $arg) );
        return;
     }
 
@@ -849,38 +863,36 @@ if (0) {
     }
 
     # wantNick. xk++
-    if ($message =~ /^wantNick(\+)?$/i) {
-       my ($force) = ($1) ? 1 : 0;
-       $force = 0 unless (&IsFlag("n"));
+    # FIXME does not try to get nick "back", just switches nicks
+    if ($message =~ /^wantNick\s(.*)?$/i) {
+       return unless (&hasFlag("o"));
+       my $wantnick = lc $1;
+       my $mynick = $conn->nick();
 
-       # cannot trust Net::IRC's nick() (TimRiker asks why?)
-       if ($param{'ircNick'} eq $ident) {
-           &msg($who, "I hope you're right. I'll try anyway.");
-           &DEBUG("ircNick => $param{'ircNick'}");
-           &DEBUG("ident => $ident");
+       if ($mynick eq $wantnick) {
+           &msg($who, "I hope you're right. I'll try anyway (mynick=$mynick, wantnick=$wantnick).");
        }
 
        # fallback check, I guess.  needed?
-       if (! &IsNickInAnyChan( $param{'ircNick'} ) ) {
-           my $str = "attempting to change nick to $param{'ircNick'}";
+       if (! &IsNickInAnyChan( $wantnick ) ) {
+           my $str = "attempting to change nick from $mynick to $wantnick";
            &status($str);
            &msg($who, $str);
-           &nick($param{ 'ircNick' });
+           &nick($wantnick);
            return;
        }
 
        # idea from dondelecarlo :)
        # TODO: use cache{nickserv}
        if ($param{'nickServ_pass'}) {
-           return if ($param{'ircNick'} eq $ident or $force == 0);
-
-           &status("someone is using our nick; GHOSTing");
-           &msg($who, "using GHOST on $param{'ircNick'}.");
-           &msg("NickServ", "GHOST $param{'ircNick'} $param{'nickServ_pass'}");
+           my $str = "someone is using nick $wantnick; GHOSTing";
+           &status($str);
+           &msg($who, $str);
+           &msg("NickServ", "GHOST $wantnick $param{'nickServ_pass'}");
 
            $conn->schedule(5, sub {
-               &status("going to change nick after GHOST.");
-               &nick( $param{'ircNick'} );
+               &status("going to change nick from $mynick to $wantnick after GHOST.");
+               &nick($wantnick);
            } );
 
            return;