-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
actions: create types and begin to parse
this is still not completed, actions should use #72 format
- Loading branch information
Showing
2 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package main | ||
|
||
// TODO: capire come implementare funzioni di questo tipo | ||
func GetActionFromType(commandType string) Action[T] { | ||
switch commandType { | ||
case "message": | ||
return Action[MessageData]() | ||
case "help": | ||
return Action[HelpData]() | ||
case "aggiorna": | ||
return Action[AggiornaData]() | ||
case "lookingFor": | ||
return Action[LookingForData]() | ||
case "notLookingFor": | ||
return Action[NotLookingForData]() | ||
case "yearly": | ||
return Action[YearlyData]() | ||
case "todayLecture": | ||
return Action[TodayLectureData]() | ||
case "tomorrowLecture": | ||
return Action[TomorrowLectureData]() | ||
case "scelta": | ||
return Action[SceltaData]() | ||
case "course": | ||
return Action[CourseData]() | ||
default: | ||
return Action[MessageData]() | ||
} | ||
} | ||
|
||
type Action[T any] struct { | ||
Name string | ||
Type string `json:"type"` | ||
Data T | ||
} | ||
|
||
type MessageData struct { | ||
Text string `json:"text"` | ||
} | ||
|
||
type HelpData struct { | ||
Description string `json:"description"` | ||
} | ||
|
||
type AggiornaData struct { | ||
Description string `json:"description"` | ||
NoYear string `json:"noYear"` | ||
NoMod string `json:"noMod"` | ||
Started string `json:"started"` | ||
Ended string `json:"ended"` | ||
Failed string `json:"failed"` | ||
} | ||
|
||
type LookingForData struct { | ||
Description string `json:"description"` | ||
SingularText string `json:"singularText"` | ||
PluralText string `json:"pluralText"` | ||
ChatError string `json:"chatError"` | ||
} | ||
|
||
type NotLookingForData struct { | ||
Description string `json:"description"` | ||
Text string `json:"text"` | ||
ChatError string `json:"chatError"` | ||
NotFoundError string `json:"notFoundError"` | ||
} | ||
|
||
type YearlyData struct { | ||
Description string `json:"description"` | ||
Command string `json:"command"` | ||
NoYear string `json:"noYear"` | ||
} | ||
|
||
type TodayLectureData struct { | ||
Description string `json:"description"` | ||
Url string `json:"url"` | ||
Title string `json:"title"` | ||
FallbackText string `json:"fallbackText"` | ||
} | ||
|
||
type TomorrowLectureData TodayLectureData | ||
|
||
type SceltaData struct { | ||
Description string `json:"description"` | ||
Header string `json:"header"` | ||
Template string `json:"template"` | ||
Items [][]string `json:"items"` | ||
} | ||
|
||
type CourseData struct { | ||
Name string `json:"name"` | ||
Description string `json:"description"` | ||
Virtuale string `json:"virtuale"` | ||
Teams string `json:"teams"` | ||
Website string `json:"website"` | ||
Professors []string `json:"professors"` | ||
TelegramLink string `json:"telegram"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters