mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-12 02:00:24 +00:00
新增统计睡眠时间和添加协程里的异常捕获 (#84)
* fix:捕获协程异常 * feat:添加睡眠时间 * feat:添加睡眠管理功能 * fix:修改对标时间 * fix:修改注释函数名,使用一个时间 * feat:让大家能够更加清楚的看到每一个功能 * feat:把群管放在control,增加退群信息 * fix:不会recover * fix:原本的正则限制机器人回复回复的消息,故去掉正则 * fix:添加服务详情,整理manager * feat:chat进control Co-authored-by: Guohuiyuan <haibaraguo@yeahka.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"github.com/FloatTech/ZeroBot-Plugin/control"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
"time"
|
||||
@@ -13,9 +14,14 @@ import (
|
||||
|
||||
var poke = rate.NewManager(time.Minute*5, 8) // 戳一戳
|
||||
|
||||
var engine = control.Register("chat", &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "chat\n- [BOT名字]\n- [戳一戳BOT]\n- 空调开\n- 空调关\n- 群温度\n- 设置温度[正整数]",
|
||||
})
|
||||
|
||||
func init() { // 插件主体
|
||||
// 被喊名字
|
||||
zero.OnFullMatch("", zero.OnlyToMe).SetBlock(false).FirstPriority().
|
||||
engine.OnFullMatch("", zero.OnlyToMe).SetBlock(true).FirstPriority().
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
var nickname = zero.BotConfig.NickName[0]
|
||||
time.Sleep(time.Second * 1)
|
||||
@@ -29,7 +35,7 @@ func init() { // 插件主体
|
||||
))
|
||||
})
|
||||
// 戳一戳
|
||||
zero.On("notice/notify/poke", zero.OnlyToMe).SetBlock(false).FirstPriority().
|
||||
engine.On("notice/notify/poke", zero.OnlyToMe).SetBlock(false).FirstPriority().
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
var nickname = zero.BotConfig.NickName[0]
|
||||
switch {
|
||||
@@ -48,18 +54,18 @@ func init() { // 插件主体
|
||||
// 群空调
|
||||
var AirConditTemp = map[int64]int{}
|
||||
var AirConditSwitch = map[int64]bool{}
|
||||
zero.OnFullMatch("空调开").SetBlock(true).FirstPriority().
|
||||
engine.OnFullMatch("空调开").SetBlock(true).FirstPriority().
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
AirConditSwitch[ctx.Event.GroupID] = true
|
||||
ctx.SendChain(message.Text("❄️哔~"))
|
||||
})
|
||||
zero.OnFullMatch("空调关").SetBlock(true).FirstPriority().
|
||||
engine.OnFullMatch("空调关").SetBlock(true).FirstPriority().
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
AirConditSwitch[ctx.Event.GroupID] = false
|
||||
delete(AirConditTemp, ctx.Event.GroupID)
|
||||
ctx.SendChain(message.Text("💤哔~"))
|
||||
})
|
||||
zero.OnRegex(`设置温度(\d+)`).SetBlock(true).FirstPriority().
|
||||
engine.OnRegex(`设置温度(\d+)`).SetBlock(true).FirstPriority().
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
if _, exist := AirConditTemp[ctx.Event.GroupID]; !exist {
|
||||
AirConditTemp[ctx.Event.GroupID] = 26
|
||||
@@ -78,7 +84,7 @@ func init() { // 插件主体
|
||||
))
|
||||
}
|
||||
})
|
||||
zero.OnFullMatch(`群温度`).SetBlock(true).FirstPriority().
|
||||
engine.OnFullMatch(`群温度`).SetBlock(true).FirstPriority().
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
if _, exist := AirConditTemp[ctx.Event.GroupID]; !exist {
|
||||
AirConditTemp[ctx.Event.GroupID] = 26
|
||||
|
||||
Reference in New Issue
Block a user