1 # Example how to react on specific messages:
3 # !reverse <text> sends back the text reversed.
7 use vars qw($VERSION %IRSSI);
11 authors => 'Timo Sirainen',
13 description => 'Event example',
14 license => 'Public Domain'
18 # $server = server record where the message came
19 # $data = the raw data received from server, with PRIVMSGs it is:
20 # "target :text" where target is either your nick or #channel
21 # $nick = the nick who sent the message
22 # $host = host of the nick who sent the message
23 my ($server, $data, $nick, $host) = @_;
25 # split data to target/text
26 my ($target, $text) = $data =~ /^(\S*)\s:(.*)/;
28 # skip lines not beginning with !reverse
29 return if ($text !~ /!reverse (.*)/);
32 if (!$server->ischannel($target)) {
33 # private message, $target contains our nick, so we'll need
34 # to change it to $nick
38 $server->command("notice $target reversed $text = ".reverse($text));
41 Irssi::signal_add('event privmsg', 'event_privmsg');