1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
# -----------------------------------------------------------------------------
# $Id: RemoteControl.pm 11365 2008-05-10 14:58:28Z topia $
# -----------------------------------------------------------------------------
package System::RemoteControl;
use strict;
use warnings;
use base qw(Module);
use Mask;
sub message_arrived {
my ($this,$msg,$sender) = @_;
if ($sender->isa('IrcIO::Server') &&
$msg->command eq 'PRIVMSG' &&
Mask::match_deep([defined($this->config->mask) ? $this->config->mask('all') : '*!*@*'],
$msg->prefix)) {
my ($nick,$cmd) = $msg->param(1) =~ m/^\+\s+(.+?)\s+(.+)$/;
# 指定されたnickに自分はマッチするか?
if (Mask::match($nick,$sender->current_nick) &&
defined $cmd) {
# 実行。
$sender->send_message(
$this->construct_irc_message(
Line => $cmd,
Encoding => 'utf8'));
}
}
$msg;
}
1;
=pod
info: 特定の発言が送られてきたとき、それに反応してIRCコマンドを実行します。
default: off
# 実行を許可する人間を表すマスク。
-mask: *!*example@example.net
# 構文: + <nick> <IRC Message>
# <nick>は反応するbotのnickを表すマスク。
# <Tiarra::IRC::Message>はサーバーに向けて発行するIRCメッセージ。
#
# 例:
# + hoge NICK [hoge]
# hogeというBOTが[hoge]にnickを変更する。
=cut
|