mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 03:23:49 +08:00
feat: get_guild_msg api
This commit is contained in:
parent
f5ef0c188b
commit
32aa82f914
24
coolq/api.go
24
coolq/api.go
@ -1564,6 +1564,30 @@ func (bot *CQBot) CQGetMessage(messageID int32) global.MSG {
|
|||||||
return OK(m)
|
return OK(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CQGetGuildMessage 获取频道消息
|
||||||
|
// @route(get_guild_msg)
|
||||||
|
func (bot *CQBot) CQGetGuildMessage(messageID string) global.MSG {
|
||||||
|
msg, err := db.GetGuildChannelMessageByID(messageID)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("获取消息时出现错误: %v", err)
|
||||||
|
return Failed(100, "MSG_NOT_FOUND", "消息不存在")
|
||||||
|
}
|
||||||
|
m := global.MSG{
|
||||||
|
"message_id": msg.ID,
|
||||||
|
"message_source": "channel",
|
||||||
|
"guild_id": fU64(msg.GuildID),
|
||||||
|
"channel_id": fU64(msg.ChannelID),
|
||||||
|
"message_seq": msg.Attribute.MessageSeq,
|
||||||
|
"sender": global.MSG{
|
||||||
|
"user_id": fU64(msg.Attribute.SenderTinyID),
|
||||||
|
"nickname": msg.Attribute.SenderName,
|
||||||
|
},
|
||||||
|
"time": msg.Attribute.Timestamp,
|
||||||
|
"message": ToFormattedMessage(bot.ConvertContentMessage(msg.Content, MessageSourceGuildChannel), MessageSource{SourceType: MessageSourceGuildChannel, PrimaryID: msg.GuildID, SubID: msg.ChannelID}),
|
||||||
|
}
|
||||||
|
return OK(m)
|
||||||
|
}
|
||||||
|
|
||||||
// CQGetGroupSystemMessages 扩展API-获取群文件系统消息
|
// CQGetGroupSystemMessages 扩展API-获取群文件系统消息
|
||||||
//
|
//
|
||||||
// https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%B3%BB%E7%BB%9F%E6%B6%88%E6%81%AF
|
// https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%B3%BB%E7%BB%9F%E6%B6%88%E6%81%AF
|
||||||
|
@ -80,6 +80,7 @@ func NewQQBot(cli *client.QQClient) *CQBot {
|
|||||||
bot.Client.OnTempMessage(bot.tempMessageEvent)
|
bot.Client.OnTempMessage(bot.tempMessageEvent)
|
||||||
bot.Client.GuildService.OnGuildChannelMessage(bot.guildChannelMessageEvent)
|
bot.Client.GuildService.OnGuildChannelMessage(bot.guildChannelMessageEvent)
|
||||||
bot.Client.GuildService.OnGuildMessageReactionsUpdated(bot.guildMessageReactionsUpdatedEvent)
|
bot.Client.GuildService.OnGuildMessageReactionsUpdated(bot.guildMessageReactionsUpdatedEvent)
|
||||||
|
bot.Client.GuildService.OnGuildMessageRecalled(bot.guildChannelMessageRecalledEvent)
|
||||||
bot.Client.GuildService.OnGuildChannelUpdated(bot.guildChannelUpdatedEvent)
|
bot.Client.GuildService.OnGuildChannelUpdated(bot.guildChannelUpdatedEvent)
|
||||||
bot.Client.GuildService.OnGuildChannelCreated(bot.guildChannelCreatedEvent)
|
bot.Client.GuildService.OnGuildChannelCreated(bot.guildChannelCreatedEvent)
|
||||||
bot.Client.GuildService.OnGuildChannelDestroyed(bot.guildChannelDestroyedEvent)
|
bot.Client.GuildService.OnGuildChannelDestroyed(bot.guildChannelDestroyedEvent)
|
||||||
|
@ -69,6 +69,13 @@ func GetPrivateMessageByGlobalID(id int32) (*StoredPrivateMessage, error) {
|
|||||||
return backends[0].GetPrivateMessageByGlobalID(id)
|
return backends[0].GetPrivateMessageByGlobalID(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetGuildChannelMessageByID(id string) (*StoredGuildChannelMessage, error) {
|
||||||
|
if len(backends) == 0 {
|
||||||
|
return nil, DatabaseDisabledError
|
||||||
|
}
|
||||||
|
return backends[0].GetGuildChannelMessageByID(id)
|
||||||
|
}
|
||||||
|
|
||||||
func InsertGroupMessage(m *StoredGroupMessage) error {
|
func InsertGroupMessage(m *StoredGroupMessage) error {
|
||||||
for _, b := range backends {
|
for _, b := range backends {
|
||||||
if err := b.InsertGroupMessage(m); err != nil {
|
if err := b.InsertGroupMessage(m); err != nil {
|
||||||
|
@ -151,6 +151,9 @@ func (c *Caller) call(action string, p Getter) global.MSG {
|
|||||||
case "get_guild_meta_by_guest":
|
case "get_guild_meta_by_guest":
|
||||||
p0 := p.Get("guild_id").Uint()
|
p0 := p.Get("guild_id").Uint()
|
||||||
return c.bot.CQGetGuildMetaByGuest(p0)
|
return c.bot.CQGetGuildMetaByGuest(p0)
|
||||||
|
case "get_guild_msg":
|
||||||
|
p0 := p.Get("message_id").String()
|
||||||
|
return c.bot.CQGetGuildMessage(p0)
|
||||||
case "get_guild_roles":
|
case "get_guild_roles":
|
||||||
p0 := p.Get("guild_id").Uint()
|
p0 := p.Get("guild_id").Uint()
|
||||||
return c.bot.CQGetGuildRoles(p0)
|
return c.bot.CQGetGuildRoles(p0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user