class Plugins::Rainbow

Public Instance Methods

execute_eyerape(m, string) click to toggle source
# File lib/Zeta/plugins/rainbow.rb, line 53
def execute_eyerape(m, string)
  m.reply(eyerapeification(string), false)
end
execute_rainbow(m, string) click to toggle source
# File lib/Zeta/plugins/rainbow.rb, line 45
def execute_rainbow(m, string)
  m.reply(rainbowification(string), false)
end
eyerapeification(s) click to toggle source
# File lib/Zeta/plugins/rainbow.rb, line 31
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) click to toggle source
# File lib/Zeta/plugins/rainbow.rb, line 19
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