]> git.donarmstrong.com Git - infobot.git/blob - src/interface.pl
use read to get buffering
[infobot.git] / src / interface.pl
1 #
2 # interface.pl:
3 #       Author:
4 #
5
6 # use strict;   # TODO
7
8 sub whatInterface {
9     if (!&IsParam("Interface") or $param{'Interface'} =~ /IRC/) {
10         return "IRC";
11     } else {
12         return "CLI";
13     }
14 }
15
16 sub cliloop {
17     &status("Using CLI...");
18     &status("Now type what you want.");
19
20     $nuh = "local!local\@local";
21     $uh  = "local\@local";
22     $who = "local";
23     $orig{who} = "local";
24     $ident = $param{'ircNick'};
25     $chan = $talkchannel = "_local";
26     $addressed = 1;
27     $msgType = 'public';
28
29     # install libterm-readline-gnu-perl to get history support
30     use Term::ReadLine;
31     $term = new Term::ReadLine 'blootbot';
32     $prompt = "$who> ";
33     #$OUT = $term->OUT || STDOUT;
34     while ( defined ($_ = $term->readline($prompt)) ) {
35         $orig{message} = $_;
36         $message = $_;
37         chomp $message;
38         last if ($message =~ m/^quit$/);
39         $_ = &process() if $message;
40     }
41     &doExit();
42 }
43
44 1;