rboot
is a simple and efficient chatbot framework written in golang
, which is easy to extend. It can work on different chat services, and can implement聊天
,工作助手
,服务监控
,警报触发
and other functions through extended scripts.
golang v1.13+
$ go get github.com/ghaoo/ rboot
$ cd $GOPATH /github.com/ghaoo/ rboot /robot
$ go build
$ ./robot
The message adapter is used to monitor the incoming and outgoing messages. Through the message adapter, the chat client's messages can be sent to the robot. After being processed by the script, the returned message is sent to the client.
rboot
provides a simple implementation of命令行cli
微信网页版
企业微信
钉钉
倍洽
adapter.
Plugin
does not provide many out-of-the-box plug-ins, except for a help
plug-in, and the others need to be developed by developers according to their own needs.
help plugin usage :
!help <plugin>
: View plug-in help information. When the command does not include a plug-in name, all plug-in help information will be listed. With a plug-in name, only the help information for this plug-in will be listed.
There are simple plug-in cases under the folder
robot/plugins
. Developers can check how to write plug-ins.
Plugin
can not only use golang to write plug-ins, but also use script plug-ins to execute system commands or plug-in files written in script languages.
The script plug-in is a Plugin
plug-in used to parse script languages. It is an extension of the rboot plug-in. Execute system commands or scripts through yaml
configuration files.
Because script plug-ins are built on
Plugin
, each script will be registered inPlugin
, so make sure the names of plug-ins do not overlap, otherwise the plug-in registered first may be replaced by the plug-in registered later!
PLUGIN_DIR
: The folder where the script plug-in configuration file is stored. If not configured, the default is scripts
We can create a script plug-in by creating a yaml
file, and configure the script plug-in through the configuration options in the file. For example, we create a hello.yml
file with the following content:
name : hello
version : 0.1.0
ruleset :
hello : " ^hello "
usage :
hi : echo hello world and 你好
description : 脚本插件示例
command :
-
cmd :
- echo hi
- echo hello world
-
dir : plugins
cmd :
- echo 你好
This plug-in uses the system command echo
. What it means is: when we enter "hello", the script will return three messages: hi
, hello world
and你好
.
The meaning of each field in the configuration:
Configuration | must | significance |
---|---|---|
name | yes | Plugin name |
ruleset | yes | rule set |
version | no | Plugin version |
usage | no | Plug-in usage |
description | no | Plug-in introduction |
command | yes | Plug-in command set |
--- | --- | --- |
dir | no | Command execution folder |
cmd | yes | Plugin commands |
command
can configure multiple command sets, and the execution order is from top to bottom.
cmd
can be configured with multiple commands, and the order of execution is from top to bottom.
Script plug-ins support系统命令
and脚本语言
. The system command mode is like hello.yml
above. Just fill in the folder and system command in the file. When you issue the command, the robot will execute it in sequence from top to bottom.
Scripting language is an execution method based on the system command mode. We can use system commands to call language scripts to execute more complex scripts. For example, we use python to output "hello robot".
Our python script is as follows:
#!/usr/bin/env python
print ( "Hello, robot! i am a python script" )
Our configuration file is as follows:
name : pyscript
version : 0.1.0
ruleset :
py : " ^hello python "
usage :
py : execute python script
description : python插件示例
command :
dir : script
cmd :
- ./hello.py
When we enter hello python
, the robot will call the hello.py
script, and the script will output "Hello, robot! i am a python script" and display it to us through the robot.
Please confirm whether
目录分隔符
matches the current system settings under different operating systems. Please use it underwindows
please use
/
underunix
This project uses the MIT open source license, and the complete licensing instructions can be found in the LICENSE file.