]> git.donarmstrong.com Git - infobot.git/blobdiff - src/CLI/Support.pl
at least run
[infobot.git] / src / CLI / Support.pl
index 6b2de5b1e972dbdba5a92ce13620b7423f36e4a4..d3c5a3d3407aafef6e0eef1b3d541e345c493c0d 100644 (file)
@@ -4,6 +4,11 @@
 #        Version: v0.1 (20021028)
 #        Created: 20021028
 #
+use strict;
+
+my $postprocess;
+
+use vars qw($uh $message);
 
 sub cliloop {
     &status("Using CLI...");
@@ -13,15 +18,16 @@ sub cliloop {
     $uh  = "local\@local";
     $who = "local";
     $orig{who} = "local";
-    $ident = $param{'ircNick'};
+    $ident = $param{'ircUser'};
     $chan = $talkchannel = "_local";
     $addressed = 1;
-    $msgType = 'public';
+    $msgType = 'private';
+    $host = "local";
 
     # install libterm-readline-gnu-perl to get history support
     use Term::ReadLine;
-    $term = new Term::ReadLine 'blootbot';
-    $prompt = "$who> ";
+    my $term = new Term::ReadLine 'blootbot';
+    my $prompt = "$who> ";
     #$OUT = $term->OUT || STDOUT;
     while ( defined ($_ = $term->readline($prompt)) ) {
        $orig{message} = $_;
@@ -46,11 +52,36 @@ sub msg {
        return;
     }
 
+    if ( $postprocess ) {
+       undef $postprocess;
+    } elsif ($postprocess = &getChanConf('postprocess', $talkchannel)) {
+       &DEBUG("say: $postprocess $msg");
+       &parseCmdHook($postprocess . ' ' . $msg);
+       undef $postprocess;
+       return;
+    }
+
     &status(">$nick< $msg");
 
     print("$nick: $msg\n");
 }
 
+# Usage: &action(nick || chan, txt);
+sub action {
+    my ($target, $txt) = @_;
+    if (!defined $txt) {
+       &WARN("action: txt == NULL.");
+       return;
+    }
+
+    if (length $txt > 480) {
+       &status("action: txt too long; truncating.");
+       chop($txt) while (length $txt > 480);
+    }
+
+    &status("* $ident/$target $txt");
+}
+
 sub IsNickInChan {
     my ($nick,$chan) = @_;
     return 1;
@@ -69,8 +100,4 @@ sub performAddressedReply {
     &msg($who, @_);
 }
 
-sub pSReply {
-    &msg($who, @_);
-}
-
 1;