Documentation
¶
Overview ¶
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
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) Start ¶
func (t Bot) Start(conf Configuration, resp Responder)
Starts the telegram bot. The parameter conf represent 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)
Timeout string `json:"Timeout"` // Timeout in seconds for polling
}
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 {
Start(conf Configuration, resp Responder)
LoadSettings(filename string) (Configuration, error)
// contains filtered or unexported methods
}
Interface Repserent a generic telegram bot. Exported functions are just LoadSettings to load a configuration and Start to launch the bot.