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

Comparing deliantra/server/ext/irc.ext (file contents):
Revision 1.19 by root, Thu Apr 29 07:52:01 2010 UTC vs.
Revision 1.22 by root, Sun Nov 11 02:38:10 2012 UTC

1#! perl 1#! perl
2 2
3use Time::HiRes;
4use AnyEvent::IRC::Client; 3use AnyEvent::IRC::Client;
5use AnyEvent::IRC::Util qw/filter_colors/; 4use AnyEvent::IRC::Util qw/filter_colors/;
6 5
7# requires: commands.ext 6# requires: commands.ext
8 7
9return unless exists $cf::CFG{irc_server}; 8return unless exists $cf::CFG{irc_server};
10 9
11our $BOTSERVER = $cf::CFG{irc_server}; 10CONF BOTSERVER : irc_server = undef;
12our $BOTPORT = $cf::CFG{irc_port}; 11CONF BOTPORT : irc_port = undef;
13our $BOTNAME = $cf::CFG{irc_nick}; 12CONF BOTNAME : irc_nick = undef;
14our $BOTCHAN = $cf::CFG{irc_chan}; 13CONF BOTCHAN : irc_chan = undef;
15 14
16our $CON; # the connection 15our $CON; # the connection
17 16
18sub unload { 17sub unload {
19 $CON->disconnect if $CON; 18 $CON->disconnect if $CON;
29} 28}
30 29
31sub users { 30sub users {
32 $CON 31 $CON
33 ? grep $_ ne $CON->nick, keys %{ $CON->channel_list->{$BOTCHAN} || {} } 32 ? grep $_ ne $CON->nick, keys %{ $CON->channel_list->{$BOTCHAN} || {} }
34 : () 33 : ()
35} 34}
35
36# for nicklist monitoring, #d# should be done event-based
37our %NICKLIST;
38our $NICKLIST = AE::timer 20, 59.17, sub {
39 return unless defined &ext::nickmon::NT_OTHER;
40
41 my %NEXTLIST;
42 for (users) {
43 &ext::nickmon::upd ("irc/$_", &ext::nickmon::NT_OTHER, "irc")
44 unless exists $NICKLIST{$_};
45
46 delete $NICKLIST{$_};
47 undef $NEXTLIST{$_};
48 }
49
50 &ext::nickmon::del ("irc/$_")
51 for keys %NICKLIST;
52
53 %NICKLIST = %NEXTLIST;
54};
36 55
37sub handle_fcmd { 56sub handle_fcmd {
38 my ($name, $me, $msg) = @_; 57 my ($name, $me, $msg) = @_;
39 58
40 if ($msg eq "!who") { 59 if ($msg eq "!who") {
83 $CON->reg_cb ( 102 $CON->reg_cb (
84 irc_privmsg => sub { 103 irc_privmsg => sub {
85 my ($con, $msg) = @_; 104 my ($con, $msg) = @_;
86 my $name = 'irc'; 105 my $name = 'irc';
87 my $nick = AnyEvent::IRC::Util::prefix_nick ($msg); 106 my $nick = AnyEvent::IRC::Util::prefix_nick ($msg);
88 my $NOW = Time::HiRes::time; 107 my $NOW = EV::time;
89 108
90 my $tmsg = filter_colors ($msg->{params}->[-1]); 109 my $tmsg = filter_colors ($msg->{params}->[-1]);
91 $tmsg =~ s/\x01[^\x01]*\x01//g; 110 $tmsg =~ s/\x01[^\x01]*\x01//g;
92 $tmsg =~ s/\015?\012/ /g; 111 $tmsg =~ s/\015?\012/ /g;
93 112

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines