Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteEntry(db *sql.DB, userID string, title string, category Category) error
- func DoneEntry(db *sql.DB, userID string, title string, category Category) error
- func MasterHandler(db *sql.DB, s *discordgo.Session, m *discordgo.MessageCreate)
- func RateEntry(db *sql.DB, userID string, title string, category Category, rating int) error
- func UpdateEntry(db *sql.DB, userID string, title string, category Category, newLink string) error
- type Category
- type Entry
- type EntryNotFoundError
- type InvalidCategoryError
- type InvalidSortByError
- type InvalidTimestampError
- type InvalidTitleError
- type InvalidUserIDError
- type NotEnoughArgumentsError
- type SortBy
- type Watchlist
Constants ¶
View Source
const ( // Commands that the user will use to interact with the bot ENTRYPOINT = "./watchlist" ADD_COMMAND = "add" // Add entry to watchlist DELETE_COMMAND = "delete" // Delete item from watchlist VIEW_COMMAND = "view" // View watchlist UPDATE_COMMAND = "update" // Update the link for an entry DONE_COMMAND = "done" // Mark entry as complete RATE_COMMAND = "rate" // Rate an entry RANDOM_COMMAND = "random" // Get a random movie from watchlist CONTACT_COMMAND = "contact" // Get contact info for the developer HELP_COMMAND = "help" // Display help message )
Variables ¶
View Source
var REGEX_PATTERN = regexp.MustCompile(`("[^"]+"|\S+)`)
Matches words and quoted strings (ex. Godfather, "The Godfather")
"[^"]+" matches 1+ substrings inside quotes \S+ matches 1+ substrings separated by whitespaces
Functions ¶
func DeleteEntry ¶
Delete an entry from the database
Params:
db: ptr to sqlite3 database connection userID: user ID of the entry
func DoneEntry ¶
Mark an entry as completed in the database
Params:
db: ptr to sqlite3 database connection userID: user ID of the entry title: title of the entry category: category of the entry
Returns:
error: error object
func MasterHandler ¶
Main handler for the bot that will delegate to private handlers based on user input
All handler functions require use the following parameters:
- db: ptr to database connection (not required for help and contact handlers)
- s: ptr to discord session (contains methods for websocket communication)
- m: ptr to discord message (contains info about author, channel, etc.)
func RateEntry ¶
Rate an entry in the database
Params:
db: ptr to sqlite3 database connection userID: user ID of the entry title: title of the entry category: category of the entry rating: rating to update the entry with
Returns:
error: error object
func UpdateEntry ¶
Updates the link for an entry in the database
Params:
db: ptr to sqlite3 database connection userID: user ID of the entry title: title of the entry category: category of the entry newLink: new link to update the entry with
Returns:
error: error object
Types ¶
type Entry ¶
type Entry struct { UserID string `json:"user_id"` Date time.Time `json:"date"` Title string `json:"title"` Category Category `json:"category"` Done bool `json:"done"` Rating int `json:"rating"` Link string `json:"link"` }
Entry represents a single entry in the watchlist
type EntryNotFoundError ¶
type EntryNotFoundError struct {
// contains filtered or unexported fields
}
func (*EntryNotFoundError) Error ¶
func (e *EntryNotFoundError) Error() string
type InvalidCategoryError ¶
type InvalidCategoryError struct {
// contains filtered or unexported fields
}
func (*InvalidCategoryError) Error ¶
func (e *InvalidCategoryError) Error() string
type InvalidSortByError ¶
type InvalidSortByError struct {
// contains filtered or unexported fields
}
func (*InvalidSortByError) Error ¶
func (e *InvalidSortByError) Error() string
type InvalidTimestampError ¶
type InvalidTimestampError struct {
// contains filtered or unexported fields
}
func (*InvalidTimestampError) Error ¶
func (e *InvalidTimestampError) Error() string
type InvalidTitleError ¶
type InvalidTitleError struct {
// contains filtered or unexported fields
}
func (*InvalidTitleError) Error ¶
func (e *InvalidTitleError) Error() string
type InvalidUserIDError ¶
type InvalidUserIDError struct {
// contains filtered or unexported fields
}
func (*InvalidUserIDError) Error ¶
func (e *InvalidUserIDError) Error() string
type NotEnoughArgumentsError ¶
type NotEnoughArgumentsError struct {
// contains filtered or unexported fields
}
func (*NotEnoughArgumentsError) Error ¶
func (e *NotEnoughArgumentsError) Error() string
type Watchlist ¶
func FetchWatchlist ¶
Fetch watchlist from the database if it exists
Params:
db: ptr to sqlite3 database connection userID: user ID we are searching for entries for watched: true if we want all entries, false if we want only unwatched entries
Returns:
*Watchlist: ptr to watchlist object error: error object
Click to show internal directories.
Click to hide internal directories.