V2.0.4
· 阅读需 2 分钟
Project | Status | Description |
---|---|---|
alemonjs | 机器人模块 |
- 【Fix】中间件的regular 没生效。
import { createSelects } from 'alemonjs'
export const selects = createSelects(['message.create'])
// 仅限 # 和 / 开头的消息才执行该中间件
export const regular = /^(#|\/)/
export default onMiddleware(selects, (event, next) => {
next()
})
- 【Feat】支持return对象以描述其他行为
import { createSelects } from 'alemonjs'
export const selects = createSelects(['message.create'])
export default onResponse(selects, event => {
const res = {
// any
}
return {
// 允许分组,等同于 return true
allowGrouping: true,
// 即将要发送的数据,等同于 useSend(event)(...)
data: [],
...res
}
})
- 【Feat】支持内部存储实例
import { Logger, logger as log } from 'alemonjs'
const logger = new Logger().value // 同 logger as log
import { Response } from 'alemonjs'
// 内部所有的res索引
const res = new Response().value
import { Middleware } from 'alemonjs'
// 内部所有的mws索引
const res = new Middleware().value
import { SubscribeList } from 'alemonjs'
// 所有的 create + message.create 订阅
// 即 onSubscribe
const subscribeList = new SubscribeList('create', 'message.create').value
// const subscribeList = new SubscribeList('mount', 'message.create').value
// const subscribeList = new SubscribeList('unmount', 'message.create').value
import { StateSubscribe } from 'alemonjs'
const stateList = new StateSubscribe('create', 'message.create')
stateList.on(() => {}) // onState
stateList.un(() => {}) // unState
const stateSubscribe = stateList.value
import { State } from 'alemonjs'
// 即 useState
const stateList = new State('main:res:name') // new State('main:apps:name')
stateList.value = true // 设置为 true
stateList.value = false // 设置为 false
import { ChildrenApp } from 'alemonjs'
// 默认 main。
// 得到内部res、mw、周期等
const app = new ChildrenApp('main')?.value