cinch-timebomb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/LICENSE +19 -0
  2. data/README.md +51 -0
  3. data/lib/cinch/plugins/timebomb.rb +75 -0
  4. metadata +63 -0
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2012 by Dominik Honnef
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # Timebomb plugin
2
+
3
+ This plugin provides dice for your channel.
4
+
5
+ ## Installation
6
+ First install the gem by running:
7
+ [sudo] gem install cinch-timebomb
8
+
9
+ Then load it in your bot:
10
+ require "cinch"
11
+ require "cinch/plugins/timebomb"
12
+
13
+ bot = Cinch::Bot.new do
14
+ configure do |c|
15
+ # add all required options here
16
+ c.plugins.plugins = [Cinch::Plugins::Timebomb] # optionally add more plugins
17
+ end
18
+ end
19
+
20
+ bot.start
21
+
22
+ ## Commands
23
+ - timebomb <nick>
24
+ - cutwire <color>
25
+
26
+ ### Examples
27
+ timebomb dominikh
28
+
29
+ ## Options
30
+ ### :min_duration & :max_duration
31
+
32
+ These options determine how long a user has time to defuse the bomb.
33
+ The actual duration is a random value between `:min_duration` and
34
+ `:max_duration`. Defaults to 10 and 30, respectively.
35
+
36
+ ### :wires
37
+
38
+ How many wires the user has to pick from. Defaults to 6.
39
+
40
+ ### :channels
41
+
42
+ This option is an array of channels the timebomb plugin should be
43
+ enabled in. This is a required option with no default value.
44
+
45
+ ### Example configuration
46
+ configure do |c|
47
+ c.plugins.options[Cinch::Plugins::Timebomb] = {min_duration: 5,
48
+ max_duration: 20,
49
+ wires: 5,
50
+ channels: ["#cinch-bots"]
51
+ end
@@ -0,0 +1,75 @@
1
+ require "cinch"
2
+
3
+ module Cinch
4
+ module Plugins
5
+ class Timebomb
6
+ include Cinch::Plugin
7
+
8
+ Bomb = Struct.new(:user, :timer, :correct_wire)
9
+
10
+ def initialize(*args)
11
+ super
12
+
13
+ @bombs = {}
14
+ end
15
+ Colors = %w{red orange yellow green blue indigo violet black
16
+ white grey brown pink mauve beige aquamarine chartreuse bisque
17
+ crimson fuchsia gold ivory khaki lavender lime magenta maroon
18
+ navi olive plum silver tan teal turquoise}
19
+
20
+
21
+ match /timebomb (.+)/, method: :plant_bomb
22
+ match /cutwire (.+)/, method: :cut_wire
23
+ self.reacting_on = :channel
24
+ self.required_options = [:channels]
25
+
26
+ def plant_bomb(m, whom)
27
+ whom = User(whom)
28
+ return unless m.channel.users[whom]
29
+ return unless config[:channels].any? {|s| Channel(s) == m.channel}
30
+
31
+ if whom == @bot
32
+ m.channel.kick(m.user, "I will not tolerate this!")
33
+ return
34
+ end
35
+
36
+ if @bombs[m.channel]
37
+ m.channel.action "points at the bulge in the back of #{@bombs[m.channel].user}'s pants."
38
+ return
39
+ end
40
+
41
+ min_duration = config[:min_duration] || 10
42
+ max_duration = config[:max_duration] || 30
43
+ num_wires = config[:wires] || 6
44
+ duration = rand(max_duration - min_duration) + min_duration
45
+ wires = Colors.sample(num_wires)
46
+
47
+ m.channel.action "stuffs the bomb into %s's pants. The display reads [%d] seconds." % [whom, duration]
48
+ m.reply "Defuse the bomb by cutting the correct wire. There are %d wires. They are %s" % [num_wires, wires.map {|s|
49
+ s.capitalize }.join(", ")]
50
+
51
+
52
+ timer = Timer(duration, shots: 1) do
53
+ m.channel.kick(m.user, "*BOOM!*")
54
+ @bombs[m.channel] = nil
55
+ end
56
+
57
+ @bombs[m.channel] = Bomb.new(whom, timer, wires.sample)
58
+ end
59
+
60
+ def cut_wire(m, wire)
61
+ bomb = @bombs[m.channel]
62
+ return unless bomb
63
+ return unless bomb.user == m.user
64
+
65
+ if bomb.correct_wire == wire.downcase
66
+ m.reply "%s cut the %s wire. This has defused the bomb!" % [m.user, wire.capitalize]
67
+ else
68
+ m.channel.kick(m.user, "snip... *BOOM!*")
69
+ end
70
+ @bombs[m.channel] = nil
71
+ bomb.timer.stop
72
+ end
73
+ end
74
+ end
75
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cinch-timebomb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dominik Honnef
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: cinch
16
+ requirement: &22128860 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *22128860
25
+ description: Timebomb is a game where one person asks the Eggdrop bot to plant a timebomb
26
+ in another user's pants. The target user then needs to diffuse the bomb by cutting
27
+ the correct wire, or be kicked from the channel
28
+ email:
29
+ - dominikh@fork-bomb.org
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE
35
+ - README.md
36
+ - lib/cinch/plugins/timebomb.rb
37
+ homepage: http://rubydoc.info/github/cinchrb/cinch-timebomb
38
+ licenses:
39
+ - MIT
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: 1.9.1
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubyforge_project:
58
+ rubygems_version: 1.8.15
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: Plant a timebomb in someone's pants and see if he can defuse it.
62
+ test_files: []
63
+ has_rdoc: