ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/perl/schmorp-irc.ext
(Generate patch)

Comparing deliantra/maps/perl/schmorp-irc.ext (file contents):
Revision 1.16 by root, Fri Sep 29 19:21:25 2006 UTC vs.
Revision 1.19 by root, Sun Nov 26 02:37:53 2006 UTC

3use Time::HiRes; 3use Time::HiRes;
4use Net::IRC3::Client::Connection; 4use Net::IRC3::Client::Connection;
5 5
6# requires: commands.ext 6# requires: commands.ext
7 7
8my $BOTSERVER = 'localhost'; 8return unless exists $cf::CFG{irc_server};
9my $BOTPORT = '6667'; 9
10my $BOTNAME = 'cfbot'; 10my $BOTSERVER = $cf::CFG{irc_server};
11my $BOTCHAN = '#cf'; 11my $BOTPORT = $cf::CFG{irc_port};
12my $BOTNAME = $cf::CFG{irc_nick};
13my $BOTCHAN = $cf::CFG{irc_chan};
12 14
13my $CON; # the connection 15my $CON; # the connection
14 16
15sub unload { 17sub unload {
16 $CON->disconnect if $CON; 18 $CON->disconnect if $CON;
19 21
20sub do_notice { 22sub do_notice {
21 my ($msg) = @_; 23 my ($msg) = @_;
22 $CON->send_chan ($BOTCHAN, NOTICE => $msg, $BOTCHAN) 24 $CON->send_chan ($BOTCHAN, NOTICE => $msg, $BOTCHAN)
23 if $CON; 25 if $CON;
26}
27
28sub users {
29 $CON
30 ? grep $_ ne $CON->nick, keys %{ $CON->channel_list->{$BOTCHAN} || {} }
31 : ()
24} 32}
25 33
26sub handle_fcmd { 34sub handle_fcmd {
27 my ($name, $me, $msg) = @_; 35 my ($name, $me, $msg) = @_;
28 36
89 0; 97 0;
90 } 98 }
91 ); 99 );
92} 100}
93 101
94my $timer; 102Event->timer (after => 1, interval => 30, cb => \&check_connection);
95 103
96sub new_timer {
97 $timer = AnyEvent->timer (after => 10, cb => sub {
98 check_connection ();
99 &new_timer; # and restart the time
100 });
101}
102
103new_timer; # create first timer
104check_connection ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines