ruby mikutter_bbop_plugin.rb

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby mikutter_bbop_plugin.rb相关的知识,希望对你有一定的参考价值。

#-*- coding: utf-8 -*-

@@elements = ["ビ","ビ","ド","レ","ド","オ","ペ","レ","ショ"]

def bbop()
  indice = []
  matches = 0
  for i in [*0..8] do
    indice[i] = [*0..8].sample()
    if @@elements[i]==@@elements[indice[i]]
      matches += 1
    end
  end
  score = matches / 9.0 * 100
  result = ""
  result << @@elements[indice[0]]
  result << @@elements[indice[1]]
  result << "ッ"
  result << @@elements[indice[2]]
  result << @@elements[indice[3]]
  result << "ッ"
  result << @@elements[indice[4]]
  result << "・"
  result << @@elements[indice[5]] 
  result << @@elements[indice[6]]
  result << @@elements[indice[7]]
  result << "ー"
  result << @@elements[indice[8]] 
  result << "ン"
  result << " (#{sprintf("%.1f",score)}\%)"
  return result
end

Plugin.create :bbop do
  on_appear do |ms|
    ms.each do |m| 
      if Time.now - m[:created] > 5
        next
      end
      if m.message.to_s =~ /^@#{Service.primary.user.to_s} bbop/
        m.favorite
        Service.primary.post :message => "@#{m.user.to_s} #{bbop}", :replyto => m.message
      end
    end
  end
end

以上是关于ruby mikutter_bbop_plugin.rb的主要内容,如果未能解决你的问题,请参考以下文章

Ruby运算符

Ruby 25 岁了!Ruby 之父说 Ruby 3 有望 3 倍提速

如何学习ruby?Ruby学习技巧分享

ruby Ruby脚本,看看是否用openssl编译了ruby

什么是ruby?

ruby和ruby ee