zhin chat app
npm install zhin-next
npm init -y
`
$3
`
npm install zhin-next
`
$3
`json
{
"scripts": {
"start": "zhin"
}
}
`
$3
`yaml
log_level: info # log level
plugin_dirs: # plugin directories
- ./plugins
plugins: # enabled plugins
- adapter-terminal
- hello
bots: # bot list
- adapter: terminal
title: 命令行
`
$3
#### 5.1 create plugin directory
`shell
mkdir plugins
`
#### 5.2 create plugin file
`shell
touch plugins/hello.js
`
#### 5.3 edit plugin file
`javascript
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}
})
`
$3
`shell
npm start
`
$3
`shell
hello
hi developer
foo
bar
test
hello world
``