From 3387e124d23bf8056edb6a2aa9490bf1fc726195 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Mon, 19 Nov 2018 14:17:22 -0500 Subject: [PATCH] latest weechat --- weechat/.weechat/buflist.conf | 2 +- weechat/.weechat/irc.conf | 90 ++++++------ .../python/autoload/buffer_autoclose.py | 1 + weechat/.weechat/python/buffer_autoclose.py | 137 ++++++++++++++++++ weechat/.weechat/weechat.conf | 2 +- 5 files changed, 185 insertions(+), 47 deletions(-) create mode 120000 weechat/.weechat/python/autoload/buffer_autoclose.py create mode 100644 weechat/.weechat/python/buffer_autoclose.py diff --git a/weechat/.weechat/buflist.conf b/weechat/.weechat/buflist.conf index b1db2a4..40f91e6 100644 --- a/weechat/.weechat/buflist.conf +++ b/weechat/.weechat/buflist.conf @@ -36,4 +36,4 @@ indent = "${color:237}${if:${buffer.next_buffer.local_variables.type}=~^(channel lag = " ${color:green}[${color:brown}${lag}${color:green}]" name = "${name}" nick_prefix = "${color_nick_prefix}${nick_prefix}" -number = "${color:green}${number}${if:${number_displayed}?:}" +number = "${color:green}${number}" diff --git a/weechat/.weechat/irc.conf b/weechat/.weechat/irc.conf index d5d98a6..66137f3 100644 --- a/weechat/.weechat/irc.conf +++ b/weechat/.weechat/irc.conf @@ -112,7 +112,7 @@ whois_double_nick = off addresses = "" anti_flood_prio_high = 2 anti_flood_prio_low = 2 -autoconnect = off +autoconnect = on autojoin = "" autoreconnect = on autoreconnect_delay = 10 @@ -156,7 +156,7 @@ tilde.addresses = "localhost" tilde.proxy tilde.ipv6 tilde.ssl = off -tilde.ssl_cert +tilde.ssl_cert = "%h/ssl/benharri.pem" tilde.ssl_priorities tilde.ssl_dhkey_size tilde.ssl_fingerprint @@ -180,7 +180,7 @@ tilde.local_hostname tilde.usermode tilde.command = "/oper root ${sec.data.tildenetoper}; /msg operserv login ${sec.data.pass}" tilde.command_delay -tilde.autojoin = "#opers,#secret-sudoers,#meta,#team,#sudoers,#YourTilde,#chaos,#bots,#music,#share,#stevenuniverse,#suwp,#projects,#politics,#dnd,#journal,#shitposting,#quotes,#gopher,#tildeverse,#venting,#idlerpg,#tilderadio,#zaphod,#thunix,#yee,#modded,#minecraft,#minetest,#bbj,#tildelinux,#tildetheater,#slbr youneedtoknowthepassword,secretsudoteam" +tilde.autojoin = "#chaos,#secret-sudoers,#opers,#meta,#team,#sudoers,#YourTilde,#bots,#music,#share,#stevenuniverse,#suwp,#projects,#politics,#dnd,#journal,#shitposting,#quotes,#gopher,#tildeverse,#venting,#idlerpg,#tilderadio,#zaphod,#thunix,#yee,#modded,#minecraft,#minetest,#bbj,#tildelinux,#tildetheater,#slbr fosslinux,secretsudoteam,youneedtoknowthepassword" tilde.autorejoin tilde.autorejoin_delay tilde.connection_timeout @@ -344,7 +344,7 @@ sdf.local_hostname sdf.usermode sdf.command sdf.command_delay -sdf.autojoin = "#helpdesk,#anonradio,#gopher,#sdf" +sdf.autojoin = "#sdf,#gopher,#anonradio,#helpdesk" sdf.autorejoin sdf.autorejoin_delay sdf.connection_timeout @@ -521,47 +521,6 @@ blinkenshell.msg_part blinkenshell.msg_quit blinkenshell.notify blinkenshell.split_msg_max_length -dgrove.addresses = "irc.dannygrove.com/6697" -dgrove.proxy -dgrove.ipv6 -dgrove.ssl = on -dgrove.ssl_cert -dgrove.ssl_priorities -dgrove.ssl_dhkey_size -dgrove.ssl_fingerprint -dgrove.ssl_verify -dgrove.password -dgrove.capabilities -dgrove.sasl_mechanism -dgrove.sasl_username -dgrove.sasl_password -dgrove.sasl_key -dgrove.sasl_timeout -dgrove.sasl_fail -dgrove.autoconnect -dgrove.autoreconnect -dgrove.autoreconnect_delay -dgrove.nicks -dgrove.nicks_alternate -dgrove.username -dgrove.realname -dgrove.local_hostname -dgrove.usermode -dgrove.command -dgrove.command_delay -dgrove.autojoin -dgrove.autorejoin -dgrove.autorejoin_delay -dgrove.connection_timeout -dgrove.anti_flood_prio_high -dgrove.anti_flood_prio_low -dgrove.away_check -dgrove.away_check_max_nicks -dgrove.msg_kick -dgrove.msg_part -dgrove.msg_quit -dgrove.notify -dgrove.split_msg_max_length cat.addresses = "tilde.cat" cat.proxy cat.ipv6 @@ -644,3 +603,44 @@ bitlbee.msg_part bitlbee.msg_quit bitlbee.notify bitlbee.split_msg_max_length +inspircd.addresses = "irc.inspircd.org" +inspircd.proxy +inspircd.ipv6 +inspircd.ssl +inspircd.ssl_cert +inspircd.ssl_priorities +inspircd.ssl_dhkey_size +inspircd.ssl_fingerprint +inspircd.ssl_verify +inspircd.password +inspircd.capabilities +inspircd.sasl_mechanism +inspircd.sasl_username = "benharri" +inspircd.sasl_password = "${sec.data.pass}" +inspircd.sasl_key +inspircd.sasl_timeout +inspircd.sasl_fail +inspircd.autoconnect = on +inspircd.autoreconnect +inspircd.autoreconnect_delay +inspircd.nicks = "benharri" +inspircd.nicks_alternate +inspircd.username +inspircd.realname +inspircd.local_hostname +inspircd.usermode +inspircd.command +inspircd.command_delay +inspircd.autojoin = "#inspircd" +inspircd.autorejoin +inspircd.autorejoin_delay +inspircd.connection_timeout +inspircd.anti_flood_prio_high +inspircd.anti_flood_prio_low +inspircd.away_check +inspircd.away_check_max_nicks +inspircd.msg_kick +inspircd.msg_part +inspircd.msg_quit +inspircd.notify +inspircd.split_msg_max_length diff --git a/weechat/.weechat/python/autoload/buffer_autoclose.py b/weechat/.weechat/python/autoload/buffer_autoclose.py new file mode 120000 index 0000000..a639358 --- /dev/null +++ b/weechat/.weechat/python/autoload/buffer_autoclose.py @@ -0,0 +1 @@ +../buffer_autoclose.py \ No newline at end of file diff --git a/weechat/.weechat/python/buffer_autoclose.py b/weechat/.weechat/python/buffer_autoclose.py new file mode 100644 index 0000000..2dfefd9 --- /dev/null +++ b/weechat/.weechat/python/buffer_autoclose.py @@ -0,0 +1,137 @@ +# -*- coding: utf-8 -*- +# +# Copyright (c) 2009 by 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 requires WeeChat 0.3.0 or newer) +# +# History: +# 2018-04-10, Sébastien Helleu +# version 0.5: fix infolist_time for WeeChat >= 2.2 (WeeChat returns a long +# integer instead of a string) +# 2016-02-05, ixti +# version 0.4: Add Python3 support +# 2009-12-15, xt +# version 0.3: moved around some control structures to not be as noisy +# 2009-12-02, xt +# version 0.2: bugfix, more printing +# 2009-12-01, xt +# version 0.1: initial release + +import weechat as w +import time + +SCRIPT_NAME = "buffer_autoclose" +SCRIPT_AUTHOR = "xt " +SCRIPT_VERSION = "0.5" +SCRIPT_LICENSE = "GPL3" +SCRIPT_DESC = "Automatically close inactive private message buffers" + +settings = { + 'interval': '1', # How often in minutes to check + 'age_limit': '30', # How old in minutes before auto close + 'ignore': '', # Buffers to ignore (use full name: server.buffer_name) +} + +if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, + SCRIPT_DESC, "", ""): + for option, default_value in settings.items(): + if not w.config_is_set_plugin(option): + w.config_set_plugin(option, default_value) + w.hook_timer(\ + int(w.config_get_plugin('interval')) * 1000 * 60, + 0, + 0, + "close_time_cb", + '') + + +def get_all_buffers(): + '''Returns list with pointers of all open buffers.''' + buffers = [] + infolist = w.infolist_get('buffer', '', '') + while w.infolist_next(infolist): + buffer_type = w.buffer_get_string(w.infolist_pointer(infolist, 'pointer'), 'localvar_type') + if buffer_type == 'private': # we only close private message buffers for now + buffers.append(w.infolist_pointer(infolist, 'pointer')) + w.infolist_free(infolist) + return buffers + +def get_last_line_date(buffer): + date = '1970-01-01 01:00:00' + infolist = w.infolist_get('buffer_lines', buffer, '') + while w.infolist_prev(infolist): + date = w.infolist_time(infolist, 'date') + # since WeeChat 2.2, infolist_time returns a long integer instead of + # a string + if not isinstance(date, str): + date = time.strftime('%F %T', time.localtime(int(date))) + if date != '1970-01-01 01:00:00': + # Some lines like "Day changed to" message doesn't have date + # set so loop until we find a message that does + break + w.infolist_free(infolist) + return date + +def is_in_hotlist(buffer): + ''' Returns true if buffer is in hotlist, false if not''' + + hotlist = w.infolist_get('hotlist', '', '') + found = False + while w.infolist_next(hotlist): + thebuffer = w.infolist_pointer(hotlist, 'buffer_pointer') + if thebuffer == buffer: + found = True + name = w.buffer_get_string(thebuffer, 'short_name') + break + + w.infolist_free(hotlist) + return found + +def close_time_cb(buffer, args): + ''' Callback for check for inactivity and close ''' + + for buffer in get_all_buffers(): + name = w.buffer_get_string(buffer, 'name') + + + date = get_last_line_date(buffer) + date = time.mktime(time.strptime(date, '%Y-%m-%d %H:%M:%S')) + now = time.time() + seconds_old = now - date + if seconds_old > int(w.config_get_plugin('age_limit'))*60: + if is_in_hotlist(buffer): + #w.prnt('', '%s: Not closing buffer: %s: it is in hotlist' %(SCRIPT_NAME, name)) + continue + if name in w.config_get_plugin('ignore').split(','): + #w.prnt('', '%s: Not closing buffer: %s: it is in ignore list' %(SCRIPT_NAME, name)) + continue + if buffer == w.current_buffer(): + # Never close current buffer + #w.prnt('', '%s: Not closing buffer: %s: it is in currently active' %(SCRIPT_NAME, name)) + continue + if len(w.buffer_get_string(buffer, 'input')): + # Don't close buffers with text on input line + #w.prnt('', '%s: Not closing buffer: %s: it has input' %(SCRIPT_NAME, name)) + continue + + w.prnt('', '%s: Closing buffer: %s' %(SCRIPT_NAME, name)) + w.command(buffer, '/buffer close') + #else: + # w.prnt('', '%s: Not closing buffer: %s: it is too new: %s' %(SCRIPT_NAME, name, seconds_old)) + + return w.WEECHAT_RC_OK diff --git a/weechat/.weechat/weechat.conf b/weechat/.weechat/weechat.conf index 4d28659..7f605e6 100644 --- a/weechat/.weechat/weechat.conf +++ b/weechat/.weechat/weechat.conf @@ -110,7 +110,7 @@ prefix_error = "=!=" prefix_join = "-->" prefix_network = "--" prefix_quit = "<--" -prefix_same_nick = "-" +prefix_same_nick = "⤷" prefix_suffix = "│" quote_nick_prefix = "<" quote_nick_suffix = ">"