From 617956e3e2cf1bfba0e40ca0d34352246cb2ab32 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: Tue, 13 May 2025 20:31:04 +0900 Subject: [PATCH] chore: make lint happy --- README.md | 4 ++-- context.go | 2 +- future.go | 4 ++-- rules.go | 12 ++++++------ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 1139617..0cf9bbe 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ func main() { }, Debug: true, Handler: &rei.Handler{ - OnMessage: func(updateid int, bot *rei.TelegramClient, msg *tgba.Message) { + OnMessage: func(_ int, bot *rei.TelegramClient, msg *tgba.Message) { if len(msg.Text) <= len("测试") { return } @@ -91,7 +91,7 @@ func main() { log.Errorln(err) } }, - OnEditedMessage: func(updateid int, bot *rei.TelegramClient, msg *tgba.Message) { + OnEditedMessage: func(_ int, bot *rei.TelegramClient, msg *tgba.Message) { if len(msg.Text) <= len("测试") { return } diff --git a/context.go b/context.go index 91bff33..9b3960a 100644 --- a/context.go +++ b/context.go @@ -66,7 +66,7 @@ func (ctx *Ctx) Parse(model interface{}) (err error) { func (ctx *Ctx) CheckSession() Rule { msg := ctx.Value.(*tgba.Message) return func(ctx2 *Ctx) bool { - msg2, ok := ctx.Value.(*tgba.Message) + msg2, ok := ctx2.Value.(*tgba.Message) if !ok || msg.From == nil || msg.Chat == nil || msg2.From == nil || msg2.Chat == nil { // 确保无空 return false } diff --git a/future.go b/future.go index 3571c86..295b28d 100644 --- a/future.go +++ b/future.go @@ -9,9 +9,9 @@ type FutureEvent struct { } // NewFutureEvent 创建一个FutureEvent, 并返回其指针 -func NewFutureEvent(Type string, Priority int, Block bool, rule ...Rule) *FutureEvent { +func NewFutureEvent(typ string, Priority int, Block bool, rule ...Rule) *FutureEvent { return &FutureEvent{ - Type: Type, + Type: typ, Priority: Priority, Rule: rule, Block: Block, diff --git a/rules.go b/rules.go index 939b33a..66b9bd9 100644 --- a/rules.go +++ b/rules.go @@ -270,14 +270,14 @@ func OnlyToMe(ctx *Ctx) bool { } // CheckUser only triggered by specific person -func CheckUser(userId ...int64) Rule { +func CheckUser(userID ...int64) Rule { return func(ctx *Ctx) bool { switch msg := ctx.Value.(type) { case *tgba.Message: if msg.From == nil { // 确保无空 return false } - for _, uid := range userId { + for _, uid := range userID { if msg.From.ID == uid { return true } @@ -287,7 +287,7 @@ func CheckUser(userId ...int64) Rule { if msg.From == nil { return false } - for _, uid := range userId { + for _, uid := range userID { if msg.From.ID == uid { return true } @@ -300,14 +300,14 @@ func CheckUser(userId ...int64) Rule { } // CheckChat only triggered in specific chat -func CheckChat(chatId ...int64) Rule { +func CheckChat(chatID ...int64) Rule { return func(ctx *Ctx) bool { switch msg := ctx.Value.(type) { case *tgba.Message: if msg.Chat == nil { // 确保无空 return false } - for _, cid := range chatId { + for _, cid := range chatID { if msg.Chat.ID == cid { return true } @@ -317,7 +317,7 @@ func CheckChat(chatId ...int64) Rule { if msg.Message == nil || msg.Message.Chat == nil { return false } - for _, cid := range chatId { + for _, cid := range chatID { if msg.Message.Chat.ID == cid { return true }