Class: Cinch::Plugins::Rainbow

Inherits:
Object
  • Object
show all
Includes:
Cinch::Plugin
Defined in:
lib/cinch/plugins/rainbow.rb

Instance Method Summary collapse

Instance Method Details

#execute_eyerape(m, string) ⇒ Object


46
# File 'lib/cinch/plugins/rainbow.rb', line 46

def execute_eyerape(m, string); m.reply(eyerapeification(string),false); end

#execute_rainbow(m, string) ⇒ Object


43
# File 'lib/cinch/plugins/rainbow.rb', line 43

def execute_rainbow(m, string); m.reply(rainbowification(string),false); end

#eyerapeification(s) ⇒ Object


30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cinch/plugins/rainbow.rb', line 30

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


18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cinch/plugins/rainbow.rb', line 18

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