From 1663c8a9fcd2d437e3d6828a544c9ce9831db2ca Mon Sep 17 00:00:00 2001 From: Pedro de Oliveira Date: Wed, 5 Jun 2019 23:37:26 +0100 Subject: [PATCH] Simplificar output, assim fica so uma linha. --- Maria/plugin.py | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/Maria/plugin.py b/Maria/plugin.py index 6af0caa..0572070 100644 --- a/Maria/plugin.py +++ b/Maria/plugin.py @@ -48,8 +48,10 @@ class Maria(callbacks.Plugin): self.__parent = super(Maria, self) self.__parent.__init__(irc) - def __format_message(self, data): - return "{} - #{} - {} [{}]".format( + def __format_message(self, data, position): + return "[{}/{}] {} - #{} - {} [{}]".format( + data['next'] - 1 if data['next'] > 0 else 1, + data['total'], data['message']['text'], data['message']['user'], data['message']['datetime'], @@ -67,13 +69,7 @@ class Maria(callbacks.Plugin): Returns the last message, or last + position. """ data = self.__do_request('latest', {'position': position}) - - if data['next'] > 0: - irc.reply("{} found 'maria latest {}' for the next one".format( - data['total'], - data['next'] - ), prefixNick=False) - irc.reply(self.__format_message(data), prefixNick=False) + irc.reply(self.__format_message(data, position), prefixNick=False) latest = wrap(latest, [optional('int', default=0)]) def find(self, irc, msg, args, text, position): @@ -91,13 +87,7 @@ class Maria(callbacks.Plugin): irc.reply(data['error'], prefixNick=False) return - if data['next'] > 0: - irc.reply("{} found. 'maria find {} {}' for the next one".format( - data['total'], - text, - data['next'] - ), prefixNick=False) - irc.reply(self.__format_message(data), prefixNick=False) + irc.reply(self.__format_message(data, position), prefixNick=False) find = wrap(find, ['anything', optional('int', default=0)]) def random(self, irc, msg, args):