Documentation ¶
Index ¶
- Variables
- type Item
- type RecordDB
- func (r *RecordDB) Add(params []string) (string, error)
- func (r *RecordDB) CheckCommand(data string) (string, error)
- func (r *RecordDB) Delete(params []string) (string, error)
- func (r *RecordDB) Import(records [][]string) (string, error)
- func (r *RecordDB) ImportRecords(records [][]string) (string, error)
- func (r *RecordDB) List(params []string) (string, error)
- func (r *RecordDB) ListRecords(cmd []string) (string, error)
- func (r *RecordDB) Listen(updates tgbotapi.UpdatesChannel, bot *tgbotapi.BotAPI)
- func (r *RecordDB) Show(params []string) (string, error)
- func (r *RecordDB) Update(params []string) (string, error)
- func (r *RecordDB) UpdateRecord(params []string) (string, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ResponseStart = "Welcome. Here's a list of my commands:\n\n" + listItems + "/showitem - show an item's details\n" + "/additem - add an item\n" + "/updateitem - update an item\n" + "/deleteitem - delete an item\n" + "/importitems - import items from a CSV file\n" ResponseInvalid = "That's not a valid command. Here's a list of valid commands:\n\n" + listItems + "/showitem - show an item's details\n" + "/additem - add an item\n" + "/updateitem - update an item\n" + "/deleteitem - delete an item\n" ResponseInvalidList = "That's not a valid command. Here's a list of valid commands:\n\n" + "*List DB*\n" + listItems + "/listitems sort by _field_ - sort list (ascending)\n" + "/listitems sort by _field_ desc - sort list (descending)\n" + "/listitems filter by _field_ = _value_ - filter items in your inventory\n" + "_filter operations: =, <, >, <=, >=, <>, like_\n" ResponseAdd = "What is this item called?" ResponseSuccessAdd = "Added \"<item>\" to the inventory.\n\n" + "Update this item's details using the commands below:\n" + "/updateitem _itemName_ description _itemDescription_\n" + "/updateitem _itemName_ calories _calories_\n" + "/updateitem _itemName_ amount _itemAmount_\n" + "/updateitem _itemName_ category _itemCategory_\n" + "/updateitem _itemName_ price _itemPrice_\n" + "/updateitem _itemName_ expiration _itemExpiration_\n" ResponseShow = "Which item do you want to see?" ResponseDelete = "Which item do you want to delete?" ResponseSuccessDelete = "Removed \"<item>\" from the inventory." ResponseUpdate = "Which item do you want to update?" ResponseSuccessUpdate = "Updated <item>'s <field>." ResponseInvalidUpdate = "Invalid parameters. To update an item, use the commands below:\n\n" + "*Update DB*\n" + "/updateitem _itemName_ description _itemDescription_\n" + "/updateitem _itemName_ calories _calories_\n" + "/updateitem _itemName_ amount _itemAmount_\n" + "/updateitem _itemName_ category _itemCategory_\n" + "/updateitem _itemName_ price _itemPrice_\n" + "/updateitem _itemName_ expiration _itemExpiration_\n" ResponseItemNotExist = "Item \"<item>\" does not exist in the inventory." ResponseNoMatchFilter = "There are no items matching that filter." ResponseNoItems = "There are no items in your inventory." ResponseImport = "Please attach the CSV file." )
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item struct { ID uint Name string Description string Amount float32 Unit string Calories uint16 Category string Price float32 Currency string Expiration time.Time CreatedAt time.Time UpdatedAt time.Time }
Item is the model used for item-specific records
type RecordDB ¶
RecordDB contains the database instance used for record transactions
func (*RecordDB) CheckCommand ¶
CheckCommand checks if the command is valid and returns the appropriate response
func (*RecordDB) ImportRecords ¶
ImportRecords imports a list of records into the "item" table
func (*RecordDB) ListRecords ¶
ListRecords returns a list of records from the "item" table
func (*RecordDB) Listen ¶
func (r *RecordDB) Listen(updates tgbotapi.UpdatesChannel, bot *tgbotapi.BotAPI)
Listen listens to the messages send to the bot and sends the appropriate response
Click to show internal directories.
Click to hide internal directories.