]> git.donarmstrong.com Git - infobot.git/blob - src/CLI/Support.pl
let's be private for a while
[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 = 'private';
20     $host = "local";
21
22     # install libterm-readline-gnu-perl to get history support
23     use Term::ReadLine;
24     $term = new Term::ReadLine 'blootbot';
25     $prompt = "$who> ";
26     #$OUT = $term->OUT || STDOUT;
27     while ( defined ($_ = $term->readline($prompt)) ) {
28         $orig{message} = $_;
29         $message = $_;
30         chomp $message;
31         last if ($message =~ m/^quit$/);
32         $_ = &process() if $message;
33     }
34     &doExit();
35 }
36
37 sub msg {
38     my ($nick, $msg) = @_;
39     if (!defined $nick) {
40         &ERROR("msg: nick == NULL.");
41         return;
42     }
43
44     if (!defined $msg) {
45         $msg ||= "NULL";
46         &WARN("msg: msg == $msg.");
47         return;
48     }
49
50     &status(">$nick< $msg");
51
52     print("$nick: $msg\n");
53 }
54
55 # Usage: &action(nick || chan, txt);
56 sub action {
57     my ($target, $txt) = @_;
58     if (!defined $txt) {
59         &WARN("action: txt == NULL.");
60         return;
61     }
62
63     if (length $txt > 480) {
64         &status("action: txt too long; truncating.");
65         chop($txt) while (length $txt > 480);
66     }
67
68     &status("* $ident/$target $txt");
69 }
70
71 sub IsNickInChan {
72     my ($nick,$chan) = @_;
73     return 1;
74 }
75
76 sub performStrictReply {
77     &msg($who, @_);
78 }
79
80 sub performReply {
81     &msg($who, @_);
82 }
83
84 sub performAddressedReply {
85     return unless ($addressed);
86     &msg($who, @_);
87 }
88
89 sub pSReply {
90     &msg($who, @_);
91 }
92
93 1;