… | |
… | |
5 | |
5 | |
6 | # requires: commands.ext |
6 | # requires: commands.ext |
7 | |
7 | |
8 | return unless exists $cf::CFG{irc_server}; |
8 | return unless exists $cf::CFG{irc_server}; |
9 | |
9 | |
10 | my $BOTSERVER = $cf::CFG{irc_server}; |
10 | my $BOTSERVER = $cf::CFG{irc_server} || "localhost"; |
11 | my $BOTPORT = $cf::CFG{irc_port}; |
11 | my $BOTPORT = $cf::CFG{irc_port} || 6667; |
12 | my $BOTNAME = $cf::CFG{irc_nick}; |
12 | my $BOTNAME = $cf::CFG{irc_nick} || "server"; |
13 | my $BOTCHAN = $cf::CFG{irc_chan}; |
13 | my $BOTCHAN = $cf::CFG{irc_chan} || "cf"; |
14 | |
14 | |
15 | my $CON; # the connection |
15 | my $CON; # the connection |
16 | |
16 | |
17 | sub unload { |
17 | sub unload { |
18 | $CON->disconnect if $CON; |
18 | $CON->disconnect if $CON; |
… | |
… | |
36 | sub handle_fcmd { |
36 | sub handle_fcmd { |
37 | my ($name, $me, $msg) = @_; |
37 | my ($name, $me, $msg) = @_; |
38 | |
38 | |
39 | if ($msg eq "!who") { |
39 | if ($msg eq "!who") { |
40 | # clobbers irc, http is available |
40 | # clobbers irc, http is available |
41 | do_notice "see http://cf.schmorp.de/userlist.crossfire.schmorp.de.html"; |
41 | do_notice "see http://www.deliantra.net/userlist.crossfire.schmorp.de.html"; |
42 | # do_notice $_ |
42 | # do_notice $_ |
43 | # for ext::commands::who_listing (0, "."); |
43 | # for ext::commands::who_listing (0, "."); |
44 | |
44 | |
45 | } elsif ($msg =~ /^\!tell/) { |
45 | } elsif ($msg =~ /^\!tell/) { |
46 | my (undef, $target, $tmsg) = split / /, $msg, 3; |
46 | my (undef, $target, $tmsg) = split / /, $msg, 3; |
… | |
… | |
53 | } elsif ($other->ob->{ext_ignore_tell}{$me} >= time) { |
53 | } elsif ($other->ob->{ext_ignore_tell}{$me} >= time) { |
54 | $CON->send_chan ($BOTCHAN, NOTICE => "$me: $target ignores what you say. Give up on it.", $BOTCHAN); |
54 | $CON->send_chan ($BOTCHAN, NOTICE => "$me: $target ignores what you say. Give up on it.", $BOTCHAN); |
55 | } else { |
55 | } else { |
56 | cf::LOG cf::llevDebug, sprintf "TELL [%s/%s>%s] %s\n", $name, $me, $target, $tmsg; |
56 | cf::LOG cf::llevDebug, sprintf "TELL [%s/%s>%s] %s\n", $name, $me, $target, $tmsg; |
57 | |
57 | |
58 | $other->ns->send_msg (cf::chat::tell_channel ("$name/$me"), "$name/$me tells you: $tmsg", cf::NDI_DK_ORANGE | cf::NDI_DEF); |
58 | $other->ns->send_msg (ext::chat::tell_channel ("$name/$me"), "$name/$me tells you: $tmsg", cf::NDI_DK_ORANGE | cf::NDI_DEF); |
59 | } |
59 | } |
60 | } else { |
60 | } else { |
61 | do_notice "$me: What do you want to tell $target?"; |
61 | do_notice "$me: What do you want to tell $target?"; |
62 | } |
62 | } |
63 | |
63 | |
… | |
… | |
87 | utf8::decode $tmsg; |
87 | utf8::decode $tmsg; |
88 | |
88 | |
89 | if ($tmsg =~ /^\!/) { |
89 | if ($tmsg =~ /^\!/) { |
90 | handle_fcmd ($name, $nick, $tmsg); |
90 | handle_fcmd ($name, $nick, $tmsg); |
91 | } elsif ($tmsg =~ m/\S/) { |
91 | } elsif ($tmsg =~ m/\S/) { |
92 | $_->ns->send_msg ($ext::chat::CHAT_CHANNEL, |
92 | $_->ns->send_msg ($cf::CHAT_CHANNEL, |
93 | "$name/".$nick." chats: $tmsg", cf::NDI_BLUE | cf::NDI_DEF |
93 | "$name/".$nick." chats: $tmsg", cf::NDI_BLUE | cf::NDI_DEF |
94 | ) for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; |
94 | ) for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; |
|
|
95 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", "$name/$nick", $tmsg; |
95 | } |
96 | } |
96 | 1; |
97 | 1; |
97 | }, |
98 | }, |
98 | # registered => sub { |
99 | # registered => sub { |
99 | # 1; |
100 | # 1; |
… | |
… | |
105 | 0; |
106 | 0; |
106 | } |
107 | } |
107 | ); |
108 | ); |
108 | } |
109 | } |
109 | |
110 | |
110 | Event->timer ( |
111 | our $RECONNECT = cf::periodic 30, Coro::unblock_sub { |
111 | reentrant => 0, |
112 | check_connection; |
112 | after => 1, |
113 | }; |
113 | interval => 30, |
|
|
114 | data => cf::WF_AUTOCANCEL, |
|
|
115 | cb => Coro::unblock_sub { check_connection }, |
|
|
116 | ); |
|
|
117 | |
114 | |