From d246f862e89f088b914083e5e573e6194b9a0fd0 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sat, 22 Sep 2001 08:15:30 +0000 Subject: /COMMAND creation example fixed/updated. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1809 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- docs/perl.txt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'docs/perl.txt') diff --git a/docs/perl.txt b/docs/perl.txt index ad20dff9..782cb452 100644 --- a/docs/perl.txt +++ b/docs/perl.txt @@ -74,10 +74,16 @@ A list of signals that irssi sends can be found from signals.txt file. You can create your own commands, or replace existing ones with Irssi::command_bind(). The command handling work internally pretty much the same as signal handlers, so if you replace existing command and don't -wish to let it run, call Irssi::signal_stop(). Here's an example: +wish to let it run, call Irssi::signal_stop(). + +Here's an example: # Usage: /HELLO [] sub cmd_hello { + # data - contains the parameters for /HELLO + # server - the active server in window + # witem - the active window item (eg. channel, query) + # or undef if the window is empty my ($data, $server, $witem) = @_; if (!$server || !$server->{connected}) { @@ -87,9 +93,10 @@ wish to let it run, call Irssi::signal_stop(). Here's an example: if ($data) { $server->command("/MSG $data Hello!"); - } elsif ($witem) { + } elsif ($witem && ($witem->{type} eq "CHANNEL" || + $witem->{type} eq "QUERY")) { # there's query/channel active in window - $server->command("/MSG * Hello!"); + $witem->command("/MSG ".$witem->{name}." Hello!"); } else { Irssi::print("Nick not given, and no active channel/query in window"); } @@ -97,6 +104,7 @@ wish to let it run, call Irssi::signal_stop(). Here's an example: Irssi::command_bind('hello', 'cmd_hello'); + Message levels -------------- -- cgit v1.2.3