diff -Nru weechat-scripts-20130123/debian/changelog weechat-scripts-20131007/debian/changelog --- weechat-scripts-20130123/debian/changelog 2013-04-21 19:38:44.000000000 +0000 +++ weechat-scripts-20131007/debian/changelog 2013-12-08 19:43:53.000000000 +0000 @@ -1,8 +1,23 @@ -weechat-scripts (20130123-1~ubuntu12.10.1~ppa1) quantal; urgency=low +weechat-scripts (20131007-1~ubuntu12.10.1~ppa1) quantal; urgency=low * No-change backport to quantal - -- Chris Johnston Sun, 21 Apr 2013 15:38:44 -0400 + -- Chris Johnston Sun, 08 Dec 2013 14:43:53 -0500 + +weechat-scripts (20131007-1) unstable; urgency=low + + * New upstream Git repository snapshot + * Update debian/copyright with new, updated and removed scripts + * Bump Standards-Version to 3.9.4 + + -- Emmanuel Bouthenot Mon, 07 Oct 2013 12:15:11 +0000 + +weechat-scripts (20130521-1) unstable; urgency=low + + * New upstream Git repository snapshot + * Update debian/copyright with new, updated and removed scripts + + -- Emmanuel Bouthenot Tue, 21 May 2013 20:53:15 +0000 weechat-scripts (20130123-1) unstable; urgency=low diff -Nru weechat-scripts-20130123/debian/control weechat-scripts-20131007/debian/control --- weechat-scripts-20130123/debian/control 2012-10-03 19:33:59.000000000 +0000 +++ weechat-scripts-20131007/debian/control 2013-10-07 12:16:11.000000000 +0000 @@ -3,7 +3,7 @@ Priority: extra Maintainer: Emmanuel Bouthenot Build-Depends: debhelper (>= 7) -Standards-Version: 3.9.3 +Standards-Version: 3.9.4 Homepage: http://weechat.flashtux.org/plugins.php Vcs-Git: git://anonscm.debian.org/users/kolter/weechat-scripts.git Vcs-Browser: http://anonscm.debian.org/gitweb/?p=users/kolter/weechat-scripts.git diff -Nru weechat-scripts-20130123/debian/copyright weechat-scripts-20131007/debian/copyright --- weechat-scripts-20130123/debian/copyright 2013-01-23 19:00:28.000000000 +0000 +++ weechat-scripts-20131007/debian/copyright 2013-10-07 12:15:00.000000000 +0000 @@ -5,7 +5,7 @@ Files: debian/* Copyright: 2006-2007, Julien Louis - 2007-2011, Emmanuel Bouthenot + 2007-2013, Emmanuel Bouthenot License: GPL-3 Files: lua/text_effects.lua @@ -16,6 +16,14 @@ Copyright: 2012, rumia License: WTFPL +Files: lua/http_item.lua +Copyright: 2013, xt +License: GPL-3 + +Files: lua/oldswarner.lua +Copyright: 2013, xt +License: GPL-3 + Files: perl/weetris.pl Copyright: 2008-2011, FlashCode License: GPL-3 @@ -29,11 +37,11 @@ License: GPL-3 Files: perl/buffers.pl -Copyright: 2008-2012, FlashCode +Copyright: 2008-2013, FlashCode License: GPL-3 Files: perl/iset.pl -Copyright: 2008-2012, FlashCode +Copyright: 2008-2013, FlashCode License: GPL-3 Files: perl/launcher.pl @@ -125,7 +133,7 @@ License: GPL-3 Files: perl/buddylist.pl -Copyright: 2009-2012, nils_2 +Copyright: 2009-2013, nils_2 License: GPL-3 Files: perl/strmon.pl @@ -133,7 +141,7 @@ License: GPL-3 Files: perl/query_blocker.pl -Copyright: 2010-2012, rettub +Copyright: 2010-2013, rettub License: GPL-3 Files: perl/newsbar.pl @@ -169,7 +177,7 @@ License: GPL-3 Files: perl/colorize_lines.pl -Copyright: 2010-2012, nils_2 +Copyright: 2010-2013, nils_2 License: GPL-3 Files: perl/curiousignore.pl @@ -185,7 +193,7 @@ License: GPL-3 Files: perl/pop3_mail.pl -Copyright: 2010, nils_2 +Copyright: 2010-2013, nils_2 License: GPL-3 Files: perl/bashorg.pl @@ -201,7 +209,7 @@ License: GPL-3 Files: perl/sort_buffers.pl -Copyright: 2011, nils_2 +Copyright: 2011-2013, nils_2 License: GPL-3 Files: perl/seeks.pl @@ -213,7 +221,7 @@ License: GPL-3 Files: perl/sysinfo.pl -Copyright: 2011-2012, nils_2 +Copyright: 2011-2013, nils_2 License: BSD Files: perl/echo.pl @@ -233,7 +241,7 @@ License: GPL-3 Files: perl/unset_unused.pl -Copyright: 2011, nils_2 +Copyright: 2011-2013, nils_2 License: GPL-3 Files: perl/ncmpcpp.pl @@ -253,7 +261,7 @@ License: GPL-3 Files: perl/isgd.pl -Copyright: 2011-2012, stfn +Copyright: 2011-2013, stfn License: GPL-3 Files: perl/snake.pl @@ -273,7 +281,7 @@ License: GPL-3 Files: perl/chatters.pl -Copyright: 2012, Asido +Copyright: 2012-2013, Asido License: GPL-3 Files: perl/maildir.pl @@ -281,19 +289,19 @@ License: MIT Files: perl/coords.pl -Copyright: 2012, Nei +Copyright: 2012-2013, Nei License: GPL-3 Files: perl/join2fast.pl -Copyright: 2012, Ratler +Copyright: 2012-2013, Ratler License: GPL-3 Files: perl/parse_relayed_msg.pl -Copyright: 2012, w8rabbit +Copyright: 2012-2013, w8rabbit License: GPL-3 Files: perl/rssagg.pl -Copyright: 2012, R1cochet +Copyright: 2012-2013, R1cochet License: GPL-3 Files: perl/xterm_paste.pl @@ -316,6 +324,34 @@ Copyright: 2013, R1cochet License: GPL-3 +Files: perl/luanma.pl +Copyright: 2013, Nei +License: GPL-3 + +Files: perl/notify_send.pl +Copyright: 2013, shmibs +License: GPL-3 + +Files: perl/pushover.pl +Copyright: 2013, stfn +License: GPL-3 + +Files: perl/stalker.pl +Copyright: 2013, nils_2 +License: GPL-3 + +Files: perl/spacer.pl +Copyright: 2013, Biohazard +License: GPL-3 + +Files: perl/mass_hl_blocker.pl +Copyright: 2013, arza +License: GPL-3 + +Files: perl/url_arza.pl +Copyright: 2013, arza +License: GPL-3 + Files: python/crypt.py Copyright: 2008-2012, Nicolai Lissner License: GPL-3 @@ -333,7 +369,7 @@ License: public-domain Files: python/shell.py -Copyright: 2006-2012, kolter +Copyright: 2006-2013, kolter License: GPL-2 Files: python/tinyurl.py @@ -349,7 +385,7 @@ License: GPL-3 Files: python/weeget.py -Copyright: 2009-2012, FlashCode +Copyright: 2009-2013, FlashCode License: GPL-3 Files: python/quodnp.py @@ -369,7 +405,7 @@ License: GPL-3 Files: python/chanact.py -Copyright: 2009-2012, xt +Copyright: 2009-2013, xt License: GPL-3 Files: python/urlbar.py @@ -413,7 +449,7 @@ License: GPL-3 Files: python/country.py -Copyright: 2009-2011, m4v +Copyright: 2009-2013, m4v License: GPL-3 Files: python/moc_control.py @@ -501,7 +537,7 @@ License: GPL-3 Files: python/alternatetz.py -Copyright: 2010, Chmouel +Copyright: 2010-2013, Chmouel License: GPL-3 Files: python/dcc_antispam.py @@ -513,7 +549,7 @@ License: GPL-3 Files: python/facebook_rename.py -Copyright: 2010-2011, crwl +Copyright: 2010-2013, crwl License: public-domain Files: python/inotify.py @@ -521,15 +557,15 @@ License: GPL-3 Files: python/typing_counter.py -Copyright: 2010-2012, fauno +Copyright: 2010-2013, fauno License: GPL-3 Files: python/colorize_nicks.py -Copyright: 2010-2012, xt +Copyright: 2010-2013, xt License: GPL-3 Files: python/away_action.py -Copyright: 2010, xt +Copyright: 2010-2013, xt License: GPL-3 Files: python/gweather.py @@ -545,11 +581,11 @@ License: GPL-3 Files: python/bitlbee_typing_notice.py -Copyright: 2010, Alexander Schremmer +Copyright: 2010-2013, Alexander Schremmer License: GPL-3 Files: python/prism.py -Copyright: 2010, Alex Barrett +Copyright: 2010-2013, Alex Barrett License: WTFPL Files: python/chanstat.py @@ -573,11 +609,11 @@ License: BSD Files: python/zerotab.py -Copyright: 2010-2011, i686 +Copyright: 2010-2013, i686 License: GPL-3 Files: python/jabber.py -Copyright: 2010-2012, FlashCode +Copyright: 2010-2013, FlashCode License: GPL-3 Files: python/lnotify.py @@ -585,7 +621,7 @@ License: GPL-3 Files: python/windicate.py -Copyright: 2010, Leon Bogaert +Copyright: 2010-2013, Leon Bogaert License: GPL-2 Files: python/sensors.py @@ -601,7 +637,7 @@ License: GPL-3 Files: python/confversion.py -Copyright: 2010, drubin +Copyright: 2010-2013, drubin License: GPL-3 Files: python/pybuffer.py @@ -649,7 +685,7 @@ License: GPL-3 Files: python/purgelogs.py -Copyright: 2011, nils_2 +Copyright: 2011-2013, nils_2 License: GPL-3 Files: python/correction_completion.py @@ -705,11 +741,11 @@ License: WTFPL Files: python/listbuffer.py -Copyright: 2011-2012, FiXato +Copyright: 2011-2013, FiXato License: MIT Files: python/allquery.py -Copyright: 2011, F. Besser +Copyright: 2011-2013, F. Besser License: GPL-3 Files: python/nma.py @@ -717,7 +753,7 @@ License: GPL-2 Files: python/clone_scanner.py -Copyright: 2011-2012, FiXato +Copyright: 2011-2013, FiXato License: MIT Files: python/buffer_swap.py @@ -749,7 +785,7 @@ License: GPL-3 Files: python/urlserver.py -Copyright: 2011-2012, FlashCode +Copyright: 2011-2013, FlashCode License: GPL-3 Files: python/memon.py @@ -757,11 +793,11 @@ License: GPL-3 Files: python/im_kayac_com_notify.py -Copyright: 2012, Gosuke Miyashita +Copyright: 2012-2013, Gosuke Miyashita License: MIT Files: python/bufsize.py -Copyright: 2012, nils_2 +Copyright: 2012-2013, nils_2 License: GPL-3 Files: python/logsize.py @@ -781,15 +817,15 @@ License: GPL-3 Files: python/server_autoswitch.py -Copyright: 2012, nils_2 +Copyright: 2012-2013, nils_2 License: GPL-3 Files: python/quick_force_color.py -Copyright: 2012, nils_2 +Copyright: 2012-2013, nils_2 License: GPL-3 Files: python/keepnick.py -Copyright: 2012, nils_2 +Copyright: 2012-2013, nils_2 License: GPL-3 Files: python/unwanted_msg.py @@ -805,7 +841,7 @@ License: GPL-3 Files: python/fish.py -Copyright: 2012, David Flatz +Copyright: 2012-2013, David Flatz License: GPL-3 Files: python/weestats.py @@ -821,11 +857,11 @@ License: GPL-3 Files: python/pyrnotify.py -Copyright: 2012, Krister Svanlund +Copyright: 2012-2013, Krister Svanlund License: GPL-3 -Files: python/twitter.py -Copyright: 2012, Jimmy Zelinskie +Files: python/wtwitter.py +Copyright: 2012-2013, Jimmy Zelinskie License: GPL-3 Files: python/apply_corrections.py @@ -844,6 +880,10 @@ Copyright: 2012, magnific0 License: MIT +Files: python/prowl_notify.py +Copyright: 2013, kidchunks +License: GPL-3 + Files: python/noirccolors.py Copyright: 2012, Fredrick Brennan License: public-domain @@ -872,8 +912,32 @@ Copyright: 2013, nils_2 License: GPL-3 +Files: python/stick_buffer.py +Copyright: 2013, nils_2 +License: GPL-3 + +Files: python/opall.py +Copyright: 2013, blarz +License: ISC + +Files: python/cmus.py +Copyright: 2013, Isaac Ross +License: GPL-2 + +Files: python/weetweet.py +Copyright: 2013, DarkDefender +License: GPL-3 + +Files: python/queryman.py +Copyright: 2013, nils_2 +License: GPL-3 + +Files: python/vimode.py +Copyright: 2013, GermainZ +License: GPL-3 + Files: ruby/url_shorten.rb -Copyright: 2008-2011, Daniel Bretoi +Copyright: 2008-2013, Daniel Bretoi License: BSD Files: ruby/mpdspam.rb @@ -920,6 +984,10 @@ Copyright: 2012, Dominik Honnef License: MIT +Files: ruby/challengeauth.rb +Copyright: 2013, Dominik Honnef +License: MIT + Files: tcl/chan_hl.tcl Copyright: 2009, Karvur License: GPL-3 @@ -929,7 +997,7 @@ License: GPL-3 Files: tcl/xosdnotify.tcl -Copyright: 2010, Karvur +Copyright: 2010-2013, Karvur License: GPL-3 License: Apache-2 diff -Nru weechat-scripts-20130123/debian/tools/copyright.in weechat-scripts-20131007/debian/tools/copyright.in --- weechat-scripts-20130123/debian/tools/copyright.in 2011-05-28 19:36:58.000000000 +0000 +++ weechat-scripts-20131007/debian/tools/copyright.in 2013-05-21 20:56:03.000000000 +0000 @@ -5,5 +5,5 @@ Files: debian/* Copyright: 2006-2007, Julien Louis - 2007-2011, Emmanuel Bouthenot + 2007-2013, Emmanuel Bouthenot License: GPL-3 diff -Nru weechat-scripts-20130123/lua/http_item.lua weechat-scripts-20131007/lua/http_item.lua --- weechat-scripts-20130123/lua/http_item.lua 1970-01-01 00:00:00.000000000 +0000 +++ weechat-scripts-20131007/lua/http_item.lua 2013-10-07 12:14:50.000000000 +0000 @@ -0,0 +1,120 @@ +-- HTTP bar item, using lua patterns to get content +-- +-- Copyright 2013 Tor Hveem +-- +-- 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 . +-- + +-- +-- Usage: put [http_item] in your status bar items. (Or any other bar to your liking) +-- "/set weechat.bar.status.items". +-- + +local w = weechat + + +SCRIPT_NAME = "http_item" +SCRIPT_AUTHOR = "xt " +SCRIPT_VERSION = "1" +SCRIPT_LICENSE = "GPL3" +SCRIPT_DESC = "Bar item with HTTP source, using lua patterns to match content" +BAR_ITEM_NAME = SCRIPT_NAME + +-- Settings +settings = { + url = 'http://weechat.org/info/stable/', + pattern = '(%d+%.%d+%.%d+)', + message_prefix = 'Latest WeeChat: ', + message_postfix = '', + message_color = 'default', + interval = '5', -- poll every 5 minutes +} +-- other globals +ITEM_TEXT = nil + +function http_bi_cb(data, item, window) + -- Return the bar item string + if ITEM_TEXT then + return string.format('%s%s%s%s', + w.config_get_plugin('message_prefix'), + w.color(w.config_get_plugin('message_color')), + ITEM_TEXT, + w.config_get_plugin('message_postfix') + ) + end + return '' +end + +function http_bi_update() + -- Function to manually update the bar item + w.bar_item_update(BAR_ITEM_NAME) + return w.WEECHAT_RC_OK +end + +function debug(buf, str) + -- helper function for debugging + local debug = false + if debug and str then + w.print(buf, SCRIPT_NAME .. ': ' .. str) + end + return w.WEECHAT_RC_OK +end + +function init_config() + -- Set defaults + for option, default_value in pairs(settings) do + if w.config_is_set_plugin(option) == 0 then + w.config_set_plugin(option, default_value) + end + end + -- read options from weechat into our lua table + for option, default_value in pairs(settings) do + settings[option] = w.config_get_plugin(option) + end + return w.WEECHAT_RC_OK +end + +function start_fetch() + -- Get URL using weechat API for URL + local url = w.config_get_plugin('url') + -- 30 seconds timeout + local timeout = 30*1000 + debug('', url) + w.hook_process('url:'..url, timeout, 'http_fetch_cb', '') + return w.WEECHAT_RC_OK +end + +function http_fetch_cb(data, command, return_code, out, err) + if #out > 0 then + out = out:match(w.config_get_plugin('pattern')) + ITEM_TEXT = out + debug('', ITEM_TEXT) + -- Update bar item since we got new data + w.bar_item_update(BAR_ITEM_NAME) + end + return w.WEECHAT_RC_OK +end + +if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', '') then + init_config() + + -- create the bar item + w.bar_item_new(BAR_ITEM_NAME, 'http_bi_cb', '') + + -- Initial fetch + start_fetch() + + -- hook the fetch timer + w.hook_timer( w.config_get_plugin('interval')*60*1000, 0, 0, 'start_fetch', '') +end diff -Nru weechat-scripts-20130123/lua/oldswarner.lua weechat-scripts-20131007/lua/oldswarner.lua --- weechat-scripts-20130123/lua/oldswarner.lua 1970-01-01 00:00:00.000000000 +0000 +++ weechat-scripts-20131007/lua/oldswarner.lua 2013-10-07 12:14:51.000000000 +0000 @@ -0,0 +1,150 @@ +-- Copyright 2013 xt +-- +-- 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 . +-- + + +--[[ + +This script will try to prevent you from posting URLs to a buffer that was recently posted, as recently as your weechat will remember lines. + +Usage: + To get notice when trying to send old URL you will have to add a new item to + your input bar. To override the default setting please run this command: + + /set weechat.bar.input.items "[input_prompt]+(away),[input_search],[input_paste],[input_olds],input_text" + + If you already have customized this setting, you will have to edit your own setting and add input_olds where you want it to be displayed. + + + + Changelog: + version 2, 2013-09-21, xt + * Use hdata instead of infolines to improve performance + version 1, 2013-09-15, xt + * initial version +--]] + +SCRIPT_NAME = "oldswarner" +SCRIPT_AUTHOR = "xt " +SCRIPT_VERSION = "2" +SCRIPT_LICENSE = "GPL3" +SCRIPT_DESC = "Warn user if about to paste URL already existing in buffer" + +ITEM_NAME = 'input_olds' +ITEM_TEXT = '' + +local w = weechat + +local patterns = { + -- X://Y url + "^(https?://%S+)", + "^", + "^", + "^<(https?://%S+)>", + "^(https?://%S+)>", + "%f[%S](https?://%S+)", + -- www.X.Y url + "^(www%.[%w_-%%]+%.%S+)", + "%f[%S](www%.[%w_-%%]+%.%S+)", +} + +-- return a table containing all urls in a message +function findURLs(message) + local urls = {} + + local index = 1 + for split in message:gmatch('%S+') do + for i=1, #patterns do + local _, count = split:gsub(patterns[i], function(url) + table.insert(urls, url) + end) + if(count > 0) then + index = index + 1 + break + end + end + end + return urls +end + +function is_url_in_buffer(buffer, url) + lines = weechat.hdata_pointer(weechat.hdata_get('buffer'), buffer, 'own_lines') + line = weechat.hdata_pointer(weechat.hdata_get('lines'), lines, 'first_line') + hdata_line = weechat.hdata_get('line') + hdata_line_data = weechat.hdata_get('line_data') + while #line > 0 do + data = weechat.hdata_pointer(hdata_line, line, 'data') + message = weechat.hdata_string(hdata_line_data, data, 'message') + if string.find(message, url) then + return true + end + line = weechat.hdata_move(hdata_line, line, 1) + end + return false +end + +function oldschecker(data, buffer, command) + saved_input = weechat.buffer_get_string(buffer, "input") + + for _,url in pairs(findURLs(saved_input)) do + if is_url_in_buffer(buffer, url) and not is_being_warned() then + set_item_text() + return weechat.WEECHAT_RC_OK_EAT + end + end + clear_item_text() + return w.WEECHAT_RC_OK +end + +function set_item_text() + message = 'URL already in buffer. Press enter again if you are sure' + color = w.color(w.config_color(w.config_get('weechat.color.input_actions'))) + ITEM_TEXT = string.format('%s%s%s', color, message, w.color('reset')) + w.bar_item_update(ITEM_NAME) +end + +function clear_item_text() + ITEM_TEXT = '' + w.bar_item_update(ITEM_NAME) +end + +function input_olds_cb(data, item, window) + return ITEM_TEXT +end + +function is_being_warned() + if ITEM_TEXT == '' then + return false + end + return true +end + +function p_init() + if w.register( + SCRIPT_NAME, + SCRIPT_AUTHOR, + SCRIPT_VERSION, + SCRIPT_LICENSE, + SCRIPT_DESC, + '', + '') then + w.hook_command_run('/input return', 'oldschecker', '') + + -- create the bar item + w.bar_item_new(ITEM_NAME, 'input_olds_cb', '') + end +end + +p_init() diff -Nru weechat-scripts-20130123/perl/buddylist.pl weechat-scripts-20131007/perl/buddylist.pl --- weechat-scripts-20130123/perl/buddylist.pl 2013-01-23 19:00:23.000000000 +0000 +++ weechat-scripts-20131007/perl/buddylist.pl 2013-10-07 12:14:54.000000000 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2010-2012 by Nils Görs +# Copyright (c) 2010-2013 by Nils Görs # # display the status and visited buffers of your buddies in a buddylist bar # @@ -16,6 +16,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +# 1.8 : fixed: problem with temporary server +# : added: %h variable for filename +# 1.7 : fixed: perl error when adding and removing nick +# : fixed: perl error: Use of uninitialized value $bitlbee_service_separator (reported by gtmanfred) +# : improved: a warning will be displayed if no filename for the buddylist is given. # 1.6 : added: support for new option "irc.network.whois_double_nick" # 1.5 : fixed: wrong pointer in bar_item_remove() # : fixed: perl error: Use of uninitialized value $nickname @@ -76,11 +81,11 @@ use strict; my $prgname = "buddylist"; -my $version = "1.6"; +my $version = "1.8"; my $description = "display status from your buddies a bar-item."; # -------------------------------[ config ]------------------------------------- -my $default_buddylist = "buddylist.txt"; +my $default_buddylist = "%h/buddylist.txt"; my %buddylist_level = (0 => "online", 1 => "away", 2 => "offline"); my %default_color_buddylist = ("online" => "yellow", "away" => "cyan", @@ -164,8 +169,8 @@ weechat::bar_item_new($prgname, "build_buddylist", ""); weechat::bar_new($prgname, "1", "0", "root", "", "left", "horizontal", - "vertical", "0", "0", "default", "default", "default", "1", - $prgname); + "vertical", "0", "0", "default", "default", "default", "1", + $prgname); weechat::hook_signal("buffer_*", "buddylist_signal_buffer", ""); @@ -205,7 +210,7 @@ " show buddylist\n". "\n". "Options:\n". - "'plugins.var.perl.buddylist.buddylist' : path/file-name to store your buddies.\n". + "'plugins.var.perl.buddylist.buddylist' : path/file-name to store your buddies. \"%h\" will be replaced by WeeChat home (by default: ~/.weechat)\n". "\n". "'plugins.var.perl.buddylist.color.default : fall back color. (default: standard weechat color)\n". "'plugins.var.perl.buddylist.color.online' : color for " . weechat::color($default_color_buddylist{online}) . "online " . weechat::color("reset") . "buddies.\n". @@ -255,60 +260,69 @@ "\n\n". "name of buddy has to be written 'case sensitive' (it's recommended to use nick-completion or to drag'n'drop buddy with mouse).\n". "\n\n". - "Examples:\n". - " Add buddy (nils) to buddylist (server of current buffer will be used):\n". - " /$prgname add nils\n". - " Delete buddy (nils) from buddylist:\n". - " /$prgname del nils (server of current buffer will be used)\n", - "add %(nick) %-||". - "del %(perl_buddylist) %-||". - "list %-", "settings", ""); + "Examples:\n". + " Add buddy (nils) to buddylist (server of current buffer will be used):\n". + " /$prgname add nils\n". + " Delete buddy (nils) from buddylist:\n". + " /$prgname del nils (server of current buffer will be used)\n", + "add %(nick)|%*||". + "del %(perl_buddylist)|%*||". + "list %-", "settings_cb", ""); server_check(); return weechat::WEECHAT_RC_OK; -sub buddylist_upgrade_ended{ - server_check(); - return weechat::WEECHAT_RC_OK; +sub buddylist_upgrade_ended +{ + server_check(); + return weechat::WEECHAT_RC_OK; } + # weechat connected to a server (irc_server_connected) -sub server_connected{ - server_check(); - weechat::bar_item_update($prgname); - return weechat::WEECHAT_RC_OK; +sub server_connected +{ + server_check(); + weechat::bar_item_update($prgname); + return weechat::WEECHAT_RC_OK; } # weechat disconnected from server (irc_server_disconnected) -sub server_disconnected{ -my $server = $_[2]; - set_nick_status_for_one_server("2",$server); # all nicks off for server - server_check(); - weechat::bar_item_update($prgname); - return weechat::WEECHAT_RC_OK; +sub server_disconnected +{ + my $server = $_[2]; + set_nick_status_for_one_server("2",$server); # all nicks off for server + server_check(); + weechat::bar_item_update($prgname); + return weechat::WEECHAT_RC_OK; } -sub set_nick_status_for_one_server{ -my ($status, $server) = @_; - - foreach my $nickname (%{$nick_structure{$server}} ) { - if (exists $nick_structure{$server}{$nickname}){ # set buddy to offline - $nick_structure{$server}{$nickname}{status} = $status; - if ($status eq "2"){ - $nick_structure{$server}{$nickname}{buffer} = ""; - $nick_structure{$server}{$nickname}{buf_name} = ""; - }elsif($status eq "0"){ # set buddy online - $nick_structure{$server}{$nickname}{buffer} = "()"; - } - } - } -} +sub set_nick_status_for_one_server +{ + my ($status, $server) = @_; -sub buffer_closing{ -my ($signal, $callback, $callback_data) = @_; + foreach my $nickname (%{$nick_structure{$server}} ) + { + if (exists $nick_structure{$server}{$nickname}) # set buddy to offline + { + $nick_structure{$server}{$nickname}{status} = $status; + if ($status eq "2") + { + $nick_structure{$server}{$nickname}{buffer} = ""; + $nick_structure{$server}{$nickname}{buf_name} = ""; + }elsif($status eq "0") # set buddy online + { + $nick_structure{$server}{$nickname}{buffer} = "()"; + } + } + } +} -weechat::bar_item_update($prgname); -return weechat::WEECHAT_RC_OK; +sub buffer_closing +{ + my ($signal, $callback, $callback_data) = @_; + weechat::bar_item_update($prgname); + return weechat::WEECHAT_RC_OK; } # my $infolist_buf_closing = weechat::infolist_get("buffer",$callback_data,""); # get pointer from closing buffer # weechat::infolist_next($infolist_buf_closing); @@ -353,13 +367,13 @@ #return weechat::WEECHAT_RC_OK; -sub buffer_moved{ -my ($signal, $callback, $callback_data) = @_; -weechat::print("","signal: " . $signal); -weechat::print("","callback: " . $callback); -weechat::print("","callback_data: " . $callback_data); - -return weechat::WEECHAT_RC_OK; +sub buffer_moved +{ + my ($signal, $callback, $callback_data) = @_; + weechat::print("","signal: " . $signal); + weechat::print("","callback: " . $callback); + weechat::print("","callback_data: " . $callback_data); + return weechat::WEECHAT_RC_OK; } # build buddylist in bar @@ -474,6 +488,7 @@ # first sort by bitlbee_service and then name case insensitiv foreach my $n (sort { $nick_structure{$s}{$b}->{bitlbee_service} cmp $nick_structure{$s}{$a}->{bitlbee_service}} (sort {uc($a) cmp uc($b)} (sort keys(%{$nick_structure{$s}})) ) ){ # write each bitlbee_service only once + $nick_structure{$s}{$n}{bitlbee_service} = "" if ( not defined $nick_structure{$s}{$n}{bitlbee_service} ); $bitlbee_service_separator = $nick_structure{$s}{$n}{bitlbee_service}; if ( $bitlbee_service_separator ne "" and $bitlbee_service_separator_copy ne $bitlbee_service_separator ){ $str .= weechat::color($default_options{display_social_net_color}) . "(" . $bitlbee_service_separator . ") " . $visual; @@ -607,31 +622,33 @@ } sub add_nick{ - my ( $data, $servername, $args ) = @_; - my ($server) = split(/,/, $servername); # get name from server - my ($nickname) = ($args =~ /\:(.*)\!/); - - if (exists $nick_structure{$server}{$nickname}){ # nick in buddylist? - $nick_structure{$server}{$nickname}{status} = 0; # create structure - $nick_structure{$server}{$nickname}{bitlbee_service} = ""; - weechat::bar_item_update($prgname); - } + my ( $data, $servername, $args ) = @_; + my ($server) = split(/,/, $servername); # get name from server + my ($nickname) = ($args =~ /\:(.*)\!/); + + if (defined $nick_structure{$server}{$nickname} and exists $nick_structure{$server}{$nickname}){ # nick in buddylist? + $nick_structure{$server}{$nickname}{status} = 0; # create structure + $nick_structure{$server}{$nickname}{bitlbee_service} = ""; + weechat::bar_item_update($prgname); + } } # buddy leaves channel (irc_in_part / irc_in_quit) sub remove_nick{ #($nick,$name,$ip,$action,$channel) = ($args =~ /\:(.*)\!n=(.*)@(.*?)\s(.*)\s(.*)/); # maybe for future use - my ( $data, $servername, $args ) = @_; - my ($server) = split(/,/, $servername); # get name from server - my ($nickname) = ($args =~ /\:(.*)\!/); - if (exists $nick_structure{$server}{$nickname}){ # nick in buddylist? - $nick_structure{$server}{$nickname}{status} = 2; # yes and he left channel - $nick_structure{$server}{$nickname}{buf_name} = ""; - $nick_structure{$server}{$nickname}{buffer} = ""; - $nick_structure{$server}{$nickname}{counter} = ""; - $nick_structure{$server}{$nickname}{bitlbee_service} = ""; - weechat::bar_item_update($prgname); - } + my ( $data, $servername, $args ) = @_; + my ($server) = split(/,/, $servername); # get name from server + my ($nickname) = ($args =~ /\:(.*)\!/); + + + if (defined $nick_structure{$server}{$nickname} and exists $nick_structure{$server}{$nickname}){ # nick in buddylist? + $nick_structure{$server}{$nickname}{status} = 2; # yes and he left channel + $nick_structure{$server}{$nickname}{buf_name} = ""; + $nick_structure{$server}{$nickname}{buffer} = ""; + $nick_structure{$server}{$nickname}{counter} = ""; + $nick_structure{$server}{$nickname}{bitlbee_service} = ""; + weechat::bar_item_update($prgname); + } } # get information from who command (irc_in2_352) @@ -662,83 +679,85 @@ } # user commands -sub settings{ - my ($getargs) = ($_[2]); - my $servername = current_buffer_test(); - - if ($getargs eq ""){ - weechat::command("", "/help $prgname"); # no arguments given. Print help - return weechat::WEECHAT_RC_OK; - } +sub settings_cb{ + my ($data, $ptr_buffer, $getargs) = ($_[0], $_[1], $_[2]); - my ( $cmd, $args ) = ( $getargs =~ /(.*?)\s+(.*)/ ); # get parameters and cut cmd from nicks - $cmd = $getargs unless $cmd; - - if ($cmd eq "list"){ # print buddylist (with status) in core buffer - weechat::print("",weechat::color("white")."Buddylist:\n" . weechat::color("green"). "Servername" . weechat::color("reset") . "." . weechat::color("lightgreen") . "Nickname" . weechat::color("lightred") . " (status)" . weechat::color("reset") . " ==> Channelname:"); - foreach my $s ( sort keys %nick_structure ) { # sort server (a-z) - foreach my $n ( sort keys %{$nick_structure{$s}} ) { # sort nicks (a-z) - my $show_buffer = ""; - my $show_bitlbee_service = ""; - $show_buffer = " ==> " . $nick_structure{$s}{$n}{buf_name} if (defined $nick_structure{$s}{$n}{buf_name} and $nick_structure{$s}{$n}{buf_name} ne ""); - $show_bitlbee_service = " (" . $nick_structure{$s}{$n}{bitlbee_service} .")" if (defined $nick_structure{$s}{$n}{bitlbee_service} and $nick_structure{$s}{$n}{bitlbee_service} ne ""); - weechat::print( ""," " - . weechat::color("green") - . $s . weechat::color("reset") - . "." - . weechat::color("lightgreen") - . $n - . weechat::color("reset") - . $show_bitlbee_service - # status - . weechat::color("lightred") - . " (" . weechat::color($default_color_buddylist{$buddylist_level{$nick_structure{$s}{$n}{status}}}) - . $buddylist_level{$nick_structure{$s}{$n}{status}} - . weechat::color("lightred") . ")" - . weechat::color("reset") - . $show_buffer); - } - } - return weechat::WEECHAT_RC_OK; - } + if ($getargs eq "") + { + weechat::command("", "/help $prgname"); # no arguments given. print help + return weechat::WEECHAT_RC_OK; + } - if ($servername eq "0") { - weechat::print("",weechat::prefix("error")."$prgname: You can't add nor del buddies in core buffer."); - return weechat::WEECHAT_RC_OK; + my $localvar_name = weechat::buffer_get_string($ptr_buffer, "localvar_name"); + my $localvar_servername = weechat::buffer_get_string($ptr_buffer, "localvar_server"); + my $localvar_channelname = weechat::buffer_get_string($ptr_buffer, "localvar_channel"); + my $localvar_type = weechat::buffer_get_string($ptr_buffer, "localvar_type"); +# my $localvar_plugin = weechat::buffer_get_string($ptr_buffer, "localvar_plugin"); + + my ( $cmd, $args ) = ( $getargs =~ /(.*?)\s+(.*)/ ); # get parameters and cut cmd from nicks + $cmd = $getargs unless $cmd; + + if ($cmd eq "list") # print buddylist (with status) in core buffer + { + weechat::print("",weechat::color("white")."Buddylist:\n" . weechat::color("green"). "Servername" . weechat::color("reset") . "." . weechat::color("lightgreen") . "Nickname" . weechat::color("lightred") . " (status)" . weechat::color("reset") . " ==> Channelname:"); + foreach my $s ( sort keys %nick_structure ) # sort server (a-z) + { + foreach my $n ( sort keys %{$nick_structure{$s}} ) # sort nicks (a-z) + { + my $show_buffer = ""; + my $show_bitlbee_service = ""; + $show_buffer = " ==> " . $nick_structure{$s}{$n}{buf_name} if (defined $nick_structure{$s}{$n}{buf_name} and $nick_structure{$s}{$n}{buf_name} ne ""); + $show_bitlbee_service = " (" . $nick_structure{$s}{$n}{bitlbee_service} .")" if (defined $nick_structure{$s}{$n}{bitlbee_service} and $nick_structure{$s}{$n}{bitlbee_service} ne ""); + weechat::print( ""," " + . weechat::color("green") + . $s . weechat::color("reset") + . "." + . weechat::color("lightgreen") + . $n + . weechat::color("reset") + . $show_bitlbee_service + # status + . weechat::color("lightred") + . " (" . weechat::color($default_color_buddylist{$buddylist_level{$nick_structure{$s}{$n}{status}}}) + . $buddylist_level{$nick_structure{$s}{$n}{status}} + . weechat::color("lightred") . ")" + . weechat::color("reset") + . $show_buffer); + } } + return weechat::WEECHAT_RC_OK; + } - if (defined $args and current_buffer_test() ne "0") { # buddy choosen? - foreach ( split( / +/, $args ) ) { # more than one nick? - if ($cmd eq "add"){ - $nick_structure{$servername}{$_}{status} = 2; - $nick_structure{$servername}{$_}{bitlbee_service} = ""; - buddylist_save(); - } - if ($cmd eq "del" and exists $nick_structure{$servername}{$_}){ - delete $nick_structure{$servername}{$_}; + if ( $localvar_type ne "channel" and $localvar_type ne "private" and $localvar_type ne "server" ) + { + weechat::print("",weechat::prefix("error")."$prgname: You can add/del buddies only in channel/server/private buffers."); + return weechat::WEECHAT_RC_OK; + } + if (defined $args) + { + foreach ( split( / +/, $args ) ) # more than one nick? + { + if ($cmd eq "add") + { + $nick_structure{$localvar_servername}{$_}{status} = 2; + $nick_structure{$localvar_servername}{$_}{bitlbee_service} = ""; + buddylist_save(); + } + if ($cmd eq "del" and exists $nick_structure{$localvar_servername}{$_}) + { + delete $nick_structure{$localvar_servername}{$_}; # delete servername from structure, if last nick from server was deleted - delete $nick_structure{$servername} if (keys (%{$nick_structure{$servername}}) == 0); - buddylist_save(); - } - } - }else{ - weechat::command("", "/help $prgname"); # no arguments given. Print help - } - weechat::bar_item_update($prgname); - return weechat::WEECHAT_RC_OK; -} - -# check for buffer. add/del function can not be used in core buffer -sub current_buffer_test{ - my $buffer_name = weechat::buffer_get_string(weechat::current_buffer(),"name"); # get current buffer name - if ($buffer_name =~ /\./){ # format? - my ($servername, $channelname) = split (/\./,$buffer_name); # split - if ($servername eq "server"){ # user in server buffer? - return $channelname; # yes - } - return $servername; # user in channel buffer! - } -return 0; # in core buffer!!! + delete $nick_structure{$localvar_servername} if (keys (%{$nick_structure{$localvar_servername}}) == 0); + buddylist_save(); + } + } + } + else + { + weechat::command("", "/help $prgname"); # no arguments given. Print help + } + weechat::bar_item_update($prgname); + return weechat::WEECHAT_RC_OK; } # check server status for option hide_bar (to hide or show bar) @@ -779,25 +798,49 @@ } ### read the buddylist -sub buddylist_read { - my $buddylist = weechat::config_get_plugin("buddylist"); - return unless -e $buddylist; - open (WL, "<", $buddylist) || DEBUG("$buddylist: $!"); - while () { - chomp; # kill LF - my ( $servername, $nickname ) = split /,|\./; # servername,nickname (seperator could be "," or ".") - if (not defined $nickname){ - close WL; - weechat::print("",weechat::prefix("error")."$prgname: $buddylist is not valid or uses old format (new format: servername.nickname)."); - return; - } - $nick_structure{$servername}{$nickname}{status} = 2 if length $_; # status offline - $nick_structure{$servername}{$nickname}{bitlbee_service} = ""; - } - close WL; +sub buddylist_read +{ + my $buddylist = weechat_dir(); + if ($buddylist eq "") + { + weechat::print("","Please set a valid filename : /set plugins.var.perl.".$prgname.".buddylist"); + return; + } + return unless -e $buddylist; + open (WL, "<", $buddylist) || DEBUG("$buddylist: $!"); + while () + { + chomp; # kill LF + # search for last "." or "," in buddylist.txt + # server.nick or irc.temporary.server.nick + my $cut_here = rindex($_,"."); + $cut_here = rindex($_,",") if ($cut_here == -1); + if ($cut_here == -1) + { + close WL; + weechat::print("",weechat::prefix("error")."$prgname: $buddylist is not valid or uses old format (new format: servername.nickname)."); + return; + } + my $servername = substr( $_, 0, $cut_here); + my $nickname = substr( $_,$cut_here + 1); + if (not defined $nickname) + { + close WL; + weechat::print("",weechat::prefix("error")."$prgname: $buddylist is not valid or uses old format (new format: servername.nickname)."); + return; + } + $nick_structure{$servername}{$nickname}{status} = 2 if length $_; # status offline + $nick_structure{$servername}{$nickname}{bitlbee_service} = ""; + } + close WL; } sub buddylist_save { - my $buddylist = weechat::config_get_plugin( "buddylist" ); + my $buddylist = weechat_dir(); + if ($buddylist eq "") + { + weechat::print("","Please set a valid filename : /set plugins.var.perl.buddylist.buddylist"); + return; + } open (WL, ">", $buddylist) || DEBUG("write buddylist: $!"); foreach my $s ( sort keys %nick_structure ) { # sortiert die Server alphabetisch foreach my $n ( sort keys %{$nick_structure{$s}} ) { # sortiert die Nicks alphabetisch @@ -898,183 +941,213 @@ return weechat::WEECHAT_RC_OK; } +sub weechat_dir +{ + my $dir = weechat::config_get_plugin("buddylist"); + if ( $dir =~ /%h/ ) + { + my $weechat_dir = weechat::info_get( 'weechat_dir', ''); + $dir =~ s/%h/$weechat_dir/; + } + return $dir; +} + # init the settings sub init{ - $weechat_version = weechat::info_get("version_number", ""); - $default_version = 0; - if (($weechat_version ne "") && ($weechat_version >= 0x00030400)){ # v0.3.4 - $default_version = 1; # used!! - } + $weechat_version = weechat::info_get("version_number", ""); + $default_version = 0; + if (($weechat_version ne "") && ($weechat_version >= 0x00030400)) # v0.3.4 + { + $default_version = 1; + } -# load buddylist file - if ( weechat::config_get_plugin("buddylist") eq "" ) { - my $wd = weechat::info_get( "weechat_dir", "" ); - $wd =~ s/\/$//; - weechat::config_set_plugin("buddylist", $wd . "/" . $default_buddylist ); - } + # a filename is defined in option? + weechat::config_set_plugin("buddylist", $default_buddylist ) if ( weechat::config_get_plugin("buddylist") eq "" ); - if (!weechat::config_is_set_plugin("color.default")){ - weechat::config_set_plugin("color.default", $default_options{color_default}); - }else{ - $default_options{color_default} = weechat::config_get_plugin("color.default"); - } - if (!weechat::config_is_set_plugin("color.server")){ - weechat::config_set_plugin("color.server", $default_options{color_server_online}); - }else{ - $default_options{color_server_online} = weechat::config_get_plugin("color.server"); - } - if (!weechat::config_is_set_plugin("color.server.offline")){ - weechat::config_set_plugin("color.server.offline", $default_options{color_server_offline}); - }else{ - $default_options{color_server_offline} = weechat::config_get_plugin("color.server.offline"); - } - if (!weechat::config_is_set_plugin("buddy.on.server.color")){ - weechat::config_set_plugin("buddy.on.server.color", $default_options{buddy_on_server_color}); - }else{ - $default_options{buddy_on_server_color} = weechat::config_get_plugin("buddy.on.server.color"); - } - if (!weechat::config_is_set_plugin("color.number")){ - weechat::config_set_plugin("color.number", $default_options{color_number}); - }else{ - $default_options{color_number} = weechat::config_get_plugin("color.number"); - } - if (!weechat::config_is_set_plugin("show.query")){ - weechat::config_set_plugin("show.query", $default_options{show_query}); - }else{ - $default_options{show_query} = weechat::config_get_plugin("show.query"); - } - if (!weechat::config_is_set_plugin("hide.bar")){ - weechat::config_set_plugin("hide.bar", $default_options{hide_bar}); - }else{ - $default_options{hide_bar} = weechat::config_get_plugin("hide.bar"); - } - if (!weechat::config_is_set_plugin("sort")){ - weechat::config_set_plugin("sort", $default_options{sort}); - }else{ - $default_options{sort} = weechat::config_get_plugin("sort"); - } - if (!weechat::config_is_set_plugin("hide.server.if.buddies.offline")){ - weechat::config_set_plugin("hide.server.if.buddies.offline", $default_options{hide_server}); - }else{ - $default_options{hide_server} = weechat::config_get_plugin("hide.server.if.buddies.offline"); - } - if (!weechat::config_is_set_plugin("hide.buddy.if.offline")){ - weechat::config_set_plugin("hide.buddy.if.offline", $default_options{hide_buddy}); - }else{ - $default_options{hide_buddy} = weechat::config_get_plugin("hide.buddy.if.offline"); - } - if (!weechat::config_is_set_plugin("buddy.on.server")){ - weechat::config_set_plugin("buddy.on.server", $default_options{buddy_on_server}); - }else{ - $default_options{buddy_on_server} = weechat::config_get_plugin("buddy.on.server"); - } - if (!weechat::config_is_set_plugin("check.buddies")){ - weechat::config_set_plugin("check.buddies", $default_options{check_buddies}); - }else{ - $default_options{check_buddies} = weechat::config_get_plugin("check.buddies"); - } - if (!weechat::config_is_set_plugin("callback.timeout")){ - weechat::config_set_plugin("callback.timeout", $default_options{callback_timeout}); - }else{ - $default_options{callback_timeout} = weechat::config_get_plugin("callback.timeout"); - } - if (!weechat::config_is_set_plugin("use.redirection")){ - weechat::config_set_plugin("use.redirection", $default_options{use_redirection}); - }else{ - $default_options{use_redirection} = weechat::config_get_plugin("use.redirection"); - } - if (!weechat::config_is_set_plugin("display.original.nick")){ - weechat::config_set_plugin("display.original.nick", $default_options{display_original_nick}); - }else{ - $default_options{display_original_nick} = weechat::config_get_plugin("display.original.nick"); - } - if (!weechat::config_is_set_plugin("display.social.net")){ - weechat::config_set_plugin("display.social.net", $default_options{display_social_net}); - }else{ - $default_options{display_social_net} = weechat::config_get_plugin("display.social.net"); - } - if (!weechat::config_is_set_plugin("display.social.net.color")){ - weechat::config_set_plugin("display.social.net.color", $default_options{display_social_net_color}); - }else{ - $default_options{display_social_net_color} = weechat::config_get_plugin("display.social.net.color"); - } - if (!weechat::config_is_set_plugin("text.online")){ - weechat::config_set_plugin("text.online", $default_options{text_online}); - }else{ - $default_options{text_online} = weechat::config_get_plugin("text.online"); - } - if (!weechat::config_is_set_plugin("text.away")){ - weechat::config_set_plugin("text.away", $default_options{text_away}); - }else{ - $default_options{text_away} = weechat::config_get_plugin("text.away"); - } - if (!weechat::config_is_set_plugin("text.offline")){ - weechat::config_set_plugin("text.offline", $default_options{text_offline}); - }else{ - $default_options{text_offline} = weechat::config_get_plugin("text.offline"); - } - if (!weechat::config_is_set_plugin("text.color")){ - weechat::config_set_plugin("text.color", $default_options{text_color}); - }else{ - $default_options{text_color} = weechat::config_get_plugin("text.color"); - } - if (!weechat::config_is_set_plugin("hide.servername.in.buddylist")){ - weechat::config_set_plugin("hide.servername.in.buddylist", $default_options{hide_servername_in_buddylist}); - }else{ - $default_options{hide_servername_in_buddylist} = weechat::config_get_plugin("hide.servername.in.buddylist"); - } + if (!weechat::config_is_set_plugin("color.default")) + { + weechat::config_set_plugin("color.default", $default_options{color_default}); + }else + { + $default_options{color_default} = weechat::config_get_plugin("color.default"); + } + if (!weechat::config_is_set_plugin("color.server")) + { + weechat::config_set_plugin("color.server", $default_options{color_server_online}); + }else + { + $default_options{color_server_online} = weechat::config_get_plugin("color.server"); + } + if (!weechat::config_is_set_plugin("color.server.offline")) + { + weechat::config_set_plugin("color.server.offline", $default_options{color_server_offline}); + }else + { + $default_options{color_server_offline} = weechat::config_get_plugin("color.server.offline"); + } + if (!weechat::config_is_set_plugin("buddy.on.server.color")) + { + weechat::config_set_plugin("buddy.on.server.color", $default_options{buddy_on_server_color}); + }else + { + $default_options{buddy_on_server_color} = weechat::config_get_plugin("buddy.on.server.color"); + } + if (!weechat::config_is_set_plugin("color.number")) + { + weechat::config_set_plugin("color.number", $default_options{color_number}); + }else + { + $default_options{color_number} = weechat::config_get_plugin("color.number"); + } + if (!weechat::config_is_set_plugin("show.query")) + { + weechat::config_set_plugin("show.query", $default_options{show_query}); + }else + { + $default_options{show_query} = weechat::config_get_plugin("show.query"); + } + if (!weechat::config_is_set_plugin("hide.bar")) + { + weechat::config_set_plugin("hide.bar", $default_options{hide_bar}); + }else + { + $default_options{hide_bar} = weechat::config_get_plugin("hide.bar"); + } + if (!weechat::config_is_set_plugin("sort")) + { + weechat::config_set_plugin("sort", $default_options{sort}); + }else + { + $default_options{sort} = weechat::config_get_plugin("sort"); + } + if (!weechat::config_is_set_plugin("hide.server.if.buddies.offline")) + { + weechat::config_set_plugin("hide.server.if.buddies.offline", $default_options{hide_server}); + }else + { + $default_options{hide_server} = weechat::config_get_plugin("hide.server.if.buddies.offline"); + } + if (!weechat::config_is_set_plugin("hide.buddy.if.offline")) + { + weechat::config_set_plugin("hide.buddy.if.offline", $default_options{hide_buddy}); + }else + { + $default_options{hide_buddy} = weechat::config_get_plugin("hide.buddy.if.offline"); + } + if (!weechat::config_is_set_plugin("buddy.on.server")){ + weechat::config_set_plugin("buddy.on.server", $default_options{buddy_on_server}); + }else{ + $default_options{buddy_on_server} = weechat::config_get_plugin("buddy.on.server"); + } + if (!weechat::config_is_set_plugin("check.buddies")){ + weechat::config_set_plugin("check.buddies", $default_options{check_buddies}); + }else{ + $default_options{check_buddies} = weechat::config_get_plugin("check.buddies"); + } + if (!weechat::config_is_set_plugin("callback.timeout")){ + weechat::config_set_plugin("callback.timeout", $default_options{callback_timeout}); + }else{ + $default_options{callback_timeout} = weechat::config_get_plugin("callback.timeout"); + } + if (!weechat::config_is_set_plugin("use.redirection")){ + weechat::config_set_plugin("use.redirection", $default_options{use_redirection}); + }else{ + $default_options{use_redirection} = weechat::config_get_plugin("use.redirection"); + } + if (!weechat::config_is_set_plugin("display.original.nick")){ + weechat::config_set_plugin("display.original.nick", $default_options{display_original_nick}); + }else{ + $default_options{display_original_nick} = weechat::config_get_plugin("display.original.nick"); + } + if (!weechat::config_is_set_plugin("display.social.net")){ + weechat::config_set_plugin("display.social.net", $default_options{display_social_net}); + }else{ + $default_options{display_social_net} = weechat::config_get_plugin("display.social.net"); + } + if (!weechat::config_is_set_plugin("display.social.net.color")){ + weechat::config_set_plugin("display.social.net.color", $default_options{display_social_net_color}); + }else{ + $default_options{display_social_net_color} = weechat::config_get_plugin("display.social.net.color"); + } + if (!weechat::config_is_set_plugin("text.online")){ + weechat::config_set_plugin("text.online", $default_options{text_online}); + }else{ + $default_options{text_online} = weechat::config_get_plugin("text.online"); + } + if (!weechat::config_is_set_plugin("text.away")){ + weechat::config_set_plugin("text.away", $default_options{text_away}); + }else{ + $default_options{text_away} = weechat::config_get_plugin("text.away"); + } + if (!weechat::config_is_set_plugin("text.offline")){ + weechat::config_set_plugin("text.offline", $default_options{text_offline}); + }else{ + $default_options{text_offline} = weechat::config_get_plugin("text.offline"); + } + if (!weechat::config_is_set_plugin("text.color")){ + weechat::config_set_plugin("text.color", $default_options{text_color}); + }else{ + $default_options{text_color} = weechat::config_get_plugin("text.color"); + } + if (!weechat::config_is_set_plugin("hide.servername.in.buddylist")){ + weechat::config_set_plugin("hide.servername.in.buddylist", $default_options{hide_servername_in_buddylist}); + }else{ + $default_options{hide_servername_in_buddylist} = weechat::config_get_plugin("hide.servername.in.buddylist"); + } - if ( ($weechat_version ne "") && (weechat::info_get("version_number", "") >= 0x00030500) ) { # v0.3.5 - weechat::config_set_desc_plugin("buddylist","path/file-name to store your buddies"); - weechat::config_set_desc_plugin("color.default","fall back color. (default: standard weechat color)"); - weechat::config_set_desc_plugin("color.online","color for online buddies"); - weechat::config_set_desc_plugin("color.away","color for away buddies"); - weechat::config_set_desc_plugin("color.offline","color for offline buddies"); - weechat::config_set_desc_plugin("color.server","color for servername"); - weechat::config_set_desc_plugin("color.server.offline","color for disconnected server (default: hide)"); - weechat::config_set_desc_plugin("color.number","color for channel number (default: lightred). If empty, channel list option is off"); - - weechat::config_set_desc_plugin("show.query","displays a query buffer in front of the channel list"); - - weechat::config_set_desc_plugin("hide.server.if.buddies.offline","hides server when all buddies are offline for this server (default: off)"); - weechat::config_set_desc_plugin("hide.buddy.if.offline","hide buddy if offline (default: off)"); - - weechat::config_set_desc_plugin("buddy.on.server","show buddy who is connected to a server, but not visiting the same channel(s) (default: on)"); - weechat::config_set_desc_plugin("buddy.on.server.color","color for online buddy but not visiting the same channel(s) (default: lightgreen)"); - - weechat::config_set_desc_plugin("hide.bar","hides buddylist bar when all servers with added buddies are offline (on = default, always = buddylist bar will be hidden (for example if you want to add item 'buddylist' to 'weechat.bar.status.items', off = buddylist bar will not be hidden))"); - weechat::config_set_desc_plugin("check.buddies","time in seconds to send a /whois request to server. Be careful not to flood server (default: 20)"); - weechat::config_set_desc_plugin("callback.timeout","time in seconds to wait for answer from server. (default: 60)"); - weechat::config_set_desc_plugin("display.original.nick","display original nickname even if buddy changed his /nick (you have to add new nick to buddylist (default: off)"); - - weechat::config_set_desc_plugin("sort","sort method for buddylist (default = buddylist will be sort by nickname, status = buddylist will be sort by status (online, away, offline))"); - - weechat::config_set_desc_plugin("display.social.net","using bitlbee, buddies will be sorted in sublists with social-network name (eg. msn/jabber/facebook)(default: on)"); - weechat::config_set_desc_plugin("display.social.net.color","color for social-network name (default: yellow)"); - - weechat::config_set_desc_plugin("text.color","color for optional online/away/offline-text in buddylist (default: white)"); - weechat::config_set_desc_plugin("text.online","optional online text in buddylist (sort method has to be 'status')"); - weechat::config_set_desc_plugin("text.away","optional away text in buddylist (sort method has to be 'status')"); - weechat::config_set_desc_plugin("text.offline","optional offline text in buddylist (sort method has to be 'status')"); + if ( ($weechat_version ne "") && (weechat::info_get("version_number", "") >= 0x00030500) ) # v0.3.5 + { + weechat::config_set_desc_plugin("buddylist","path/file-name to store your buddies. \"%h\" will be replaced by WeeChat home (by default: ~/.weechat)"); + weechat::config_set_desc_plugin("color.default","fall back color. (default: standard weechat color)"); + weechat::config_set_desc_plugin("color.online","color for online buddies"); + weechat::config_set_desc_plugin("color.away","color for away buddies"); + weechat::config_set_desc_plugin("color.offline","color for offline buddies"); + weechat::config_set_desc_plugin("color.server","color for servername"); + weechat::config_set_desc_plugin("color.server.offline","color for disconnected server (default: hide)"); + weechat::config_set_desc_plugin("color.number","color for channel number (default: lightred). If empty, channel list option is off"); + + weechat::config_set_desc_plugin("show.query","displays a query buffer in front of the channel list"); + + weechat::config_set_desc_plugin("hide.server.if.buddies.offline","hides server when all buddies are offline for this server (default: off)"); + weechat::config_set_desc_plugin("hide.buddy.if.offline","hide buddy if offline (default: off)"); + + weechat::config_set_desc_plugin("buddy.on.server","show buddy who is connected to a server, but not visiting the same channel(s) (default: on)"); + weechat::config_set_desc_plugin("buddy.on.server.color","color for online buddy but not visiting the same channel(s) (default: lightgreen)"); + + weechat::config_set_desc_plugin("hide.bar","hides buddylist bar when all servers with added buddies are offline (on = default, always = buddylist bar will be hidden (for example if you want to add item 'buddylist' to 'weechat.bar.status.items', off = buddylist bar will not be hidden))"); + weechat::config_set_desc_plugin("check.buddies","time in seconds to send a /whois request to server. Be careful not to flood server (default: 20)"); + weechat::config_set_desc_plugin("callback.timeout","time in seconds to wait for answer from server. (default: 60)"); + weechat::config_set_desc_plugin("display.original.nick","display original nickname even if buddy changed his /nick (you have to add new nick to buddylist (default: off)"); + + weechat::config_set_desc_plugin("sort","sort method for buddylist (default = buddylist will be sort by nickname, status = buddylist will be sort by status (online, away, offline))"); + + weechat::config_set_desc_plugin("display.social.net","using bitlbee, buddies will be sorted in sublists with social-network name (eg. msn/jabber/facebook)(default: on)"); + weechat::config_set_desc_plugin("display.social.net.color","color for social-network name (default: yellow)"); + + weechat::config_set_desc_plugin("text.color","color for optional online/away/offline-text in buddylist (default: white)"); + weechat::config_set_desc_plugin("text.online","optional online text in buddylist (sort method has to be 'status')"); + weechat::config_set_desc_plugin("text.away","optional away text in buddylist (sort method has to be 'status')"); + weechat::config_set_desc_plugin("text.offline","optional offline text in buddylist (sort method has to be 'status')"); - weechat::config_set_desc_plugin("use.redirection","using redirection to get status of buddies (needs weechat >=0.3.4) (default: on)"); - weechat::config_set_desc_plugin("hide.servername.in.buddylist","hide the servername in buddylist. If \"on\" only nicks will be displayed in buddylist (default: off)"); - } + weechat::config_set_desc_plugin("use.redirection","using redirection to get status of buddies (needs weechat >=0.3.4) (default: on)"); + weechat::config_set_desc_plugin("hide.servername.in.buddylist","hide the servername in buddylist. If \"on\" only nicks will be displayed in buddylist (default: off)"); + } # only for debugging - if (weechat::config_is_set_plugin("debug.redir.out")){ - $debug_redir_out = weechat::config_get_plugin("debug.redir.out"); - } - + $debug_redir_out = weechat::config_get_plugin("debug.redir.out") if (weechat::config_is_set_plugin("debug.redir.out")); # get color settings. - foreach my $level (values %buddylist_level){ - if (weechat::config_get_plugin("color.".$level) eq ""){ - weechat::config_set_plugin("color.".$level, - $default_color_buddylist{$level}); - }else{ - $default_color_buddylist{$level} = weechat::config_get_plugin("color.".$level); - } - } + foreach my $level (values %buddylist_level) + { + if (weechat::config_get_plugin("color.".$level) eq "") + { + weechat::config_set_plugin("color.".$level, + $default_color_buddylist{$level}); + } + else + { + $default_color_buddylist{$level} = weechat::config_get_plugin("color.".$level); + } + } } # hide bar when buddylist was closed @@ -1108,26 +1181,27 @@ return 1; } -sub unhook_timer{ - if (defined $Hooks{timer}){ - weechat::unhook($Hooks{timer}); - delete $Hooks{timer}; - } - if (defined $Hooks{redirect}){ - weechat::unhook($Hooks{redirect}); - delete $Hooks{redirect}; - } +sub unhook_timer +{ + if (defined $Hooks{timer}) + { + weechat::unhook($Hooks{timer}); + delete $Hooks{timer}; + } + if (defined $Hooks{redirect}) + { + weechat::unhook($Hooks{redirect}); + delete $Hooks{redirect}; + } } - -sub call_whois_one{ -my ( $server, $nickname ) = @_; - +sub call_whois_one +{ + my ( $server, $nickname ) = @_; my $hash = { "server" => $server, "pattern" => "whois", "signal" => "buddylist", - "count" => "1", "string" => $nickname, "timeout" => $default_options{callback_timeout}, "cmd_filter" => "" }; + "count" => "1", "string" => $nickname, "timeout" => $default_options{callback_timeout}, "cmd_filter" => "" }; weechat::hook_hsignal_send("irc_redirect_command", $hash); weechat::hook_signal_send("irc_input_send", weechat::WEECHAT_HOOK_SIGNAL_STRING, $server.";;2;;/whois ".$nickname); #server;channel;flags;tags;text - } # -------------------------------[ redirection ]------------------------------------- diff -Nru weechat-scripts-20130123/perl/buffers.pl weechat-scripts-20131007/perl/buffers.pl --- weechat-scripts-20130123/perl/buffers.pl 2013-01-23 19:00:20.000000000 +0000 +++ weechat-scripts-20131007/perl/buffers.pl 2013-10-07 12:14:52.000000000 +0000 @@ -1,6 +1,6 @@ # -# Copyright (C) 2008-2012 Sebastien Helleu -# Copyright (C) 2011-2012 Nils G +# Copyright (C) 2008-2013 Sebastien Helleu +# Copyright (C) 2011-2013 Nils G # # 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 @@ -20,6 +20,9 @@ # # History: # +# 2013-09-27, nils_2@freenode.#weechat: +# v3.9: add option "toggle_bar" and option "show_prefix_query" (idea by IvarB) +# : fix problem with linefeed at end of list of buffers (reported by grawity) # 2012-10-18, nils_2@freenode.#weechat: # v3.8: add option "mark_inactive", to mark buffers you are not in (idea by xrdodrx) # : add wildcard "*" for immune_detach_buffers (idea by StarWeaver) @@ -134,7 +137,8 @@ use strict; use Encode qw( decode encode ); # -------------------------------[ internal ]------------------------------------- -my $version = "3.8"; +my $SCRIPT_NAME = "buffers"; +my $version = "3.9"; my $BUFFERS_CONFIG_FILE_NAME = "buffers"; my $buffers_config_file; @@ -152,26 +156,33 @@ my %Hooks = (); # --------------------------------[ init ]-------------------------------------- -weechat::register("buffers", "Sebastien Helleu ", $version, - "GPL3", "Sidebar with list of buffers", "", ""); +weechat::register($SCRIPT_NAME, "Sebastien Helleu ", $version, + "GPL3", "Sidebar with list of buffers", "shutdown_cb", ""); my $weechat_version = weechat::info_get("version_number", "") || 0; buffers_config_init(); buffers_config_read(); -weechat::bar_item_new("buffers", "build_buffers", ""); -weechat::bar_new("buffers", "0", "0", "root", "", "left", "horizontal", +weechat::bar_item_new($SCRIPT_NAME, "build_buffers", ""); +weechat::bar_new($SCRIPT_NAME, "0", "0", "root", "", "left", "horizontal", "vertical", "0", "0", "default", "default", "default", "1", - "buffers"); + $SCRIPT_NAME); + +if ( check_bar_item() == 0 ) +{ + weechat::command("","/bar show " . $SCRIPT_NAME) if ( weechat::config_boolean($options{"toggle_bar"}) eq 1 ); +} + weechat::hook_signal("buffer_*", "buffers_signal_buffer", ""); weechat::hook_signal("window_switch", "buffers_signal_buffer", ""); weechat::hook_signal("hotlist_*", "buffers_signal_hotlist", ""); -weechat::hook_signal("window_switch", "buffers_signal_buffer", ""); #weechat::hook_command_run("/input switch_active_*", "buffers_signal_buffer", ""); -weechat::bar_item_update("buffers"); +weechat::bar_item_update($SCRIPT_NAME); + + if ($weechat_version >= 0x00030600) { - weechat::hook_focus("buffers", "buffers_focus_buffers", ""); + weechat::hook_focus($SCRIPT_NAME, "buffers_focus_buffers", ""); weechat::hook_hsignal("buffers_mouse", "buffers_hsignal_mouse", ""); weechat::key_bind("mouse", \%mouse_keys); } @@ -287,6 +298,7 @@ } return weechat::WEECHAT_RC_OK; } + sub create_whitelist { my @buffers_list = @{$_[0]}; @@ -313,7 +325,7 @@ weechat::unhook($Hooks{timer_detach}) if $Hooks{timer_detach}; $Hooks{timer_detach} = weechat::hook_timer( weechat::config_integer( $options{"detach"}) * 1000, 60, 0, "buffers_signal_buffer", ""); } - weechat::bar_item_update("buffers"); + weechat::bar_item_update($SCRIPT_NAME); return weechat::WEECHAT_RC_OK; } @@ -330,7 +342,7 @@ weechat::unhook($Hooks{timer_lag}) if $Hooks{timer_lag}; $Hooks{timer_lag} = weechat::hook_timer( weechat::config_integer(weechat::config_get("irc.network.lag_refresh_interval")) * 1000, 0, 0, "buffers_signal_hotlist", ""); } - weechat::bar_item_update("buffers"); + weechat::bar_item_update($SCRIPT_NAME); return weechat::WEECHAT_RC_OK; } @@ -399,8 +411,9 @@ "short_names" => ["short_names", "boolean", "display short names (remove text before first \".\" in buffer name)", "", 0, 0,"on", "on", 0, "", "", "buffers_signal_config", "", "", ""], "show_number" => ["show_number", "boolean", "display channel number in front of buffername", "", 0, 0,"on", "on", 0, "", "", "buffers_signal_config", "", "", ""], "show_number_char" => ["number_char", "string", "display a char after channel number", "", 0, 0,".", ".", 0, "", "", "buffers_signal_config", "", "", ""], - "show_prefix" => ["prefix", "boolean", "show your prefix for channel", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""], - "show_prefix_empty" => ["prefix_empty", "boolean", "use a placeholder for channels without prefix", "", 0, 0,"on", "on", 0, "", "", "buffers_signal_config", "", "", ""], + "show_prefix" => ["prefix", "boolean", "displays your prefix for channel in front of buffername", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""], + "show_prefix_empty" => ["prefix_empty", "boolean", "use a placeholder for channels without prefix", "", 0, 0,"on", "on", 0, "", "", "buffers_signal_config", "", "", ""], +"show_prefix_query" => ["prefix_for_query", "string", "prefix displayed in front of query buffer", "", 0, 0,"", "", 0, "", "", "buffers_signal_config", "", "", ""], "sort" => ["sort", "integer", "sort buffer-list by \"number\" or \"name\"", "number|name", 0, 0,"number", "number", 0, "", "", "buffers_signal_config", "", "", ""], "core_to_front" => ["core_to_front", "boolean", "core buffer and buffers with free content will be listed first. Take only effect if buffer sort is by name", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""], "jump_prev_next_visited_buffer" => ["jump_prev_next_visited_buffer", "boolean", "jump to previously or next visited buffer if you click with left/right mouse button on currently visiting buffer", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""], @@ -411,6 +424,7 @@ "detach_query" => ["detach_query", "boolean", "query buffer will be detachted", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""], "detach_free_content" => ["detach_free_content", "boolean", "buffers with free content will be detached (Ex: iset, chanmon)", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""], "mark_inactive" => ["mark_inactive", "boolean", "if option is \"on\", inactive buffers (those you are not in) will have parentesis around them. An inactive buffer will not be detached.", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""], + "toggle_bar" => ["toogle_bar", "boolean", "if option is \"on\", buffers bar will hide/show when script is (un)loaded.", "", 0, 0,"on", "on", 0, "", "", "buffers_signal_config", "", "", ""], ); # section "color" my $section_color = weechat::config_new_section($buffers_config_file,"color", 0, 0, "", "", "", "", "", "", "", "", "", ""); @@ -443,7 +457,8 @@ $default_options_look{$option}[3],$default_options_look{$option}[4],$default_options_look{$option}[5], $default_options_look{$option}[6],$default_options_look{$option}[7],$default_options_look{$option}[8], $default_options_look{$option}[9],$default_options_look{$option}[10],$default_options_look{$option}[11], - $default_options_look{$option}[12],$default_options_look{$option}[13],$default_options_look{$option}[14]); + $default_options_look{$option}[12],$default_options_look{$option}[13],$default_options_look{$option}[14], + $default_options_look{$option}[15]); } } @@ -831,6 +846,9 @@ } } } + + $str .= weechat::config_string( $options{"show_prefix_query"}) if (weechat::config_string( $options{"show_prefix_query"} ) ne "" and $buffer->{"type"} eq "private"); + if (weechat::config_boolean( $options{"show_prefix"} ) eq 1) { my $nickname = weechat::buffer_get_string($buffer->{"pointer"}, "localvar_nick"); @@ -928,6 +946,9 @@ $old_number = $buffer->{"number"}; } + # remove spaces and/or linefeed at the end + $str =~ s/\s+$//; + chomp($str); return $str; } @@ -1051,13 +1072,13 @@ } } - weechat::bar_item_update("buffers"); + weechat::bar_item_update($SCRIPT_NAME); return weechat::WEECHAT_RC_OK; } sub buffers_signal_hotlist { - weechat::bar_item_update("buffers"); + weechat::bar_item_update($SCRIPT_NAME); return weechat::WEECHAT_RC_OK; } @@ -1066,20 +1087,20 @@ { @whitelist_buffers = (); @whitelist_buffers = split( /,/, weechat::config_string( $options{"look_whitelist_buffers"} ) ); - weechat::bar_item_update("buffers"); + weechat::bar_item_update($SCRIPT_NAME); return weechat::WEECHAT_RC_OK; } sub buffers_signal_config_immune_detach_buffers { @immune_detach_buffers = (); @immune_detach_buffers = split( /,/, weechat::config_string( $options{"immune_detach_buffers"} ) ); - weechat::bar_item_update("buffers"); + weechat::bar_item_update($SCRIPT_NAME); return weechat::WEECHAT_RC_OK; } sub buffers_signal_config { - weechat::bar_item_update("buffers"); + weechat::bar_item_update($SCRIPT_NAME); return weechat::WEECHAT_RC_OK; } @@ -1090,7 +1111,7 @@ my %info = %{$_[1]}; my $item_line = int($info{"_bar_item_line"}); undef my $hash; - if (($info{"_bar_item_name"} eq "buffers") && ($item_line >= 0) && ($item_line <= $#buffers_focus)) + if (($info{"_bar_item_name"} eq $SCRIPT_NAME) && ($item_line >= 0) && ($item_line <= $#buffers_focus)) { $hash = $buffers_focus[$item_line]; } @@ -1196,3 +1217,30 @@ } return 0; } + +sub shutdown_cb +{ + weechat::command("","/bar hide " . $SCRIPT_NAME) if ( weechat::config_boolean($options{"toggle_bar"}) eq 1 ); + return weechat::WEECHAT_RC_OK +} + +sub check_bar_item +{ + my $item = 0; + my $infolist = weechat::infolist_get("bar", "", ""); + while (weechat::infolist_next($infolist)) + { + my $bar_items = weechat::infolist_string($infolist, "items"); + if (index($bar_items,$SCRIPT_NAME) != -1) + { + my $name = weechat::infolist_string($infolist, "name"); + if ($name ne $SCRIPT_NAME) + { + $item = 1; + last; + } + } + } + weechat::infolist_free($infolist); + return $item; +} \ No newline at end of file diff -Nru weechat-scripts-20130123/perl/chatters.pl weechat-scripts-20131007/perl/chatters.pl --- weechat-scripts-20130123/perl/chatters.pl 2013-01-23 19:00:26.000000000 +0000 +++ weechat-scripts-20131007/perl/chatters.pl 2013-10-07 12:14:58.000000000 +0000 @@ -39,12 +39,14 @@ # Version 0.3: missing return value for callbacks fixed # version check added # improved option handling +# 2013-02-07, Ailin Nemui +# Version 0.4: add focus info # use strict; use warnings; -my $version = "0.3"; +my $version = "0.4"; my $script_name = "chatters"; my $weechat_version = ""; @@ -88,8 +90,12 @@ # On config change weechat::hook_config("plugins.var.perl.${script_name}.*", "config_change_cb", ""); + weechat::bar_item_new($chatters_bar_item_name, "chatters_bar_cb", ""); +# For mouse support +weechat::hook_focus($chatters_bar_item_name, "chatters_focus_cb", "") if $weechat_version >= 0x00030600; + ############################################################################### # Buffer update callback sub chatters_bar_cb @@ -131,7 +137,7 @@ { delete $chatter_groups{$channel}; } -return weechat::WEECHAT_RC_OK; + return weechat::WEECHAT_RC_OK; } ############################################################################### @@ -202,7 +208,22 @@ { cleanup_chatters(); } -return weechat::WEECHAT_RC_OK; + return weechat::WEECHAT_RC_OK; +} + +############################################################################### +# Adds nick info to focus hashtable +sub chatters_focus_cb +{ + my $channel = buf_to_channel_key($_[1]{_buffer}); + if ($channel and $chatter_groups{$channel} and + $_[1]{_bar_item_line} > 0 and $_[1]{_bar_item_line} <= keys %{ $chatter_groups{$channel} }) + { + +{ nick => (sort {uc($a) cmp uc($b)} keys %{ $chatter_groups{$channel} })[$_[1]{_bar_item_line}-1] } + } + else { + $_[1] + } } ############################################################################### diff -Nru weechat-scripts-20130123/perl/colorize_lines.pl weechat-scripts-20131007/perl/colorize_lines.pl --- weechat-scripts-20130123/perl/colorize_lines.pl 2013-01-23 19:00:24.000000000 +0000 +++ weechat-scripts-20131007/perl/colorize_lines.pl 2013-10-07 12:14:55.000000000 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2010-2012 by Nils Görs +# Copyright (c) 2010-2013 by Nils Görs # # colors the channel text with nick color and also highlight the whole line # colorize_nicks.py script will be supported @@ -20,6 +20,11 @@ # for settings see help page # # history: +# 2.1: fix: changing highlight color did not apply messages already displayed (reported by rafi_) +# 2.0: fix: debugging weechat::print() removed (thanks demure) +# 1.9: fix: display bug with nick_mode +# 1.8 add: option "use_irc_colors" (requested by Zertap) +# fix: empty char for nick_mode was used, even when "irc.look.nick_mode_empty" was OFF (reported by FlashCode) # 1.7: fix: broken lines in dcc chat (reported by equatorping) # 1.6: improved: wildcard "*" can be used for server and/or nick. (requested by ldvx) # : add: new value, "only", for option "own_lines" (read help!) @@ -65,7 +70,7 @@ use strict; my $prgname = "colorize_lines"; -my $version = "1.7"; +my $version = "2.1"; my $description = "colors text in chat area with according nick color. Highlight messages will be fully highlighted in chat area"; # default values @@ -80,6 +85,7 @@ "var_blacklist_channels" => "", "var_nicks" => "", "var_own_lines" => "off", + "var_use_irc_colors" => "off", ); my %help_desc = ( "avail_buffer" => "messages will be colored in buffer (all = all buffers, channel = channel buffers, query = query buffers (default: all ", @@ -93,11 +99,11 @@ "look_highlight_regex" => "toggle highlight color in chat area for value in option \"weechat.look.highlight_regex\" (default: off)", "nicks" => "comma separated list with nicknames. Only messages from nicks in this list will be colorized. (e.g.: freenode.nils_2,freenode.flashcode,freenode.weebot). You can use \"*\" as a wildcard (e.g.: *.nils_* to match all \"nils_\" on all servers). Also a file with nicks is allowed. The filename in option has to start with \"/\" (e.g.: /buddylist.txt). The format has to be, one nick each line with .", "own_lines" => "messages written by your own will be colored. color from \"weechat.color.chat_nick_self\" will be used. If you only want to color your lines, use value \"only\" (default: off)", + "use_irc_colors" => "if a message contains irc_color_codes, those color codes will be used instead of the nick color (default: off)", ); my $weechat_version; my $zahl = 0; -my $nick_mode = ""; my $get_prefix_action = ""; my @var_blacklist_channels = ""; my @nick_list = ""; @@ -120,6 +126,16 @@ return $string; } +if ( weechat::config_boolean(weechat::config_get("irc.network.colors_receive")) and $default_options{var_use_irc_colors} eq "on" ) +{ + my $string2 = $string; + $string2 =~ s/\[cl_irc_color\]//g; + if ( $string2 ne $string ) + { + return $string2; + } +} + if ($default_options{var_highlight} eq "off" and $default_options{var_chat} eq "off"){ # all options OFF return $string; } @@ -189,31 +205,40 @@ # check for action (/me) my $prefix_action_with_color = ""; -if (index($modifier_data,"irc_action") >= 0){ - my $prefix_action_color = weechat::color( weechat::config_color( weechat::config_get( "weechat.color.chat_prefix_action" ))); - my $prefix_action = weechat::config_string( weechat::config_get("weechat.look.prefix_action")); - $prefix_action_with_color = $prefix_action_color . $prefix_action; +if (index($modifier_data,"irc_action") >= 0) +{ +# my $prefix_action_color = weechat::color( weechat::config_color( weechat::config_get( "weechat.color.chat_prefix_action" ))); + my $prefix_action_color = weechat::color( "chat_prefix_action" ); + my $prefix_action = weechat::config_string( weechat::config_get("weechat.look.prefix_action")); + $prefix_action_with_color = $prefix_action_color . $prefix_action; } # check if look.nickmode is ON and no prefix and no query buffer -$nick_mode = ""; -my $nickmode_value = 0; +my $nick_mode = ""; +my $nick_mode_value = 0; if (($weechat_version ne "") && ($weechat_version >= 0x00030900)){ - my $temp_nickmode_value = weechat::config_integer(weechat::config_get("irc.look.nick_mode")); - $nickmode_value = 1 if ($temp_nickmode_value == 1 or $temp_nickmode_value == 3); -}else{ - $nickmode_value = weechat::config_boolean(weechat::config_get("weechat.look.nickmode")); + # 0 = none, 1 = prefix, 2 = action, 3 = both + my $temp_nickmode_value = weechat::config_string(weechat::config_get("irc.look.nick_mode")); + $nick_mode_value = 1 if ($temp_nickmode_value eq "prefix" or $temp_nickmode_value eq "both"); +} +else +{ + $nick_mode_value = weechat::config_boolean(weechat::config_get("weechat.look.nickmode")); } -if ( $nickmode_value == 1 and ($nick ne $get_prefix_action) and (index($modifier_data,"notify_private")) == -1){ -# if ($nick =~ m/^\@|^\%|^\+|^\~|^\*|^\&|^\!|^\-/) { # check for nick modes (@%+~*&!-) without colour +if ( $nick_mode_value == 1 and ($nick ne $get_prefix_action) and (index($modifier_data,"notify_private")) == -1) +{ +# if ($nick =~ m/^\@|^\%|^\+|^\~|^\*|^\&|^\!|^\-/) { # check for nick modes (@%+~*&!-) without color my $nick_pointer = weechat::nicklist_search_nick($buf_pointer,"",$nick_wo_suffix); $nick_mode = weechat::nicklist_nick_get_string($buf_pointer,$nick_pointer,"prefix"); my $color_mode = weechat::color( weechat::nicklist_nick_get_string($buf_pointer, $nick_pointer, "prefix_color") ); - if ( $nick_mode eq "" or $color_mode eq ""){ # no nick_mode! - $nick_mode = ""; - }else{ # nick_mode exists + if ( $nick_mode eq " ") + { + $nick_mode = "" if ( !weechat::config_boolean(weechat::config_get("irc.look.nick_mode_empty")) ); + } + else + { $nick_mode = $color_mode . $nick_mode; } } @@ -222,8 +247,9 @@ if ($nick_wo_suffix eq $my_nick ){ # i wrote the message return $string if check_whitelist_nicks($servername, $my_nick, $nick_wo_suffix); # check for whitelist if ($default_options{var_chat} eq "on"){ - my $nick_color = weechat::config_color(weechat::config_get("weechat.color.chat_nick_self")); # get my nick color - $nick_color = weechat::color($nick_color); +# my $nick_color = weechat::config_color(weechat::config_get("weechat.color.chat_nick_self")); # get my nick color +# my $nick_color = weechat::color($nick_color); + my $nick_color = weechat::color("chat_nick_self"); # get my nick color $line = colorize_nicks($nick_color,$modifier_data,$line); if (index($modifier_data,"irc_action") >= 0){ # /me message? @@ -242,8 +268,8 @@ # get nick color $nick = $nick_wo_suffix; -#$nick = weechat::string_remove_color($nick_wo_suffix,""); # remove colour-codes from nick -my $nick_color = weechat::info_get('irc_nick_color', $nick_wo_suffix); # get nick-colour +#$nick = weechat::string_remove_color($nick_wo_suffix,""); # remove color-codes from nick +my $nick_color = weechat::info_get('irc_nick_color', $nick_wo_suffix); # get nick-color my $var_hl_max_level_nicks_add = 0; # highlight message received? @@ -280,15 +306,14 @@ my $search_string = shell2regex($_); if ($string =~ m/\b$search_string\b/gi){ # i (ignorecase) - my $color_highlight = weechat::config_color(weechat::config_get("weechat.color.chat_highlight")); - my $color_highlight_bg = weechat::config_color(weechat::config_get("weechat.color.chat_highlight_bg")); - my $high_color = weechat::color("$color_highlight,$color_highlight_bg"); - if (index($modifier_data,"irc_action") >= 0){ - $line = colorize_nicks($high_color,$modifier_data,$line); - $nick = $prefix_action_with_color; - $line = $high_color . $nick . "\t" . $high_color . $line . weechat::color('reset'); - return $line; - } + my $high_color = weechat::color('chat_highlight'); + if (index($modifier_data,"irc_action") >= 0) + { + $line = colorize_nicks($high_color,$modifier_data,$line); + $nick = $prefix_action_with_color; + $line = $high_color . $nick . "\t" . $high_color . $line . weechat::color('reset'); + return $line; + } $line = colorize_nicks($high_color,$modifier_data,$line); $line = $nick_mode . $high_color . $nick_prefix_with_color . $nick . $nick_suffix_with_color . "\t" . $high_color . $line . weechat::color('reset'); return $line; @@ -296,12 +321,10 @@ } } # buffer_autoset is off. - if ( weechat::string_has_highlight($line, $my_nick) >= 1){ + if ( weechat::string_has_highlight($line, $my_nick) >= 1) + { # if (lc($string) =~ m/(\w.*$my_nick.*)/){ # my name called in string (case insensitiv)? - my $color_highlight = weechat::config_color(weechat::config_get("weechat.color.chat_highlight")); - my $color_highlight_bg = weechat::config_color(weechat::config_get("weechat.color.chat_highlight_bg")); - - my $high_color = weechat::color("$color_highlight,$color_highlight_bg"); + my $high_color = weechat::color('chat_highlight'); if (index($modifier_data,"irc_action") >= 0){ # action used (/me)? $line = colorize_nicks($high_color,$modifier_data,$line); @@ -338,7 +361,8 @@ if ($default_options{var_chat} eq "on"){ # chat_mode on? if ($default_options{var_shuffle} eq "on"){ # color_shuffle on? my $zahl2 = 0; - my $my_color = weechat::config_color(weechat::config_get("weechat.color.chat_nick_self"));# get my own nick colour +# my $my_color = weechat::config_color(weechat::config_get("weechat.color.chat_nick_self"));# get my own nick colour + my $my_color = weechat::color("chat_nick_self"); # get my own nick colour for (1){ # get a random colour but don't use redo if ( $zahl == ($zahl2 = int(rand(14))) or ($colours{$zahl2} eq $my_color) );# latest color nor own nick color $zahl = $zahl2; @@ -350,10 +374,8 @@ if (( $weechat_version ne "" ) && ( $weechat_version >= 0x00030400 )){ # >= v0.3.4? if ( $default_options{var_look_highlight_regex} eq "on" ){ if ( weechat::string_has_highlight_regex($line,weechat::config_string(weechat::config_get("weechat.look.highlight_regex"))) eq 1 ){ - my $color_highlight = weechat::config_color(weechat::config_get("weechat.color.chat_highlight")); - my $color_highlight_bg = weechat::config_color(weechat::config_get("weechat.color.chat_highlight_bg")); + my $high_color = weechat::color('chat_highlight'); - my $high_color = weechat::color("$color_highlight,$color_highlight_bg"); $line = colorize_nicks($high_color,$modifier_data,$line); $line = $nick_prefix_with_color . $nick_mode . $high_color . $nick . $nick_suffix_with_color . "\t" . $high_color . $line . weechat::color('reset'); return $line; @@ -378,6 +400,35 @@ } } # end of sub colorize_cb{} + +# check for irc color codes in message. +# if exists, add "[cl_irc_color]" to message body +# :nick!host PRIVMSG #channel : 02message +sub irc_in_privmsg_cb +{ + my ( $data, $modifier, $modifier_data, $string ) = @_; + + if ( weechat::config_boolean(weechat::config_get("irc.network.colors_receive")) and $default_options{var_use_irc_colors} eq "on" ) + { + # search for color code in string! + if ( $string =~ /\03/ ) + { + $string =~ m/^(.*) :(.*)/; + my $msg_part1 = $1; + if (index($msg_part1,"PRIVMSG") == -1) + { # its neither a channel nor a query buffer + return $string; + } + if (index($msg_part1,"NOTICE") >= 0) + { + return $string; + } + my $msg_part2 = "[cl_irc_color]" . $2; + $string = $msg_part1 . " :" . $msg_part2; + } + } + return $string; +} # whitelist nicks : 0 = color, 1 = no color sub check_whitelist_nicks{ my ( $servername, $my_nick, $nick_wo_suffix ) = @_; @@ -434,8 +485,8 @@ my $pyth_ptn = weechat::infolist_get("python_script","","colorize_nicks"); weechat::infolist_next($pyth_ptn); -if ( "colorize_nicks" eq weechat::infolist_string($pyth_ptn,"name") ){ # does colorize_nicks is installed? - $line = weechat::hook_modifier_exec( "colorize_nicks",$mf_data,$line); # call colorize_nicks function and color the nick(s) +if ( "colorize_nicks" eq weechat::infolist_string($pyth_ptn,"name") ){ # does colorize_nicks is installed? + $line = weechat::hook_modifier_exec( "colorize_nicks",$mf_data,$line); # call colorize_nicks function and color the nick(s) my @array = ""; my $color_code_reset = weechat::color('reset'); @array=split(/$color_code_reset/,$line); @@ -443,7 +494,7 @@ foreach (@array){ $new_line .= $nick_color . $_ . weechat::color('reset'); } - $new_line =~ s/\s+$//g; # remove space at end + $new_line =~ s/\s+$//g; # remove space at end $line = $new_line; } weechat::infolist_free($pyth_ptn); @@ -580,6 +631,7 @@ $get_prefix_action = weechat::config_string(weechat::config_get("weechat.look.prefix_action")); +weechat::hook_modifier("1000|irc_in_privmsg","irc_in_privmsg_cb", ""); # use higher prio than "weechat_print"! weechat::hook_modifier("weechat_print","colorize_cb", ""); weechat::hook_modifier("colorize_lines","colorize_cb", ""); diff -Nru weechat-scripts-20130123/perl/coords.pl weechat-scripts-20131007/perl/coords.pl --- weechat-scripts-20130123/perl/coords.pl 2013-01-23 19:00:27.000000000 +0000 +++ weechat-scripts-20131007/perl/coords.pl 2013-10-07 12:14:58.000000000 +0000 @@ -21,11 +21,11 @@ in weechat to load the script. Use - /copywin + /coords to open the coords screen, or conveniently - /key bind meta-/ /copywin / + /key bind meta-/ /coords / to open it with the Alt+/ keybinding. @@ -50,7 +50,7 @@ =head1 USAGE -to open the url overlay on a window, type C or use the +to open the url overlay on a window, type C or use the keybinding you created as explained in the L. =head2 Selection Mode @@ -62,7 +62,7 @@ =head2 URL Mode to switch between selection mode and URL mode, use the C key or -type the command C to directly start in URL mode. +type the command C to directly start in URL mode. inside the overlay, you can use Arrow-Up and Arrow-Down keys to select URLs. This script will try to copy them into your selection clipboard @@ -234,20 +234,20 @@ =head2 copybuf_short_name -short_name to use for copywin buffer. it is set to the copy sign by +short_name to use for coords buffer. it is set to the copy sign by default to not disturb buffers bar width, set to the empty string to have window position and size shown =head2 mouse.copy_on_click set to on if it should be possible to directly click on URLs and -select text, set to off if mouse should only work in open copywin +select text, set to off if mouse should only work in open coords buffer =head2 mouse.close_on_release -set to on or a delay (in ms) to autoclose copywin buffer opened by -I on button release, set to off if the copywin buffer +set to on or a delay (in ms) to autoclose coords buffer opened by +I on button release, set to off if the coords buffer should stay open after click =head2 mouse.click_select_pane @@ -263,7 +263,7 @@ =head2 mouse.url_open_2nd_click if this is set, URLs are only opened when clicked twice (in the same -incarnation of a copywin) instead of on first click. it can be set to +incarnation of a coords buffer) instead of on first click. it can be set to a delay (in ms) that will be added to the I delay if the script is waiting for a second click on the URL to happen @@ -303,7 +303,7 @@ use MIME::Base64; use constant SCRIPT_NAME => 'coords'; -weechat::register(SCRIPT_NAME, 'Nei ', '0.6', 'GPL3', 'copy text and urls', 'stop_coords', '') || return; +weechat::register(SCRIPT_NAME, 'Nei ', '0.7', 'GPL3', 'copy text and urls', 'stop_coords', '') || return; sub SCRIPT_FILE() { my $infolistptr = weechat::infolist_get('perl_script', '', SCRIPT_NAME); my $filename = weechat::infolist_string($infolistptr, 'filename') if weechat::infolist_next($infolistptr); @@ -314,7 +314,7 @@ { package Nlib; # this is a weechat perl library -use strict; use warnings; +use strict; use warnings; no warnings 'redefine'; ## i2h -- copy weechat infolist content into perl hash ## $infolist - name of the infolist in weechat @@ -394,6 +394,7 @@ my ($arg, $name, $var) = splice @_, 0, 3; my $hdata = weechat::hdata_get($name); + $var =~ s/!(.*)/weechat::hdata_get_string($hdata, $1)/e; (my $plain_var = $var) =~ s/^\d+\|//; my $type = weechat::hdata_get_var_type_string($hdata, $plain_var); if ($type eq 'pointer') { @@ -749,7 +750,7 @@ $pt->output_string(\my $ss_f); $pt->parse_string_document($ss); - my ($res) = $ss_f =~ /^\s*\Q$setting\E\s+(.*)\s*$/; + my ($res) = $ss_f =~ /^\s*\Q$setting\E\s+(.*)\s*/; $res } @@ -786,7 +787,10 @@ my $name = shift; if (my $obuf = weechat::buffer_search('perl', "man $name")) { - weechat::buffer_close($obuf); + eval qq{ + package $caller_package; + weechat::buffer_close(\$obuf); + }; } my @wee_keys = Nlib::i2h('key'); @@ -832,7 +836,7 @@ weechat::buffer_set($buf, 'key_bind_q', '/buffer close'); weechat::print($buf, " \t".mangle_man_for_wee($_)) - for `pod2man \Q$file\E | GROFF_NO_SGR=1 nroff -mandoc -rLL=${width}n -rLT=${width}n -Tutf8 2>/dev/null`; + for `pod2man \Q$file\E 2>/dev/null | GROFF_NO_SGR=1 nroff -mandoc -rLL=${width}n -rLT=${width}n -Tutf8 2>/dev/null`; weechat::command($buf, '/window scroll_top'); unless (hdh($buf, 'buffer', 'lines', 'lines_count') > 0) { @@ -852,7 +856,7 @@ 1 } -use constant CMD_COPYWIN => 'copywin'; +use constant CMD_COPYWIN => SCRIPT_NAME; weechat::hook_command(CMD_COPYWIN, 'copy active window for hyperlink operations or free selection of text', '[/] || url nicks channels', 'if any or more arguments are given, go into hyperlink mode and set this filter.'."\n". @@ -872,8 +876,10 @@ weechat::hook_hsignal(SCRIPT_NAME, 'hsignal_evt', ''); weechat::key_bind('mouse', +{ map { $_ => 'hsignal:'.SCRIPT_NAME } - '@chat:button1*', '@chat:button1-event-*' + '@chat:button1*', '@chat:button1-event-*', '@chat(perl.[*):button1' }); +weechat::command('', '/alias copywin '.CMD_COPYWIN) + if 'copywin' ne CMD_COPYWIN && !Nlib::i2h('alias', '', 'copywin') && Nlib::i2h('hook', '', 'command,alias'); # downloaded line fields use constant TRACE => -1; @@ -987,7 +993,8 @@ $prefix = $repl if length $repl; $prefix = '' if $repl eq ' '; } - $base_trace->[5] = (sort { $a <=> $b } ($no_prefix_align?$no_prefix_align+1:0), screen_length fu8on weechat::string_remove_color($prefix, ''))[0]; + $base_trace->[5] = (sort { $a <=> $b } #($no_prefix_align?$no_prefix_align+1:0), + screen_length fu8on weechat::string_remove_color($prefix, ''))[0]; } } $base_trace->[1] = $show_time ? screen_length fu8on weechat::string_remove_color($lineinfo->{'str_time'}, '') : 0; @@ -3103,6 +3110,7 @@ sub close_copywin { copywin_cmd(undef, $ACT_STR->[BUFPTR], '**q') if $ACT_STR; + weechat::WEECHAT_RC_OK } sub init_coords { diff -Nru weechat-scripts-20130123/perl/iset.pl weechat-scripts-20131007/perl/iset.pl --- weechat-scripts-20130123/perl/iset.pl 2013-01-23 19:00:20.000000000 +0000 +++ weechat-scripts-20131007/perl/iset.pl 2013-10-07 12:14:52.000000000 +0000 @@ -1,5 +1,5 @@ # -# Copyright (C) 2008-2012 Sebastien Helleu +# Copyright (C) 2008-2013 Sebastien Helleu # Copyright (C) 2010-2012 Nils Görs # # This program is free software; you can redistribute it and/or modify @@ -19,11 +19,19 @@ # # History: # -# 2012-12-16, nils_2 : +# 2013-08-03, Sebastien Helleu : +# version 3.2: allow "q" as input in iset buffer to close it +# 2013-07-14, Sebastien Helleu : +# version 3.1: remove unneeded calls to iset_refresh() in mouse callback +# (faster mouse actions when lot of options are displayed), +# fix bug when clicking on a line after the last option displayed +# 2013-04-30, arza : +# version 3.0: simpler title, fix refresh on unset +# 2012-12-16, nils_2 : # version 2.9: fix focus window with iset buffer on mouse click -# 2012-08-25, nils_2 : +# 2012-08-25, nils_2 : # version 2.8: most important key and mouse bindings for iset buffer added to title-bar (idea The-Compiler) -# 2012-07-31, nils_2 : +# 2012-07-31, nils_2 : # version 2.7: add combined option and value search (see /help iset) # : add exact value search (see /help iset) # : fix problem with metacharacter in value search @@ -100,7 +108,7 @@ use strict; my $PRGNAME = "iset"; -my $VERSION = "2.9"; +my $VERSION = "3.2"; my $DESCR = "Interactive Set for configuration options"; my $AUTHOR = "Sebastien Helleu "; my $LICENSE = "GPL3"; @@ -124,8 +132,8 @@ # search modes: 0 = index() on value, 1 = grep() on value, 2 = grep() on option, 3 = grep on option & value my $search_mode = 2; my $search_value = ""; -my $help_text_keys = "Keys: alt+space: toggle boolean on/off, alt+'+'/'-': increase/decrease value (for integer or color), alt+enter: set new value for option, alt+'i',alt+'r': reset value of option, alt+'i',alt+'u': unset option, alt+'v': toggle help bar on/off, alt+'p': toggle 'plugin_description' on/off"; -my $help_text_mouse = "Mouse: left button: select an option from list, right button: toggle boolean (on/off) or set a new value for option (edit with command line), right button + gesture left/right: increase/decrease value (for integer or color)"; +my $help_text_keys = "alt + space: toggle, +/-: increase/decrease, enter: change, ir: reset, iu: unset, v: toggle help bar"; +my $help_text_mouse = "Mouse: left: select, right: toggle/set, right + drag left/right: increase/decrease"; my %options_iset; my %mouse_keys = ("\@chat(perl.$PRGNAME):button1" => "hsignal:iset_mouse", @@ -143,7 +151,7 @@ my $show_filter = ""; if ($search_mode eq 0) { - $iset_filter_title = "Filter (by value): "; + $iset_filter_title = "(value) "; $show_filter = $search_value; if ( substr($show_filter,0,1) eq weechat::config_string($options_iset{"value_search_char"}) ) { @@ -152,39 +160,31 @@ } elsif ($search_mode eq 1) { - $iset_filter_title = "Filter (by value): "; + $iset_filter_title = "(value) "; $show_filter = "*".$search_value."*"; } elsif ($search_mode eq 2) { - $iset_filter_title = "Filter: "; + $iset_filter_title = ""; $filter = "*" if ($filter eq ""); $show_filter = $filter; } elsif ($search_mode eq 3) { - $iset_filter_title = "Filter (by option): "; + $iset_filter_title = "(option) "; $show_filter = $filter .weechat::color("default") - ." / (value): " + ." / (value) " .weechat::color("yellow") ."*".$search_value."*"; } - my $postfix = "s"; - my $option_txt = " option"; - my $opt_txt = $option_txt; - $opt_txt = $option_txt.$postfix if (@options_names > 1); - my $show_plugin_descr_txt = ""; - $show_plugin_descr_txt = " (plugins description hidden)" if (weechat::config_boolean($options_iset{"show_plugin_description"}) == 0); weechat::buffer_set($iset_buffer, "title", - "Interactive set (iset.pl v$VERSION) | " - .$iset_filter_title + $iset_filter_title .weechat::color("yellow") .$show_filter .weechat::color("default")." | " .$current_line_counter - .@options_names.$opt_txt - .$show_plugin_descr_txt + .@options_names ." | " .$help_text_keys ." | " @@ -217,6 +217,11 @@ sub iset_buffer_input { my ($data, $buffer, $string) = ($_[0], $_[1], $_[2]); + if ($string eq "q") + { + weechat::buffer_close($buffer); + return weechat::WEECHAT_RC_OK; + } $search_value = ""; my @cmd_array = split(/ /,$string); my $array_count = @cmd_array; @@ -257,7 +262,6 @@ } weechat::buffer_set($iset_buffer, "localvar_set_iset_search_mode", $search_mode); weechat::buffer_clear($buffer); - iset_title(); $current_line = 0; iset_refresh(); return weechat::WEECHAT_RC_OK; @@ -506,7 +510,7 @@ $iset_buffer = weechat::buffer_search($LANG, $PRGNAME); if ($iset_buffer ne "") { - weechat::buffer_clear($iset_buffer); + weechat::buffer_clear($iset_buffer) unless defined $_[0]; # iset_full_refresh(1) does a full refresh without clearing buffer # search for "*" in $filter. if ($filter =~ m/\*/ and $search_mode == 2) { @@ -544,14 +548,17 @@ sub iset_set_current_line { my $new_current_line = $_[0]; - my $old_current_line = $current_line; - $current_line = $new_current_line; - $current_line = $#options_names if ($current_line > $#options_names); - if ($old_current_line != $current_line) - { - iset_refresh_line($old_current_line); - iset_refresh_line($current_line); - weechat::bar_item_update("isetbar_help") if (weechat::config_boolean($options_iset{"show_help_bar"}) == 1); + if ($new_current_line >= 0) + { + my $old_current_line = $current_line; + $current_line = $new_current_line; + $current_line = $#options_names if ($current_line > $#options_names); + if ($old_current_line != $current_line) + { + iset_refresh_line($old_current_line); + iset_refresh_line($current_line); + weechat::bar_item_update("isetbar_help") if (weechat::config_boolean($options_iset{"show_help_bar"}) == 1); + } } } @@ -626,6 +633,7 @@ if ($start_line_y <= $current_line - $chat_height) { weechat::command($iset_buffer, "/window scroll ".$window_number."+".($current_line - $start_line_y - $chat_height + 1)); + } } } @@ -673,7 +681,8 @@ } else { - iset_full_refresh(); + iset_full_refresh(1); # if not found, refresh fully without clearing buffer + weechat::print_y($iset_buffer, $#options_names + 1, ""); } weechat::infolist_free($infolist); } @@ -714,9 +723,7 @@ { $option = weechat::config_get($option); weechat::config_option_unset($option) if ($option ne ""); - weechat::buffer_clear($iset_buffer); } - iset_refresh(); } @@ -746,7 +753,6 @@ iset_refresh(); weechat::buffer_set($iset_buffer, "display", "1"); # $filter = $var_value; - iset_title(); return weechat::WEECHAT_RC_OK; } else @@ -808,7 +814,6 @@ if ($args eq "**refresh") { iset_full_refresh(); - iset_title(); } if ($args eq "**up") { @@ -817,7 +822,6 @@ $current_line--; iset_refresh_line($current_line + 1); iset_refresh_line($current_line); - iset_title(); iset_check_line_outside_window(); } } @@ -828,7 +832,6 @@ $current_line++; iset_refresh_line($current_line - 1); iset_refresh_line($current_line); - iset_title(); iset_check_line_outside_window(); } } @@ -888,7 +891,6 @@ if ($args eq "**unset") { iset_unset_option($options_names[$current_line]); - iset_title(); } if ($args eq "**toggle_help") { @@ -1112,24 +1114,18 @@ { if ($hash{"_key"} eq "button1") { - $current_line = $hash{"_chat_line_y"}; - iset_refresh_line($current_line); - iset_refresh(); + iset_set_current_line($hash{"_chat_line_y"}); } elsif ($hash{"_key"} eq "button2") { if ($options_types[$hash{"_chat_line_y"}] eq "boolean") { iset_set_option($options_names[$hash{"_chat_line_y"}], "toggle"); - $current_line = $hash{"_chat_line_y"}; - iset_refresh_line($current_line); - iset_refresh(); + iset_set_current_line($hash{"_chat_line_y"}); } elsif ($options_types[$hash{"_chat_line_y"}] eq "string") { - $current_line = $hash{"_chat_line_y"}; - iset_refresh_line($current_line); - iset_refresh(); + iset_set_current_line($hash{"_chat_line_y"}); weechat::command("", "/$PRGNAME **set"); } } @@ -1137,20 +1133,16 @@ { if ($options_types[$hash{"_chat_line_y"}] eq "integer" or ($options_types[$hash{"_chat_line_y"}] eq "color")) { - $current_line = $hash{"_chat_line_y"}; - iset_refresh_line($current_line); - iset_refresh(); + iset_set_current_line($hash{"_chat_line_y"}); my $distance = distance($hash{"_chat_line_x"},$hash{"_chat_line_x2"}); weechat::command("", "/repeat $distance /$PRGNAME **decr"); } } elsif ($hash{"_key"} eq "button2-gesture-right" or $hash{"_key"} eq "button2-gesture-right-long") { - if ($options_types[$hash{"_chat_line_y"}] eq "integer" or ($options_types[$hash{"_chat_line_y"}] eq "color")) + if ($options_types[$hash{"_chat_line_y"}] eq "integer" or ($options_types[$hash{"_chat_line_y"}] eq "color")) { - $current_line = $hash{"_chat_line_y"}; - iset_refresh_line($current_line); - iset_refresh(); + iset_set_current_line($hash{"_chat_line_y"}); my $distance = distance($hash{"_chat_line_x"},$hash{"_chat_line_x2"}); weechat::command("", "/repeat $distance /$PRGNAME **incr"); } @@ -1272,7 +1264,7 @@ $options_iset{"show_plugin_description"} = weechat::config_new_option( $iset_config_file, $section_help, "show_plugin_description", "boolean", "Show plugin description in iset buffer", "", 0, 0, - "on", "on", 0, "", "", "full_refresh_cb", "", "", ""); + "off", "off", 0, "", "", "full_refresh_cb", "", "", ""); # section "look" my $section_look = weechat::config_new_section($iset_config_file, "look", 0, 0, "", "", "", "", "", "", "", "", "", ""); @@ -1342,11 +1334,11 @@ iset_config_read(); weechat::hook_command($PRGNAME, "Interactive set", "f || s
|| [=][=]", - "f file : show options for a file\n". - "s section : show options for a section\n". - "text : show options with 'text' in name\n". - weechat::config_string($options_iset{"value_search_char"})."text : show options with 'text' in value\n". - weechat::config_string($options_iset{"value_search_char"}).weechat::config_string($options_iset{"value_search_char"})."text : show options with exact 'text' in value\n\n". + "f file : show options for a file\n". + "s section: show options for a section\n". + "text : show options with 'text' in name\n". + weechat::config_string($options_iset{"value_search_char"})."text : show options with 'text' in value\n". + weechat::config_string($options_iset{"value_search_char"}).weechat::config_string($options_iset{"value_search_char"})."text : show options with exact 'text' in value\n\n". "Keys for iset buffer:\n". "f11,f12 : move iset content left/right\n". "up,down : move one option up/down\n". @@ -1363,11 +1355,11 @@ "alt+'v' : toggle help bar on/off\n". "alt+'p' : toggle option \"show_plugin_description\" on/off\n". "\n". - "standard mouse actions:\n". - "wheel up / wheel down : move option up/down\n". - "left-mouse-button : select an option from list\n". - "right-mouse-button : toggle boolean (on/off) or set a new value for option (edit it with command line)\n". - "right-mouse-button + gesture left/right: increase/decrease value (for integer or color)\n". + "Mouse actions:\n". + "wheel up/down : move cursor up/down\n". + "left button : select an option from list\n". + "right button : toggle boolean (on/off) or set a new value for option (edit it with command line)\n". + "right button + drag left/right: increase/decrease value (for integer or color)\n". "\n". "Examples:\n". " show options for file 'weechat'\n". diff -Nru weechat-scripts-20130123/perl/isgd.pl weechat-scripts-20131007/perl/isgd.pl --- weechat-scripts-20130123/perl/isgd.pl 2013-01-23 19:00:26.000000000 +0000 +++ weechat-scripts-20131007/perl/isgd.pl 2013-10-07 12:14:57.000000000 +0000 @@ -1,5 +1,5 @@ # -# Copyright (C) 2011-2012 stfn +# Copyright (C) 2011-2013 stfn # # 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 @@ -27,44 +27,80 @@ my %SCRIPT = ( name => 'isgd', author => 'stfn ', - version => '0.3', + version => '0.6', license => 'GPL3', - desc => 'Shorten URLs with is.gd on command', + desc => 'Shorten URLs with is.gd on demand or automatically', opt => 'plugins.var.perl', ); -my %OPTIONS = ( - color => 'white', # color used for printing short URLs +my %OPTIONS_DEFAULT = ( + 'color' => ['white', 'Color used for printing shortened URLs'], + 'auto' => ['off', 'Shorten all incoming URLs automatically'], ); +my %OPTIONS = (); my $SHORTENER_URL = "http://is.gd/create.php?format=simple&url="; +my $SHORTENER_BASE = "http://is.gd/"; my $TIMEOUT = 30 * 1000; -my %LOOKUP; +my $CACHE_MAX_SIZE = 128; +my (%LOOKUP, %CACHE); weechat::register($SCRIPT{"name"}, $SCRIPT{"author"}, $SCRIPT{"version"}, $SCRIPT{"license"}, $SCRIPT{"desc"}, "", ""); +weechat::hook_print("", "", "", 1, "print_cb", ""); weechat::hook_command($SCRIPT{"name"}, $SCRIPT{"desc"}, - "[ ...]\n" . - " []\n" . - " []\n", + "[-o] [||]\n", + " -o: send shortened URL to current buffer as input\n" . " URL: URL to shorten (multiple URLs may be given)\n" . " number: shorten up to n last found URLs in current buffer\n" . "partial expr: shorten last found URL in current buffer which matches the given partial expression\n" . "\nWithout any URL arguments, the last found URL in the current buffer will be shortened.\n\n" . "Examples:\n" . + " /isgd\n" . " /isgd http://google.de\n" . + " /isgd -o http://slashdot.org/\n" . " /isgd 3\n" . " /isgd youtube", "", "command_cb", ""); init_config(); +# +# Catch printed messages +# +sub print_cb +{ + my ($data, $buffer, $date, $tags, $displayed, $highlight, $prefix, $message) = @_; + my @URLs; + + if ($OPTIONS{auto} ne "on" || $tags =~ /\bno_log\b/) { + return weechat::WEECHAT_RC_OK; + } + + # Find URLs + @URLs = grep_urls($message); + + # Process all found URLs + shorten_urls(\@URLs, $buffer); + + return weechat::WEECHAT_RC_OK; +} + +# +# /isgd +# sub command_cb { my ($data, $buffer, $args) = @_; + my $send = 0; my @URLs; - # If URLs were provided in command arguments, shorten them - while ($args =~ m{(https?://\S+)}gi) { - push(@URLs, $1); + # Check for command switch + if ($args =~ /^-o/) { + $args =~ s/^-o//; + $send = 1; } + + # If URLs were provided in command arguments, shorten them + @URLs = grep_urls($args); + # Otherwise search backwards in lines of current buffer if (@URLs == 0) { # @@ -74,69 +110,143 @@ # my $match = ""; $match = $1 if ($count == 0 && $args =~ /^(\S+)$/); - - my $infolist = weechat::infolist_get("buffer_lines", $buffer, ""); $count = 1 if ($count == 0); - while (weechat::infolist_prev($infolist) == 1) { - my $message = weechat::infolist_string($infolist, "message"); - while ($message =~ m{(https?://\S+)}gi) { - my $url = $1; - if ($match eq "" || $url =~ /\Q$match\E/i) { - push(@URLs, $url) unless ($url =~ m{^https?://is\.gd/}gi); + + # Iterate through lines of buffer backwards + my $own_lines = weechat::hdata_pointer(weechat::hdata_get("buffer"), $buffer, "own_lines"); + if ($own_lines) { + my $line = weechat::hdata_pointer(weechat::hdata_get("lines"), $own_lines, "last_line"); + my $hdata_line = weechat::hdata_get("line"); + my $hdata_line_data = weechat::hdata_get("line_data"); + while ($line) { + my $data = weechat::hdata_pointer($hdata_line, $line, "data"); + if ($data) { + my $message = weechat::hdata_string($hdata_line_data, $data, "message"); + my $tags = weechat::hdata_string($hdata_line_data, $data, "tags"); + + foreach (grep_urls($message)) { + my $url = $_; + if ($match eq "" || $url =~ /\Q$match\E/i) { + push(@URLs, $url) unless ($tags =~ /\bno_log\b/); + } + } + last if (@URLs >= $count); } + $line = weechat::hdata_move($hdata_line, $line, -1); } - last if (@URLs >= $count); } - weechat::infolist_free($infolist); + } + # Now process all found URLs + shorten_urls(\@URLs, $buffer, $send); + + return weechat::WEECHAT_RC_OK; +} + +# +# Shortens a list of URLs +# +sub shorten_urls($$$) +{ + my @URLs = @{$_[0]}; + my $buffer = $_[1]; + my $send = $_[2]; + foreach (@URLs) { - my $cmd = "url:$SHORTENER_URL" . CGI::escape($_); - $LOOKUP{$cmd} = $_; - weechat::hook_process($cmd, $TIMEOUT, "process_cb", $buffer); + my $url = $_; + my $cmd = "url:$SHORTENER_URL" . CGI::escape($url); + $LOOKUP{$cmd} = $url; + + if (my $url_short = $CACHE{$cmd}) { + if ($send) { + weechat::command($buffer, $url_short); + } else { + print_url($buffer, $url_short, $url); + } + } else { + weechat::hook_process($cmd, $TIMEOUT, $send ? "url_send_cb" : "url_cb", $buffer); + } + } +} + +sub url_cb +{ + my ($data, $command, $return_code, $out, $err) = @_; + my $buffer = $data; + my $url_short = $out; + + if ($return_code == 0 && $url_short) { + cache_url($command, $url_short); + print_url($buffer, $url_short, $LOOKUP{$command}); } return weechat::WEECHAT_RC_OK; } -sub process_cb +sub url_send_cb { my ($data, $command, $return_code, $out, $err) = @_; my $buffer = $data; - my $url = $out; + my $url_short = $out; - if ($return_code == 0 && $url) { - print_url($buffer, $url, $LOOKUP{$command}); + if ($return_code == 0 && $url_short) { + cache_url($command, $url_short); + weechat::command($buffer, $url_short); } return weechat::WEECHAT_RC_OK; } +sub grep_urls($) +{ + my $str = $_[0]; + my @urls; + while ($str =~ m{(https?://\S+)}gi) { + push(@urls, $1) unless ($1 =~ /^\Q$SHORTENER_BASE\E/); + } + return @urls; +} + sub print_url($$$) { - my ($buffer, $url, $cmd) = @_; - my $domain = ""; - $domain = $1 if ($cmd =~ m{^https?://([^/]+)}gi); - weechat::print_date_tags($buffer, 0, "no_log", weechat::color($OPTIONS{color}) . "$url ($domain)"); + my ($buffer, $url_short, $cmd) = @_; + my $domain = ""; + $domain = $1 if ($cmd =~ m{^https?://([^/]+)}gi); + weechat::print_date_tags($buffer, 0, "no_log", weechat::color($OPTIONS{color}) . "$url_short ($domain)"); +} + +sub cache_url($$) +{ + my ($command, $url_short) = @_; + %CACHE = () if (keys(%CACHE) > $CACHE_MAX_SIZE); + $CACHE{$command} = $url_short; } +# +# Handle config stuff +# sub init_config { weechat::hook_config("$SCRIPT{'opt'}.$SCRIPT{'name'}.*", "config_cb", ""); - foreach my $option (keys %OPTIONS) { + my $version = weechat::info_get("version_number", "") || 0; + foreach my $option (keys %OPTIONS_DEFAULT) { if (!weechat::config_is_set_plugin($option)) { - weechat::config_set_plugin($option, $OPTIONS{$option}); + weechat::config_set_plugin($option, $OPTIONS_DEFAULT{$option}[0]); + $OPTIONS{$option} = $OPTIONS_DEFAULT{$option}[0]; } else { $OPTIONS{$option} = weechat::config_get_plugin($option); } + if ($version >= 0x00030500) { + weechat::config_set_desc_plugin($option, $OPTIONS_DEFAULT{$option}[1]." (default: \"".$OPTIONS_DEFAULT{$option}[0]."\")"); + } } } sub config_cb { my ($pointer, $name, $value) = @_; - $name = substr($name, length("$SCRIPT{'opt'}.$SCRIPT{'name'}."), length($name)); + $name = substr($name, length("$SCRIPT{opt}.$SCRIPT{name}."), length($name)); $OPTIONS{$name} = $value; - return weechat::WEECHAT_RC_OK; } diff -Nru weechat-scripts-20130123/perl/join2fast.pl weechat-scripts-20131007/perl/join2fast.pl --- weechat-scripts-20130123/perl/join2fast.pl 2013-01-23 19:00:27.000000000 +0000 +++ weechat-scripts-20131007/perl/join2fast.pl 2013-10-07 12:14:58.000000000 +0000 @@ -1,4 +1,4 @@ -# Copyright (C) 2012 Stefan Wold +# Copyright (C) 2012-2013 Stefan Wold # # 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 @@ -14,39 +14,67 @@ # along with this program. If not, see . # # -# Automatically join channels on UnderNET that get throttled due to "Target change too fast". +# Source available on GitHUB: https://github.com/Ratler/join2fast +# +# +# Automatically queue and join channels on UnderNET that get throttled due to "Target change too fast". +use 5.010; +use POSIX qw/strftime/; use strict; use warnings; my $SCRIPT_NAME = "join2fast"; -my $VERSION = "0.5"; -my $weechat_version = ""; +my $VERSION = "0.8.1"; my %timers; +my %next_join; my %channel_list; +my %default_options = ('timer_delay' => ['4', 'default delay in seconds added to the timer before trying to join the next channel in the list'], + 'date_format' => ['%H:%M:%S', 'date and time format for time of the next join. Used by join2fast bar item.'], + 'hide_event_msg' => ['on', 'hide target change too fast message']); +my %options = (); # Register script weechat::register($SCRIPT_NAME, "Ratler ", $VERSION, "GPL3", - "Automatically join channels on UnderNET that get throttled due to \"Target change too fast\"", "", ""); + "Automatically join channels on UnderNET that get throttled due to \"Target change too fast\"", "clear_all_on_script_unload", ""); -$weechat_version = weechat::info_get("version_number", ""); +my $weechat_version = weechat::info_get("version_number", "") || 0; if ($weechat_version < 0x00030200) { weechat::print("", weechat::prefix("error") . "$SCRIPT_NAME: requires weechat >= v0.3.2"); weechat::command("", "/wait 1ms /perl unload $SCRIPT_NAME"); } -# Callback for "Target changed too fast" events -weechat::hook_signal("*,irc_raw_in_439", "event_439_cb", ""); +# Initialize config +init_config(); -sub event_439_cb { - # $_[1] - name of the event - # $_[2] - the message (:server 439 nick #channel :Target change too fast. Please wait 17 seconds.) +# Hook command /j2f +weechat::hook_command("j2f", + "list/clear join2fast queue", + "[list] | [clear [server]]", + " list: list current queues\n". + " clear [server]: clear all queues or the queue for a specific server", + "list || clear %(irc_servers)", + "j2f_command_cb", ""); - my $server = (split ",", $_[1])[0]; - my @msg = split " ", $_[2]; - my $channel = $msg[3]; - my $delay = $msg[10]; +# Hook server disconnect to clear active queue +weechat::hook_signal("irc_server_disconnected", "clear_queue_on_disconnect", ""); + +# Callback for "Target change too fast" events +weechat::hook_modifier("irc_in_439", "event_439_cb", ""); + +# Setup bar item +weechat::bar_item_new($SCRIPT_NAME, "bar_cb", ""); + +sub event_439_cb { + my ($data, $modifier, $server, $string) = @_; + # $string - the message (:server 439 nick #channel :Target change too fast. Please wait 17 seconds.) + my $channel = (split " ", $string)[3]; + my $delay = (split " ", $string)[10]; + + # Return if target is not a channel + # TODO: Add option to allow queueing private messages + return $string unless $channel =~ /^(#|&)/; # Check if channel has been already added or add it if (!exists($channel_list{$server}) or ((ref $channel_list{$server} eq 'ARRAY') and !($channel ~~ @{$channel_list{$server}}))) { @@ -54,9 +82,36 @@ } # Reset timer to the last delay received - weechat::unhook($timers{$server}) if $timers{$server}; + weechat::unhook($timers{$server}) if exists($timers{$server}); + + $next_join{$server} = {timestamp => time() + $delay + 2}; $timers{$server} = weechat::hook_timer(($delay + 2) * 1000, 0, 1, "join_channel_cb", $server); + # Update bar + weechat::bar_item_update($SCRIPT_NAME); + + return lc($options{hide_event_msg}) eq 'off' ? $string : ""; +} + +sub clear_queue_on_disconnect { + my $server = $_[2]; + + if (exists($channel_list{$server})) { + delete $channel_list{$server}; + delete $next_join{$server}; + weechat::bar_item_update($SCRIPT_NAME); + } + + return weechat::WEECHAT_RC_OK; +} + +sub clear_all_on_script_unload { + foreach my $server (keys %timers) { + weechat::unhook($timers{$server}); + } + undef %channel_list; + undef %next_join; + return weechat::WEECHAT_RC_OK; } @@ -66,30 +121,96 @@ if ((ref $channel_list{$server} eq 'ARRAY') and scalar @{$channel_list{$server}} > 0) { my $channel = pop @{$channel_list{$server}}; - # Save current buffer - my $buffer_ptr = weechat::current_buffer(); - my $buffer_name = weechat::buffer_get_string($buffer_ptr, "name"); - if ($weechat_version >= 0x00040000) { weechat::command("", "/join -noswitch -server $server $channel"); } else { + # Save current buffer + my $buffer_ptr = weechat::current_buffer(); + my $buffer_name = weechat::buffer_get_string($buffer_ptr, "name"); + weechat::command("", "/join -server $server $channel"); - } - # Switch back to the old buffer (a bit flakey) - disabled when irc.look.buffer_switch_join is set to off - # or weechat version >= 0.4.0 - my $option = weechat::config_get("irc.look.buffer_switch_join"); - if (($weechat_version < 0x00040000) and weechat::config_boolean($option)) { - weechat::command("", "/wait 1s /buffer $buffer_name"); + # Switch back to the old buffer (a bit flakey) - disabled when irc.look.buffer_switch_join is set to off + my $option = weechat::config_get("irc.look.buffer_switch_join"); + if (weechat::config_boolean($option)) { + weechat::command("", "/wait 1s /buffer $buffer_name"); + } } # Setup a new timer if ((ref $channel_list{$server} eq 'ARRAY') and scalar @{$channel_list{$server}} > 0) { - $timers{$server} = weechat::hook_timer(4 * 1000, 0, 1, "join_channel_cb", $server); + $timers{$server} = weechat::hook_timer($options{timer_delay} * 1000, 0, 1, "join_channel_cb", $server); + $next_join{$server} = {timestamp => time() + $options{timer_delay}}; } else { delete $channel_list{$server}; + delete $next_join{$server}; } } + # Update bar + weechat::bar_item_update($SCRIPT_NAME); + return weechat::WEECHAT_RC_OK; } + +sub bar_cb { + my $queue_size = 0; + + foreach my $server (keys %channel_list) { + $queue_size += scalar @{$channel_list{$server}}; + } + + return $queue_size > 0 ? "Q: $queue_size N: " . get_next_join_time() : ""; +} + +sub get_next_join_time { + my $key = (sort {$next_join{$a}->{timestamp} <=> $next_join{$b}->{timestamp}} keys (%next_join))[0]; + return strftime($options{date_format}, localtime($next_join{$key}{timestamp})); +} + +sub j2f_command_cb { + my ($data, $buffer, $args) = @_; + my ($option, $arg) = split " ", $args; + + if ($option eq 'list') { + if (scalar (keys %channel_list) > 0) { + foreach my $server (keys %channel_list) { + weechat::print("", "$SCRIPT_NAME: Throttled channels on '$server': " . join(', ', @{$channel_list{$server}})); + } + } else { + weechat::print("", "$SCRIPT_NAME: no channels currently queued."); + } + } elsif ($option eq 'clear') { + if (defined($arg)) { + if (exists($timers{$arg})) { + weechat::unhook($timers{$arg}); + delete $timers{$arg}; + } + delete $channel_list{$arg}; + delete $next_join{$arg}; + } else { + foreach my $server (keys %channel_list) { + if (exists($timers{$server})) { + weechat::unhook($timers{$server}); + delete $timers{$server}; + } + delete $channel_list{$server}; + delete $next_join{$server}; + } + } + weechat::bar_item_update($SCRIPT_NAME); + } + return weechat::WEECHAT_RC_OK; +} + +sub init_config { + foreach my $option (keys %default_options) { + if (!weechat::config_is_set_plugin($option)) { + weechat::config_set_plugin($option, $default_options{$option}[0]); + $options{$option} = $default_options{$option}[0]; + } else { + $options{$option} = weechat::config_get_plugin($option); + } + weechat::config_set_desc_plugin($option, $default_options{$option}[1] . " (default: " . $default_options{$option}[0] . ")") if ($weechat_version >= 0x00030500); + } +} diff -Nru weechat-scripts-20130123/perl/luanma.pl weechat-scripts-20131007/perl/luanma.pl --- weechat-scripts-20130123/perl/luanma.pl 1970-01-01 00:00:00.000000000 +0000 +++ weechat-scripts-20131007/perl/luanma.pl 2013-10-07 12:14:59.000000000 +0000 @@ -0,0 +1,1563 @@ +use strict; use warnings; +$INC{'Encode/ConfigLocal.pm'}=1; +use Encode; +eval { local $SIG{__DIE__}; # silence weechat die handler + require Encode::HanExtra }; # more chinese +eval { local $SIG{__DIE__}; + require Encode::JIS2K }; # more japanese +use Time::Local; + +# luanma.pl is written by Nei +# and licensed under the under GNU General Public License v3 +# or any later version + +# to read the following docs, you can use "perldoc luanma.pl" + +=head1 NAME + +luanma - store more info about encoding of message, and change it with update (weechat edition) + +=head1 SYNOPSIS + +more help for charset troubles + +command is called /lma + +see "/help lma" for usage + +=head1 DESCRIPTION + +luanma will allow you to view received messages as they would appear +when decoded using different charsets. you might know this feature +from your webbrowser. it is useful if you need to understand a message +that was received, but it looks garbled because the sender used +different charset than you. + +as usual, a list of charsets can be defined that will be tried in +consecution until a successful decode is made. + +the charset can be choosen differently for different times in the past +and based on nick and weechat buffer. furthermore, you can use /debug +tags to see which charset was used to decode a message. + +a table of charset rules will be saved to luanma.conf and can be +edited with /lma set command. + +=head1 CAVEATS + +=over + +=item * + +the automatic encoding of outgoing notices is visible on display and +no assessment of success is given, because weechat does not set the +appropriate tag on outgoing notices + +=item * + +in order to not convert all messages as raw, only high bit data +(extended ascii) is encoded. that means the script works fine for +latin variants and utf8, but B for any 7bit-clean encoding or for +national EBCDIC + +=item * + +colours might get mixed up with colorize_nicks script when there is a +nick with the same name as a 2-hex-character encoding (example: +"b2"). One possible workaround is to turn off greedy_matching in +colorize_nicks + +=item * + +no encoding is done when outgoing charset is specified as 'utf8' + +=back + +=head1 BUGS + +=over + +=item * + +splitting of messages is not supported, so if byte-length of message +in utf8 exceeds 510, it will get split by weechat. result is that only +the first part is encoded properly. + +if byte-length of B message exceeds 510, then it will usually +get cut off (exact behaviour depends on IRC server) + +=item * + +the prefix on ACTION messages ('/me') gets recoded for messages that +you send yourself. this will cause problems with utf8 nicknames where +supported + +=back + +=head1 SETTINGS + +the settings are usually found in the + + plugins.var.perl.luanma + +namespace, that is, type + + /set plugins.var.perl.luanma.* + +to see them and + + /set plugins.var.perl.luanma.SETTINGNAME VALUE + +to change a setting C to a new value C. Finally, + + /unset plugins.var.perl.luanma.SETTINGNAME + +will reset a setting to its default value. + +the following settings are available: + +=head2 tags + +white-space separated list of irc_(in_) tags to store raw messages of +(only those can be recoded). see /debug tags + +=head2 encode_warn + +add a warning message into the line displayed on your buffer, when +encoding of outgoing messages fails/is lossy + +=head2 parser + +parser to use for line parsing. valid options: ondemand, async, +full. ondemand will parse lines when displayed on screen (needs parse +on every buffer switch, but fast on load). async and full do not need +to parse lines when switching buffers, but WILL FREEZE your weechat on +/script (re)load and /upgrade. be careful. + +async uses timers to do the parsing which should make it less likely +for you to drop network connection. full will do the parse in one +swipe, so it is faster and the freeze is of shorter duration. + +=cut + +use constant SCRIPT_NAME => 'luanma'; +weechat::register(SCRIPT_NAME, 'Nei ', '0.2', 'GPL3', + 'more flexibility with incoming charset', 'stop_luanma', '') || return; +sub SCRIPT_FILE() { + my $infolistptr = weechat::infolist_get('perl_script', '', SCRIPT_NAME); + my $filename = weechat::infolist_string($infolistptr, 'filename') if weechat::infolist_next($infolistptr); + weechat::infolist_free($infolistptr); + return $filename unless @_; +} + +{ +package Nlib; +# this is a weechat perl library +use strict; use warnings; no warnings 'redefine'; + +## hdh -- hdata helper +## $_[0] - arg pointer or hdata list name +## $_[1] - hdata name +## $_[2..$#_] - hdata variable name +## $_[-1] - hashref with key/value to update (optional) +## returns value of hdata, and hdata name in list ctx, or number of variables updated +sub hdh { + if (@_ > 1 && $_[0] !~ /^0x/ && $_[0] !~ /^\d+$/) { + my $arg = shift; + unshift @_, weechat::hdata_get_list(weechat::hdata_get($_[0]), $arg); + } + while (@_ > 2) { + my ($arg, $name, $var) = splice @_, 0, 3; + my $hdata = weechat::hdata_get($name); + unless (ref $var eq 'HASH') { + $var =~ s/!(.*)/weechat::hdata_get_string($hdata, $1)/e; + (my $plain_var = $var) =~ s/^\d+\|//; + my $type = weechat::hdata_get_var_type_string($hdata, $plain_var); + if ($type eq 'pointer') { + my $name = weechat::hdata_get_var_hdata($hdata, $var); + unshift @_, $name if $name; + } + + my $fn = "weechat::hdata_$type"; + unshift @_, do { no strict 'refs'; + &$fn($hdata, $arg, $var) }; + } + else { + return weechat::hdata_update($hdata, $arg, $var); + } + } + wantarray ? @_ : $_[0] +} + +## hook_dynamic -- weechat::hook something and store hook reference +## $hook_call - hook type (e.g. modifier) +## $what - event type to hook (depends on $hook_call) +## $sub - subroutine name to install +## @params - parameters +sub hook_dynamic { + my ($hook_call, $what, $sub, @params) = @_; + my $caller_package = (caller)[0]; + eval qq{ + package $caller_package; + no strict 'vars'; + \$DYNAMIC_HOOKS{\$what}{\$sub} = + weechat::hook_$hook_call(\$what, \$sub, \@params) + unless exists \$DYNAMIC_HOOKS{\$what} && + exists \$DYNAMIC_HOOKS{\$what}{\$sub}; + }; + die $@ if $@; +} + +## unhook_dynamic -- weechat::unhook something where hook reference has been stored with hook_dynamic +## $what - event type that was hooked +## $sub - subroutine name that was installed +sub unhook_dynamic { + my ($what, $sub) = @_; + my $caller_package = (caller)[0]; + eval qq{ + package $caller_package; + no strict 'vars'; + weechat::unhook(\$DYNAMIC_HOOKS{\$what}{\$sub}) + if exists \$DYNAMIC_HOOKS{\$what} && + exists \$DYNAMIC_HOOKS{\$what}{\$sub}; + delete \$DYNAMIC_HOOKS{\$what}{\$sub}; + delete \$DYNAMIC_HOOKS{\$what} unless \%{\$DYNAMIC_HOOKS{\$what}}; + }; + die $@ if $@; +} + +sub fu8on(@) { + Encode::_utf8_on($_) for @_; wantarray ? @_ : shift +} + +use Pod::Select qw(); +use Pod::Simple::TextContent; + +## get_desc_from_pod -- return setting description from pod documentation +## $file - filename with pod +## $setting - name of setting +## returns description as text +sub get_desc_from_pod { + my $file = shift; + return unless -s $file; + my $setting = shift; + + open my $pod_sel, '>', \my $ss; + Pod::Select::podselect({ + -output => $pod_sel, + -sections => ["SETTINGS/$setting"]}, $file); + + my $pt = new Pod::Simple::TextContent; + $pt->output_string(\my $ss_f); + $pt->parse_string_document($ss); + + my ($res) = $ss_f =~ /^\s*\Q$setting\E\s+(.*)\s*/; + $res +} + +## get_settings_from_pod -- retrieve all settings in settings section of pod +## $file - file with pod +## returns list of all settings +sub get_settings_from_pod { + my $file = shift; + return unless -s $file; + + open my $pod_sel, '>', \my $ss; + Pod::Select::podselect({ + -output => $pod_sel, + -sections => ["SETTINGS//!.+"]}, $file); + + $ss =~ /^=head2\s+(.*)\s*$/mg +} + +1 +} + +use constant CMD_NAME => 'lma'; + +our @nags; +our $nag_tag; +our %nag_modifiers; + +our $CFG_FILE_NAME = weechat::info_get('weechat_dir', '').weechat::info_get('dir_separator', '').SCRIPT_NAME.'.conf'; + +our (@CFG_TABLE, @CFG_TABLE_2); +our @STO = (\(our (%BYTE_MSGS, %ESC_MSG, %MSG_TIME, %MSG_BUF, %MSG_NICK, %MSG_ENC, %MSG_FLT, %MSG_COLOR))); +our (@ENCODE_TABLE, @ENCODE_TABLE2); +our %DEC; +our $GC_COUNT; + +our $GC_LIMIT = 10_000; +our $PARSE_STATS = 987; + +our $ASYNC_PARSE = $PARSE_STATS; +our %ASYNC_BUF; +our $ASYNC_TIMER; + +our @mon = qw(jan feb mar apr may jun jul aug sep oct nov dec); +our %mon = do { my $i = 0; map { $_ => $i++ } @mon }; +our $mon_re = join '|', @mon; + +## esc1 -- escape all endangered characters +## @_ - strings to modify +sub esc1 { + for (@_) { + # need to fix up escape here, weechat kills it + # see grep { weechat::string_remove_color(chr $_, "") ne chr $_ } (000..0177) + # our escape bracket is 020 + s/([^\000-\017\021-\030\035-\175\177])/sprintf "\020%x\020", ord $1/ge; + } +} + +## esc_only -- message needs no recode +## $_[0] - message string to check +## returns bool +sub esc_only { + $_[0] !~ /[^\000-\032\034-\175\177]/ +} + +init_luanma(); + +weechat::hook_config('plugins.var.perl.'.SCRIPT_NAME.'.*', 'default_options', ''); +weechat::hook_signal('buffer_line_added', 'line_sig', ''); +weechat::hook_signal('upgrade', 'restore_lines', ''); +weechat::hook_modifier('input_text_for_buffer', 'auto_encode_mod', ''); +weechat::hook_command(CMD_NAME, 'a better /charset', + (join ' || ', 'list', + 'set [] [-out ]', + 'set -out ', + 'del [-g]', + 'del -out [-g]', + 'save', + 'reload', + 'list_rules', + 'gc', + 'forget -yes', + ), (join "\n", + 'without arguments, the list of keys is displayed', + '', + ' list: show list of current recode rules', + ' set: adds or modifies a recode rule', + ' del: delete one or many recode rules', + ' save: save rules to config file', + ' reload: reload rules from config file', + 'list_rules: list internal rules and pointers (for debug and /debug tags)', + ' gc: remove raw lines from cache that are no longer valid in weechat (this is also done autoatically)', + " forget: forget everything about messages, forget all raw and all ESC messages. be careful, /@{[CMD_NAME]} cannot be used anymore after youx do this!", + '', + ' ts: timestamp at which the rule starts to become effective', + ' the following time specifications are supported:', + ' 1357986420: unix timestamp as output by `date +%s\' (used by weechat internally)', + ' -59 | -59m: relative time, 59 seconds/minutes /', + ' -23h | -1d: 23 hours / 1 day ago', + ' HH:MM:SS : time (hour:minutes:seconds)', + ' Jan01 : date (format: MonDD)', + ' Jan0100:00:00 = midnight on January 1st.', + ' 1: from the beginning on', + ' 0: starting from now', + ' the "del" command additionally supports these specifiers:', + ' *: any time', + ' >ts: rule effective after ts', + ' length $a } keys %DEC; + if ($s =~ s/^\02010\020/\020/) {} + elsif ($s =~ s/^\020($codecs)\020//) { + $s = $DEC{$1}->encode($s, Encode::FB_DEFAULT); # must make best effort here + } + elsif ($p =~ /^PRIVMSG/ && $s =~ /^(\01ACTION )\020($codecs)\020(.*)(\01)$/) { # /me + $s = "\01ACTION ".$DEC{$2}->encode($3, Encode::FB_DEFAULT)."\01"; # avoid upgrade + } + else { + return $_[3] + } + "$p$x$s" +} + +## auto_encode_mod -- add encoding prefixes to buffer input line +## () - modifier handler +## $_[1] - modifier +## $_[3] - content of line before sending +sub auto_encode_mod { + # XXX should do the splitting + my $in = Nlib::fu8on(weechat::string_input_for_buffer($_[3])); + return $_[3] unless $in; # pass through commands + return $_[3] unless exists $nag_modifiers{privmsg}; + return $_[3] if $in =~ /^\020/; # already marked + + my $buf = Nlib::hdh($_[2], 'buffer', 'name'); + + my ($r) = + grep { $buf =~ $_->{buf_re} && $in =~ $_->{pat_re} } @ENCODE_TABLE2; + + return $_[3] unless $r; + return $_[3] if $r->{_}{charset} eq 'utf8'; # XXX + "\020${$r}{_}{charset}\020$in" +} + +## auto_encode_cmd -- add tag to command for encode marker +## () - command_run handler +## $_[0] - forward to which command +## $_[1] - buffer pointer +## $_[2] - command +sub auto_encode_cmd { + # XXX should do the splitting + Encode::_utf8_on($_[2]); + #my @args = split ' ', $_[2]; + my ($pre, $in, $buf); + if ($_[0] eq 'me' && $_[2] =~ /^(\S+\s)(.*)$/i) { + ($pre, $in) = ($1, $2); + $buf = weechat::buffer_get_string($_[1], 'name'); + } + elsif ($_[0] eq 'msg' && $_[2] =~ /^(\S+(?:\s+-server\s+(\S+))?\s+(\S+) )(.*)$/i) { + my ($srv, $targ) = ($2, $3); + ($pre, $in) = ($1, $4); + $srv //= weechat::buffer_get_string($_[1], 'localvar_server'); + $buf = $targ ne '*' ? "$srv.$targ" : weechat::buffer_get_string($_[1], 'name'); + } + elsif ($_[0] eq 'query' && $_[2] =~ /^(\S+(?:\s+-server\s+(\S+))?\s+(\S+) )(\s*\S.*)$/i) { + my ($srv, $targ) = ($2, $3); + ($pre, $in) = ($1, $4); + $srv //= weechat::buffer_get_string($_[1], 'localvar_server'); + $buf = "$srv.$targ"; + } + elsif ($_[0] eq 'wallchops' && $_[2] =~ /^(\S+(?:\s+([#&]\S+))? )(.*)$/i) { + my $targ = $2; + ($pre, $in) = ($1, $3); + $buf = $targ ? weechat::buffer_get_string($_[1], 'localvar_server').'.'.$targ : + weechat::buffer_get_string($_[1], 'name'); + } + elsif ($_[0] eq 'topic' && $_[2] !~ /\s-delete\s*$/i && $_[2] =~ /^(\S+(?:\s+([#&\S+]))? )(.*)$/i) { + my $targ = $2; + ($pre, $in) = ($1, $3); + $buf = $targ ? weechat::buffer_get_string($_[1], 'localvar_server').'.'.$targ : + weechat::buffer_get_string($_[1], 'name'); + } + else { + return weechat::WEECHAT_RC_OK + } + + return weechat::WEECHAT_RC_OK if $in =~ /^\020/; # already marked + + my ($r) = + grep { $buf =~ $_->{buf_re} && $in =~ $_->{pat_re} } @ENCODE_TABLE2; + + return weechat::WEECHAT_RC_OK unless $r; + return weechat::WEECHAT_RC_OK if $r->{_}{charset} eq 'utf8'; # XXX + weechat::command($_[1], "$pre\020${$r}{_}{charset}\020$in"); + return weechat::WEECHAT_RC_OK_EAT +} + + +## find_rule -- find rule to recode this line +## $time - timestamp of line +## $buf - buffer name +## $nick - nick +## returns rule if found or undef +sub find_rule { + my ($time, $buf, $nick) = @_; + my ($r) = + grep { $_->{_}{time} <= $time && $buf =~ $_->{buf_re} && $nick =~ $_->{nick_re} } @CFG_TABLE_2; + $r +} + +## apply_recode -- recode a line, looking up its rule first +## $lp - pointer to 'line' hdata +sub apply_recode { + my $lp = shift; + my $rule = find_rule($MSG_TIME{$lp}, $MSG_BUF{$lp}, $MSG_NICK{$lp})//\undef; + return if $rule == $MSG_FLT{$lp}; + my ($s, $e); + for my $enc ((($rule == \undef) ? () : @{$rule->{_}{charsets}}), 'x') { + $s = $BYTE_MSGS{$lp}; + if ($enc eq 'x') { + esc1($s); + $e = $enc; + last; + } + else { + my $enc2 = $enc; + my $partial = $enc2 =~ s/!$//; + next if $enc2 eq 'hz' && $s =~ /[^\000-\177]/; # hack for hz + # put further hacks here... + + my $t = $DEC{$enc2}->decode($s, Encode::FB_QUIET); # FB_CROAK not reliable + #$t =~ s/[[:cntrl:]]//g; + if (length $t && !length $s) { # decoding succeeds + $s = $t; + $e = $enc2; + last; + } + elsif (length $t && $partial) { + esc1($s); + $s = $t . '' . $s; + $e = $enc2 . '_loss'; + last; + } + } + } + if ($MSG_ENC{$lp} ne $e) { + my @line_data = Nlib::hdh((sprintf '0x%x', $lp), 'line', 'data'); + my @tags = grep { !/^lma_/ } map { Nlib::hdh(@line_data, "$_|tags_array") } + 0 .. Nlib::hdh(@line_data, 'tags_count')-1; + + my @ctrl_res = split "\0", $MSG_COLOR{$lp}, -1; + my $c = 1; + $s =~ s/\01+/$ctrl_res[$c++]/g; + + Nlib::hdh(@line_data, +{ + message => $s, + tags_array => (join ',', (($e eq 'x') ? () : ("lma_$e", (sprintf 'lma_0x%x', $rule))), @tags), + }); + $MSG_ENC{$lp} = $e; + } + $MSG_FLT{$lp} = $rule; +} + +## line_sig -- decode charset previously replaced and fix up outgoing msgs +## () - signal handler +## $_[2] - line ptr +sub line_sig { + my @line_data = Nlib::hdh($_[2], 'line', 'data'); + my $lp = oct $_[2]; + $ASYNC_BUF{$lp} = undef if $ASYNC_TIMER; # we are still in async reread loop, mark this line as seen + return weechat::WEECHAT_RC_OK unless Nlib::hdh(@line_data, 'buffer', 'plugin', 'name') eq 'irc'; + my @tags = map { Nlib::hdh(@line_data, "$_|tags_array") } + 0 .. Nlib::hdh(@line_data, 'tags_count')-1; + return weechat::WEECHAT_RC_OK unless grep /$nag_tag/i, @tags; + + my $message_c = Nlib::hdh(@line_data, 'message'); + return weechat::WEECHAT_RC_OK unless $message_c =~ /\020/; + + my $message = my $message_nc = weechat::string_remove_color($message_c, "\1"); + + if (defined $_[0] && grep { $_ eq 'no_highlight' } @tags) { # might be own msg, $_[0] == undef on history parsing + my $action_pfx_re = qr//; + if (grep { $_ eq 'irc_action' } @tags) { + # XXX might erroneously recode the in-line prefix (utf8 nicks anyone? ircx?!) + $action_pfx_re = qr/\S+ \K/; + } + my $codecs = join '|', map { quotemeta } sort { length $b <=> length $a } keys %DEC; + if ($message =~ /^\02010\020/) {} # fall through + elsif ($message =~ s/^$action_pfx_re\020($codecs)\020//) { + my $dec = $1; + + my @ctrl_res; + if ($message_nc =~ /\01/) { + my $id_control = quotemeta $message_nc; + $id_control =~ s/(\\\01)+/(.+?)/g; + @ctrl_res = $message_c =~ /^()$id_control()$/; + } + + $message_nc =~ s/^$action_pfx_re\020\Q$dec\E\020//; + Encode::_utf8_on($message); + my $s = $DEC{$dec}->decode($DEC{$dec}->encode($message, Encode::FB_DEFAULT), Encode::FB_DEFAULT); + my $not_equal = $s ne $message; + + my $c = 1; + $s =~ s/\01+/$ctrl_res[$c++]/g; + + if ($not_equal && weechat::config_string_to_boolean(weechat::config_get_plugin('encode_warn'))) { + $s .= ' '.weechat::color('chat_prefix_error').'[warning: lossy encode]'; + } + + Nlib::hdh(@line_data, +{ + message => $s, + tags_array => (join ',', "lmaout_$dec", ($not_equal ? "lmaout_loss" : ()), @tags), + }); + + return weechat::WEECHAT_RC_OK + } + } + + # XXX bad hack: \01* might be sprinkled from colorize_nicks, but will mess up later on color restore + $message =~ s/\020\01*([[:xdigit:]]+)\01*\020/chr hex $1/ge || return weechat::WEECHAT_RC_OK; + + my @ctrl_res; + if ($message_nc =~ /\01/) { + my $id_control = quotemeta $message_nc; + $id_control =~ s/(\\\01)+/(.+?)/g; + @ctrl_res = $message_c =~ /^()$id_control()$/; + } + + if (esc_only($message)) { + my $c = 1; + $message =~ s/\01+/$ctrl_res[$c++]/g; + Nlib::hdh(@line_data, +{ message => $message }); + $ESC_MSG{$lp} = undef; + return weechat::WEECHAT_RC_OK + } + + $BYTE_MSGS{$lp} = $message; + $MSG_COLOR{$lp} = join "\0", @ctrl_res; + $MSG_TIME{$lp} = 0+Nlib::hdh(@line_data, 'date'); + $MSG_BUF{$lp} = Nlib::hdh(@line_data, 'buffer', 'name'); + my ($nick_tag) = grep s/^nick_//, @tags; + $MSG_NICK{$lp} = $nick_tag//''; + $MSG_ENC{$lp} = 'x'; + $MSG_FLT{$lp} = \undef; + + apply_recode($lp); + + if (defined $GC_LIMIT && ++$GC_COUNT > $GC_LIMIT) { + gc_lines('int'); + $GC_COUNT = 0; + } + + weechat::WEECHAT_RC_OK +} + +## hook_encode_commands -- hook irc commands needed to add encode prefix +## - tag name +sub hook_encode_commands { + if ($_[0] eq 'privmsg') { + (weechat::hook_command_run('/me', 'auto_encode_cmd', 'me'), + weechat::hook_command_run('/msg', 'auto_encode_cmd', 'msg'), + weechat::hook_command_run('/query', 'auto_encode_cmd', 'query'), + ) + } + elsif ($_[0] eq 'notice') { + (weechat::hook_command_run('/notice', 'auto_encode_cmd', 'query'), + weechat::hook_command_run('/wallchops', 'auto_encode_cmd', 'wallchops'), + ) + } + elsif ($_[0] eq 'topic') { + (weechat::hook_command_run('/topic', 'auto_encode_cmd', 'topic'), + ) + } + elsif ($_[0] eq 'part') { + (weechat::hook_command_run('/part', 'auto_encode_cmd', 'wallchops'), + weechat::hook_command_run('/cycle', 'auto_encode_cmd', 'wallchops'), + ) + } + else { + () + } +} + +# /lma set