# (this script requires WeeChat 0.3.0 or newer)
#
# History:
+# 2013-11-08, Stefan Huber <shuber@sthu.org>
+# version 0.2.2: add match_prefix setting
# 2012-12-29, Stefan Huber <shuber@sthu.org>
# version 0.2.1: fix channel determination in join_cb
# 2010-05-20, Alexander Schremmer <alex@alexanderweb.de>
SCRIPT_NAME = "postpone"
SCRIPT_AUTHOR = "Alexander Schremmer <alex@alexanderweb.de>"
-SCRIPT_VERSION = "0.2.1"
+SCRIPT_VERSION = "0.2.2"
SCRIPT_LICENSE = "GPL3"
SCRIPT_DESC = "Postpones written messages for later dispatching if target nick is not on channel"
-
postpone_data = {}
+settings = {
+ 'match_prefix': ('', 'Postpone message if prefix before "nick:" is matched.')
+}
+
def join_cb(data, signal, signal_data):
server = signal.split(',')[0] # EFNet,irc_in_JOIN
input_s = w.buffer_get_string(buffer, 'input')
server = w.buffer_get_string(buffer, 'localvar_server')
channel = w.buffer_get_string(buffer, 'localvar_channel')
+ match_prefix = w.config_get_plugin('match_prefix')
- match = re.match(r'([\w-]+?): (.*)$', input_s)
+ match = re.match(match_prefix + r'([\w-]+?): (.*)$', input_s)
if match:
nick, message = match.groups()
if not channel_has_nick(server, channel, nick):
w.prnt(buffer, "| Enqueued message for %s: %s" % (nick, message))
+ save = nick + ": " + message
postpone_data.setdefault(server, {}).setdefault(channel,
- {}).setdefault(nick.lower(), []).append(input_s)
+ {}).setdefault(nick.lower(), []).append(save)
w.buffer_set(buffer, 'input', "")
# XXX why doesn't this work? i want to have the typed text
# in the history
if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
SCRIPT_DESC, "", ""):
+
+ version = w.info_get('version_number', '') or 0
+ for option, default_desc in settings.iteritems():
+ if not w.config_is_set_plugin(option):
+ w.config_set_plugin(option, default_desc[0])
+ if int(version) >= 0x00030500:
+ w.config_set_desc_plugin(option, default_desc[1])
+
w.hook_command_run("/input return", "command_run_input", "")
w.hook_signal('*,irc_in2_join', 'join_cb', '')