我需要用Irssi Perl脚本建立这个单一任务。我有自己的频道,我希望在某些情况下直接将msg发送到该频道。
我对Perl的体验非常有限,所以我还没有这个。我很困惑如何在Irssi Perl脚本中管理不同的聊天网和频道。那么我如何发送例如频道#testchan@Quakenet
的消息呢?
测试一:
server->command("^MSG $info{'#testchan'} $info{'Test message.'}");
测试二(tuto about scripting):
sub away_describe_pub_channels {
my($net, $channel) = @_;
my ($text) = @_;
my $c = Irssi::server_find_chatnet("QuakeNet")->channel_find("testchan");
$c->command("DESCRIBE $channel $text")
}
答案 0 :(得分:1)
这是一个用于机器人的例子:)
#==========================BEGINNING OF PARMS======================================
#name of the channels where this feature will be used
my @channels = ("foo","bar");
#the public commands
#help
my $cmd_help = '!help';
#new ticket
my $cmd_newticket = "!stack";
my %url_newticket = ( 'foo'=>{url=>"http://stackoverflow.com/questions/ask"},
'bar'=>{url=>"http://https://github.com/repo/project/issues/new"}
sub bootstrap {
my ($server, $msg, $nick, $address, $target) = @_;
#lowercase of the channel name in case this one will be registered in camelCase ;)
$target = lc $target;
foreach my $channel (@channels) {
if ( $target eq "#".$channel) {
#split the line first peace the command second the rest
my ($cmd,$line) = split / /,$msg,2;
if ($cmd =~ $cmd_help) {
$server->command("MSG ". $nick ." Here are the available commands : !stack");
} elsif ($cmd eq $cmd_newticket) {
my $h = $url_newticket{$channel};
$server->command("MSG $target submit an issue/a ticket $h->{'url'}");
}
}
}
}
#let's add the sub as a signal and let's play
Irssi::signal_add_last('message public', 'bootstrap');
希望这可以提供帮助