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:
parent
3c9433d7b7
commit
6240e875ce
16
coolq/api.go
16
coolq/api.go
@ -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"}
|
||||
|
@ -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,
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user