From ed0af3cdb7ef62c3f2ceb41d5be8d42abebc4d07 Mon Sep 17 00:00:00 2001 From: quantumlemur Date: Thu, 25 Mar 2010 18:47:21 -0400 Subject: [PATCH 01/20] First commit, with LinkRelay and Timebomb plugins --- README.txt | 1 + __init__.py | 76 ++++++++++++++++ config.py | 75 +++++++++++++++ plugin.py | 256 ++++++++++++++++++++++++++++++++++++++++++++++++++++ test.py | 37 ++++++++ 5 files changed, 445 insertions(+) create mode 100644 README.txt create mode 100644 __init__.py create mode 100644 config.py create mode 100644 plugin.py create mode 100644 test.py diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..d60b47a --- /dev/null +++ b/README.txt @@ -0,0 +1 @@ +Insert a description of your plugin here, with any notes, etc. about using it. diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..9dd9e4c --- /dev/null +++ b/__init__.py @@ -0,0 +1,76 @@ +### +# Copyright (c) 2010, quantumlemur +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions, and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions, and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the author of this software nor the name of +# contributors to this software may be used to endorse or promote products +# derived from this software without specific prior written consent. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +### + + +# Many thanks to pawarswap for the ascii-art bomb! + +""" +Add a description of the plugin (to be presented to the user inside the wizard) +here. This should describe *what* the plugin does. +""" + +import supybot +import supybot.world as world + +# Use this for the version of this plugin. You may wish to put a CVS keyword +# in here if you're keeping the plugin in CVS or some similar system. +__version__ = "" + +# XXX Replace this with an appropriate author or supybot.Author instance. +__author__ = supybot.authors.unknown + +# This is a dictionary mapping supybot.Author instances to lists of +# contributions. +__contributors__ = {} + +# This is a url where the most recent plugin package can be downloaded. +__url__ = '' # 'http://supybot.com/Members/yourname/Timebomb/download' + +import config +import plugin +reload(plugin) # In case we're being reloaded. +# Add more reloads here if you add third-party modules and want them to be +# reloaded when this plugin is reloaded. Don't forget to import them as well! +import sys +if not '/home/eggdrop/supybot/modules' in sys.path: + sys.path.append('/home/eggdrop/supybot/modules') +import scihd + +reload(scihd) + + +if world.testing: + import test + +Class = plugin.Class +configure = config.configure + + +# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/config.py b/config.py new file mode 100644 index 0000000..6421585 --- /dev/null +++ b/config.py @@ -0,0 +1,75 @@ +### +# Copyright (c) 2010, quantumlemur +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions, and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions, and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the author of this software nor the name of +# contributors to this software may be used to endorse or promote products +# derived from this software without specific prior written consent. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +### + +import supybot.conf as conf +import supybot.registry as registry + +def configure(advanced): + # This will be called by supybot to configure this module. advanced is + # a bool that specifies whether the user identified himself as an advanced + # user or not. You should effect your configuration by manipulating the + # registry as appropriate. + from supybot.questions import expect, anything, something, yn + conf.registerPlugin('Timebomb', True) + + +Timebomb = conf.registerPlugin('Timebomb') +# This is where your configuration variables (if any) should go. For example: +# conf.registerGlobalValue(Timebomb, 'someConfigVariableName', +# registry.Boolean(False, """Help for someConfigVariableName.""")) +conf.registerGlobalValue(Timebomb, 'colors', + registry.SpaceSeparatedListOfStrings(['AliceBlue', 'AntiqueWhite', 'Aqua', 'Aquamarine', 'Azure', 'Beige', 'Bisque', 'Black', 'BlanchedAlmond', 'Blue', 'BlueViolet', 'Brown', 'BurlyWood', 'CadetBlue', 'Chartreuse', 'Chocolate', 'Coral', 'CornflowerBlue', 'Cornsilk', 'Crimson', 'Cyan', 'DarkBlue', 'DarkCyan', 'DarkGoldenRod', 'DarkGray', 'DarkGreen', 'DarkKhaki', 'DarkMagenta', 'DarkOliveGreen', 'DarkOrange', 'DarkOrchid', 'DarkRed', 'DarkSalmon', 'DarkSeaGreen', 'DarkSlateBlue', 'DarkSlateGray', 'DarkTurquoise', 'DarkViolet', 'DeepPink', 'DeepSkyBlue', 'DimGray', 'DodgerBlue', 'FireBrick', 'FloralWhite', 'ForestGreen', 'Fuchsia', 'Gainsboro', 'GhostWhite', 'Gold', 'GoldenRod', 'Gray', 'Green', 'GreenYellow', 'HoneyDew', 'HotPink', 'IndianRed', 'Indigo', 'Ivory', 'Khaki', 'Lavender', 'LavenderBlush', 'LawnGreen', 'LemonChiffon', 'LightBlue', 'LightCoral', 'LightCyan', 'LightGoldenRodYellow', 'LightGrey', 'LightGreen', 'LightPink', 'LightSalmon', 'LightSeaGreen', 'LightSkyBlue', 'LightSlateGray', 'LightSteelBlue', 'LightYellow', 'Lime', 'LimeGreen', 'Linen', 'Magenta', 'Maroon', 'MediumAquaMarine', 'MediumBlue', 'MediumOrchid', 'MediumPurple', 'MediumSeaGreen', 'MediumSlateBlue', 'MediumSpringGreen', 'MediumTurquoise', 'MediumVioletRed', 'MidnightBlue', 'MintCream', 'MistyRose', 'Moccasin', 'NavajoWhite', 'Navy', 'OldLace', 'Olive', 'OliveDrab', 'Orange', 'OrangeRed', 'Orchid', 'PaleGoldenRod', 'PaleGreen', 'PaleTurquoise', 'PaleVioletRed', 'PapayaWhip', 'PeachPuff', 'Peru', 'Pink', 'Plum', 'PowderBlue', 'Purple', 'Red', 'RosyBrown', 'RoyalBlue', 'SaddleBrown', 'Salmon', 'SandyBrown', 'SeaGreen', 'SeaShell', 'Sienna', 'Silver', 'SkyBlue', 'SlateBlue', 'SlateGray', 'Snow', 'SpringGreen', 'SteelBlue', 'Tan', 'Teal', 'Thistle', 'Tomato', 'Turquoise', 'Violet', 'Wheat', 'White', 'WhiteSmoke', 'Yellow', 'YellowGreen'], + """The set of possible timebomb wire colors""")) + +conf.registerGlobalValue(Timebomb, 'shortcolors', + registry.SpaceSeparatedListOfStrings(['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'pink', 'black', 'brown', 'gray', 'white'], + """The set of possible timebomb wire colors when there are few wires""")) + +conf.registerChannelValue(Timebomb, 'exclusions', + registry.SpaceSeparatedListOfStrings([], + """A list of nicks who should be excluded from being randombombed""")) + +conf.registerChannelValue(Timebomb, 'allowBombs', + registry.Boolean(False, """Determines whether timebombs are allowed in the channel.""")) + +conf.registerGlobalValue(Timebomb, 'minWires', + registry.PositiveInteger(3, """Determines the minimum number of wires a timebomb will have.""")) + +conf.registerGlobalValue(Timebomb, 'maxWires', + registry.PositiveInteger(5, """Determines the maximum number of wires a timebomb will have.""")) + +conf.registerGlobalValue(Timebomb, 'minTime', + registry.PositiveInteger(30, """Determines the minimum time of a timebomb timer, in seconds.""")) + +conf.registerGlobalValue(Timebomb, 'maxTime', + registry.PositiveInteger(60, """Determines the maximum time of a timebomb timer, in seconds.""")) + + +# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/plugin.py b/plugin.py new file mode 100644 index 0000000..f850746 --- /dev/null +++ b/plugin.py @@ -0,0 +1,256 @@ +### +# Copyright (c) 2010, quantumlemur +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions, and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions, and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the author of this software nor the name of +# contributors to this software may be used to endorse or promote products +# derived from this software without specific prior written consent. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +### + +import time +import string +import random +import supybot.utils as utils +import supybot.world as world +from supybot.commands import * +import supybot.plugins as plugins +import supybot.ircmsgs as ircmsgs +import supybot.ircutils as ircutils +import supybot.schedule as schedule +import supybot.callbacks as callbacks + + +class Timebomb(callbacks.Plugin): + """Add the help for "@plugin help Timebomb" here + This should describe *how* to use this plugin.""" + threaded = True + + def __init__(self, irc): + self.__parent = super(Timebomb, self) + self.__parent.__init__(irc) + self.rng = random.Random() + self.rng.seed() + self.bombs = {} + self.lastBomb = "" + self.talktimes = {} + + + def doPrivmsg(self, irc, msg): + self.talktimes[msg.nick] = time.time() + + +# def doJoin(self, irc, msg): +# self.talktimes[msg.nick] = time.time() + + + class Bomb(): + def __init__(self, irc, victim, wires, detonateTime, goodWire, channel, sender): + self.victim = victim + self.detonateTime = detonateTime + self.wires = wires + self.goodWire = goodWire + self.active = True + self.channel = channel + self.sender = sender + self.irc = irc + self.thrown = False + self.responded = False + def detonate(): + self.detonate(irc) + schedule.addEvent(detonate, time.time() + self.detonateTime, 'bomb') + s = 'stuffs a bomb down %s\'s pants. The timer is set for %s seconds! There are %s wires. They are: %s.' % (self.victim, self.detonateTime, len(wires), utils.str.commaAndify(wires)) + self.irc.queueMsg(ircmsgs.action(self.channel, s)) + + 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('bomb', time.time() + 5) + else: + schedule.removeEvent('bomb') + self.detonate(irc) + + def duck(self, irc, ducker): + if self.thrown and ircutils.nickEqual(self.victim, ducker): + self.irc.queueMsg(ircmsgs.privmsg(self.channel, '%s ducks! The bomb misses, and explodes harmlessly a few meters away.' % self.victim)) + self.active = False + self.thrown = False + schedule.removeEvent('bomb') + + def detonate(self, irc): + self.active = False + self.thrown = False + self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.....\x0315,1_.\x0314,1-^^---....,\x0315,1,-_\x031,1.......')) + self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.\x0315,1_--\x0314,1,.\';,`.,\';,.;;`;,.\x0315,1--_\x031,1...')) + self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x0315,1<,.\x0314,1;\'`".,;`..,;`*.,\';`.\x0315,1;\'>)\x031,1.')) + self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x0315,1I.:;\x0314,1.,`;~,`.;\'`,.;\'`,..\x0315,1\';`I\x031,1.')) + self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.\x0315,1\\_.\x0314,1`\'`..`\';.,`\';,`\';,\x0315,1_../\x031,1..')) + self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1....\x0315,1```\x0314,1--. . , ; .--\x0315,1\'\'\'\x031,1.....')) + self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1..........\x034,1I\x031,1.\x038,1I\x037,1I\x031,1.\x038,1I\x034,1I\x031,1...........')) + self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1..........\x034,1I\x031,1.\x037,1I\x038,1I\x031,1.\x037,1I\x034,1I\x031,1...........')) + self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.......,\x034,1-=\x034,1II\x037,1..I\x034,1.I=-,\x031,1........')) + self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.......\x034,1`-=\x037,1#$\x038,1%&\x037,1%$#\x034,1=-\'\x031,1........')) + self.irc.queueMsg(ircmsgs.kick(self.channel, self.victim, 'BOOM!')) + def reinvite(): + if not self.victim in irc.state.channels[self.channel].users: + self.irc.queueMsg(ircmsgs.invite(self.victim, self.channel)) + if not self.responded: + schedule.addEvent(reinvite, time.time()+5) + + + def duck(self, irc, msg, args): + """takes no arguments + + DUCK!""" + try: + if not self.bombs[0].active: + return + except KeyError: + return + self.bombs[0].duck(irc, msg.nick) + irc.noReply() + duck = wrap(duck) + + + def randombomb(self, irc, msg, args, channel, nicks): + """takes no arguments + + Bombs a random person in the channel + """ + try: + if self.bombs[0].active: + irc.reply('There\'s already an active bomb, in %s\'s pants!' % self.bombs[0].victim) + return + except KeyError: + pass + if len(nicks) == 0: + nicks = list(irc.state.channels[channel].users) +# items = self.talktimes.iteritems() +# nicks = [] +# for i in range(0, len(self.talktimes)): +# try: +# item = items.next() +# if time.time() - item[1] < 60*60 and item[0] in irc.state.channels[channel].users: +# nicks.append(item[0]) +# except StopIteration: +# irc.reply('hey quantumlemur, something funny happened... I got a StopIteration exception') +# if len(nicks) == 1 and nicks[0] == msg.nick: +# nicks = [] +# if len(nicks) == 0: +# irc.reply('Well, no one\'s talked in the past hour, so I guess I\'ll just choose someone from the whole channel') +# nicks = list(irc.state.channels[channel].users) +# elif len(nicks) == 2: +# irc.reply('Well, it\'s just been you two talking recently, so I\'m going to go ahead and just bomb someone at random from the whole channel') +# nicks = list(irc.state.channels[channel].users) +# irc.reply('These people are eligible: %s' % utils.str.commaAndify(nicks)) + victim = self.rng.choice(nicks) + while victim == self.lastBomb or victim in self.registryValue('exclusions'): + victim = self.rng.choice(nicks) + self.lastBomb = victim + detonateTime = self.rng.randint(self.registryValue('minTime')*2, self.registryValue('maxTime')*2) + wireCount = self.rng.randint(self.registryValue('minWires'), self.registryValue('maxWires')) + if wireCount < 12: + colors = self.registryValue('shortcolors') + else: + colors = self.registryValue('colors') + wires = self.rng.sample(colors, wireCount) + goodWire = self.rng.choice(wires) + self.bombs[0] = self.Bomb(irc, victim, wires, detonateTime, goodWire, channel, msg.nick) + try: + irc.noReply() + except AttributeError: + pass + randombomb = wrap(randombomb, ['Channel', ('checkChannelCapability', 'timebombs'), any('NickInChannel')]) + + + def timebomb(self, irc, msg, args, channel, victim): + """ + + For bombing people!""" + irc.noReply() + try: + if self.bombs[0].active: + irc.reply('There\'s already an active bomb, in %s\'s pants!' % self.bombs[0].victim) + return + except KeyError: + pass + if victim == irc.nick: + irc.reply('You really expect me to bomb myself? Stuffing explosives into my own pants isn\'t exactly my idea of fun.') + return + victim = string.lower(victim) + found = False + for nick in list(irc.state.channels[channel].users): + if victim == string.lower(nick): + victim = nick + found = True + if not found: + irc.reply('Error: nick not found.') + return + detonateTime = self.rng.randint(self.registryValue('minTime'), self.registryValue('maxTime')) + wireCount = self.rng.randint(self.registryValue('minWires'), self.registryValue('maxWires')) + if wireCount < 12: + colors = self.registryValue('shortcolors') + else: + colors = self.registryValue('colors') + wires = self.rng.sample(colors, wireCount) + goodWire = self.rng.choice(wires) + self.bombs[0] = self.Bomb(irc, victim, wires, detonateTime, goodWire, channel, msg.nick) + timebomb = wrap(timebomb, ['Channel', ('checkChannelCapability', 'timebombs'), 'somethingWithoutSpaces']) + + + def cutwire(self, irc, msg, args, cutWire): + """ + + Will cut the given wire if you've been timebombed.""" + try: + if not self.bombs[0].active: + return + if not ircutils.nickEqual(self.bombs[0].victim, msg.nick): + irc.reply('You can\'t cut the wire on someone else\'s bomb!') + return + except KeyError: + pass + self.bombs[0].cutwire(irc, cutWire) + irc.noReply() + cutwire = wrap(cutwire, ['something']) + + + def detonate(self, irc, msg, args, channel): + """Takes no arguments + + Detonates the active bomb.""" + if self.bombs[0].active: + schedule.rescheduleEvent('bomb', time.time()) + irc.noReply() + detonate = wrap(detonate, [('checkChannelCapability', 'op')]) + + +Class = Timebomb + + +# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/test.py b/test.py new file mode 100644 index 0000000..c8e38ec --- /dev/null +++ b/test.py @@ -0,0 +1,37 @@ +### +# Copyright (c) 2010, quantumlemur +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions, and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions, and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the author of this software nor the name of +# contributors to this software may be used to endorse or promote products +# derived from this software without specific prior written consent. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +### + +from supybot.test import * + +class TimebombTestCase(PluginTestCase): + plugins = ('Timebomb',) + + +# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: From 9b951fcaa2aba6c6f330688721af158493e0cbd1 Mon Sep 17 00:00:00 2001 From: quantumlemur Date: Thu, 25 Mar 2010 18:56:51 -0400 Subject: [PATCH 02/20] Deleted a couple lines of old code --- __init__.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/__init__.py b/__init__.py index 9dd9e4c..d59eeb2 100644 --- a/__init__.py +++ b/__init__.py @@ -58,12 +58,6 @@ import plugin reload(plugin) # In case we're being reloaded. # Add more reloads here if you add third-party modules and want them to be # reloaded when this plugin is reloaded. Don't forget to import them as well! -import sys -if not '/home/eggdrop/supybot/modules' in sys.path: - sys.path.append('/home/eggdrop/supybot/modules') -import scihd - -reload(scihd) if world.testing: From fa0c2cc2fa0cd24154d55371b48b9abbc25700f6 Mon Sep 17 00:00:00 2001 From: quantumlemur Date: Thu, 25 Mar 2010 19:21:22 -0400 Subject: [PATCH 03/20] Added config option for whether or not detonation ASCII art is displayed --- config.py | 2 ++ plugin.py | 23 +++++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/config.py b/config.py index 6421585..b01ad07 100644 --- a/config.py +++ b/config.py @@ -71,5 +71,7 @@ conf.registerGlobalValue(Timebomb, 'minTime', conf.registerGlobalValue(Timebomb, 'maxTime', registry.PositiveInteger(60, """Determines the maximum time of a timebomb timer, in seconds.""")) +conf.registerGlobalValue(Timebomb, 'showArt', + registry.Boolean(True, """Determines whether an ASCII art bomb should be shown on detonation, or a simple message.""")) # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/plugin.py b/plugin.py index f850746..9214803 100644 --- a/plugin.py +++ b/plugin.py @@ -105,16 +105,19 @@ class Timebomb(callbacks.Plugin): def detonate(self, irc): self.active = False self.thrown = False - self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.....\x0315,1_.\x0314,1-^^---....,\x0315,1,-_\x031,1.......')) - self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.\x0315,1_--\x0314,1,.\';,`.,\';,.;;`;,.\x0315,1--_\x031,1...')) - self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x0315,1<,.\x0314,1;\'`".,;`..,;`*.,\';`.\x0315,1;\'>)\x031,1.')) - self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x0315,1I.:;\x0314,1.,`;~,`.;\'`,.;\'`,..\x0315,1\';`I\x031,1.')) - self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.\x0315,1\\_.\x0314,1`\'`..`\';.,`\';,`\';,\x0315,1_../\x031,1..')) - self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1....\x0315,1```\x0314,1--. . , ; .--\x0315,1\'\'\'\x031,1.....')) - self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1..........\x034,1I\x031,1.\x038,1I\x037,1I\x031,1.\x038,1I\x034,1I\x031,1...........')) - self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1..........\x034,1I\x031,1.\x037,1I\x038,1I\x031,1.\x037,1I\x034,1I\x031,1...........')) - self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.......,\x034,1-=\x034,1II\x037,1..I\x034,1.I=-,\x031,1........')) - self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.......\x034,1`-=\x037,1#$\x038,1%&\x037,1%$#\x034,1=-\'\x031,1........')) + if self.registryValue('showArt'): + self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.....\x0315,1_.\x0314,1-^^---....,\x0315,1,-_\x031,1.......')) + self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.\x0315,1_--\x0314,1,.\';,`.,\';,.;;`;,.\x0315,1--_\x031,1...')) + self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x0315,1<,.\x0314,1;\'`".,;`..,;`*.,\';`.\x0315,1;\'>)\x031,1.')) + self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x0315,1I.:;\x0314,1.,`;~,`.;\'`,.;\'`,..\x0315,1\';`I\x031,1.')) + self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.\x0315,1\\_.\x0314,1`\'`..`\';.,`\';,`\';,\x0315,1_../\x031,1..')) + self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1....\x0315,1```\x0314,1--. . , ; .--\x0315,1\'\'\'\x031,1.....')) + self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1..........\x034,1I\x031,1.\x038,1I\x037,1I\x031,1.\x038,1I\x034,1I\x031,1...........')) + self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1..........\x034,1I\x031,1.\x037,1I\x038,1I\x031,1.\x037,1I\x034,1I\x031,1...........')) + self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.......,\x034,1-=\x034,1II\x037,1..I\x034,1.I=-,\x031,1........')) + self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.......\x034,1`-=\x037,1#$\x038,1%&\x037,1%$#\x034,1=-\'\x031,1........')) + else: + self.irc.sendMsg(ircmsgs.privmsg(self.channel, 'KABOOM!')) self.irc.queueMsg(ircmsgs.kick(self.channel, self.victim, 'BOOM!')) def reinvite(): if not self.victim in irc.state.channels[self.channel].users: From f02a0d6bf788815dafbb79694101192cb9a7ebd2 Mon Sep 17 00:00:00 2001 From: quantumlemur Date: Fri, 26 Mar 2010 01:35:25 -0400 Subject: [PATCH 04/20] Added config options for only randombombing active users --- config.py | 6 ++++++ plugin.py | 59 +++++++++++++++++++++++++++++++------------------------ 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/config.py b/config.py index b01ad07..5c6369f 100644 --- a/config.py +++ b/config.py @@ -74,4 +74,10 @@ conf.registerGlobalValue(Timebomb, 'maxTime', conf.registerGlobalValue(Timebomb, 'showArt', registry.Boolean(True, """Determines whether an ASCII art bomb should be shown on detonation, or a simple message.""")) +conf.registerChannelValue(Timebomb, 'bombActiveUsers', + registry.Boolean(False, """Determines whether only active users should be randombombed""")) + +conf.registerChannelValue(Timebomb, 'joinIsActivity', + registry.Boolean(False, """Determines whether channel joins should count as activity for randombombs""")) + # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/plugin.py b/plugin.py index 9214803..abd8fe9 100644 --- a/plugin.py +++ b/plugin.py @@ -60,12 +60,13 @@ class Timebomb(callbacks.Plugin): self.talktimes[msg.nick] = time.time() -# def doJoin(self, irc, msg): -# self.talktimes[msg.nick] = time.time() + def doJoin(self, irc, msg): + if self.registryValue('joinIsActivity'): + self.talktimes[msg.nick] = time.time() class Bomb(): - def __init__(self, irc, victim, wires, detonateTime, goodWire, channel, sender): + def __init__(self, irc, victim, wires, detonateTime, goodWire, channel, sender, showArt): self.victim = victim self.detonateTime = detonateTime self.wires = wires @@ -74,6 +75,7 @@ class Timebomb(callbacks.Plugin): self.channel = channel self.sender = sender self.irc = irc + self.showArt = showArt self.thrown = False self.responded = False def detonate(): @@ -105,7 +107,7 @@ class Timebomb(callbacks.Plugin): def detonate(self, irc): self.active = False self.thrown = False - if self.registryValue('showArt'): + if self.showArt: self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.....\x0315,1_.\x0314,1-^^---....,\x0315,1,-_\x031,1.......')) self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.\x0315,1_--\x0314,1,.\';,`.,\';,.;;`;,.\x0315,1--_\x031,1...')) self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x0315,1<,.\x0314,1;\'`".,;`..,;`*.,\';`.\x0315,1;\'>)\x031,1.')) @@ -151,26 +153,31 @@ class Timebomb(callbacks.Plugin): return except KeyError: pass - if len(nicks) == 0: - nicks = list(irc.state.channels[channel].users) -# items = self.talktimes.iteritems() -# nicks = [] -# for i in range(0, len(self.talktimes)): -# try: -# item = items.next() -# if time.time() - item[1] < 60*60 and item[0] in irc.state.channels[channel].users: -# nicks.append(item[0]) -# except StopIteration: -# irc.reply('hey quantumlemur, something funny happened... I got a StopIteration exception') -# if len(nicks) == 1 and nicks[0] == msg.nick: -# nicks = [] -# if len(nicks) == 0: -# irc.reply('Well, no one\'s talked in the past hour, so I guess I\'ll just choose someone from the whole channel') -# nicks = list(irc.state.channels[channel].users) -# elif len(nicks) == 2: -# irc.reply('Well, it\'s just been you two talking recently, so I\'m going to go ahead and just bomb someone at random from the whole channel') -# nicks = list(irc.state.channels[channel].users) -# irc.reply('These people are eligible: %s' % utils.str.commaAndify(nicks)) + if self.registryValue('bombActiveUsers'): + if len(nicks) == 0: + nicks = list(irc.state.channels[channel].users) + items = self.talktimes.iteritems() + nicks = [] + for i in range(0, len(self.talktimes)): + try: + item = items.next() + if time.time() - item[1] < 60*60 and item[0] in irc.state.channels[channel].users: + nicks.append(item[0]) + except StopIteration: + irc.reply('hey quantumlemur, something funny happened... I got a StopIteration exception') + if len(nicks) == 1 and nicks[0] == msg.nick: + nicks = [] + if irc.nick in nicks: + nicks.remove(irc.nick) + if len(nicks) == 0: + irc.reply('Well, no one\'s talked in the past hour, so I guess I\'ll just choose someone from the whole channel') + nicks = list(irc.state.channels[channel].users) + elif len(nicks) == 2: + irc.reply('Well, it\'s just been you two talking recently, so I\'m going to go ahead and just bomb someone at random from the whole channel') + nicks = list(irc.state.channels[channel].users) + # irc.reply('These people are eligible: %s' % utils.str.commaAndify(nicks)) + elif len(nicks) == 0: + nicks = list(irc.state.channels[channel].users) victim = self.rng.choice(nicks) while victim == self.lastBomb or victim in self.registryValue('exclusions'): victim = self.rng.choice(nicks) @@ -183,7 +190,7 @@ class Timebomb(callbacks.Plugin): colors = self.registryValue('colors') wires = self.rng.sample(colors, wireCount) goodWire = self.rng.choice(wires) - self.bombs[0] = self.Bomb(irc, victim, wires, detonateTime, goodWire, channel, msg.nick) + self.bombs[0] = self.Bomb(irc, victim, wires, detonateTime, goodWire, channel, msg.nick, self.registryValue('showArt')) try: irc.noReply() except AttributeError: @@ -222,7 +229,7 @@ class Timebomb(callbacks.Plugin): colors = self.registryValue('colors') wires = self.rng.sample(colors, wireCount) goodWire = self.rng.choice(wires) - self.bombs[0] = self.Bomb(irc, victim, wires, detonateTime, goodWire, channel, msg.nick) + self.bombs[0] = self.Bomb(irc, victim, wires, detonateTime, goodWire, channel, msg.nick, self.registryValue('showArt')) timebomb = wrap(timebomb, ['Channel', ('checkChannelCapability', 'timebombs'), 'somethingWithoutSpaces']) From c2fd110a38f4309c0d40728ea30ef089c554ce94 Mon Sep 17 00:00:00 2001 From: quantumlemur Date: Fri, 26 Mar 2010 13:31:54 -0400 Subject: [PATCH 05/20] Initial push of Wikipedia plugin, and added some config options for Timebomb --- config.py | 84 +++++++++++++++++++++++++++++++++++++++++++++---------- plugin.py | 16 ++++++----- 2 files changed, 79 insertions(+), 21 deletions(-) diff --git a/config.py b/config.py index 5c6369f..2aaaec9 100644 --- a/config.py +++ b/config.py @@ -45,39 +45,95 @@ Timebomb = conf.registerPlugin('Timebomb') # conf.registerGlobalValue(Timebomb, 'someConfigVariableName', # registry.Boolean(False, """Help for someConfigVariableName.""")) conf.registerGlobalValue(Timebomb, 'colors', - registry.SpaceSeparatedListOfStrings(['AliceBlue', 'AntiqueWhite', 'Aqua', 'Aquamarine', 'Azure', 'Beige', 'Bisque', 'Black', 'BlanchedAlmond', 'Blue', 'BlueViolet', 'Brown', 'BurlyWood', 'CadetBlue', 'Chartreuse', 'Chocolate', 'Coral', 'CornflowerBlue', 'Cornsilk', 'Crimson', 'Cyan', 'DarkBlue', 'DarkCyan', 'DarkGoldenRod', 'DarkGray', 'DarkGreen', 'DarkKhaki', 'DarkMagenta', 'DarkOliveGreen', 'DarkOrange', 'DarkOrchid', 'DarkRed', 'DarkSalmon', 'DarkSeaGreen', 'DarkSlateBlue', 'DarkSlateGray', 'DarkTurquoise', 'DarkViolet', 'DeepPink', 'DeepSkyBlue', 'DimGray', 'DodgerBlue', 'FireBrick', 'FloralWhite', 'ForestGreen', 'Fuchsia', 'Gainsboro', 'GhostWhite', 'Gold', 'GoldenRod', 'Gray', 'Green', 'GreenYellow', 'HoneyDew', 'HotPink', 'IndianRed', 'Indigo', 'Ivory', 'Khaki', 'Lavender', 'LavenderBlush', 'LawnGreen', 'LemonChiffon', 'LightBlue', 'LightCoral', 'LightCyan', 'LightGoldenRodYellow', 'LightGrey', 'LightGreen', 'LightPink', 'LightSalmon', 'LightSeaGreen', 'LightSkyBlue', 'LightSlateGray', 'LightSteelBlue', 'LightYellow', 'Lime', 'LimeGreen', 'Linen', 'Magenta', 'Maroon', 'MediumAquaMarine', 'MediumBlue', 'MediumOrchid', 'MediumPurple', 'MediumSeaGreen', 'MediumSlateBlue', 'MediumSpringGreen', 'MediumTurquoise', 'MediumVioletRed', 'MidnightBlue', 'MintCream', 'MistyRose', 'Moccasin', 'NavajoWhite', 'Navy', 'OldLace', 'Olive', 'OliveDrab', 'Orange', 'OrangeRed', 'Orchid', 'PaleGoldenRod', 'PaleGreen', 'PaleTurquoise', 'PaleVioletRed', 'PapayaWhip', 'PeachPuff', 'Peru', 'Pink', 'Plum', 'PowderBlue', 'Purple', 'Red', 'RosyBrown', 'RoyalBlue', 'SaddleBrown', 'Salmon', 'SandyBrown', 'SeaGreen', 'SeaShell', 'Sienna', 'Silver', 'SkyBlue', 'SlateBlue', 'SlateGray', 'Snow', 'SpringGreen', 'SteelBlue', 'Tan', 'Teal', 'Thistle', 'Tomato', 'Turquoise', 'Violet', 'Wheat', 'White', 'WhiteSmoke', 'Yellow', 'YellowGreen'], + registry.SpaceSeparatedListOfStrings(['AliceBlue', 'AntiqueWhite', 'Aqua', + 'Aquamarine', 'Azure', 'Beige', 'Bisque', 'Black', 'BlanchedAlmond', + 'Blue', 'BlueViolet', 'Brown', 'BurlyWood', 'CadetBlue', 'Chartreuse', + 'Chocolate', 'Coral', 'CornflowerBlue', 'Cornsilk', 'Crimson', 'Cyan', + 'DarkBlue', 'DarkCyan', 'DarkGoldenRod', 'DarkGray', 'DarkGreen', + 'DarkKhaki', 'DarkMagenta', 'DarkOliveGreen', 'DarkOrange', + 'DarkOrchid', 'DarkRed', 'DarkSalmon', 'DarkSeaGreen', 'DarkSlateBlue', + 'DarkSlateGray', 'DarkTurquoise', 'DarkViolet', 'DeepPink', + 'DeepSkyBlue', 'DimGray', 'DodgerBlue', 'FireBrick', 'FloralWhite', + 'ForestGreen', 'Fuchsia', 'Gainsboro', 'GhostWhite', 'Gold', + 'GoldenRod', 'Gray', 'Green', 'GreenYellow', 'HoneyDew', 'HotPink', + 'IndianRed', 'Indigo', 'Ivory', 'Khaki', 'Lavender', 'LavenderBlush', + 'LawnGreen', 'LemonChiffon', 'LightBlue', 'LightCoral', 'LightCyan', + 'LightGoldenRodYellow', 'LightGrey', 'LightGreen', 'LightPink', + 'LightSalmon', 'LightSeaGreen', 'LightSkyBlue', 'LightSlateGray', + 'LightSteelBlue', 'LightYellow', 'Lime', 'LimeGreen', 'Linen', + 'Magenta', 'Maroon', 'MediumAquaMarine', 'MediumBlue', 'MediumOrchid', + 'MediumPurple', 'MediumSeaGreen', 'MediumSlateBlue', + 'MediumSpringGreen', 'MediumTurquoise', 'MediumVioletRed', + 'MidnightBlue', 'MintCream', 'MistyRose', 'Moccasin', 'NavajoWhite', + 'Navy', 'OldLace', 'Olive', 'OliveDrab', 'Orange', 'OrangeRed', + 'Orchid', 'PaleGoldenRod', 'PaleGreen', 'PaleTurquoise', + 'PaleVioletRed', 'PapayaWhip', 'PeachPuff', 'Peru', 'Pink', 'Plum', + 'PowderBlue', 'Purple', 'Red', 'RosyBrown', 'RoyalBlue', + 'SaddleBrown', 'Salmon', 'SandyBrown', 'SeaGreen', 'SeaShell', + 'Sienna', 'Silver', 'SkyBlue', 'SlateBlue', 'SlateGray', 'Snow', + 'SpringGreen', 'SteelBlue', 'Tan', 'Teal', 'Thistle', 'Tomato', + 'Turquoise', 'Violet', 'Wheat', 'White', 'WhiteSmoke', 'Yellow', + 'YellowGreen'], """The set of possible timebomb wire colors""")) + conf.registerGlobalValue(Timebomb, 'shortcolors', - registry.SpaceSeparatedListOfStrings(['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'pink', 'black', 'brown', 'gray', 'white'], - """The set of possible timebomb wire colors when there are few wires""")) + registry.SpaceSeparatedListOfStrings(['red', 'orange', 'yellow', + 'green', 'blue', 'purple', 'pink', 'black', 'brown', 'gray', + 'white'], + """The set of possible timebomb wire colors when there are few + wires""")) conf.registerChannelValue(Timebomb, 'exclusions', - registry.SpaceSeparatedListOfStrings([], - """A list of nicks who should be excluded from being randombombed""")) + registry.SpaceSeparatedListOfStrings([], + """A list of nicks who should be excluded from being + randombombed""")) -conf.registerChannelValue(Timebomb, 'allowBombs', - registry.Boolean(False, """Determines whether timebombs are allowed in the channel.""")) +conf.registerChannelValue(Timebomb, 'allowBombs', + registry.Boolean(False, """Determines whether timebombs are allowed + in the channel.""")) conf.registerGlobalValue(Timebomb, 'minWires', - registry.PositiveInteger(3, """Determines the minimum number of wires a timebomb will have.""")) + registry.PositiveInteger(2, """Determines the minimum number of wires + a timebomb will have.""")) conf.registerGlobalValue(Timebomb, 'maxWires', - registry.PositiveInteger(5, """Determines the maximum number of wires a timebomb will have.""")) + registry.PositiveInteger(5, """Determines the maximum number of wires + a timebomb will have.""")) conf.registerGlobalValue(Timebomb, 'minTime', - registry.PositiveInteger(30, """Determines the minimum time of a timebomb timer, in seconds.""")) + registry.PositiveInteger(30, """Determines the minimum time of a + timebomb timer, in seconds.""")) conf.registerGlobalValue(Timebomb, 'maxTime', - registry.PositiveInteger(60, """Determines the maximum time of a timebomb timer, in seconds.""")) + registry.PositiveInteger(60, """Determines the maximum time of a + timebomb timer, in seconds.""")) + +conf.registerGlobalValue(Timebomb, 'minRandombombTime', + registry.PositiveInteger(60, """Determines the minimum time of a + randombomb timer, which should in general be greater than the + minimum targeted bomb time, to allow someone who's not paying + attention to respond.""")) + +conf.registerChannelValue(Timebomb, 'maxRandombombTime', + registry.PositiveInteger(120, """Determines the maximum time of a + randombomb timer, which should in general be greater than the + maxiumum targeted bomb time, to allow someone who's not paying + attention to respond.""")) conf.registerGlobalValue(Timebomb, 'showArt', - registry.Boolean(True, """Determines whether an ASCII art bomb should be shown on detonation, or a simple message.""")) + registry.Boolean(True, """Determines whether an ASCII art bomb should + be shown on detonation, or a simple message.""")) conf.registerChannelValue(Timebomb, 'bombActiveUsers', - registry.Boolean(False, """Determines whether only active users should be randombombed""")) + registry.Boolean(False, """Determines whether only active users + should be randombombed""")) conf.registerChannelValue(Timebomb, 'joinIsActivity', - registry.Boolean(False, """Determines whether channel joins should count as activity for randombombs""")) + registry.Boolean(False, """Determines whether channel joins should + count as activity for randombombs""")) + +conf.registerChannelValue(Timebomb, 'allowSelfBombs', + registry.Boolean(False, """Allow the bot to bomb itself?""")) # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/plugin.py b/plugin.py index abd8fe9..79632d5 100644 --- a/plugin.py +++ b/plugin.py @@ -167,22 +167,24 @@ class Timebomb(callbacks.Plugin): irc.reply('hey quantumlemur, something funny happened... I got a StopIteration exception') if len(nicks) == 1 and nicks[0] == msg.nick: nicks = [] - if irc.nick in nicks: - nicks.remove(irc.nick) if len(nicks) == 0: irc.reply('Well, no one\'s talked in the past hour, so I guess I\'ll just choose someone from the whole channel') nicks = list(irc.state.channels[channel].users) elif len(nicks) == 2: irc.reply('Well, it\'s just been you two talking recently, so I\'m going to go ahead and just bomb someone at random from the whole channel') nicks = list(irc.state.channels[channel].users) - # irc.reply('These people are eligible: %s' % utils.str.commaAndify(nicks)) elif len(nicks) == 0: - nicks = list(irc.state.channels[channel].users) + nicks = list(irc.state.channels[channel].users) + if irc.nick in nicks and not self.registryValue('allowSelfBombs'): + irc.reply('removing myself') + nicks.remove(irc.nick) + ##### + #irc.reply('These people are eligible: %s' % utils.str.commaAndify(nicks)) victim = self.rng.choice(nicks) while victim == self.lastBomb or victim in self.registryValue('exclusions'): victim = self.rng.choice(nicks) self.lastBomb = victim - detonateTime = self.rng.randint(self.registryValue('minTime')*2, self.registryValue('maxTime')*2) + detonateTime = self.rng.randint(self.registryValue('minRandombombTime'), self.registryValue('maxRandombombTime')) wireCount = self.rng.randint(self.registryValue('minWires'), self.registryValue('maxWires')) if wireCount < 12: colors = self.registryValue('shortcolors') @@ -209,8 +211,8 @@ class Timebomb(callbacks.Plugin): return except KeyError: pass - if victim == irc.nick: - irc.reply('You really expect me to bomb myself? Stuffing explosives into my own pants isn\'t exactly my idea of fun.') + if victim == irc.nick and not self.registryValue('allowSelfBombs'): + irc.reply('You really expect me to bomb myself? Stuffing explosives into my own pants isn\'t exactly my idea of fun.') return victim = string.lower(victim) found = False From 3869d5347a864e9fdc7741390d080f7905929ede Mon Sep 17 00:00:00 2001 From: quantumlemur Date: Fri, 26 Mar 2010 13:41:50 -0400 Subject: [PATCH 06/20] Updated Timebomb config defaults --- config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index 2aaaec9..5c098ec 100644 --- a/config.py +++ b/config.py @@ -98,15 +98,15 @@ conf.registerGlobalValue(Timebomb, 'minWires', a timebomb will have.""")) conf.registerGlobalValue(Timebomb, 'maxWires', - registry.PositiveInteger(5, """Determines the maximum number of wires + registry.PositiveInteger(4, """Determines the maximum number of wires a timebomb will have.""")) conf.registerGlobalValue(Timebomb, 'minTime', - registry.PositiveInteger(30, """Determines the minimum time of a + registry.PositiveInteger(45, """Determines the minimum time of a timebomb timer, in seconds.""")) conf.registerGlobalValue(Timebomb, 'maxTime', - registry.PositiveInteger(60, """Determines the maximum time of a + registry.PositiveInteger(70, """Determines the maximum time of a timebomb timer, in seconds.""")) conf.registerGlobalValue(Timebomb, 'minRandombombTime', From d682721dfbd4aadc08bba09c2cf4a6ee029bbfa8 Mon Sep 17 00:00:00 2001 From: quantumlemur Date: Fri, 26 Mar 2010 17:06:11 -0400 Subject: [PATCH 07/20] Added a couple Timebomb configs --- __init__.py | 7 ++++--- config.py | 21 +++++++++++++++------ plugin.py | 39 +++++++++++++++++++++++---------------- 3 files changed, 42 insertions(+), 25 deletions(-) diff --git a/__init__.py b/__init__.py index d59eeb2..a7eff95 100644 --- a/__init__.py +++ b/__init__.py @@ -32,8 +32,8 @@ # Many thanks to pawarswap for the ascii-art bomb! """ -Add a description of the plugin (to be presented to the user inside the wizard) -here. This should describe *what* the plugin does. +Allows you to 'bomb' people in the channel. If they get the get the wire +wrong, they get kicked. (It's a game) """ import supybot @@ -44,7 +44,8 @@ import supybot.world as world __version__ = "" # XXX Replace this with an appropriate author or supybot.Author instance. -__author__ = supybot.authors.unknown +__author__ = supybot.Authors('quantumlemur', 'quantumlemur', + 'quantumlemur@users.sourceforge.net') # This is a dictionary mapping supybot.Author instances to lists of # contributions. diff --git a/config.py b/config.py index 5c098ec..db65824 100644 --- a/config.py +++ b/config.py @@ -93,23 +93,23 @@ conf.registerChannelValue(Timebomb, 'allowBombs', registry.Boolean(False, """Determines whether timebombs are allowed in the channel.""")) -conf.registerGlobalValue(Timebomb, 'minWires', +conf.registerChannelValue(Timebomb, 'minWires', registry.PositiveInteger(2, """Determines the minimum number of wires a timebomb will have.""")) -conf.registerGlobalValue(Timebomb, 'maxWires', +conf.registerChannelValue(Timebomb, 'maxWires', registry.PositiveInteger(4, """Determines the maximum number of wires a timebomb will have.""")) -conf.registerGlobalValue(Timebomb, 'minTime', +conf.registerChannelValue(Timebomb, 'minTime', registry.PositiveInteger(45, """Determines the minimum time of a timebomb timer, in seconds.""")) -conf.registerGlobalValue(Timebomb, 'maxTime', +conf.registerChannelValue(Timebomb, 'maxTime', registry.PositiveInteger(70, """Determines the maximum time of a timebomb timer, in seconds.""")) -conf.registerGlobalValue(Timebomb, 'minRandombombTime', +conf.registerChannelValue(Timebomb, 'minRandombombTime', registry.PositiveInteger(60, """Determines the minimum time of a randombomb timer, which should in general be greater than the minimum targeted bomb time, to allow someone who's not paying @@ -121,7 +121,7 @@ conf.registerChannelValue(Timebomb, 'maxRandombombTime', maxiumum targeted bomb time, to allow someone who's not paying attention to respond.""")) -conf.registerGlobalValue(Timebomb, 'showArt', +conf.registerChannelValue(Timebomb, 'showArt', registry.Boolean(True, """Determines whether an ASCII art bomb should be shown on detonation, or a simple message.""")) @@ -136,4 +136,13 @@ conf.registerChannelValue(Timebomb, 'joinIsActivity', conf.registerChannelValue(Timebomb, 'allowSelfBombs', registry.Boolean(False, """Allow the bot to bomb itself?""")) +conf.registerChannelValue(Timebomb, 'idleTime', + registry.PositiveInteger(60, """The number of minutes before someone + is counted as idle for randombombs, if idle-checking is + enabled.""")) + +conf.registerChannelValue(Timebomb, 'showCorrectWire', + registry.Boolean(False, """Determines whether the correct wire will be + shown when a bomb detonates.""")) + # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/plugin.py b/plugin.py index 79632d5..5c81aba 100644 --- a/plugin.py +++ b/plugin.py @@ -61,12 +61,12 @@ class Timebomb(callbacks.Plugin): def doJoin(self, irc, msg): - if self.registryValue('joinIsActivity'): + if self.registryValue('joinIsActivity', msg.args[0]): self.talktimes[msg.nick] = time.time() class Bomb(): - def __init__(self, irc, victim, wires, detonateTime, goodWire, channel, sender, showArt): + def __init__(self, irc, victim, wires, detonateTime, goodWire, channel, sender, showArt, showCorrectWire): self.victim = victim self.detonateTime = detonateTime self.wires = wires @@ -76,6 +76,7 @@ class Timebomb(callbacks.Plugin): self.sender = sender self.irc = irc self.showArt = showArt + self.showCorrectWire = showCorrectWire self.thrown = False self.responded = False def detonate(): @@ -107,6 +108,8 @@ class Timebomb(callbacks.Plugin): def detonate(self, irc): self.active = False self.thrown = False + if self.showCorrectWire: + self.irc.reply('Should\'ve gone for the %s wire!' % self.goodWire) if self.showArt: self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.....\x0315,1_.\x0314,1-^^---....,\x0315,1,-_\x031,1.......')) self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.\x0315,1_--\x0314,1,.\';,`.,\';,.;;`;,.\x0315,1--_\x031,1...')) @@ -147,13 +150,16 @@ class Timebomb(callbacks.Plugin): Bombs a random person in the channel """ + if not self.registryValue('allowBombs', msg.args[0]): + irc.noReply() + return try: if self.bombs[0].active: irc.reply('There\'s already an active bomb, in %s\'s pants!' % self.bombs[0].victim) return except KeyError: pass - if self.registryValue('bombActiveUsers'): + if self.registryValue('bombActiveUsers', msg.args[0]): if len(nicks) == 0: nicks = list(irc.state.channels[channel].users) items = self.talktimes.iteritems() @@ -161,7 +167,7 @@ class Timebomb(callbacks.Plugin): for i in range(0, len(self.talktimes)): try: item = items.next() - if time.time() - item[1] < 60*60 and item[0] in irc.state.channels[channel].users: + if time.time() - item[1] < self.registryValue('idleTime', msg.args[0])*60 and item[0] in irc.state.channels[channel].users: nicks.append(item[0]) except StopIteration: irc.reply('hey quantumlemur, something funny happened... I got a StopIteration exception') @@ -175,43 +181,44 @@ class Timebomb(callbacks.Plugin): nicks = list(irc.state.channels[channel].users) elif len(nicks) == 0: nicks = list(irc.state.channels[channel].users) - if irc.nick in nicks and not self.registryValue('allowSelfBombs'): - irc.reply('removing myself') + if irc.nick in nicks and not self.registryValue('allowSelfBombs', msg.args[0]): nicks.remove(irc.nick) ##### #irc.reply('These people are eligible: %s' % utils.str.commaAndify(nicks)) victim = self.rng.choice(nicks) - while victim == self.lastBomb or victim in self.registryValue('exclusions'): + while victim == self.lastBomb or victim in self.registryValue('exclusions', msg.args[0]): victim = self.rng.choice(nicks) self.lastBomb = victim - detonateTime = self.rng.randint(self.registryValue('minRandombombTime'), self.registryValue('maxRandombombTime')) - wireCount = self.rng.randint(self.registryValue('minWires'), self.registryValue('maxWires')) + detonateTime = self.rng.randint(self.registryValue('minRandombombTime', msg.args[0]), self.registryValue('maxRandombombTime', msg.args[0])) + wireCount = self.rng.randint(self.registryValue('minWires', msg.args[0]), self.registryValue('maxWires', msg.args[0])) if wireCount < 12: colors = self.registryValue('shortcolors') else: colors = self.registryValue('colors') wires = self.rng.sample(colors, wireCount) goodWire = self.rng.choice(wires) - self.bombs[0] = self.Bomb(irc, victim, wires, detonateTime, goodWire, channel, msg.nick, self.registryValue('showArt')) + self.bombs[0] = self.Bomb(irc, victim, wires, detonateTime, goodWire, channel, msg.nick, self.registryValue('showArt', msg.args[0]), self.registryValue('showCorrectWire', msg.args[0])) try: irc.noReply() except AttributeError: pass - randombomb = wrap(randombomb, ['Channel', ('checkChannelCapability', 'timebombs'), any('NickInChannel')]) + randombomb = wrap(randombomb, ['Channel', any('NickInChannel')]) def timebomb(self, irc, msg, args, channel, victim): """ For bombing people!""" - irc.noReply() + if not self.registryValue('allowBombs', msg.args[0]): + irc.noReply() + return try: if self.bombs[0].active: irc.reply('There\'s already an active bomb, in %s\'s pants!' % self.bombs[0].victim) return except KeyError: pass - if victim == irc.nick and not self.registryValue('allowSelfBombs'): + if victim == irc.nick and not self.registryValue('allowSelfBombs', msg.args[0]): irc.reply('You really expect me to bomb myself? Stuffing explosives into my own pants isn\'t exactly my idea of fun.') return victim = string.lower(victim) @@ -223,15 +230,15 @@ class Timebomb(callbacks.Plugin): if not found: irc.reply('Error: nick not found.') return - detonateTime = self.rng.randint(self.registryValue('minTime'), self.registryValue('maxTime')) - wireCount = self.rng.randint(self.registryValue('minWires'), self.registryValue('maxWires')) + detonateTime = self.rng.randint(self.registryValue('minTime', msg.args[0]), self.registryValue('maxTime', msg.args[0])) + wireCount = self.rng.randint(self.registryValue('minWires', msg.args[0]), self.registryValue('maxWires', msg.args[0])) if wireCount < 12: colors = self.registryValue('shortcolors') else: colors = self.registryValue('colors') wires = self.rng.sample(colors, wireCount) goodWire = self.rng.choice(wires) - self.bombs[0] = self.Bomb(irc, victim, wires, detonateTime, goodWire, channel, msg.nick, self.registryValue('showArt')) + self.bombs[0] = self.Bomb(irc, victim, wires, detonateTime, goodWire, channel, msg.nick, self.registryValue('showArt', msg.args[0]), self.registryValue('showCorrectWire', msg.args[0])) timebomb = wrap(timebomb, ['Channel', ('checkChannelCapability', 'timebombs'), 'somethingWithoutSpaces']) From 2a5e04cf2627ce866c45287dc3b4a66c6472688c Mon Sep 17 00:00:00 2001 From: quantumlemur Date: Fri, 26 Mar 2010 17:32:42 -0400 Subject: [PATCH 08/20] Made timebombs per-channel --- plugin.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/plugin.py b/plugin.py index 5c81aba..d317ef4 100644 --- a/plugin.py +++ b/plugin.py @@ -81,7 +81,7 @@ class Timebomb(callbacks.Plugin): self.responded = False def detonate(): self.detonate(irc) - schedule.addEvent(detonate, time.time() + self.detonateTime, 'bomb') + schedule.addEvent(detonate, time.time() + self.detonateTime, '%s_bomb' % self.channel) s = 'stuffs a bomb down %s\'s pants. The timer is set for %s seconds! There are %s wires. They are: %s.' % (self.victim, self.detonateTime, len(wires), utils.str.commaAndify(wires)) self.irc.queueMsg(ircmsgs.action(self.channel, s)) @@ -93,9 +93,9 @@ class Timebomb(callbacks.Plugin): 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('bomb', time.time() + 5) + schedule.rescheduleEvent('%s_bomb' % self.channel, time.time() + 5) else: - schedule.removeEvent('bomb') + schedule.removeEvent('%s_bomb' % self.channel) self.detonate(irc) def duck(self, irc, ducker): @@ -103,7 +103,7 @@ class Timebomb(callbacks.Plugin): self.irc.queueMsg(ircmsgs.privmsg(self.channel, '%s ducks! The bomb misses, and explodes harmlessly a few meters away.' % self.victim)) self.active = False self.thrown = False - schedule.removeEvent('bomb') + schedule.removeEvent('%s_bomb' % self.channel) def detonate(self, irc): self.active = False @@ -131,18 +131,18 @@ class Timebomb(callbacks.Plugin): schedule.addEvent(reinvite, time.time()+5) - def duck(self, irc, msg, args): + def duck(self, irc, msg, args, channel): """takes no arguments DUCK!""" try: - if not self.bombs[0].active: + if not self.bombs[channel].active: return except KeyError: return - self.bombs[0].duck(irc, msg.nick) + self.bombs[channel].duck(irc, msg.nick) irc.noReply() - duck = wrap(duck) + duck = wrap(duck, ['Channel']) def randombomb(self, irc, msg, args, channel, nicks): @@ -154,8 +154,8 @@ class Timebomb(callbacks.Plugin): irc.noReply() return try: - if self.bombs[0].active: - irc.reply('There\'s already an active bomb, in %s\'s pants!' % self.bombs[0].victim) + if self.bombs[channel].active: + irc.reply('There\'s already an active bomb, in %s\'s pants!' % self.bombs[channel].victim) return except KeyError: pass @@ -197,7 +197,7 @@ class Timebomb(callbacks.Plugin): colors = self.registryValue('colors') wires = self.rng.sample(colors, wireCount) goodWire = self.rng.choice(wires) - self.bombs[0] = self.Bomb(irc, victim, wires, detonateTime, goodWire, channel, msg.nick, self.registryValue('showArt', msg.args[0]), self.registryValue('showCorrectWire', msg.args[0])) + self.bombs[channel] = self.Bomb(irc, victim, wires, detonateTime, goodWire, channel, msg.nick, self.registryValue('showArt', msg.args[0]), self.registryValue('showCorrectWire', msg.args[0])) try: irc.noReply() except AttributeError: @@ -213,8 +213,8 @@ class Timebomb(callbacks.Plugin): irc.noReply() return try: - if self.bombs[0].active: - irc.reply('There\'s already an active bomb, in %s\'s pants!' % self.bombs[0].victim) + if self.bombs[channel].active: + irc.reply('There\'s already an active bomb, in %s\'s pants!' % self.bombs[channel].victim) return except KeyError: pass @@ -238,33 +238,33 @@ class Timebomb(callbacks.Plugin): colors = self.registryValue('colors') wires = self.rng.sample(colors, wireCount) goodWire = self.rng.choice(wires) - self.bombs[0] = self.Bomb(irc, victim, wires, detonateTime, goodWire, channel, msg.nick, self.registryValue('showArt', msg.args[0]), self.registryValue('showCorrectWire', msg.args[0])) + self.bombs[channel] = self.Bomb(irc, victim, wires, detonateTime, goodWire, channel, msg.nick, self.registryValue('showArt', msg.args[0]), self.registryValue('showCorrectWire', msg.args[0])) timebomb = wrap(timebomb, ['Channel', ('checkChannelCapability', 'timebombs'), 'somethingWithoutSpaces']) - def cutwire(self, irc, msg, args, cutWire): + def cutwire(self, irc, msg, args, channel, cutWire): """ Will cut the given wire if you've been timebombed.""" try: - if not self.bombs[0].active: + if not self.bombs[channel].active: return - if not ircutils.nickEqual(self.bombs[0].victim, msg.nick): + if not ircutils.nickEqual(self.bombs[channel].victim, msg.nick): irc.reply('You can\'t cut the wire on someone else\'s bomb!') return except KeyError: pass - self.bombs[0].cutwire(irc, cutWire) + self.bombs[channel].cutwire(irc, cutWire) irc.noReply() - cutwire = wrap(cutwire, ['something']) + cutwire = wrap(cutwire, ['Channel', 'something']) def detonate(self, irc, msg, args, channel): """Takes no arguments Detonates the active bomb.""" - if self.bombs[0].active: - schedule.rescheduleEvent('bomb', time.time()) + if self.bombs[channel].active: + schedule.rescheduleEvent('%s_bomb' % channel, time.time()) irc.noReply() detonate = wrap(detonate, [('checkChannelCapability', 'op')]) From 5bab04a84ff41a78c9d57c6e5843b0165c6b0a19 Mon Sep 17 00:00:00 2001 From: quantumlemur Date: Sun, 28 Mar 2010 20:29:23 -0400 Subject: [PATCH 09/20] Fixed typo in __init__.py --- __init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__init__.py b/__init__.py index a7eff95..7e3b78b 100644 --- a/__init__.py +++ b/__init__.py @@ -44,7 +44,7 @@ import supybot.world as world __version__ = "" # XXX Replace this with an appropriate author or supybot.Author instance. -__author__ = supybot.Authors('quantumlemur', 'quantumlemur', +__author__ = supybot.Author('quantumlemur', 'quantumlemur', 'quantumlemur@users.sourceforge.net') # This is a dictionary mapping supybot.Author instances to lists of From eb66ed168c76f1fe63ec8d7fac895e2a64643c4f Mon Sep 17 00:00:00 2001 From: quantumlemur Date: Sun, 25 Apr 2010 23:44:22 -0400 Subject: [PATCH 10/20] added the ability for the bot to cut his own wires --- plugin.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugin.py b/plugin.py index d317ef4..fee8877 100644 --- a/plugin.py +++ b/plugin.py @@ -79,11 +79,19 @@ class Timebomb(callbacks.Plugin): self.showCorrectWire = showCorrectWire self.thrown = False self.responded = False + self.rng = random.Random() + self.rng.seed() def detonate(): self.detonate(irc) schedule.addEvent(detonate, time.time() + self.detonateTime, '%s_bomb' % self.channel) s = 'stuffs a bomb down %s\'s pants. The timer is set for %s seconds! There are %s wires. They are: %s.' % (self.victim, self.detonateTime, len(wires), utils.str.commaAndify(wires)) self.irc.queueMsg(ircmsgs.action(self.channel, s)) + if self.victim == irc.nick: + time.sleep(1) + cutWire = self.rng.choice(self.wires) + self.irc.queueMsg(ircmsgs.privmsg(self.channel, '@cutwire %s' % cutWire)) + time.sleep(1) + self.cutwire(self.irc, cutWire) def cutwire(self, irc, cutWire): self.cutWire = cutWire @@ -94,6 +102,11 @@ class Timebomb(callbacks.Plugin): 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) From 2b1fd4b5458ef857c0d0c91714409dc424eced30 Mon Sep 17 00:00:00 2001 From: quantumlemur Date: Thu, 6 May 2010 13:14:47 -0400 Subject: [PATCH 11/20] hopefully fixed channel case bug --- plugin.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugin.py b/plugin.py index fee8877..e8ff6f9 100644 --- a/plugin.py +++ b/plugin.py @@ -148,6 +148,7 @@ class Timebomb(callbacks.Plugin): """takes no arguments DUCK!""" + channel = ircutils.toLower(channel) try: if not self.bombs[channel].active: return @@ -163,6 +164,7 @@ class Timebomb(callbacks.Plugin): Bombs a random person in the channel """ + channel = ircutils.toLower(channel) if not self.registryValue('allowBombs', msg.args[0]): irc.noReply() return @@ -222,6 +224,7 @@ class Timebomb(callbacks.Plugin): """ For bombing people!""" + channel = ircutils.toLower(channel) if not self.registryValue('allowBombs', msg.args[0]): irc.noReply() return @@ -259,6 +262,7 @@ class Timebomb(callbacks.Plugin): """ Will cut the given wire if you've been timebombed.""" + channel = ircutils.toLower(channel) try: if not self.bombs[channel].active: return @@ -276,6 +280,7 @@ class Timebomb(callbacks.Plugin): """Takes no arguments Detonates the active bomb.""" + channel = ircutils.toLower(channel) if self.bombs[channel].active: schedule.rescheduleEvent('%s_bomb' % channel, time.time()) irc.noReply() From d1493362667dcfc955132347f67dde615cbb38b4 Mon Sep 17 00:00:00 2001 From: quantumlemur Date: Thu, 6 May 2010 13:39:31 -0400 Subject: [PATCH 12/20] Trying again with the bug fix --- config.py | 4 ++++ plugin.py | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index db65824..4a2381e 100644 --- a/config.py +++ b/config.py @@ -145,4 +145,8 @@ conf.registerChannelValue(Timebomb, 'showCorrectWire', registry.Boolean(False, """Determines whether the correct wire will be shown when a bomb detonates.""")) +conf.registerGlobalValue(Timebomb, 'debug', + registry.Boolean(False, """Determines whether debugging info will be + shown.""")) + # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/plugin.py b/plugin.py index e8ff6f9..d614296 100644 --- a/plugin.py +++ b/plugin.py @@ -269,9 +269,9 @@ class Timebomb(callbacks.Plugin): if not ircutils.nickEqual(self.bombs[channel].victim, msg.nick): irc.reply('You can\'t cut the wire on someone else\'s bomb!') return + self.bombs[channel].cutwire(irc, cutWire) except KeyError: pass - self.bombs[channel].cutwire(irc, cutWire) irc.noReply() cutwire = wrap(cutwire, ['Channel', 'something']) @@ -281,8 +281,11 @@ class Timebomb(callbacks.Plugin): Detonates the active bomb.""" channel = ircutils.toLower(channel) - if self.bombs[channel].active: - schedule.rescheduleEvent('%s_bomb' % channel, time.time()) + try: + if self.bombs[channel].active: + schedule.rescheduleEvent('%s_bomb' % channel, time.time()) + except KeyError: + pass irc.noReply() detonate = wrap(detonate, [('checkChannelCapability', 'op')]) From ae004239cd0909c700df7ad2376d8ad862737206 Mon Sep 17 00:00:00 2001 From: quantumlemur Date: Thu, 6 May 2010 13:44:35 -0400 Subject: [PATCH 13/20] added in some debugging info --- plugin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin.py b/plugin.py index d614296..968346b 100644 --- a/plugin.py +++ b/plugin.py @@ -285,7 +285,9 @@ class Timebomb(callbacks.Plugin): if self.bombs[channel].active: schedule.rescheduleEvent('%s_bomb' % channel, time.time()) except KeyError: - pass + 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() detonate = wrap(detonate, [('checkChannelCapability', 'op')]) From 1650230d81065b73da4bac6d296bfc3524c64777 Mon Sep 17 00:00:00 2001 From: quantumlemur Date: Thu, 6 May 2010 13:54:24 -0400 Subject: [PATCH 14/20] more debugging --- plugin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin.py b/plugin.py index 968346b..93d2576 100644 --- a/plugin.py +++ b/plugin.py @@ -81,6 +81,8 @@ class Timebomb(callbacks.Plugin): self.responded = False self.rng = random.Random() self.rng.seed() + if self.registryValue('debug'): + self.reply('I just created a bomb in %s' % channel) def detonate(): self.detonate(irc) schedule.addEvent(detonate, time.time() + self.detonateTime, '%s_bomb' % self.channel) From 8f036b8205f086132fa913b9f25322bbfe20db42 Mon Sep 17 00:00:00 2001 From: quantumlemur Date: Thu, 6 May 2010 13:58:19 -0400 Subject: [PATCH 15/20] more debugging --- plugin.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugin.py b/plugin.py index 93d2576..81b45bc 100644 --- a/plugin.py +++ b/plugin.py @@ -66,7 +66,7 @@ class Timebomb(callbacks.Plugin): class Bomb(): - def __init__(self, irc, victim, wires, detonateTime, goodWire, channel, sender, showArt, showCorrectWire): + def __init__(self, irc, victim, wires, detonateTime, goodWire, channel, sender, showArt, showCorrectWire, debug): self.victim = victim self.detonateTime = detonateTime self.wires = wires @@ -77,12 +77,13 @@ class Timebomb(callbacks.Plugin): self.irc = irc self.showArt = showArt self.showCorrectWire = showCorrectWire + self.debug = debug self.thrown = False self.responded = False self.rng = random.Random() self.rng.seed() - if self.registryValue('debug'): - self.reply('I just created a bomb in %s' % channel) + if self.debug: + self.irc.reply('I just created a bomb in %s' % channel) def detonate(): self.detonate(irc) schedule.addEvent(detonate, time.time() + self.detonateTime, '%s_bomb' % self.channel) @@ -214,7 +215,7 @@ class Timebomb(callbacks.Plugin): colors = self.registryValue('colors') wires = self.rng.sample(colors, wireCount) goodWire = self.rng.choice(wires) - self.bombs[channel] = self.Bomb(irc, victim, wires, detonateTime, goodWire, channel, msg.nick, self.registryValue('showArt', msg.args[0]), self.registryValue('showCorrectWire', msg.args[0])) + self.bombs[channel] = self.Bomb(irc, victim, wires, detonateTime, goodWire, channel, msg.nick, self.registryValue('showArt', msg.args[0]), self.registryValue('showCorrectWire', msg.args[0]), self.registryValue('debug')) try: irc.noReply() except AttributeError: @@ -256,7 +257,7 @@ class Timebomb(callbacks.Plugin): colors = self.registryValue('colors') wires = self.rng.sample(colors, wireCount) goodWire = self.rng.choice(wires) - self.bombs[channel] = self.Bomb(irc, victim, wires, detonateTime, goodWire, channel, msg.nick, self.registryValue('showArt', msg.args[0]), self.registryValue('showCorrectWire', msg.args[0])) + self.bombs[channel] = self.Bomb(irc, victim, wires, detonateTime, goodWire, channel, msg.nick, self.registryValue('showArt', msg.args[0]), self.registryValue('showCorrectWire', msg.args[0]), self.registryValue('debug')) timebomb = wrap(timebomb, ['Channel', ('checkChannelCapability', 'timebombs'), 'somethingWithoutSpaces']) From 345304b7d310fd9e40cb546b8b9ec330b7de12ed Mon Sep 17 00:00:00 2001 From: quantumlemur Date: Thu, 6 May 2010 14:02:07 -0400 Subject: [PATCH 16/20] more debugging --- plugin.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugin.py b/plugin.py index 81b45bc..e2b48c6 100644 --- a/plugin.py +++ b/plugin.py @@ -257,7 +257,11 @@ class Timebomb(callbacks.Plugin): colors = self.registryValue('colors') wires = self.rng.sample(colors, wireCount) goodWire = self.rng.choice(wires) + if self.registryValue('debug'): + irc.reply('I\'m about to create a bomb in %s' % channel) self.bombs[channel] = self.Bomb(irc, victim, wires, detonateTime, goodWire, channel, msg.nick, self.registryValue('showArt', msg.args[0]), self.registryValue('showCorrectWire', msg.args[0]), self.registryValue('debug')) + if self.registryValue('debug'): + irc.reply('This message means that I got past the bomb creation line in the timebomb command') timebomb = wrap(timebomb, ['Channel', ('checkChannelCapability', 'timebombs'), 'somethingWithoutSpaces']) From 2e2020e56fa50ef881629615068c5c5bff9b2f09 Mon Sep 17 00:00:00 2001 From: quantumlemur Date: Tue, 15 Jun 2010 11:04:28 -0700 Subject: [PATCH 17/20] Listener network specification and better socket closing --- plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin.py b/plugin.py index e2b48c6..d0ebb33 100644 --- a/plugin.py +++ b/plugin.py @@ -169,7 +169,7 @@ class Timebomb(callbacks.Plugin): """ channel = ircutils.toLower(channel) if not self.registryValue('allowBombs', msg.args[0]): - irc.noReply() + irc.reply('Timebombs aren\'t allowed in this channel. Set plugins.Timebomb.allowBombs to true if you want them.') return try: if self.bombs[channel].active: @@ -229,7 +229,7 @@ class Timebomb(callbacks.Plugin): For bombing people!""" channel = ircutils.toLower(channel) if not self.registryValue('allowBombs', msg.args[0]): - irc.noReply() + irc.reply('Timebombs aren\'t allowed in this channel. Set plugins.Timebomb.allowBombs to true if you want them.') return try: if self.bombs[channel].active: From 4588caae9f5a0ccf4a38066e2ea4444a6af05886 Mon Sep 17 00:00:00 2001 From: quantumlemur Date: Thu, 6 Jan 2011 18:56:16 -0500 Subject: [PATCH 18/20] Fixed infinite throw-back loop --- plugin.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/plugin.py b/plugin.py index d0ebb33..df24f39 100644 --- a/plugin.py +++ b/plugin.py @@ -99,20 +99,23 @@ class Timebomb(callbacks.Plugin): 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) + 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: - schedule.removeEvent('%s_bomb' % self.channel) - self.detonate(irc) + 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 duck(self, irc, ducker): if self.thrown and ircutils.nickEqual(self.victim, ducker): From 242f6057ff86162d8167ae1fff1adf398e5a09a5 Mon Sep 17 00:00:00 2001 From: quantumlemur Date: Thu, 6 Jan 2011 19:03:48 -0500 Subject: [PATCH 19/20] Fixed infinite throw-back loop --- plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.py b/plugin.py index df24f39..fad3b68 100644 --- a/plugin.py +++ b/plugin.py @@ -99,7 +99,7 @@ class Timebomb(callbacks.Plugin): def cutwire(self, irc, cutWire): self.cutWire = cutWire self.responded = True - if self.Thrown == 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(): From 7ec759eb261075db0d32f3fcf6440ddf48a0b6a1 Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Sun, 14 Apr 2019 16:46:56 -0400 Subject: [PATCH 20/20] Update README.txt --- README.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.txt b/README.txt index d60b47a..e2e2199 100644 --- a/README.txt +++ b/README.txt @@ -1 +1 @@ -Insert a description of your plugin here, with any notes, etc. about using it. +Forked from https://github.com/quantumlemur/Supybot-Plugins/tree/master/Timebomb