# Copyright (c) 2009 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 . # # # Send "whois" on nick when receiving new IRC query. # (this script requires WeeChat 0.2.7 or newer) # # History: # # 2009-05-02, FlashCode : # version 0.2: sync with last API changes # 2009-02-08, FlashCode : # version 0.1: initial release # use strict; my $SCRIPT_NAME = "whois_on_query"; my $SCRIPT_AUTHOR = "FlashCode "; my $SCRIPT_VERSION = "0.2"; my $SCRIPT_LICENSE = "GPL3"; my $SCRIPT_DESC = "Whois on query"; # script options my %settings = ("command" => "/whois \$nick \$nick"); weechat::register($SCRIPT_NAME, $SCRIPT_AUTHOR, $SCRIPT_VERSION, $SCRIPT_LICENSE, $SCRIPT_DESC, "", ""); weechat::hook_signal("irc_pv_opened", "signal_irc_pv_opened", ""); foreach my $option (keys %settings) { if (weechat::config_get_plugin($option) eq "") { weechat::config_set_plugin($option, $settings{$option}); } } sub signal_irc_pv_opened { my ($data, $signal, $signal_data) = ($_[0], $_[1], $_[2]); if (weechat::buffer_get_string($buffer, "plugin") eq "irc") { my $channel = weechat::buffer_get_string($buffer, "localvar_channel"); if (weechat::info_get("irc_is_channel", $channel) ne "1") { my $command = weechat::config_get_plugin("command"); $command =~ s/\$nick/${channel}/g; weechat::command($buffer, $command); } } return weechat::WEECHAT_RC_OK }