Documentation ΒΆ
Index ΒΆ
- func EditedMessageWithButton(text string, keyboard tgbotapi.InlineKeyboardMarkup, chatID int64, msgID int) tgbotapi.EditMessageTextConfig
- func FormatDate(t time.Time) string
- func FormatTime(localT time.Time) string
- func FormatTimeDate(t time.Time) string
- func NewMessageWithButton(text string, keyboard tgbotapi.InlineKeyboardMarkup, chatID int64) tgbotapi.MessageConfig
- func ParseDDMMYYDate(date string) (time.Time, error)
- type Callback
- type CallbackFunc
- type Cinnabot
- func (cb *Cinnabot) About(msg *message)
- func (cb *Cinnabot) AddFunction(command string, resp ResponseFunc) error
- func (cb *Cinnabot) AddHandler(command string, resp CallbackFunc) error
- func (cb *Cinnabot) Cancel(msg *message)
- func (cb *Cinnabot) Capitalize(msg *message)
- func (cb *Cinnabot) CheckArgCmdPair(cmd string, args []string) bool
- func (cb *Cinnabot) CinnabotFeedback(msg *message)
- func (cb *Cinnabot) DHSurvey(msg *message)
- func (cb *Cinnabot) DHSurveyFeedback(msg *message)
- func (cb *Cinnabot) DiningFeedback(msg *message)
- func (cb *Cinnabot) Echo(msg *message)
- func (cb *Cinnabot) Feedback(msg *message)
- func (cb *Cinnabot) GetStats(msg *message)
- func (cb *Cinnabot) GoSafely(fn func())
- func (cb *Cinnabot) Handle(qry tgbotapi.CallbackQuery)
- func (cb *Cinnabot) Help(msg *message)
- func (cb *Cinnabot) Laundry(msg *message)
- func (cb *Cinnabot) LaundryRefresh(qry *Callback)
- func (cb *Cinnabot) Listen(timeout int) tgbotapi.UpdatesChannel
- func (cb *Cinnabot) NUSBus(msg *message)
- func (cb *Cinnabot) NUSBusRefresh_Buttons(qry *Callback)
- func (cb *Cinnabot) NUSBusRefresh_Location(qry *Callback)
- func (cb *Cinnabot) NUSMap(msg *message)
- func (cb *Cinnabot) PublicBus(msg *message)
- func (cb *Cinnabot) PublicBusRefresh(qry *Callback)
- func (cb *Cinnabot) ResidentialFeedback(msg *message)
- func (cb *Cinnabot) Resources(msg *message)
- func (cb *Cinnabot) Router(msg tgbotapi.Message)
- func (cb *Cinnabot) SayHello(msg *message)
- func (cb *Cinnabot) SendMessage(chattable tgbotapi.Chattable)
- func (cb *Cinnabot) SendTextMessage(recipient int, text string) error
- func (cb *Cinnabot) Spaces(msg *message)
- func (cb *Cinnabot) Start(msg *message)
- func (cb *Cinnabot) USCFeedback(msg *message)
- func (cb *Cinnabot) Weather(msg *message)
- type Event
- type FuncMap
- type ResponseFunc
- type Space
- type Spaces
- type WeatherForecast
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
func EditedMessageWithButton ΒΆ
func EditedMessageWithButton(text string, keyboard tgbotapi.InlineKeyboardMarkup, chatID int64, msgID int) tgbotapi.EditMessageTextConfig
EditedMessageWithButton creates an edited text message with buttons (eg. refresh button)
func FormatDate ΒΆ
FormatDate formats a time.Time into date in a standardised format. Does not change timezone.
func FormatTime ΒΆ
FormatTime formats a time.Time into a time in a standardised format. Does not change timezone.
func FormatTimeDate ΒΆ
FormatTimeDate formats a time.Time into a full time and date, in a standardised format. Does not change timezone.
func NewMessageWithButton ΒΆ
func NewMessageWithButton(text string, keyboard tgbotapi.InlineKeyboardMarkup, chatID int64) tgbotapi.MessageConfig
NewMessageWithButton creates a new text message with buttons (eg. refresh button)
Types ΒΆ
type Callback ΒΆ
Wrapper struct for a callback query
func (Callback) GetArgString ΒΆ
GetArgStrings prints out the arguments for the callback in one string.
type CallbackFunc ΒΆ
type CallbackFunc func(*Callback)
CallbackFunc is a handler for a callback function
type Cinnabot ΒΆ
type Cinnabot struct { Name string // The name of the bot registered with Botfather // contains filtered or unexported fields }
Cinnabot is main struct that processes user requests.
func InitCinnabot ΒΆ
InitCinnabot initializes an instance of Cinnabot.
func (*Cinnabot) About ΒΆ
func (cb *Cinnabot) About(msg *message)
About returns a link to Cinnabot's source code.
func (*Cinnabot) AddFunction ΒΆ
func (cb *Cinnabot) AddFunction(command string, resp ResponseFunc) error
AddFunction binds a response function to a command string in Cinnabot's FuncMap
func (*Cinnabot) AddHandler ΒΆ
func (cb *Cinnabot) AddHandler(command string, resp CallbackFunc) error
AddHandler binds a handler function to a callback cmd string in Cinnabot's HandlerMap
func (*Cinnabot) Capitalize ΒΆ
func (cb *Cinnabot) Capitalize(msg *message)
Capitalize returns a capitalized form of the input string.
func (*Cinnabot) CheckArgCmdPair ΒΆ
CheckArgCmdPair checks if arg can be used with command Used to supplement cache as cache only records functions as states
func (*Cinnabot) CinnabotFeedback ΒΆ
func (cb *Cinnabot) CinnabotFeedback(msg *message)
CinnabotFeedback forwards feedback to USDevs
func (*Cinnabot) DHSurvey ΒΆ
func (cb *Cinnabot) DHSurvey(msg *message)
DHSurvey sends message when someone enters dhsurvey tag
func (*Cinnabot) DHSurveyFeedback ΒΆ
func (cb *Cinnabot) DHSurveyFeedback(msg *message)
DHSurveyFeedback adds DH survey entry to database
func (*Cinnabot) DiningFeedback ΒΆ
func (cb *Cinnabot) DiningFeedback(msg *message)
DiningFeedback forwards feedback to DH Comm
func (*Cinnabot) Echo ΒΆ
func (cb *Cinnabot) Echo(msg *message)
Echo parrots back the argument given by the user.
func (*Cinnabot) Feedback ΒΆ
func (cb *Cinnabot) Feedback(msg *message)
Feedback allows users an avenue to give feedback. Admins can retrieve by searching the /feedback handler in the db
func (*Cinnabot) GetStats ΒΆ
func (cb *Cinnabot) GetStats(msg *message)
function to count number of users and messages
func (*Cinnabot) GoSafely ΒΆ
func (cb *Cinnabot) GoSafely(fn func())
GoSafely is a utility wrapper to recover and log panics in goroutines. If we use naked goroutines, a panic in any one of them crashes the whole program. Using GoSafely prevents this.
func (*Cinnabot) Handle ΒΆ
func (cb *Cinnabot) Handle(qry tgbotapi.CallbackQuery)
Handle routes Telegram callback queries to the appropriate handlers.
func (*Cinnabot) Help ΒΆ
func (cb *Cinnabot) Help(msg *message)
Help gives a list of handles that the user may call along with a description of them
func (*Cinnabot) Laundry ΒΆ
func (cb *Cinnabot) Laundry(msg *message)
Laundry checks the washer and dryer availability.
func (*Cinnabot) LaundryRefresh ΒΆ
func (*Cinnabot) Listen ΒΆ
func (cb *Cinnabot) Listen(timeout int) tgbotapi.UpdatesChannel
Listen exposes the telebot Listen API.
func (*Cinnabot) NUSBus ΒΆ
func (cb *Cinnabot) NUSBus(msg *message)
NUSBus retrieves the next timing for NUS Shuttle buses
func (*Cinnabot) NUSBusRefresh_Buttons ΒΆ
NUSBusRefresh_Buttons handles the refresh button for messages from /nusbus -> location button
func (*Cinnabot) NUSBusRefresh_Location ΒΆ
NUSBusRefresh_Location handles the refresh button for messages from /nusbus by GPS location
func (*Cinnabot) PublicBus ΒΆ
func (cb *Cinnabot) PublicBus(msg *message)
BusTimings checks the public bus timings based on given location
func (*Cinnabot) PublicBusRefresh ΒΆ
PublicBusRefresh handles the refresh button for messages from /publicbus
func (*Cinnabot) ResidentialFeedback ΒΆ
func (cb *Cinnabot) ResidentialFeedback(msg *message)
ResidentialFeedback forwards feedback to Residential Comm
func (*Cinnabot) Resources ΒΆ
func (cb *Cinnabot) Resources(msg *message)
Link returns useful resources
func (*Cinnabot) Router ΒΆ
Router routes Telegram messages to the appropriate response functions. Hack: Cache to store previous function information
func (*Cinnabot) SayHello ΒΆ
func (cb *Cinnabot) SayHello(msg *message)
Test functions [Not meant to be used in bot] SayHello says hi.
func (*Cinnabot) SendMessage ΒΆ
SendMessage sends messages which require non-default options such as reply markups.
func (*Cinnabot) SendTextMessage ΒΆ
SendTextMessage sends a basic text message back to the specified user.
func (*Cinnabot) Spaces ΒΆ
func (cb *Cinnabot) Spaces(msg *message)
Spaces is the primary Cinnabot Spaces method that the end user interacts with.
"/spaces" displays bookings for today. "/spaces now" displays bookings right this moment. "/spaces week" displays bookings in the next 7 days. "/spaces dd/mm/yy" displays bookings on the given date. "/spaces dd/mm/yy dd/mm/yy" displays bookings in the given interval (limited to one month++). "/spaces help" informs the user of available commands. Extra arguments are ignored. Unparseable commands return the help menu.
func (*Cinnabot) USCFeedback ΒΆ
func (cb *Cinnabot) USCFeedback(msg *message)
USCFeedback forwards feedback to USC
type FuncMap ΒΆ
type FuncMap map[string]ResponseFunc
A FuncMap is a map of command strings to response functions. It is used for routing commands to responses.
type ResponseFunc ΒΆ
type ResponseFunc func(m *message)
ResponseFunc is a handler for a bot command.
type WeatherForecast ΒΆ
type WeatherForecast struct { AM []areaMetadata `json:"area_metadata"` FD []forecastData `json:"items"` }
Structs for weather forecast function