diff options
author | Ben Harris <ben@tilde.team> | 2018-08-08 20:20:19 -0400 |
---|---|---|
committer | Ben Harris <ben@tilde.team> | 2018-08-11 16:40:48 -0400 |
commit | d2fb2856fc724dd8ef3400d944eabcc61fb0ea26 (patch) | |
tree | 0222c59e333f04b19aef51685f5d70008500f531 /weechat/.weechat/python/autojoin.py | |
parent | cc9935fcac9cdec1d34e132c135783438f538db6 (diff) |
looooots of weechat
Diffstat (limited to 'weechat/.weechat/python/autojoin.py')
-rw-r--r-- | weechat/.weechat/python/autojoin.py | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/weechat/.weechat/python/autojoin.py b/weechat/.weechat/python/autojoin.py index 3fe4b6b..61449ff 100644 --- a/weechat/.weechat/python/autojoin.py +++ b/weechat/.weechat/python/autojoin.py @@ -43,6 +43,9 @@ # 2014-05-22, Nathaniel Wesley Filardo <PADEBR2M2JIQN02N9OO5JM0CTN8K689P@cmx.ietfng.org> # version 0.2.5: Fix keyed channel support # +# 2016-01-13, The fox in the shell <KellerFuchs@hashbang.sh> +# version 0.2.6: Support keeping chan list as secured data +# # @TODO: add options to ignore certain buffers # @TODO: maybe add an option to enable autosaving on part/join messages @@ -51,7 +54,7 @@ import re SCRIPT_NAME = "autojoin" SCRIPT_AUTHOR = "xt <xt@bash.no>" -SCRIPT_VERSION = "0.2.5" +SCRIPT_VERSION = "0.2.6" SCRIPT_LICENSE = "GPL3" SCRIPT_DESC = "Configure autojoin for all servers according to currently joined channels" SCRIPT_COMMAND = "autojoin" @@ -89,9 +92,7 @@ def autosave_channels_on_quit(signal, callback, callback_data): # print/execute commands for server, channels in items.iteritems(): - channels = channels.rstrip(',') - command = "/set irc.server.%s.autojoin '%s'" % (server, channels) - w.command('', command) + process_server(server, channels) return w.WEECHAT_RC_OK @@ -111,10 +112,7 @@ def autosave_channels_on_activity(signal, callback, callback_data): match = re.match(pattern, callback_data) if match: # check if nick is my nick. In that case: save - channel = match.group(2) - channels = channels.rstrip(',') - command = "/set irc.server.%s.autojoin '%s'" % (server, channels) - w.command('', command) + process_server(server, channels) else: # someone else: ignore continue @@ -126,19 +124,38 @@ def autojoin_cb(data, buffer, args): """But I can't believe somebody would want that behaviour""" items = find_channels() + if args == '--run': + run = True + else: + run = False + # print/execute commands for server, channels in items.iteritems(): + process_server(server, channels, run) + + return w.WEECHAT_RC_OK + +def process_server(server, channels, run=True): + option = "irc.server.%s.autojoin" % server channels = channels.rstrip(',') + oldchans = w.config_string(w.config_get(option)) + if not channels: # empty channel list - continue - command = '/set irc.server.%s.autojoin %s' % (server, channels) - if args == '--run': + return + + # Note: re already caches the result of regexp compilation + sec = re.match('^\${sec\.data\.(.*)}$', oldchans) + if sec: + secvar = sec.group(1) + command = "/secure set %s %s" % (secvar, channels) + else: + command = "/set irc.server.%s.autojoin '%s'" % (server, channels) + + if run: w.command('', command) else: w.prnt('', command) - return w.WEECHAT_RC_OK - def find_channels(): """Return list of servers and channels""" #@TODO: make it return a dict with more options like "nicks_count etc." |