Project

rubirai

0.0
There's a lot of open issues
No release in over a year
A Mirai QQ bot http interface lib for Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 5.0
 Project Readme

Rubirai

Gem Version CI codecov Maintainability Inline docs FOSSA Status

A light-weight Mirai QQ bot http interface lib for Ruby.

中文 | Rubydocs

Description

This library is designed specifically for integration with mirai-api-http. Mirai is a QQ bot framework. The relationship is like this:

mirai <-jvm-> mirai-console <-plugin-> mirai-api-http <-http-> rubirai

Prerequisite

Install mirai-api-http and configure its setting.yml file.

Now its easier to enable singleMode if you have only one account in the mirai console.

Note that you must enable Http Adapter with configuration of http under adapterSettings. More mode support to come.

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 verify 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 

Wiki and Documentation

License

AGPL-3.0 License

FOSSA Status