# # Copyright (c) 2008 by FlashCode # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # Format messages and notices when the identify-msg and/or identify-ctcp # capability is available on IRC server. # # History: # 2009-05-02, FlashCode : # version 0.2: sync with last API changes # 2008-11-16, FlashCode : # script creation use strict; my $version = "0.2"; sub capab_irc_290 { my ($server, $null) = split(",", $_[1]); if ($_[2] =~ /IDENTIFY-MSG/) { weechat::config_set_plugin("msg_".$server, "1"); } if ($_[2] =~ /IDENTIFY-CTCP/) { weechat::config_set_plugin("ctcp_".$server, "1"); } return weechat::WEECHAT_RC_OK; } sub capab_server_connecting { my $server = $_[2]; weechat::config_set_plugin("msg_".$server, ""); weechat::config_set_plugin("ctcp_".$server, ""); } sub capab_identify_print_modifier { my ($plugin, $name, $tags) = split(";", $_[2]); my $buffer = weechat::buffer_search($plugin, $name); my $server = weechat::buffer_get_string($buffer, "localvar_server"); #weechat::log_print("plugin=".$plugin.", name=".$name.", buffer=".$buffer.", server=".$server.", tags=".$tags.", modifier=".$_[1].", data=".$_[2].", string=".$_[3]); if ($server ne "") { if ($tags =~ /irc_privmsg/) { my ($prefix, $msg) = split("\t", $_[3]); if (weechat::config_get_plugin("msg_".$server) eq "1") { if ($msg =~ /^([-\+])(.*)/) { $prefix = $1.$prefix; $msg = $2; } return $prefix."\t".$msg; } } } return $_[3]; } weechat::register("capab_identify", "FlashCode ", $version, "GPL3", "Format messages and notices when the identify-msg and/or " ."identify-ctcp capability is available on IRC server", "", ""); weechat::hook_signal("*,irc_in2_290", "capab_irc_290", ""); weechat::hook_signal("irc_server_connecting", "capab_server_connecting", ""); weechat::hook_modifier("weechat_print", "capab_identify_print_modifier", "");