package im_service import ( "encoding/json" "errors" "fmt" "hudongzhuanjia/libs/im" "hudongzhuanjia/models" "hudongzhuanjia/utils" "strconv" ) func SendNoticeByActivityId(activityId int64, _type im.NoticeStatus, data map[string]interface{}, members ...string) error { live := new(models.LiveConfig) exist, err := live.GetByActivityId(activityId) if err != nil { return err } if !exist { return errors.New("直播信息不存在") } groupId := fmt.Sprintf("%v%d%d", live.LiveRoomId, live.Id, live.ActivityId) return im.SendGroupSystemNotification(groupId, _type, data, members...) } func SendGroupCustomMessage(activityId int64, _type im.NoticeStatus, data map[string]interface{}) error { live := new(models.LiveConfig) exist, err := live.GetByActivityId(activityId) if err != nil { return err } if !exist { return errors.New("直播信息不存在") } bs, err := json.Marshal(data) if err != nil { return err } groupId := fmt.Sprintf("%v%d%d", live.LiveRoomId, live.Id, live.ActivityId) return im.SendGroupMessage(&im.SendGroupMessageParam{ GroupId: groupId, Random: utils.RandomInt(6), MsgPriority: "High", MsgBody: []im.MsgBody{ { MsgType: "TIMCustomElem", MsgContent: im.MsgBodyContent{ Data: string(bs), Desc: strconv.Itoa(int(_type)), Ext: "", Sound: "", }, }, }, }) }