mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 19:43:49 +08:00
fix(all): resolve issues reported by golangci-lint
This commit is contained in:
parent
7751aa942e
commit
96e0411c97
16
coolq/api.go
16
coolq/api.go
@ -135,15 +135,17 @@ func (bot *CQBot) CQGetGuildMembers(guildID uint64) global.MSG {
|
||||
if guild == nil {
|
||||
return Failed(100, "GUILD_NOT_FOUND")
|
||||
}
|
||||
var members, bots, admins []global.MSG
|
||||
for _, m := range guild.Members {
|
||||
members = append(members, convertGuildMemberInfo(m))
|
||||
members := make([]global.MSG, len(guild.Members))
|
||||
bots := make([]global.MSG, len(guild.Bots))
|
||||
admins := make([]global.MSG, len(guild.Admins))
|
||||
for i, m := range guild.Members {
|
||||
members[i] = convertGuildMemberInfo(m)
|
||||
}
|
||||
for _, m := range guild.Bots {
|
||||
bots = append(bots, convertGuildMemberInfo(m))
|
||||
for i, m := range guild.Bots {
|
||||
bots[i] = convertGuildMemberInfo(m)
|
||||
}
|
||||
for _, m := range guild.Admins {
|
||||
admins = append(admins, convertGuildMemberInfo(m))
|
||||
for i, m := range guild.Admins {
|
||||
admins[i] = convertGuildMemberInfo(m)
|
||||
}
|
||||
return OK(global.MSG{
|
||||
"members": members,
|
||||
|
@ -182,7 +182,7 @@ func (bot *CQBot) UploadLocalImageAsPrivate(userID int64, img *LocalImageElement
|
||||
}
|
||||
|
||||
// UploadLocalImageAsGuildChannel 上传本地图片至频道
|
||||
func (bot *CQBot) UploadLocalImageAsGuildChannel(guildId, channelId uint64, img *LocalImageElement) (*message.GuildImageElement, error) {
|
||||
func (bot *CQBot) UploadLocalImageAsGuildChannel(guildID, channelID uint64, img *LocalImageElement) (*message.GuildImageElement, error) {
|
||||
if img.File != "" {
|
||||
f, err := os.Open(img.File)
|
||||
if err != nil {
|
||||
@ -194,7 +194,7 @@ func (bot *CQBot) UploadLocalImageAsGuildChannel(guildId, channelId uint64, img
|
||||
if lawful, mime := base.IsLawfulImage(img.Stream); !lawful {
|
||||
return nil, errors.New("image type error: " + mime)
|
||||
}
|
||||
return bot.Client.GuildService.UploadGuildImage(guildId, channelId, img.Stream)
|
||||
return bot.Client.GuildService.UploadGuildImage(guildID, channelID, img.Stream)
|
||||
}
|
||||
|
||||
// SendGroupMessage 发送群消息
|
||||
|
@ -1,11 +1,13 @@
|
||||
package coolq
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/Mrs4s/MiraiGo/client"
|
||||
"github.com/Mrs4s/MiraiGo/message"
|
||||
"github.com/Mrs4s/go-cqhttp/global"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"strconv"
|
||||
|
||||
"github.com/Mrs4s/go-cqhttp/global"
|
||||
)
|
||||
|
||||
func convertGroupMemberInfo(groupID int64, m *client.GroupMemberInfo) global.MSG {
|
||||
|
@ -80,15 +80,18 @@ type MessageSource struct {
|
||||
// MessageSourceType 消息来源类型
|
||||
type MessageSourceType int32
|
||||
|
||||
// MessageSourceType 常量
|
||||
const (
|
||||
maxImageSize = 1024 * 1024 * 30 // 30MB
|
||||
maxVideoSize = 1024 * 1024 * 100 // 100MB
|
||||
|
||||
MessageSourcePrivate MessageSourceType = 0
|
||||
MessageSourceGroup MessageSourceType = 1
|
||||
MessageSourceGuildChannel MessageSourceType = 2
|
||||
)
|
||||
|
||||
const (
|
||||
maxImageSize = 1024 * 1024 * 30 // 30MB
|
||||
maxVideoSize = 1024 * 1024 * 100 // 100MB
|
||||
)
|
||||
|
||||
// Type implements the message.IMessageElement.
|
||||
func (e *LocalImageElement) Type() message.ElementType {
|
||||
return message.Image
|
||||
@ -1414,6 +1417,7 @@ func (bot *CQBot) readImageCache(b []byte, sourceType MessageSourceType) (messag
|
||||
if sourceType == MessageSourceGuildChannel {
|
||||
if len(bot.Client.GuildService.Guilds) == 0 {
|
||||
err = errors.New("cannot query guild image: not any joined guild")
|
||||
goto ok
|
||||
}
|
||||
guild := bot.Client.GuildService.Guilds[0]
|
||||
rsp, err = bot.Client.GuildService.QueryImage(guild.GuildId, guild.Channels[0].ChannelId, hash, uint64(size))
|
||||
|
@ -187,17 +187,17 @@ func (bot *CQBot) guildMessageReactionsUpdatedEvent(c *client.QQClient, e *clien
|
||||
return
|
||||
}
|
||||
str := fmt.Sprintf("频道 %v(%v) 消息 %v 表情贴片已更新: ", guild.GuildName, guild.GuildId, e.MessageId)
|
||||
var currentReactions []global.MSG
|
||||
for _, r := range e.CurrentReactions {
|
||||
currentReactions := make([]global.MSG, len(e.CurrentReactions))
|
||||
for i, r := range e.CurrentReactions {
|
||||
str += fmt.Sprintf("%v*%v ", r.Face.Name, r.Count)
|
||||
currentReactions = append(currentReactions, global.MSG{
|
||||
currentReactions[i] = global.MSG{
|
||||
"emoji_id": r.EmojiId,
|
||||
"emoji_index": r.Face.Index,
|
||||
"emoji_type": r.EmojiType,
|
||||
"emoji_name": r.Face.Name,
|
||||
"count": r.Count,
|
||||
"clicked": r.Clicked,
|
||||
})
|
||||
}
|
||||
}
|
||||
if len(e.CurrentReactions) == 0 {
|
||||
str += "无任何表情"
|
||||
|
Loading…
x
Reference in New Issue
Block a user