Module: Ruboty::NyanNyan
- Defined in:
- lib/ruboty/nyan_nyan.rb,
lib/ruboty/nyan_nyan/version.rb,
lib/ruboty/nyan_nyan/actions/nyan_nyan.rb
Defined Under Namespace
Modules: Actions
Constant Summary collapse
- NAMESPACE =
'nyan_nyan'
- VERSION =
"0.0.1"
Instance Method Summary collapse
Instance Method Details
#nekonize! ⇒ Object
38 39 40 |
# File 'lib/ruboty/nyan_nyan.rb', line 38 def nekonize! brain.data[NAMESPACE] = true end |
#nyan_nyan? ⇒ Boolean
34 35 36 |
# File 'lib/ruboty/nyan_nyan.rb', line 34 def nyan_nyan? brain.data[NAMESPACE] end |
#say(message) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ruboty/nyan_nyan.rb', line 11 def say() super and return unless nyan_nyan? nyan_body = Enumerator.new {|y| [: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(.merge(body: nyan_body)) end |
#unnekonize! ⇒ Object
42 43 44 |
# File 'lib/ruboty/nyan_nyan.rb', line 42 def unnekonize! brain.data[NAMESPACE] = false end |