From 82d942607ed9d3d1f04a9b0df624e02788a984c6 Mon Sep 17 00:00:00 2001 From: jcao219 Date: Tue, 9 Aug 2011 20:55:52 -0500 Subject: [PATCH] refactoring (multiple target privmsg) --- wolfgame.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/wolfgame.py b/wolfgame.py index 88d461f..1c09270 100644 --- a/wolfgame.py +++ b/wolfgame.py @@ -1662,6 +1662,17 @@ def getfeatures(cli, nick, *rest): +def mass_privmsg(cli, targets, msg): + while targets: + if len(targets) <= var.MAX_PRIVMSG_TARGETS: + bgs = ",".join(targets) + targets = () + else: + bgs = ",".join(targets[0:var.MAX_PRIVMSG_TARGETS]) + targets = targets[var.MAX_PRIVMSG_TARGETS:] + cli.msg(bgs, msg) + + @pmcmd("") def relay(cli, nick, rest): @@ -1671,14 +1682,7 @@ def relay(cli, nick, rest): if len(badguys) > 1: if nick in badguys: badguys.remove(nick) # remove self from list - while badguys: - if len(badguys) <= var.MAX_PRIVMSG_TARGETS: - bgs = ",".join(badguys) - badguys = [] - else: - bgs = ",".join(badguys[0:var.MAX_PRIVMSG_TARGETS]) - badguys = badguys[var.MAX_PRIVMSG_TARGETS:] - cli.msg(bgs, "\02{0}\02 says: {1}".format(nick, rest)) + mass_privmsg(cli, badguys, "\02{0}\02 says: {1}".format(nick, rest))