New builtin IRC command: !next, similar to !more

This commit is contained in:
nemunaire 2014-08-28 12:43:22 +02:00
parent 97143a0182
commit 039c578987
2 changed files with 13 additions and 3 deletions

12
bot.py
View File

@ -443,6 +443,18 @@ class Bot:
if msg.channel in srv.moremessages: if msg.channel in srv.moremessages:
return srv.moremessages[msg.channel] return srv.moremessages[msg.channel]
elif msg.cmds[0] == "next":
ret = None
if msg.channel == srv.nick:
if msg.sender in srv.moremessages:
ret = srv.moremessages[msg.sender]
else:
if msg.channel in srv.moremessages:
ret = srv.moremessages[msg.channel]
if ret is not None:
ret.pop()
return ret
elif msg.cmds[0] == "dcc": elif msg.cmds[0] == "dcc":
logger.debug("dcctest for %s", msg.sender) logger.debug("dcctest for %s", msg.sender)
srv.send_dcc("Hello %s!" % msg.nick, msg.sender) srv.send_dcc("Hello %s!" % msg.nick, msg.sender)

View File

@ -100,6 +100,7 @@ class Response:
def pop(self): def pop(self):
self.messages.pop(0) self.messages.pop(0)
self.elt = 0
if isinstance(self.rawtitle, list): if isinstance(self.rawtitle, list):
self.rawtitle.pop(0) self.rawtitle.pop(0)
if len(self.rawtitle) <= 0: if len(self.rawtitle) <= 0:
@ -136,13 +137,11 @@ class Response:
msg += e + ", " msg += e + ", "
self.elt += 1 self.elt += 1
self.pop() self.pop()
self.elt = 0
return msg[:len(msg)-2] return msg[:len(msg)-2]
else: else:
if len(elts) <= 432: if len(elts) <= 432:
self.pop() self.pop()
self.elt = 0
if self.count is not None: if self.count is not None:
return msg + elts + (self.count % len(self.messages)) return msg + elts + (self.count % len(self.messages))
else: else:
@ -164,7 +163,6 @@ class Response:
msg += w + " " msg += w + " "
self.elt += len(w) + 1 self.elt += len(w) + 1
self.pop() self.pop()
self.elt = 0
return msg return msg
import hooks import hooks