mirror of
https://github.com/fumiama/ReiBot.git
synced 2026-06-05 00:50:25 +08:00
chore: make lint happy
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
12
rules.go
12
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user