summaryrefslogtreecommitdiff
path: root/mentio.py
diff options
context:
space:
mode:
authorjomo <github@jomo.tv>2014-06-21 12:47:25 +0200
committerjomo <github@jomo.tv>2014-06-21 12:47:25 +0200
commit7dcda40b1ac8642e7d379bede367b4919b69e08d (patch)
tree70ffef7ff2dfcfc7f8b50bf657639fb4d5708715 /mentio.py
parenteb06427ecfcc08ee0555a6ba472a815b23983948 (diff)
only using recipient list when iterating
Diffstat (limited to 'mentio.py')
-rw-r--r--mentio.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/mentio.py b/mentio.py
index 1d29d57..bda1e6d 100644
--- a/mentio.py
+++ b/mentio.py
@@ -13,9 +13,9 @@ def onChat(event):
if not event.isCancelled():
sender = event.getPlayer()
words = event.getMessage().split(" ")
- recipients = list(event.getRecipients())
+ recipients = event.getRecipients()
- for recipient in recipients[:]:
+ for recipient in recipients.tolist():
rec_words = words[:] # copy
for i in range(len(rec_words)):
word = rec_words[i]
@@ -25,9 +25,10 @@ def onChat(event):
# player was mentioned
if rec_words != words:
- try: # list might not be mutable
+ try:
recipients.remove(recipient) # don't send original message
except:
+ # list might not be mutable, ignoring. Receiver will get the message twice
pass
message = " ".join([sender.getDisplayName(), arrow] + rec_words)
msg(recipient, message, usecolor = False)