module Ruboty::NyanNyan
Constants
- NAMESPACE
- VERSION
Public Instance Methods
nekonize!()
click to toggle source
# File lib/ruboty/nyan_nyan.rb, line 38 def nekonize! brain.data[NAMESPACE] = true end
nyan_nyan?()
click to toggle source
# File lib/ruboty/nyan_nyan.rb, line 34 def nyan_nyan? brain.data[NAMESPACE] end
say(message)
click to toggle source
Calls superclass method
# File lib/ruboty/nyan_nyan.rb, line 11 def say(message) super and return unless nyan_nyan? nyan_body = Enumerator.new {|y| message[:body].to_s.lines.each do |line| loop do url = line[URI.regexp(%w(http https))] if url token, line = line.split(url, 2) y << token.gsub(/[^ー〜 \n]{3}/, 'ニャン').gsub(/[^ー〜ニャ \n]{2}/, 'ニャ').gsub(/[^ー〜ニャン \n]/, 'ニャ') y << url else y << line.gsub(/[^ー〜 \n]{3}/, 'ニャン').gsub(/[^ー〜ニャ \n]{2}/, 'ニャ').gsub(/[^ー〜ニャン \n]/, 'ニャ') break end end end }.to_a.join super(message.merge(body: nyan_body)) end
unnekonize!()
click to toggle source
# File lib/ruboty/nyan_nyan.rb, line 42 def unnekonize! brain.data[NAMESPACE] = false end