From 3f27cb2124fea90248493d32b3ecb0cc9d9b07aa Mon Sep 17 00:00:00 2001 From: Johannes Löthberg Date: Sat, 17 Mar 2018 13:20:15 +0100 Subject: weechat: Update plugins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Johannes Löthberg --- weechat/perl/stalker.pl | 78 ++++++++++++++++++++++++++++++++++------ weechat/plugins.conf | 2 +- weechat/python/colorize_nicks.py | 23 ++++++++++-- weechat/python/infolist.py | 13 +++++-- weechat/python/whois_on_query.py | 6 ++-- 5 files changed, 104 insertions(+), 18 deletions(-) (limited to 'weechat') diff --git a/weechat/perl/stalker.pl b/weechat/perl/stalker.pl index ce2bb65..36da161 100644 --- a/weechat/perl/stalker.pl +++ b/weechat/perl/stalker.pl @@ -1,5 +1,5 @@ # -# Copyright (c) 2013-2014 by Nils Görs +# Copyright (c) 2013-2018 by Nils Görs # Copyright (c) 2013-2014 by Stefan Wold # based on irssi script stalker.pl from Kaitlyn Parkhurst (SymKat) # https://github.com/symkat/Stalker @@ -20,6 +20,13 @@ # along with this program. If not, see . # # History: +# version 1.6.1:nils_2@freenode.#weechat +# 2018-01-11: fix: wrong variable name +# +# version 1.6:nils_2@freenode.#weechat +# 2018-01-09: add: use hook_process_hashtable() for /WHOIS +# : imp: use hook_process_hashtable() instead hook_process() for security reasons +# # version 1.5:nils_2@freenode.#weechat # 2015-06-15: add: new option del_date # @@ -101,7 +108,7 @@ use File::Spec; use DBI; my $SCRIPT_NAME = "stalker"; -my $SCRIPT_VERSION = "1.5"; +my $SCRIPT_VERSION = "1.6.1"; my $SCRIPT_AUTHOR = "Nils Görs "; my $SCRIPT_LICENCE = "GPL3"; my $SCRIPT_DESC = "Records and correlates nick!user\@host information"; @@ -148,7 +155,7 @@ my %desc_options = ('db_name' => 'file containing the SQLite database 'ignore_whois' => 'When enabled, /WHOIS won\'t be monitored. (default: off)', 'tags' => 'comma separated list of tags used for messages printed by stalker. See documentation for possible tags (e.g. \'no_log\', \'no_highlight\'). This option does not effect DEBUG messages.', 'additional_join_info' => 'add a line below the JOIN message that will display alternative nicks (tags: "irc_join", "irc_smart_filter" will be add to additional_join_info). You can use a localvar to drop additional join info for specific buffer(s) "stalker_drop_additional_join_info" (default: off)', - 'timeout' => 'timeout in seconds for hook_process(), used with option "additional_join_info". On slower machines, like raspberry pi, increase time. (default: 1)', + 'timeout' => 'timeout in seconds for hook_process_hashtable(), used with option "additional_join_info". On slower machines, like raspberry pi, increase time. (default: 1)', 'flood_timer' => 'Time in seconds for which flood protection is active. Once max_nicks is reached, joins will be ignored for the remaining duration of the timer. (default:10)', 'flood_max_nicks' => 'Maximum number of joins to allow in flood_timer length of time. Once maximum number of joins is reached, joins will be ignored until the timer ends (default:20)', ); @@ -181,7 +188,7 @@ my %indices = ( ], ); -# ---------------[ external routines for hook_process() ]--------------------- +# ---------------[ external routines for hook_process_hashtable() ]--------------------- if ($#ARGV == 8 ) # (0-8) nine arguments given? { my $db_filename = $ARGV[0]; @@ -515,7 +522,7 @@ sub add_record my ( $nick, $user, $host, $serv ) = @_; return unless ($nick and $user and $host and $serv); - # Check if we already have this record, before using a hook_process() + # Check if we already have this record, before using a hook_process_hashtable() my $sth = $DBH_child->prepare( "SELECT nick FROM records WHERE nick = ? AND user = ? AND host = ? AND serv = ?" ); $sth->execute( $nick, $user, $host, $serv ); my $result = $sth->fetchrow_hashref; @@ -533,7 +540,22 @@ sub add_record my $db_filename = weechat_dir(); DEBUG("info", "Start hook_process(), to add $nick $user\@$host on $serv to database"); - weechat::hook_process("perl $filename $db_filename 'db_add_record' '$nick' '$user' '$host' '$serv' 'dummy' 'dummy' 'dummy'", 1000 * $options{'timeout'},"db_add_record_cb",""); + + weechat::hook_process_hashtable("perl", + { + "arg1" => $filename, + "arg2" => $db_filename, + "arg3" => 'db_add_record', + "arg4" => $nick, + "arg5" => $user, + "arg6" => $host, + "arg7" => $serv, + "arg8" => 'dummy', + "arg9" => 'dummy', + "arg10" => 'dummy', + }, 1000 * $options{'timeout'},"db_add_record_cb",""); + + } # function called when data from child is available, or when child has ended, arguments and return value @@ -1102,7 +1124,6 @@ sub irc_in2_whois_cb my (undef, undef, undef, $nick, $user, $host, undef) = split(' ', $callback_data); my $msgbuffer_whois = weechat::config_string(weechat::config_get('irc.msgbuffer.whois')); - DEBUG('info', 'weechat_hook_signal(): WHOIS'); # check for nick_regex @@ -1144,11 +1165,32 @@ sub irc_in2_whois_cb } my $use_regex = 0; - my $nicks_found = join( ", ", (get_nick_records('yes', 'nick', $nick, $server, $use_regex))); -# my $nicks_found = join( ", ", (get_nick_records('no', 'nick', $nick, $server, $use_regex))); + my $filename = get_script_filename(); + return weechat::WEECHAT_RC_OK if ($filename eq ""); + my $db_filename = weechat_dir(); + my $name = weechat::buffer_get_string($ptr_buffer,'localvar_name'); + DEBUG("info", "Start hook_process(), get additional for WHOIS() info from $nick with $user\@$host on $name"); + + weechat::hook_process_hashtable("perl", + { + "arg1" => $filename, + "arg2" => $db_filename, + "arg3" => 'additional_join_info', + "arg4" => $nick, + "arg5" => $user, + "arg6" => $host, + "arg7" => $server, + "arg8" => $options{'max_recursion'}, + "arg9" => $options{'ignore_guest_nicks'}, + "arg10" => $options{'guest_nick_regex'}, + }, 1000 * $options{'timeout'},"hook_process_get_nicks_records_cb","$nick $ptr_buffer 'dummy'"); + +# my $nicks_found = join( ", ", (get_nick_records('yes', 'nick', $nick, $server, $use_regex))); + + return weechat::WEECHAT_RC_OK; # only the given nick is returned? - return weechat::WEECHAT_RC_OK if ($nicks_found eq $nick or $nicks_found eq ""); +# return weechat::WEECHAT_RC_OK if ($nicks_found eq $nick or $nicks_found eq ""); # more than one nick was returned from sqlite my $prefix_network = weechat::prefix('network'); @@ -1259,7 +1301,21 @@ sub irc_in2_join_cb my $db_filename = weechat_dir(); DEBUG("info", "Start hook_process(), get additional info from $nick with $user\@$host on $name"); - weechat::hook_process("perl $filename $db_filename 'additional_join_info' '$nick' '$user' '$host' '$server' $options{'max_recursion'} $options{'ignore_guest_nicks'} '$options{'guest_nick_regex'}'", 1000 * $options{'timeout'},"hook_process_get_nicks_records_cb","$nick $buffer $my_tags"); + + weechat::hook_process_hashtable("perl", + { + "arg1" => $filename, + "arg2" => $db_filename, + "arg3" => 'additional_join_info', + "arg4" => $nick, + "arg5" => $user, + "arg6" => $host, + "arg7" => $server, + "arg8" => $options{'max_recursion'}, + "arg9" => $options{'ignore_guest_nicks'}, + "arg10" => $options{'guest_nick_regex'}, + }, 1000 * $options{'timeout'},"hook_process_get_nicks_records_cb","$nick $buffer $my_tags"); + } return weechat::WEECHAT_RC_OK; } diff --git a/weechat/plugins.conf b/weechat/plugins.conf index b5263f6..edbe274 100644 --- a/weechat/plugins.conf +++ b/weechat/plugins.conf @@ -303,7 +303,7 @@ perl.stalker.normalize_nicks = "this option will truncate special chars from use perl.stalker.recursive_search = "When enabled, recursive search causes stalker to function better than a simple hostname to nickname map. Disabling the recursive search in effect turns stalker into a more standard hostname -> nickname map." perl.stalker.search_this_network_only = "When enabled searches are limited to within the network the window is currently set on. Turning this off is really only useful if multiple networks don't encode the hostmask. (default: on)" perl.stalker.tags = "comma separated list of tags used for messages printed by stalker. See documentation for possible tags (e.g. 'no_log', 'no_highlight'). This option does not effect DEBUG messages." -perl.stalker.timeout = "timeout in seconds for hook_process(), used with option "additional_join_info". On slower machines, like raspberry pi, increase time. (default: 1)" +perl.stalker.timeout = "timeout in seconds for hook_process_hashtable(), used with option "additional_join_info". On slower machines, like raspberry pi, increase time. (default: 1)" perl.stalker.use_localvar = "When enabled, only channels with a localvar 'stalker' will be monitored. This option will not affect /NICK and /WHOIS monitoring. It's only for /JOIN messages. (default: off)" perl.url_arza.min_length = "minimum length for incoming urls to shorten, after http:// (default: 100)" perl.url_arza.url = "url for shortener, url to shorten is appended, the shortener should return the short url (default: http://arza.us/s/?password=&url=)" diff --git a/weechat/python/colorize_nicks.py b/weechat/python/colorize_nicks.py index 1460f01..5d268b5 100644 --- a/weechat/python/colorize_nicks.py +++ b/weechat/python/colorize_nicks.py @@ -21,6 +21,8 @@ # # # History: +# 2017-06-20: lbeziaud +# version 24: colorize utf8 nicks # 2017-03-01, arza # version 23: don't colorize nicklist group names # 2016-05-01, Simmo Saan @@ -79,11 +81,13 @@ w = weechat SCRIPT_NAME = "colorize_nicks" SCRIPT_AUTHOR = "xt " -SCRIPT_VERSION = "23" +SCRIPT_VERSION = "24" SCRIPT_LICENSE = "GPL" SCRIPT_DESC = "Use the weechat nick colors in the chat area" -VALID_NICK = r'([@~&!%+])?([-a-zA-Z0-9\[\]\\`_^\{|\}]+)' +# Based on the recommendations in RFC 7613. A valid nick is composed +# of anything but " ,*?.!@". +VALID_NICK = r'([@~&!%+-])?([^\s,\*?\.!@]+)' valid_nick_re = re.compile(VALID_NICK) ignore_channels = [] ignore_nicks = [] @@ -189,6 +193,21 @@ def colorize_cb(data, modifier, modifier_data, line): if len(nick) < min_length or nick in ignore_nicks: continue + # If the matched word is not a known nick, we try to match the + # word without its first or last character (if not a letter). + # This is necessary as "foo:" is a valid nick, which could be + # adressed as "foo::". + if nick not in colored_nicks[buffer]: + if not nick[-1].isalpha() and not nick[0].isalpha(): + if nick[1:-1] in colored_nicks[buffer]: + nick = nick[1:-1] + elif not nick[0].isalpha(): + if nick[1:] in colored_nicks[buffer]: + nick = nick[1:] + elif not nick[-1].isalpha(): + if nick[:-1] in colored_nicks[buffer]: + nick = nick[:-1] + # Check that nick is in the dictionary colored_nicks if nick in colored_nicks[buffer]: nick_color = colored_nicks[buffer][nick] diff --git a/weechat/python/infolist.py b/weechat/python/infolist.py index 471f63c..5c57ecd 100644 --- a/weechat/python/infolist.py +++ b/weechat/python/infolist.py @@ -18,6 +18,8 @@ # Display infolist in a buffer. # # History: +# 2017-10-22, nils_2 : +# version 0.6: add string_eval_expression() # 2012-10-02, nils_2 : # version 0.5: switch to infolist buffer (if exists) when command /infolist # is called with arguments, add some examples to help page @@ -35,7 +37,7 @@ SCRIPT_NAME = "infolist" SCRIPT_AUTHOR = "Sebastien Helleu " -SCRIPT_VERSION = "0.5" +SCRIPT_VERSION = "0.6" SCRIPT_LICENSE = "GPL3" SCRIPT_DESC = "Display infolist in a buffer" @@ -165,6 +167,8 @@ def infolist_buffer_new(): def infolist_cmd(data, buffer, args): global infolist_buffer + args = string_eval_expression(args) + if infolist_buffer == "": infolist_buffer_new() if infolist_buffer != "" and args != "": @@ -173,6 +177,9 @@ def infolist_cmd(data, buffer, args): return weechat.WEECHAT_RC_OK +def string_eval_expression(string): + return weechat.string_eval_expression(string,{},{},{}) + if __name__ == "__main__" and import_ok: if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): @@ -190,6 +197,8 @@ if __name__ == "__main__" and import_ok: " Show information about nick \"FlashCode\" in channel \"#weechat\" on server \"freenode\":\n" " /infolist irc_nick freenode,#weechat,FlashCode\n" " Show nicklist from a specific buffer:\n" - " /infolist nicklist " + " /infolist nicklist \n" + " Show current buffer:\n" + " /infolist buffer ${buffer}" "", "%(infolists)", "infolist_cmd", "") diff --git a/weechat/python/whois_on_query.py b/weechat/python/whois_on_query.py index 4721437..be5572c 100644 --- a/weechat/python/whois_on_query.py +++ b/weechat/python/whois_on_query.py @@ -24,6 +24,8 @@ # # History: # +# 2017-05-28, Jos Ahrens : +# version 0.6.1: Corrected a typo in help description for option self_query # 2012-01-03, Sebastien Helleu : # version 0.6: make script compatible with Python 3.x # 2011-10-17, Sebastien Helleu : @@ -52,13 +54,13 @@ except ImportError: SCRIPT_NAME = 'whois_on_query' SCRIPT_AUTHOR = 'Sebastien Helleu ' -SCRIPT_VERSION = '0.6' +SCRIPT_VERSION = '0.6.1' SCRIPT_LICENSE = 'GPL3' SCRIPT_DESC = 'Whois on query' # script options woq_settings_default = { - 'command' : ('/whois $nick $nick', 'the command sent to do the whois ($nick is repladed by nick)'), + 'command' : ('/whois $nick $nick', 'the command sent to do the whois ($nick is replaced by nick)'), 'self_query': ('off', 'if on, send whois for self queries'), } -- cgit v1.2.3-54-g00ecf