Documentation ¶
Overview ¶
Package model contains the structure and functions used to pass information between the computations of the bot and the driver code, in bot.go
Index ¶
- Constants
- Variables
- func InitGlobals()
- func ParseDegrees() (degrees map[string]Degree, err error)
- func ParseRepresentatives() (map[string]Representative, error)
- func ParseTeachings() (teachings map[string]Teaching, err error)
- func ParseTimetables() (timetables map[string]Timetable, err error)
- func SaveGroups(groups GroupsStruct) error
- type Action
- type AutoReply
- type CommandResponse
- type Curriculum
- type DataInterface
- type Degree
- type GroupsStruct
- type HelpData
- type InlineKeyboardRows
- type InvalidData
- type IssueData
- type Lectures
- type ListData
- type LookingForData
- type LuckData
- type Mantainer
- type Meme
- type MessageData
- type NotLookingForData
- type Representative
- type RepresentativesData
- type SettingsStruct
- type Teaching
- type Timetable
- type Year
- type YearStudyDiagram
Constants ¶
const COMMAND_MAX_LENGTH = 32
Variables ¶
var ( Autoreplies []AutoReply Actions []Action Degrees map[string]Degree MemeList []Meme Settings SettingsStruct Teachings map[string]Teaching Groups GroupsStruct Timetables map[string]Timetable Mantainers []Mantainer Representatives map[string]Representative )
Functions ¶
func InitGlobals ¶
func InitGlobals()
func ParseDegrees ¶
func ParseRepresentatives ¶
func ParseRepresentatives() (map[string]Representative, error)
func ParseTeachings ¶
func ParseTimetables ¶
func SaveGroups ¶
func SaveGroups(groups GroupsStruct) error
Types ¶
type Action ¶
type Action struct { Name string Type string `json:"type"` Data DataInterface `json:"data"` }
func GetActionFromType ¶
GetActionFromType returns an Action struct with the right DataInterface, inferred from the commandType string
func ParseActions ¶
type AutoReply ¶
type AutoReply struct { Text string `json:"text"` IsStrict bool `json:"strict"` Reply string `json:"reply"` }
func ParseAutoReplies ¶
type CommandResponse ¶
type CommandResponse struct { Text string NextCommand string Rows tgbotapi.InlineKeyboardMarkup }
CommandResponse is returned by the command handler, it contains information about the command computation.
func (CommandResponse) HasNextCommand ¶
func (r CommandResponse) HasNextCommand() bool
HasNextCommand returns true if the CommandResponse has some nextCommand
func (CommandResponse) HasRows ¶
func (r CommandResponse) HasRows() bool
HasButtonRows returns true if the CommandResponse has some rows
func (CommandResponse) HasText ¶
func (r CommandResponse) HasText() bool
HasText returns true if the CommandResponse has some text
func (CommandResponse) IsEmpty ¶
func (r CommandResponse) IsEmpty() bool
IsEmpty returns true if the CommandResponse has no text and no nextCommand
type Curriculum ¶
type DataInterface ¶
type GroupsStruct ¶
SECTION GLOBAL JSON STRUCTS
func ParseOrCreateGroups ¶
func ParseOrCreateGroups() (GroupsStruct, error)
type HelpData ¶
func (HelpData) GetDescription ¶
func (HelpData) HandleBotCallback ¶
func (HelpData) HandleBotCommand ¶
type InlineKeyboardRows ¶
type InlineKeyboardRows [][]tgbotapi.InlineKeyboardButton
func ChooseTimetableDay ¶
func ChooseTimetableDay(callback_text string) InlineKeyboardRows
Returns buttons which permits to choose the day for the timetable
func GetLectureYears ¶
func GetLectureYears(callback_text string, course string) InlineKeyboardRows
Returns a group of buttons rows for the available years of a `course`
func GetTimetableCoursesRows ¶
func GetTimetableCoursesRows(timetables *map[string]Timetable) InlineKeyboardRows
Returns a group of button rows for a selected groups on `timetables`
type InvalidData ¶
type InvalidData struct{}
func (InvalidData) GetDescription ¶
func (d InvalidData) GetDescription() string
func (InvalidData) HandleBotCallback ¶
func (InvalidData) HandleBotCommand ¶
func (data InvalidData) HandleBotCommand(*tgbotapi.BotAPI, *tgbotapi.Message) CommandResponse
type IssueData ¶
type IssueData struct { Description string `json:"description"` Response string `json:"response"` Fallback string `json:"fallback"` }
func (IssueData) GetDescription ¶
func (IssueData) HandleBotCallback ¶
func (IssueData) HandleBotCommand ¶
type Lectures ¶
type Lectures struct { Description string `json:"description"` Title string `json:"title"` FallbackText string `json:"fallbackText"` }
func (Lectures) GetDescription ¶
func (Lectures) HandleBotCallback ¶
func (data Lectures) HandleBotCallback(bot *tgbotapi.BotAPI, update *tgbotapi.Update, callback_text string)
Handle the callback for the lectures command (`/lezioni`) Parse the `callback_text` to check which operation it must to do: - If the string ends with "_today" or "_tomorrow" it returns the timetable - If the string just contains a "_y_<number>" it asks for today or tomorrow - Otherwise prints the course year of what timetable the user wants to see
func (Lectures) HandleBotCommand ¶
type ListData ¶
type ListData struct { Description string `json:"description"` Header string `json:"header"` Template string `json:"template"` Items [][]string `json:"items"` }
func (ListData) GetDescription ¶
func (ListData) HandleBotCallback ¶
func (ListData) HandleBotCommand ¶
type LookingForData ¶
type LookingForData struct { Description string `json:"description"` SingularText string `json:"singularText"` PluralText string `json:"pluralText"` ChatError string `json:"chatError"` }
func (LookingForData) GetDescription ¶
func (d LookingForData) GetDescription() string
func (LookingForData) HandleBotCallback ¶
func (LookingForData) HandleBotCommand ¶
func (data LookingForData) HandleBotCommand(bot *tgbotapi.BotAPI, message *tgbotapi.Message) CommandResponse
type LuckData ¶
type LuckData struct { Description string `json:"description"` NoLuckGroupText string `json:"noLuckGroupText"` }
func (LuckData) GetDescription ¶
func (LuckData) HandleBotCallback ¶
func (LuckData) HandleBotCommand ¶
type Mantainer ¶
func ParseMantainers ¶
type Meme ¶
func ParseMemeList ¶
type MessageData ¶
SECTION ACTION STRUCTS DATA
func (MessageData) GetDescription ¶
func (d MessageData) GetDescription() string
func (MessageData) HandleBotCallback ¶
func (MessageData) HandleBotCommand ¶
func (data MessageData) HandleBotCommand(*tgbotapi.BotAPI, *tgbotapi.Message) CommandResponse
type NotLookingForData ¶
type NotLookingForData struct { Description string `json:"description"` Text string `json:"text"` ChatError string `json:"chatError"` NotFoundError string `json:"notFoundError"` }
func (NotLookingForData) GetDescription ¶
func (d NotLookingForData) GetDescription() string
func (NotLookingForData) HandleBotCallback ¶
func (NotLookingForData) HandleBotCommand ¶
func (data NotLookingForData) HandleBotCommand(_ *tgbotapi.BotAPI, message *tgbotapi.Message) CommandResponse
type Representative ¶
type RepresentativesData ¶
type RepresentativesData struct { Description string `json:"description"` Title string `json:"title"` FallbackText string `json:"fallbackText"` }
func (RepresentativesData) GetDescription ¶
func (d RepresentativesData) GetDescription() string
func (RepresentativesData) HandleBotCallback ¶
func (RepresentativesData) HandleBotCommand ¶
func (data RepresentativesData) HandleBotCommand(_ *tgbotapi.BotAPI, message *tgbotapi.Message) CommandResponse
type SettingsStruct ¶
type SettingsStruct struct {
MainGroupsIdentifiers []string `json:"mainGroupsIdentifiers"`
}
func ParseSettings ¶
func ParseSettings() (settings SettingsStruct, err error)
type Timetable ¶
type Timetable struct { Course string `json:"course"` // Course title Name string `json:"name"` // Course name Type string `json:"type"` // Type (laurea|magistrale|2cycle) Curriculum string `json:"curricula"` // Curriculum Title string `json:"title"` FallbackText string `json:"fallbackText"` }
Recognized by a callback string
type Year ¶
type Year struct { Year int64 `json:"year"` Chat string `json:"chat"` Teachings YearStudyDiagram `json:"teachings"` }