Miao-Yunzai/apps/event/newcomer.ts

41 lines
791 B
TypeScript
Raw Normal View History

2024-06-12 10:47:19 +08:00
import { Plugin, segment } from 'yunzai/core'
2024-06-11 21:03:42 +08:00
/**
2024-06-17 22:52:15 +08:00
*
2024-06-11 21:03:42 +08:00
*/
2024-06-12 10:47:19 +08:00
export class newcomer extends Plugin {
2024-06-11 21:03:42 +08:00
/**
2024-06-17 22:52:15 +08:00
*
2024-06-11 21:03:42 +08:00
*/
constructor() {
/**
name: '欢迎新人',
dsc: '新人入群欢迎',
*/
2024-06-12 22:36:39 +08:00
super()
2024-06-17 22:52:15 +08:00
this.event = 'notice.group.increase'
2024-06-12 22:36:39 +08:00
this.priority = 5000
2024-06-11 21:03:42 +08:00
}
/**
*
2024-06-17 22:52:15 +08:00
* @returns
2024-06-11 21:03:42 +08:00
*/
async accept() {
/** 定义入群欢迎内容 */
let msg = '欢迎新人!'
/** 冷却cd 30s */
let cd = 30
if (this.e.user_id == this.e.bot.uin) return
/** cd */
let key = `Yz:newcomers:${this.e.group_id}`
if (await redis.get(key)) return
redis.set(key, '1', { EX: cd })
/** 回复 */
await this.reply([
segment.at(this.e.user_id),
// segment.image(),
msg
])
}
}