]> git.donarmstrong.com Git - infobot.git/blob - src/CLI/Support.pl
use user
[infobot.git] / src / CLI / Support.pl
1 #
2 # CLI/Support.pl: Stubs for functions that are from IRC/*
3 #         Author: Tim Riker <Tim@Rikers.org>
4 #        Version: v0.1 (20021028)
5 #        Created: 20021028
6 #
7
8 sub cliloop {
9     &status("Using CLI...");
10     &status("Now type what you want.");
11
12     $nuh = "local!local\@local";
13     $uh  = "local\@local";
14     $who = "local";
15     $orig{who} = "local";
16     $ident = $param{'ircUser'};
17     $chan = $talkchannel = "_local";
18     $addressed = 1;
19     $msgType = 'public';
20
21     # install libterm-readline-gnu-perl to get history support
22     use Term::ReadLine;
23     $term = new Term::ReadLine 'blootbot';
24     $prompt = "$who> ";
25     #$OUT = $term->OUT || STDOUT;
26     while ( defined ($_ = $term->readline($prompt)) ) {
27         $orig{message} = $_;
28         $message = $_;
29         chomp $message;
30         last if ($message =~ m/^quit$/);
31         $_ = &process() if $message;
32     }
33     &doExit();
34 }
35
36 sub msg {
37     my ($nick, $msg) = @_;
38     if (!defined $nick) {
39         &ERROR("msg: nick == NULL.");
40         return;
41     }
42
43     if (!defined $msg) {
44         $msg ||= "NULL";
45         &WARN("msg: msg == $msg.");
46         return;
47     }
48
49     &status(">$nick< $msg");
50
51     print("$nick: $msg\n");
52 }
53
54 # Usage: &action(nick || chan, txt);
55 sub action {
56     my ($target, $txt) = @_;
57     if (!defined $txt) {
58         &WARN("action: txt == NULL.");
59         return;
60     }
61
62     if (length $txt > 480) {
63         &status("action: txt too long; truncating.");
64         chop($txt) while (length $txt > 480);
65     }
66
67     &status("* $ident/$target $txt");
68 }
69
70 sub IsNickInChan {
71     my ($nick,$chan) = @_;
72     return 1;
73 }
74
75 sub performStrictReply {
76     &msg($who, @_);
77 }
78
79 sub performReply {
80     &msg($who, @_);
81 }
82
83 sub performAddressedReply {
84     return unless ($addressed);
85     &msg($who, @_);
86 }
87
88 sub pSReply {
89     &msg($who, @_);
90 }
91
92 1;