Add the ability to mute kills

This commit is contained in:
2014-08-27 21:49:03 +01:00
parent ed09054447
commit be84774880
2 changed files with 11 additions and 2 deletions

View File

@@ -46,6 +46,7 @@ class DropBot(ClientXMPP):
self.last_killdate = datetime.utcnow()
self.kill_corps = [int(x) for x in kwargs.pop('kill_corps', [])]
self.kill_check_timeout = kwargs.pop('kill_check_timeout', 300)
self.kills_muted = False
self.redis_pool = ConnectionPool.from_url(kwargs.pop('redis_url', 'redis://localhost:6379/0'))
self.redis = Redis(connection_pool=self.redis_pool)
@@ -610,4 +611,11 @@ class DropBot(ClientXMPP):
len(kill['attackers']),
intcomma(kill['zkb']['totalValue']),
url,
)
def cmd_togglekills(self, args, msg):
"""Toggles the broadcasting of kills to MUC channels"""
self.kills_muted = not self.kills_muted
return 'Kill messages: {}'.format(
'muted' if self.kills_muted else 'not muted'
)

View File

@@ -25,8 +25,9 @@ class ZKillboardStompListener(object):
print message
body, html = self.bot.call_command('kill', [], None, no_url=False, raw=kill)
text = 'New Kill: {}'.format(body)
for room in self.bot.rooms:
self.bot.send_message(room, text, mtype='groupchat')
if not self.bot.kills_muted:
for room in self.bot.rooms:
self.bot.send_message(room, text, mtype='groupchat')
def connect(self, url):