TimeBomb: cutwire/duck fixes.

This commit is contained in:
oddluck 2020-02-09 15:33:48 +00:00
parent 179d628c33
commit bcb1e2cea1

View File

@ -84,6 +84,7 @@ class TimeBomb(callbacks.Plugin):
self.showCorrectWire = showCorrectWire self.showCorrectWire = showCorrectWire
self.debug = debug self.debug = debug
self.thrown = False self.thrown = False
self.rethrown = False
self.responded = False self.responded = False
self.rng = random.Random() self.rng = random.Random()
self.rng.seed() self.rng.seed()
@ -140,13 +141,11 @@ class TimeBomb(callbacks.Plugin):
self.victim = self.sender self.victim = self.sender
self.sender = tmp self.sender = tmp
self.thrown = True self.thrown = True
self.rethrown = True
schedule.rescheduleEvent('{}_bomb'.format(self.channel), time.time() + 10) schedule.rescheduleEvent('{}_bomb'.format(self.channel), time.time() + 10)
if self.victim == irc.nick: if self.victim == irc.nick:
time.sleep(1) self.defuse()
self.irc.queueMsg(ircmsgs.privmsg(self.channel, '@duck'))
time.sleep(1)
self.duck(self.irc, irc.nick)
else: else:
self.defuse() self.defuse()
else: else:
@ -294,9 +293,8 @@ class TimeBomb(callbacks.Plugin):
DUCK! (You'll want to do this if someone throws a bomb back at you.) DUCK! (You'll want to do this if someone throws a bomb back at you.)
""" """
channel = ircutils.toLower(channel) channel = ircutils.toLower(channel)
try: try:
if not self.bombs[channel].active: if not self.bombs[channel].active or not self.bombs[channel].rethrown or not ircutils.nickEqual(self.bombs[channel].victim, msg.nick):
return return
except KeyError: except KeyError:
return return
@ -448,7 +446,7 @@ class TimeBomb(callbacks.Plugin):
""" """
channel = ircutils.toLower(channel) channel = ircutils.toLower(channel)
try: try:
if not self.bombs[channel].active: if not self.bombs[channel].active or self.bombs[channel].rethrown:
return return
if not ircutils.nickEqual(self.bombs[channel].victim, msg.nick) and not ircdb.checkCapability(msg.prefix, 'admin'): if not ircutils.nickEqual(self.bombs[channel].victim, msg.nick) and not ircdb.checkCapability(msg.prefix, 'admin'):