zhin next version, driven by NodeJS (esm)
npm init -y
npm install zhin-next
{
"scripts": {
"start": "zhin"
}
}
log_level: info # log level
plugin_dirs: # plugin directories
- ./plugins
plugins: # enabled plugins
- adapter-terminal
- hello
bots: # bot list
- adapter: terminal
title: 命令行
mkdir plugins
touch plugins/hello.js
import { definePlugin } from 'zhin-next';
import {Directive} from "@zhinjs/directive";
const testDirective=new Directive('test')
.handle(()=>'hello world')
export default definePlugin({
name: 'hello',// plugin name
directives:[Test],
weight: 0,// plugin weight
})
.directive('foo','bar')
.directive('hello', async (match, event) => {
return `hi ${event.user_name}`
})
npm start
hello
# hi developer
foo
# bar
test
# hello world