Rubirai
A light-weight Mirai QQ bot http interface lib for Ruby.
Usage
First, download the package using gem. In your Gemfile, add
gem 'rubirai'
Then, start to write code (no matter if it's a rails application or something else):
require 'rubirai'
# assuming your mirai http api address and port
# are 127.0.0.1 and 8080
bot = Rubirai::Bot.new('127.0.0.1', '8080')
# qq and auth key
bot.login 1145141919, 'ikisugi_key'
# Add a listener function
bot.add_listener do |event|
puts event.inspect
if event.is_a?(Rubirai::MessageEvent)
event.respond("Hello, world!")
end
end
# Listen to message every 0.5 seconds
# And blocks the current thread
bot.start_listen 0.5, is_blocking: true
If you want to install globally with
gem, use
gem install rubirai