Class: Plugins::Rainbow
- Inherits:
-
Object
- Object
- Plugins::Rainbow
- Includes:
- Cinch::Helpers, Cinch::Plugin
- Defined in:
- lib/Zeta/plugins/rainbow.rb
Instance Method Summary collapse
- #execute_eyerape(m, string) ⇒ Object
- #execute_rainbow(m, string) ⇒ Object
- #eyerapeification(s) ⇒ Object
- #rainbowification(s) ⇒ Object
Methods included from Cinch::Plugin
Instance Method Details
#execute_eyerape(m, string) ⇒ Object
54 55 56 |
# File 'lib/Zeta/plugins/rainbow.rb', line 54 def execute_eyerape(m, string) m.reply(eyerapeification(string), false) end |
#execute_rainbow(m, string) ⇒ Object
46 47 48 |
# File 'lib/Zeta/plugins/rainbow.rb', line 46 def execute_rainbow(m, string) m.reply(rainbowification(string), false) end |
#eyerapeification(s) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/Zeta/plugins/rainbow.rb', line 32 def eyerapeification(s) sd = s.dup sd.gsub(/\x03([0-9]{2}(,[0-9]{2})?)?/, "") # Because total function abuse. colour = %w{04 07 08 09 10 06 13} offset = Random.new.rand(0..colour.size-1) sd = "\x02" + sd.upcase.split(" ").map { |c| offset = (offset < colour.size-1 ? offset.next : 0) "\x03#{colour[offset]},#{colour[offset-4]}#{c.each_char.each_with_index.map { |char, index| index % 2 == 0 ? char : char.downcase }.join}" }.join(" ") #sd end |
#rainbowification(s) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/Zeta/plugins/rainbow.rb', line 20 def rainbowification(s) s.gsub(/\x03([0-9]{2}(,[0-9]{2})?)?/, "") # Because total function abuse. colour = %w{04 07 08 09 10 06 13} i = Random.new.rand(0..colour.size-1); new_string = "" s.each_char { |c| new_string << "\x03#{colour[i]}#{c}"; i = i < colour.size-1 ? i.next : 0; } new_string end |