diff --git a/README.md b/README.md index ecbee6f..cc10743 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,8 @@ the ``/prowl`` command, use the following settings: /format prowl_event_cmd Remember /save -For the first two, ``$0`` will be replaced with the respective nick or channel. +For the first two, ``$0`` will be replaced with the respective channel +and ``$1`` will be replaced with the nick. The format of the URLs passed to Prowl for private messages and hilights can be controlled with the following settings: diff --git a/prowl.pl b/prowl.pl index 4c544c3..36d2ada 100644 --- a/prowl.pl +++ b/prowl.pl @@ -69,9 +69,9 @@ # Theme Irssi::theme_register([ 'prowl_event_cmd', 'Manual Message', - # $0 = channel/nick - 'prowl_event_msgs', 'Private Message from $0', - 'prowl_event_hilight', 'Hilighted in $0', + # $0 = channel, $1 = nick + 'prowl_event_msgs', 'Private Message from $1', + 'prowl_event_hilight', 'Hilighted in $0 by $1', # $0 = irc/ircs, $1 = server address, $2 = chatnet, $3 = server port, $4 = channel/nick 'prowl_url_msgs', '$0://$1:$3/', 'prowl_url_hilight', '$0://$1:$3/$4', @@ -161,12 +161,21 @@ sub print_text_handler { my $level = $dest->{level}; if (($level & MSGLEVEL_MSGS) || ($level & MSGLEVEL_HILIGHT && !($level & MSGLEVEL_NOHILIGHT))) { - my $type = ($level & MSGLEVEL_MSGS) ? 'msgs' : 'hilight'; - my $url = _create_url($server, $target, "prowl_url_$type"); - my $format = Irssi::current_theme()->get_format('Irssi::Script::prowl', "prowl_event_$type"); - my $event = Irssi::parse_special($format, $target); - - _prowl($event, $stripped, $config{"priority_$type"}, $url); + my $nick = $stripped; + if ($level & MSGLEVEL_ACTIONS) { + $nick =~ s/^\s+.\s+(\S+)\s.*/$1/; + } else { + $nick =~ s/^\<[@\+% ]?([^\>]+)\>.*/$1/; + } + + unless ($server->{nick} eq $nick) { + my $type = ($level & MSGLEVEL_MSGS) ? 'msgs' : 'hilight'; + my $url = _create_url($server, $target, "prowl_url_$type"); + my $format = Irssi::current_theme()->get_format('Irssi::Script::prowl', "prowl_event_$type"); + my $event = Irssi::parse_special($format, "$target $nick"); + + _prowl($event, $stripped, $config{"priority_$type"}, $url); + } } } }