Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CalendarCommand = command.BasicCommandTemplate{ Help: "Get Events from Google Calendar", MentionCommand: "calendar", GenerateFn: func(d command.CommandData) command.Command { c := command.Command{} calendarCli, err := getGoogleCalendarClient() if err != nil { errMessage := fmt.Sprintf("[ERROR]\t[getGoogleCalendarClient]\t`%s`", err.Error()) task := command.NewReplyEngineTask(d.Engine, d.Channel, errMessage) c.Add(task) return c } email, err := getEmailAddress(d) if err != nil { errMessage := fmt.Sprintf("[ERROR]\t[getEmailAddress]\t`%s`", err.Error()) task := command.NewReplyEngineTask(d.Engine, d.Channel, errMessage) c.Add(task) return c } command.NewReplyEngineTask(d.Engine, d.Channel, i18n.Message("Getting events of [%s] ...", email)).Run() list, err := calendarCli.EventList(email, 10) if err != nil { errMessage := fmt.Sprintf("[ERROR]\t[EventList]\t`%s`", err.Error()) task := command.NewReplyEngineTask(d.Engine, d.Channel, errMessage) c.Add(task) return c } msg := formatCalendarAsSlackMessage(list.List) task := command.NewReplyEngineTask(d.Engine, d.Channel, msg) c.Add(task) return c }, }
To use Calendar Command, you should setup, (1) Credentials for Google API (2) OAuth Token for Calendar. (1): https://cloud.google.com/docs/authentication/ (2): https://developers.google.com/calendar/quickstart/go
View Source
var WhereCommand = command.BasicCommandTemplate{ Help: "Get current location from Google Calendar", MentionCommand: "where", GenerateFn: func(d command.CommandData) command.Command { c := command.Command{} calendarCli, err := getGoogleCalendarClient() if err != nil { errMessage := fmt.Sprintf("[ERROR]\t[getGoogleCalendarClient]\t`%s`", err.Error()) task := command.NewReplyEngineTask(d.Engine, d.Channel, errMessage) c.Add(task) return c } email, err := getEmailAddress(d) if err != nil { errMessage := fmt.Sprintf("[ERROR]\t[getEmailAddress]\t`%s`", err.Error()) task := command.NewReplyEngineTask(d.Engine, d.Channel, errMessage) c.Add(task) return c } command.NewReplyEngineTask(d.Engine, d.Channel, i18n.Message("Getting location of [%s] ...", email)).Run() list, err := calendarCli.EventListWithOption(email, calendar.EventListOption{ TimeMin: time.Now().Add(-1 * time.Hour), SingleEvents: true, OrderBy: calendar.OrderByStartTime, MaxResults: 10, }) if err != nil { errMessage := fmt.Sprintf("[ERROR]\t[EventList]\t`%s`", err.Error()) task := command.NewReplyEngineTask(d.Engine, d.Channel, errMessage) c.Add(task) return c } res := getCalendarEvent(list.List) if !res.hasTimeEvent && !res.hasAllDayEvent { task := command.NewReplyEngineTask(d.Engine, d.Channel, i18n.Message("Somewhere around there")) c.Add(task) return c } msg := makeMessage(res) task := command.NewReplyEngineTask(d.Engine, d.Channel, msg) c.Add(task) return c }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.