1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-04 19:17:37 +08:00

add: mark_msg_as_read api.

This commit is contained in:
Mrs4s 2021-08-15 02:36:11 +08:00
parent 3c9433d7b7
commit 6240e875ce
No known key found for this signature in database
GPG Key ID: 3186E98FA19CE3A7
3 changed files with 22 additions and 1 deletions

View File

@ -1418,6 +1418,22 @@ func (bot *CQBot) CQSetModelShow(modelName string, modelShow string) MSG {
return OK(nil)
}
func (bot *CQBot) CQMarkMessageAsRead(msgId int32) MSG {
m := bot.GetMessage(msgId)
if m == nil {
return Failed(100, "MSG_NOT_FOUND", "消息不存在")
}
if _, ok := m["group"]; ok {
bot.Client.MarkGroupMessageReaded(m["group"].(int64), int64(m["message-id"].(int32)))
return OK(nil)
}
if _, ok := m["from-group"]; ok {
return Failed(100, "MSG_TYPE_ERROR", "不支持标记临时会话")
}
bot.Client.MarkPrivateMessageReaded(m["sender"].(*message.Sender).Uin, m["time"].(int64))
return OK(nil)
}
// OK 生成成功返回值
func OK(data interface{}) MSG {
return MSG{"data": data, "retcode": 0, "status": "ok"}

View File

@ -426,7 +426,7 @@ func (bot *CQBot) InsertTempMessage(target int64, m *message.TempMessage) int32
val := MSG{
"message-id": m.Id,
// FIXME(InsertTempMessage) InternalId missing
"group": m.GroupCode,
"from-group": m.GroupCode,
"group-name": m.GroupName,
"target": target,
"sender": m.Sender,

View File

@ -350,6 +350,10 @@ func setModelShow(bot *coolq.CQBot, p resultGetter) coolq.MSG {
return bot.CQSetModelShow(p.Get("model").String(), p.Get("model_show").String())
}
func markMSGAsRead(bot *coolq.CQBot, p resultGetter) coolq.MSG {
return bot.CQMarkMessageAsRead(int32(p.Get("message_id").Int()))
}
// API 是go-cqhttp当前支持的所有api的映射表
var API = map[string]func(*coolq.CQBot, resultGetter) coolq.MSG{
"get_login_info": getLoginInfo,
@ -413,6 +417,7 @@ var API = map[string]func(*coolq.CQBot, resultGetter) coolq.MSG{
"qidian_get_account_info": getQiDianAccountInfo,
"_get_model_show": getModelShow,
"_set_model_show": setModelShow,
"mark_msg_as_read": markMSGAsRead,
}
func (api *apiCaller) callAPI(action string, p resultGetter) coolq.MSG {