github.com/fumiama/NanoBot@v0.0.0-20231122134259-c22d8183efca/openapi_schedule.go (about) 1 package nano 2 3 // Schedule 日程对象 4 // 5 // https://bot.q.qq.com/wiki/develop/api/openapi/schedule/model.html 6 type Schedule struct { 7 ID string `json:"id,omitempty"` 8 Name string `json:"name,omitempty"` 9 Description string `json:"description,omitempty"` 10 StartTimestamp string `json:"start_timestamp,omitempty"` 11 EndTimestamp string `json:"end_timestamp,omitempty"` 12 Creator *Member `json:"creator,omitempty"` 13 JumpChannelID string `json:"jump_channel_id,omitempty"` 14 RemindType string `json:"remind_type,omitempty"` // https://bot.q.qq.com/wiki/develop/api/openapi/schedule/model.html#remindtype 15 } 16 17 // GetChannelSchedules 获取channel_id指定的子频道中当天的日程列表 18 // 19 // https://bot.q.qq.com/wiki/develop/api/openapi/schedule/get_schedules.html 20 func (bot *Bot) GetChannelSchedules(id string, since uint64) (schedules []Schedule, err error) { 21 if since == 0 { 22 err = bot.GetOpenAPI("/channels/"+id+"/schedules", "", &schedules) 23 } else { 24 err = bot.GetOpenAPIWithBody("/channels/"+id+"/schedules", "", &schedules, WriteBodyFromJSON(&struct { 25 S uint64 `json:"since"` 26 }{since})) 27 } 28 return 29 } 30 31 // GetScheduleInChannel 获取日程子频道 channel_id 下 schedule_id 指定的的日程的详情 32 // 33 // https://bot.q.qq.com/wiki/develop/api/openapi/schedule/get_schedule.html 34 func (bot *Bot) GetScheduleInChannel(channelid string, scheduleid string) (*Schedule, error) { 35 return bot.getOpenAPIofSchedule("/channels/" + channelid + "/schedules/" + scheduleid) 36 } 37 38 // CreateScheduleInChannel 在 channel_id 指定的日程子频道下创建一个日程 39 // 40 // https://bot.q.qq.com/wiki/develop/api/openapi/schedule/post_schedule.html 41 // 42 // schedule 会被写入返回的对象 43 func (bot *Bot) CreateScheduleInChannel(id string, schedule *Schedule) error { 44 return bot.PostOpenAPI("/channels/"+id+"/schedules", "", schedule, WriteBodyFromJSON(&struct { 45 S *Schedule `json:"schedule"` 46 }{schedule})) 47 } 48 49 // PatchScheduleInChannel 修改日程子频道 channel_id 下 schedule_id 指定的日程的详情 50 // 51 // https://bot.q.qq.com/wiki/develop/api/openapi/schedule/patch_schedule.html 52 // 53 // schedule 会被写入返回的对象 54 func (bot *Bot) PatchScheduleInChannel(channelid string, scheduleid string, schedule *Schedule) error { 55 return bot.PatchOpenAPI("/channels/"+channelid+"/schedules/"+scheduleid, "", schedule, WriteBodyFromJSON(&struct { 56 S *Schedule `json:"schedule"` 57 }{schedule})) 58 } 59 60 // DeleteScheduleInChannel 删除日程子频道 channel_id 下 schedule_id 指定的日程 61 // 62 // https://bot.q.qq.com/wiki/develop/api/openapi/schedule/delete_schedule.html 63 func (bot *Bot) DeleteScheduleInChannel(channelid string, scheduleid string) error { 64 return bot.DeleteOpenAPI("/channels/"+channelid+"/schedules/"+scheduleid, "", nil) 65 }