def cutwire(self, irc, cutWire): self.cutWire = cutWire self.responded = True if self.thrown == True: self.irc.queueMsg( ircmsgs.privmsg( self.channel, 'You don\'t have the coordination to cut wires on bombs in midair while they\'re flying towards your head! Ducking might be a better idea.' )) else: if self.goodWire.lower() == self.cutWire.lower(): self.irc.queueMsg( ircmsgs.privmsg( self.channel, '%s has cut the %s wire! This has defused the bomb!' % (self.victim, self.cutWire))) self.irc.queueMsg( ircmsgs.privmsg( self.channel, 'He then quickly rearms the bomb and throws it back at %s with just seconds on the clock!' % self.sender)) self.victim = self.sender self.thrown = True schedule.rescheduleEvent('%s_bomb' % self.channel, time.time() + 5) if self.victim == irc.nick: time.sleep(1) self.irc.queueMsg( ircmsgs.privmsg(self.channel, '@duck')) time.sleep(1) self.duck(self.irc, irc.nick) else: schedule.removeEvent('%s_bomb' % self.channel) self.detonate(irc)
def cutwire(self, irc, cutWire): cutWire = cutWire.replace("pink", ircutils.mircColor('pink', '13')) cutWire = cutWire.replace("red", ircutils.mircColor('red', '4')) cutWire = cutWire.replace("orange", ircutils.mircColor('orange', '7')) cutWire = cutWire.replace("yellow", ircutils.mircColor('yellow', '8')) cutWire = cutWire.replace("green", ircutils.mircColor('green', '3')) cutWire = cutWire.replace("blue", ircutils.mircColor('blue', '12')) cutWire = cutWire.replace("grey", ircutils.mircColor('grey', '14')) cutWire = cutWire.replace("purple", ircutils.mircColor('purple', '6')) cutWire = cutWire.replace("lime", ircutils.mircColor('lime', '9')) cutWire = cutWire.replace("teal", ircutils.mircColor('teal', '10')) cutWire = cutWire.replace("brown", ircutils.mircColor('brown', '5')) cutWire = cutWire.replace("cyan", ircutils.mircColor('cyan', '11')) self.cutWire = cutWire self.responded = True if self.thrown == True: self.irc.queueMsg(ircmsgs.privmsg(self.channel, 'You don\'t have the coordination to cut wires on bombs in midair while they\'re flying towards your head! Ducking might be a better idea.')) else: if self.goodWire.lower() == self.cutWire.lower(): self.irc.queueMsg(ircmsgs.privmsg(self.channel, '%s has cut the %s wire! This has defused the bomb!' % (self.victim, self.cutWire))) self.irc.queueMsg(ircmsgs.privmsg(self.channel, '%s then quickly rearms the bomb and throws it back at %s with just seconds on the clock!' % (self.victim, self.sender))) self.victim = self.sender self.thrown = True schedule.rescheduleEvent('%s_bomb' % self.channel, time.time() + 10) if self.victim == irc.nick: time.sleep(1) self.irc.queueMsg(ircmsgs.privmsg(self.channel, '@duck')) time.sleep(1) self.duck(self.irc, irc.nick) else: schedule.removeEvent('%s_bomb' % self.channel) self.detonate(irc)
def testOpFail(self): import supybot.drivers as drivers import supybot.schedule as schedule pluginConf.autoremove.notify.channels.set('#test') try: cb = self.getCallback() self.feedBan('asd!*@*') self.assertNotError('duration 1 1') print 'waiting 4 secs ...' time.sleep(2) cb.autoRemoveBans(self.irc) msg = self.irc.takeMsg() # op msg self.assertEqual(str(msg).strip(), "PRIVMSG Chanserv :op #test test") schedule.rescheduleEvent('Bantracker_getop_#test', 1) time.sleep(2) drivers.run() msg = self.irc.takeMsg() # fail msg self.assertEqual(str(msg).strip(), "NOTICE #test :Failed to get op in #test") self.op() msg = self.irc.takeMsg() # unban msg self.assertEqual(str(msg).strip(), "MODE #test -b :asd!*@*") finally: pluginConf.autoremove.notify.channels.set('')
def cutwire(self, irc, cutWire): self.cutWire = cutWire self.responded = True specialWires = False if self.rng.randint(1, len(self.wires)) == 1 or self.victim.lower() == 'jacksonmj': specialWires = True if self.cutWire.lower() == 'potato' and specialWires: self.irc.queueMsg(ircmsgs.privmsg(self.channel, '{} has turned the bomb into a potato! This has rendered it mostly harmless, and slightly{}.'.format(self.victim, self.goodWire))) self.defuse() elif self.cutWire.lower() == 'pizza' and specialWires: self.irc.queueMsg(ircmsgs.privmsg(self.channel, '{0} has turned the bomb into a pizza! {0}\'s pants have been ruined by the pizza stuffed into them, but at least they haven\'t exploded.'.format(self.victim))) self.defuse() elif self.goodWire.lower() == self.cutWire.lower(): self.irc.queueMsg(ircmsgs.privmsg(self.channel, '{} has cut the {} wire! This has defused the bomb!'.format(self.victim, self.cutWire))) if self.victim.lower() != self.sender.lower(): self.irc.queueMsg(ircmsgs.privmsg(self.channel, 'He then quickly rearms the bomb and throws it back at {} with just seconds on the clock!'.format(self.sender))) tmp = self.victim self.victim = self.sender self.sender = tmp self.thrown = True schedule.rescheduleEvent('{}_bomb'.format(self.channel), time.time() + 10) if self.victim == irc.nick: time.sleep(1) self.irc.queueMsg(ircmsgs.privmsg(self.channel, '@duck')) time.sleep(1) self.duck(self.irc, irc.nick) else: self.defuse() else: schedule.removeEvent('{}_bomb'.format(self.channel)) self.detonate(irc)
def cutwire(self, irc, cutWire): self.cutWire = cutWire self.responded = True specialWires = False if self.rng.randint(1,len(self.wires)) == 1 or self.victim.lower()=='jacksonmj': specialWires = True if self.cutWire.lower() == 'potato' and specialWires: self.irc.queueMsg(ircmsgs.privmsg(self.channel, '%s has turned the bomb into a potato! This has rendered it mostly harmless, and slightly %s.' % (self.victim, self.goodWire))) self.defuse() elif self.cutWire.lower() == 'pizza' and specialWires: self.irc.queueMsg(ircmsgs.privmsg(self.channel, '%s has turned the bomb into a pizza! %s\'s pants have been ruined by the pizza stuffed into them, but at least they haven\'t exploded.' % (self.victim, self.victim))) self.defuse() elif self.goodWire.lower() == self.cutWire.lower(): self.irc.queueMsg(ircmsgs.privmsg(self.channel, '%s has cut the %s wire! This has defused the bomb!' % (self.victim, self.cutWire))) if self.victim.lower() != self.sender.lower(): self.irc.queueMsg(ircmsgs.privmsg(self.channel, 'He then quickly rearms the bomb and throws it back at %s with just seconds on the clock!' % self.sender)) tmp = self.victim self.victim = self.sender self.sender = tmp self.thrown = True schedule.rescheduleEvent('%s_bomb' % self.channel, time.time() + 10) if self.victim == irc.nick: time.sleep(1) self.irc.queueMsg(ircmsgs.privmsg(self.channel, '@duck')) time.sleep(1) self.duck(self.irc, irc.nick) else: self.defuse() else: schedule.removeEvent('%s_bomb' % self.channel) self.detonate(irc)
def cutwire(self, irc, cutWire): self.cutWire = cutWire self.responded = True if self.goodWire.lower() == self.cutWire.lower(): self.irc.queueMsg( ircmsgs.privmsg( self.channel, '%s has cut the %s wire! This has defused the bomb!' % (self.victim, self.cutWire))) self.irc.queueMsg( ircmsgs.privmsg( self.channel, 'He then quickly rearms the bomb and throws it back at %s with just seconds on the clock!' % self.sender)) self.victim = self.sender self.thrown = True schedule.rescheduleEvent('%s_bomb' % self.channel, time.time() + 5) if self.victim == irc.nick: time.sleep(1) self.irc.queueMsg(ircmsgs.privmsg(self.channel, '@duck')) time.sleep(1) self.duck(self.irc, irc.nick) else: schedule.removeEvent('%s_bomb' % self.channel) self.detonate(irc)
def cutwire(self, irc, cutWire): self.cutWire = cutWire self.responded = True specialWires = False if self.rng.randint(1, len(self.wires)) == 1: specialWires = True if self.cutWire.lower() == "potato" and specialWires: self.irc.queueMsg( ircmsgs.privmsg( self.channel, "{} has turned the bomb into a potato! This has rendered it" " mostly harmless, and slightly {}.".format( self.victim, self.goodWire), )) self.defuse() elif self.cutWire.lower() == "pizza" and specialWires: self.irc.queueMsg( ircmsgs.privmsg( self.channel, "{} has turned the bomb into a pizza! Their pants have been" " ruined by the pizza stuffed into them, but at least they" " haven't exploded.".format(self.victim), )) self.defuse() elif self.goodWire.lower() == self.cutWire.lower(): self.irc.queueMsg( ircmsgs.privmsg( self.channel, "{} has cut the {} wire! This has defused the bomb!". format(self.victim, self.cutWire), )) if self.victim.lower() != self.sender.lower(): self.irc.queueMsg( ircmsgs.privmsg( self.channel, "{} quickly rearms the bomb and throws it back at {} with" " just seconds on the clock!".format( self.victim, self.sender), )) tmp = self.victim self.victim = self.sender self.sender = tmp self.thrown = True self.rethrown = True schedule.rescheduleEvent("{}_bomb".format(self.channel), time.time() + 10) if self.victim == irc.nick: self.defuse() else: self.defuse() else: schedule.removeEvent("{}_bomb".format(self.channel)) self.detonate(irc)
def detonate(self, irc, msg, args, channel): """Takes no arguments Detonates the active bomb.""" channel = ircutils.toLower(channel) try: if self.bombs[channel].active: schedule.rescheduleEvent("%s_bomb" % channel, time.time()) except KeyError: if self.registryValue("debug"): irc.reply('I tried to detonate a bomb in "%s"' % channel) irc.reply("List of bombs: %s" % self.bombs.keys()) irc.noReply()
def detonate(self, irc, msg, args, channel): """Takes no arguments Detonates the active bomb.""" channel = ircutils.toLower(channel) try: if self.bombs[channel].active: schedule.rescheduleEvent('%s_bomb' % channel, time.time()) except KeyError: if self.registryValue('debug'): irc.reply('I tried to detonate a bomb in "%s"' % channel) irc.reply('List of bombs: %s' % self.bombs.keys()) irc.noReply()
def detonate(self, irc, msg, args, channel): """Takes no arguments Detonates the active bomb.""" channel = ircutils.toLower(channel) try: if self.bombs[channel].active: schedule.rescheduleEvent('{}_bomb'.format(channel), time.time()) except KeyError: if self.registryValue('debug'): irc.reply('I tried to detonate a bomb in "{}"'.format(channel)) irc.reply('List of bombs: {}'.format(", ".join(list(self.bombs.keys())))) irc.noReply()
def cutwire(self, irc, cutWire): cutWire = cutWire.replace("pink", ircutils.mircColor('pink', '13')) cutWire = cutWire.replace("red", ircutils.mircColor('red', '4')) cutWire = cutWire.replace("orange", ircutils.mircColor('orange', '7')) cutWire = cutWire.replace("yellow", ircutils.mircColor('yellow', '8')) cutWire = cutWire.replace("green", ircutils.mircColor('green', '3')) cutWire = cutWire.replace("blue", ircutils.mircColor('blue', '12')) cutWire = cutWire.replace("grey", ircutils.mircColor('grey', '14')) cutWire = cutWire.replace("purple", ircutils.mircColor('purple', '6')) cutWire = cutWire.replace("lime", ircutils.mircColor('lime', '9')) cutWire = cutWire.replace("teal", ircutils.mircColor('teal', '10')) cutWire = cutWire.replace("brown", ircutils.mircColor('brown', '5')) cutWire = cutWire.replace("cyan", ircutils.mircColor('cyan', '11')) self.cutWire = cutWire self.responded = True if self.thrown == True: self.irc.queueMsg( ircmsgs.privmsg( self.channel, 'You don\'t have the coordination to cut wires on bombs in midair while they\'re flying towards your head! Ducking might be a better idea.' )) else: if self.goodWire.lower() == self.cutWire.lower(): self.irc.queueMsg( ircmsgs.privmsg( self.channel, '%s has cut the %s wire! This has defused the bomb!' % (self.victim, self.cutWire))) self.irc.queueMsg( ircmsgs.privmsg( self.channel, '%s then quickly rearms the bomb and throws it back at %s with just seconds on the clock!' % (self.victim, self.sender))) self.victim = self.sender self.thrown = True schedule.rescheduleEvent('%s_bomb' % self.channel, time.time() + 10) if self.victim == irc.nick: time.sleep(1) self.irc.queueMsg( ircmsgs.privmsg(self.channel, '@duck')) time.sleep(1) self.duck(self.irc, irc.nick) else: schedule.removeEvent('%s_bomb' % self.channel) self.detonate(irc)
def cutwire(self, irc, cutWire): self.cutWire = cutWire self.responded = True if self.goodWire.lower() == self.cutWire.lower(): self.irc.queueMsg(ircmsgs.privmsg(self.channel, '%s has cut the %s wire! This has defused the bomb!' % (self.victim, self.cutWire))) self.irc.queueMsg(ircmsgs.privmsg(self.channel, 'He then quickly rearms the bomb and throws it back at %s with just seconds on the clock!' % self.sender)) self.victim = self.sender self.thrown = True schedule.rescheduleEvent('%s_bomb' % self.channel, time.time() + 5) if self.victim == irc.nick: time.sleep(1) self.irc.queueMsg(ircmsgs.privmsg(self.channel, '@duck')) time.sleep(1) self.duck(self.irc, irc.nick) else: schedule.removeEvent('%s_bomb' % self.channel) self.detonate(irc)
def cutwire(self, irc, cutWire): self.cutWire = cutWire self.responded = True if self.thrown == True: self.irc.queueMsg( ircmsgs.privmsg( self.channel, "You don't have the coordination to cut wires on bombs in midair while they're flying towards your head! Ducking might be a better idea.", ) ) else: if self.goodWire.lower() == self.cutWire.lower(): self.irc.queueMsg( ircmsgs.privmsg( self.channel, "%s has cut the %s wire! This has defused the bomb!" % (self.victim, self.cutWire), ) ) if self.sender != "TJSB" and self.sender != "EnderBlue": # self.irc.queueMsg(ircmsgs.privmsg(self.channel, 'self.sender: %s' % self.sender)) self.irc.queueMsg( ircmsgs.privmsg( self.channel, "He then quickly rearms the bomb and throws it back at %s with just seconds on the clock!" % self.sender, ) ) self.victim = self.sender self.thrown = True schedule.rescheduleEvent("%s_bomb" % self.channel, time.time() + 5) if self.victim == irc.nick: time.sleep(1) self.irc.queueMsg(ircmsgs.privmsg(self.channel, "@duck")) time.sleep(1) self.duck(self.irc, irc.nick) else: schedule.removeEvent("%s_bomb" % self.channel) self.active = False self.thrown = False else: schedule.removeEvent("%s_bomb" % self.channel) self.detonate(irc)
def cutwire(self, irc, cutWire): self.cutWire = cutWire self.responded = True if self.thrown == True: self.irc.queueMsg(ircmsgs.privmsg(self.channel, 'You don\'t have the coordination to cut wires on bombs in midair while they\'re flying towards your head! Ducking might be a better idea.')) else: if self.goodWire.lower() == self.cutWire.lower(): self.irc.queueMsg(ircmsgs.privmsg(self.channel, '%s has cut the %s wire! This has defused the bomb!' % (self.victim, self.cutWire))) self.irc.queueMsg(ircmsgs.privmsg(self.channel, 'He then quickly rearms the bomb and throws it back at %s with just seconds on the clock!' % self.sender)) self.victim = self.sender self.thrown = True schedule.rescheduleEvent('%s_bomb' % self.channel, time.time() + 5) if self.victim == irc.nick: time.sleep(1) self.irc.queueMsg(ircmsgs.privmsg(self.channel, '@duck')) time.sleep(1) self.duck(self.irc, irc.nick) else: schedule.removeEvent('%s_bomb' % self.channel) self.detonate(irc)
def cutwire(self, irc, cutWire): self.cutWire = cutWire self.responded = True specialWires = False if self.rng.randint(1, len(self.wires)) == 1 or self.victim.lower() == "jacksonmj": specialWires = True if self.cutWire.lower() == "potato" and specialWires: self.irc.queueMsg( ircmsgs.privmsg( self.channel, "{} has turned the bomb into a potato! This has rendered it mostly harmless, and slightly{}.".format( self.victim, self.goodWire ), ) ) self.defuse() elif self.cutWire.lower() == "pizza" and specialWires: self.irc.queueMsg( ircmsgs.privmsg( self.channel, "{0} has turned the bomb into a pizza! {0}'s pants have been ruined by the pizza stuffed into them, but at least they haven't exploded.".format( self.victim ), ) ) self.defuse() elif self.goodWire.lower() == self.cutWire.lower(): self.irc.queueMsg( ircmsgs.privmsg( self.channel, "{} has cut the {} wire! This has defused the bomb!".format(self.victim, self.cutWire), ) ) if self.victim.lower() != self.sender.lower(): self.irc.queueMsg( ircmsgs.privmsg( self.channel, "He then quickly rearms the bomb and throws it back at {} with just seconds on the clock!".format( self.sender ), ) ) tmp = self.victim self.victim = self.sender self.sender = tmp self.thrown = True schedule.rescheduleEvent("{}_bomb".format(self.channel), time.time() + 10) if self.victim == irc.nick: time.sleep(1) self.irc.queueMsg(ircmsgs.privmsg(self.channel, "@duck")) time.sleep(1) self.duck(self.irc, irc.nick) else: self.defuse() else: schedule.removeEvent("{}_bomb".format(self.channel)) self.detonate(irc)