Commit 9beb6a35 authored by Sébastien Helleu's avatar Sébastien Helleu

buffer_autoclose.py 0.5: fix infolist_time with WeeChat >= 2.2

parent 8a546673
......@@ -20,6 +20,9 @@
# (this script requires WeeChat 0.3.0 or newer)
#
# History:
# 2018-04-10, Sébastien Helleu <flashcode@flashtux.org>
# 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
......@@ -34,7 +37,7 @@ import time
SCRIPT_NAME = "buffer_autoclose"
SCRIPT_AUTHOR = "xt <xt@bash.no>"
SCRIPT_VERSION = "0.4"
SCRIPT_VERSION = "0.5"
SCRIPT_LICENSE = "GPL3"
SCRIPT_DESC = "Automatically close inactive private message buffers"
......@@ -73,6 +76,10 @@ def get_last_line_date(buffer):
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment