Documentation ¶
Overview ¶
Package for creating a running a simple Telegram bot on Google App Engine. This bot is capable just to answer simple user/group messages, all the logic must be implemented inside a Responder func
Package for creating a running a simple Telegram bot. This bot is capable just to answer simple user/group messages, all the logic must be implemented inside a Responder func
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct{}
Struct representing a telegram Bot (will implement IBot). Bot has no field (no state), it's just an empty bot
func (Bot) LoadSettings ¶
func (t Bot) LoadSettings(filename string) (Configuration, error)
Load a configuration from a Json file and returns a configuration. See file `settings.json.sample` to see how settings should be formatted.
func (Bot) Startgae ¶
func (t Bot) Startgae(conf Configuration, resp Responder)
Initialize the telegram bot. The parameter conf represents the running configuration. The conf is mandatory otherwise the bot can't authenticate. The parameter resp is the Responder function. Also this parameter is mandatory, otherwise the bot don't know how to anser to user questions.
type Configuration ¶
type Configuration struct { BotName string `json:"BotName"` // Name of the bot ApiKey string `json:"ApiKey"` // API Key of the bot (ask @BotFather) }
Configuration struct representing the configuration used from the bot to run properly. Configuration is usually loaded from file, or hardcoded inside the client code.
type IBot ¶
type IBot interface { Startgae(conf Configuration, resp Responder) LoadSettings(filename string) (Configuration, error) // contains filtered or unexported methods }
Interface Representing a generic telegram bot. Exported functions are just LoadSettings to load a configuration and Startgae to initialize the bot handlers.
type Responder ¶
Responder function, responsible of handling user commands. This function represent the logic of your bot, you must provide a couple (string, error) for every message. The returned string will be sent to the user. If you set the error, the user will see an informative message. The http.Request parameter can be used to get access to an App Engine context (to use the MemCache or other GAE features)