show "i/found_i" on each !msearch line

This commit is contained in:
jesopo 2020-01-30 15:13:15 +00:00
parent 24e84af4d2
commit 402872b3f8

View file

@ -12,16 +12,15 @@ class Module(ModuleManager.BaseModule):
if message_list: if message_list:
messages = [] messages = []
for message in message_list: for i, message in enumerate(message_list):
seconds = utils.datetime.seconds_since(message.line.timestamp) seconds = utils.datetime.seconds_since(message.line.timestamp)
messages.append("%s ago %s" % ( messages.append("(%d/%d) %s ago %s" % (i+1, message_count,
utils.datetime.to_pretty_time(seconds), utils.datetime.to_pretty_time(seconds),
message.line.format())) message.line.format()))
plural = "message" if message_count == 0 else "messages" plural = "message" if message_count == 0 else "messages"
event["stdout"].write("%s: found %d/%d messages: %s" event["stdout"].write("%s: found messages: %s"
% (event["user"].nickname, message_count, % (event["user"].nickname, "\n".join(messages)))
len(event["target"].buffer), "\n".join(messages)))
else: else:
event["stderr"].write("%s: no messages found" event["stderr"].write("%s: no messages found"
% event["user"].nickname) % event["user"].nickname)