2011-10-23 8 views
2

Irssi Perlスクリプトでこの単一のタスクを確立する必要があります。自分のチャンネルがあり、特定のシナリオでそのチャンネルに直接msgを送信したい。Perl Irssiスクリプト:msgを特定のチャンネルに送信するには?

私のPerlでの経験は非常に限られているので、私はこれを持っていません。私はIrssi Perlスクリプトで異なるチャットネットとチャンネルを管理する方法を混乱させています。だから私は例のチャネル#[email protected]のためのメッセージをどのように送ることができますか?

試験いずれか

server->command("^MSG $info{'#testchan'} $info{'Test message.'}"); 

テスト2つ(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

@ user1009108:あなたのクエストを編集するあなたのコードを追加して、何が動作していないかを正確に記述してください。書式設定にコードブロックを使用する(すべてのコードを選択し、エディタの '{}'ボタンを押す) – Mat

答えて

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'); 

ホープこの

を助けることができるために使用されています
関連する問題