Advertisement
Anarkros

Untitled

Dec 5th, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.75 KB | None | 0 0
  1. """
  2. bomb.py - Simple Willie bomb prank game
  3. Copyright 2012, Edward Powell http://embolalia.net
  4. Licensed under the Eiffel Forum License 2.
  5.  
  6. http://willie.dfbta.net
  7. """
  8. from willie.module import commands
  9. from random import choice, randint
  10. from re import search
  11. import sched
  12. import time
  13. from willie.tools import Nick
  14. colors = ['Red', 'Yellow', 'Blue', 'White', 'Black']
  15. sch = sched.scheduler(time.time, time.sleep)
  16. fuse = 120 # seconds
  17. bombs = dict()
  18.  
  19.  
  20. @commands('bomb')
  21. def start(bot, trigger):
  22.  
  23. """
  24. Put a bomb in the specified user's pants. They will be kicked if they
  25. don't guess the right wire fast enough.
  26. """
  27.  
  28. """ Ensures only OPs and HOPs can call Bomb """
  29. if (trigger.nick not in bot.ops[trigger.sender] and trigger.nick not in bot.halfplus[trigger.sender]):
  30. bot.say('I\'m sorry ' + trigger.nick + ', I\'m afraid I can\'t do that.')
  31. return
  32.  
  33. """ If no name passed to Bomb command """
  34. if not trigger.group(3):
  35. bot.say('Who do you want to Bomb?')
  36. return
  37.  
  38. """ If Bomb command sent via private message instead of in channnel """
  39. if not trigger.sender.startswith('#'):
  40. bot.say('Tell me this in a channel')
  41. return
  42.  
  43. global bombs
  44. global sch
  45. target = Nick(trigger.group(3))
  46.  
  47. """ Someone tries to bomb Willie """
  48. if target == bot.nick:
  49. bot.say('I will NOT BOMB MYSELF!')
  50. return
  51. """ Someone attempts a double-bombing """
  52. if target.lower() in bombs:
  53. bot.say('I can\'t fit another bomb in ' + target + '\'s pants!')
  54. return
  55. """ Someone tries to bomb themself """
  56. if target == trigger.nick:
  57. bot.say('I will not LET YOU BOMB YOURSELF!')
  58. return
  59. """ Bomb target not a recognised name """
  60. if target.lower() not in bot.privileges[trigger.sender.lower()]:
  61. bot.say('Please Bomb someone WHO IS HERE!')
  62. return
  63. """ Proceed with the bomb insertion """
  64. message = 'Hey, ' + target + '! Don\'t look but, I think there\'s a bomb in your pants. 2 minute timer, 5 wires: Red, Yellow, Blue, White and Black. Which wire should I cut? Don\'t worry, I know what I\'m doing! (respond with .cutwire color)'
  65. bot.say(message)
  66. color = choice(colors)
  67. bot.msg(trigger.nick,
  68. "Hey, don\'t tell %s, but the %s wire? Yeah, that\'s the one."
  69. " But shh! Don\'t say anything!" % (target, color))
  70. code = sch.enter(fuse, 1, explode, (bot, trigger))
  71. bombs[target.lower()] = (color, code)
  72. sch.run()
  73.  
  74.  
  75. @commands('cutwire')
  76. def cutwire(bot, trigger):
  77. """
  78. Tells willie to cut a wire when you've been bombed.
  79. """
  80. global bombs, colors
  81. target = Nick(trigger.nick)
  82. """
  83. Someone tries cutting a wire without first being bombed
  84. """
  85. if target.lower() != bot.nick.lower() and target.lower() not in bombs:
  86. bot.say('You can\'t cut a wire till someone bombs you')
  87. return
  88. color, code = bombs.pop(target.lower()) # remove target from bomb list
  89. wirecut = trigger.group(2).rstrip(' ')
  90. """
  91. They try cutting ALL the wires
  92. """
  93. if wirecut.lower() in ('all', 'all!'):
  94. sch.cancel(code) # defuse timer, execute premature detonation
  95. kmsg = ('KICK %s %s : Cutting ALL the wires! *boom* (You should\'ve picked the %s wire.)'
  96. % (trigger.sender, target, color))
  97. bot.write([kmsg])
  98. elif wirecut.capitalize() not in colors:
  99. bot.say('I can\'t seem to find that wire, ' + target + '! You sure you\'re picking the right one? It\'s not here!')
  100. bombs[target.lower()] = (color, code) # Add the target back onto the bomb list,
  101. elif wirecut.capitalize() == color:
  102. bot.say('You did it, ' + target + '! I\'ll be honest, I thought you were dead. But nope, you did it. You picked the right one. Well done.')
  103. sch.cancel(code) # defuse bomb
  104. else:
  105. sch.cancel(code) # defuse timer, execute premature detonation
  106. kmsg = 'KICK ' + trigger.sender + ' ' + target + \
  107. ' : No! No, that\'s the wrong one. Aww, you\'ve gone and killed yourself. Oh, that\'s... that\'s not good. No good at all, really. Wow. Sorry. (You should\'ve picked the ' + color + ' wire.)'
  108. bot.write([kmsg])
  109.  
  110.  
  111. def explode(bot, trigger):
  112. """
  113. Target didn't cut any wires
  114. """
  115. target = Nick(trigger.group(3))
  116. kmsg = 'KICK ' + trigger.sender + ' ' + target + \
  117. ' : Oh, come on, ' + target + '! You could\'ve at least picked one! Now you\'re dead. Guts, all over the place. You see that? Guts, all over your truck. (You should\'ve picked the ' + bombs[target.lower()][0] + ' wire.)'
  118. bot.write([kmsg])
  119. bombs.pop(target.lower())
  120.  
  121. #Test
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement