Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Config = ParrbotConfig{ DeleteSessionTimer: time.Hour * 2, }
Config contains all the default Parrbot configurations. Edit them before robot.Start
Functions ¶
func LoadCommands ¶
func LoadCommands(commandList []Command)
LoadCommands saves the given commandList in a form that is more efficenct for the bot to retrive. Use this function one time only, is necessary for Select to work. If robot.Start is used (as racommanded), probably, there is no need to use this function
func Start ¶
func Start(commandList ...Command)
Start give life to your amazing robo-parrot. It accepts the commands that the bot will need to handle. This function will also load all configuartion available int the Confing variable, so if you want to change them, do it before calling this function. Start will also stop the flow of execution (unless bot crash) if any error happens it will be logged on screen and progrm will terminate
Types ¶
type Bot ¶
type Bot struct {
ChatID int64 // ChatID of the user who is using the bot on a private chat
}
Bot structure
type Command ¶
type Command struct { Description string // A description of the command that will be displayed on the "/" menu if the ReplyAt includes MESSAGE Trigger string // Needs to start with the '/' character. Is the string that if contained at the start of the update would run the Scope ReplyAt message.UpdateType // Tells witch UpdateType(s) the bot will reply at, sum them to put more CallFunc CommandFunc // The actual function that the bot will run }
Command is a bot's command declaration that compose the command list
type CommandFunc ¶
CommandFunc is a custom type that rapresent a command that the bot should be able to run
func Select ¶
func Select(update *message.Update) CommandFunc
Select take an update and verify it's type and then trigger in order to return the appropriate function (or nil). If robot.Start is used (as racommanded), probably, there is no need to use this function
type ParrbotConfig ¶
type ParrbotConfig struct { DeleteSessionTimer time.Duration // time after witch the bot session will self distruct by the dispatcher // contains filtered or unexported fields }
ParrbotConfig defines all the possible configurations of your parr-bot
func (*ParrbotConfig) KeepActiveSessions ¶
func (c *ParrbotConfig) KeepActiveSessions()
KeepActiveSessions sets the DeleteSessionTimer = 0 causing all session to stay active
func (*ParrbotConfig) SetAPIToken ¶
func (c *ParrbotConfig) SetAPIToken(token string) error
SetAPIToken sets the Telegram Bot API token to the given one if valid