From f2519a7b28fe41e1b069a0d764dfccfe87b4033e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 9 Oct 2022 08:11:19 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E7=BB=93=E6=9D=9F=E5=93=8D=E5=BA=94=20no?= =?UTF-8?q?tify?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ rule.go | 28 ++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0a2485e..7087f17 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ ## Instructions +> Note: This framework is built mainly for Chinese users thus may display hard-coded Chinese prompts during the interaction. + This framework is a simple wrapper for [go-telegram-bot-api](https://github.com/go-telegram-bot-api/telegram-bot-api), aiming to make the event processing easier. ## Quick Start diff --git a/rule.go b/rule.go index 4764f73..c61a2e6 100644 --- a/rule.go +++ b/rule.go @@ -28,8 +28,8 @@ func Lookup(service string) (*ctrl.Control[*Ctx], bool) { // respLimiterManager 请求响应限速器管理 // -// 每 1d 1次触发 -var respLimiterManager = rate.NewManager[int64](time.Hour*24, 1) +// 每 1d 4次触发 +var respLimiterManager = rate.NewManager[int64](time.Hour*24, 4) func init() { process.NewCustomOnce(&m).Do(func() { @@ -102,6 +102,30 @@ func init() { } else { msg = "ERROR: " + err.Error() } + if SuperUserPermission(ctx) { + break + } + notify := &tgba.PhotoConfig{ + BaseFile: tgba.BaseFile{ + File: func() tgba.RequestFileData { + if ctx.Message.Chat.Photo != nil { + return tgba.FileID(ctx.Message.Chat.Photo.BigFileID) + } + p, err := ctx.Caller.GetUserProfilePhotos(tgba.NewUserProfilePhotos(ctx.Message.From.ID)) + if err == nil && len(p.Photos) > 0 { + fp := p.Photos[0] + return tgba.FileID(fp[len(fp)-1].FileID) + } + return nil + }(), + }, + Caption: "主人, @" + ctx.Message.From.String() + " 主动结束了响应~\n*ChatType*: " + ctx.Message.Chat.Type + "\n*ChatUserName*: " + ctx.Message.Chat.UserName + "\n*ChatID*: " + strconv.FormatInt(ctx.Message.Chat.ID, 10) + "\n*ChatTitle*: " + ctx.Message.Chat.Title + "\n*ChatDescription*: " + ctx.Message.Chat.Description, + ParseMode: "Markdown", + } + for _, id := range ctx.Caller.b.SuperUsers { + notify.ChatID = id + _, _ = ctx.Caller.Send(notify) + } default: msg = "ERROR: bad command\"" + fmt.Sprint(ctx.State["command"]) + "\"" }