From: Stefan Huber Date: Sat, 9 Nov 2013 15:23:25 +0000 (+0100) Subject: postpone: recall timestamp of postponed message X-Git-Url: https://git.sthu.org/?a=commitdiff_plain;h=c5b6d3bcd7ce1aa73bf4a3eae894bdfe7298b763;p=shutils.git postpone: recall timestamp of postponed message --- diff --git a/weechat/postpone.py b/weechat/postpone.py index 5702204..e20ffcd 100644 --- a/weechat/postpone.py +++ b/weechat/postpone.py @@ -21,7 +21,7 @@ # # History: # 2013-11-08, Stefan Huber -# version 0.2.2: add match_prefix setting +# version 0.2.2: add match_prefix setting, recall timestamp of message # 2012-12-29, Stefan Huber # version 0.2.1: fix channel determination in join_cb # 2010-05-20, Alexander Schremmer @@ -31,6 +31,8 @@ import weechat as w import re +from datetime import datetime +from time import strftime SCRIPT_NAME = "postpone" SCRIPT_AUTHOR = "Alexander Schremmer " @@ -53,8 +55,9 @@ def join_cb(data, signal, signal_data): if server in postpone_data and channel in postpone_data[server] and\ nick in postpone_data[server][channel]: messages = postpone_data[server][channel][nick] - for msg in messages: - w.command(buffer, msg + " (This message has been postponed.)") + for time, msg in messages: + tstr = strftime("%Y-%m-%d %H:%M:%S", time.timetuple()) + w.command(buffer, msg + " (This message has been postponed on " + tstr + ".)") messages[:] = [] return w.WEECHAT_RC_OK @@ -75,7 +78,7 @@ def command_run_input(data, buffer, command): 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 + save = datetime.now(), nick + ": " + message postpone_data.setdefault(server, {}).setdefault(channel, {}).setdefault(nick.lower(), []).append(save) w.buffer_set(buffer, 'input', "")