zhin-next
v0.0.1
Published
zhin chat app
Readme
zhin-next
zhin next version, driven by NodeJS (esm)
Usage
1. init NodeJS project
npm init -y2. install zhin-next
npm install zhin-next3. add script in package.json
{
"scripts": {
"start": "zhin"
}
}4. add zhin.config.yml
log_level: info # log level
plugin_dirs: # plugin directories
- ./plugins
plugins: # enabled plugins
- adapter-terminal
- hello
bots: # bot list
- adapter: terminal
title: 命令行5. create plugin
5.1 create plugin directory
mkdir plugins5.2 create plugin file
touch plugins/hello.js5.3 edit plugin file
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}`
})6. start zhin
npm start7. test
hello
# hi developer
foo
# bar
test
# hello world