Documentation ¶
Index ¶
- Constants
- type ContinueGroups
- type Dispatcher
- type EndGroups
- type Handler
- type RawUpdate
- type Update
- type Updater
- func (u Updater) GetWebhookInfo() (*WebhookInfo, error)
- func (u Updater) Idle()
- func (u Updater) RemoveWebhook() (bool, error)
- func (u Updater) SetWebhook(path string, webhook Webhook) (bool, error)
- func (u Updater) StartCleanPolling() error
- func (u Updater) StartPolling() error
- func (u Updater) StartWebhook(webhook Webhook)
- type Webhook
- type WebhookInfo
Constants ¶
const DefaultMaxDispatcherRoutines = 50
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContinueGroups ¶
type ContinueGroups struct{}
func (ContinueGroups) Error ¶
func (eg ContinueGroups) Error() string
type Dispatcher ¶
Dispatcher Store data for the dispatcher to work as expected; such as the incoming update channel, handler mappings and maximum number of goroutines allowed to be run at once
func NewDispatcher ¶
func NewDispatcher(bot *ext.Bot, updates chan *RawUpdate) *Dispatcher
func (Dispatcher) AddHandler ¶
func (d Dispatcher) AddHandler(handler Handler)
AddHandler adds a new handler to the dispatcher. The dispatcher will call CheckUpdate() to see whether the handler should be executed, and then HandleUpdate() to execute it.
func (Dispatcher) AddHandlerToGroup ¶
func (d Dispatcher) AddHandlerToGroup(handler Handler, group int)
AddHandlerToGroup adds a handler to a specific group; lowest number will be processed first.
type Handler ¶
type Handler interface { // HandleUpdate processes the update. The error return can be used to return either EndGroups{} or ContinueGroups{} // errors, which allows for either continuing execution of the current group, or stopping all further execution. HandleUpdate(u *Update, d Dispatcher) error // CheckUpdate checks whether the update should be processes or not. CheckUpdate(u *Update) (bool, error) // GetName gets the handler name; used to differentiate handlers programmatically. GetName() string }
type Update ¶
type Update struct { UpdateId int `json:"update_id"` Message *ext.Message `json:"message"` EditedMessage *ext.Message `json:"edited_message"` ChannelPost *ext.Message `json:"channel_post"` EditedChannelPost *ext.Message `json:"edited_channel_post"` InlineQuery *ext.Message `json:"inline_query"` ChosenInlineResult *ext.ChosenInlineResult `json:"chosen_inline_result"` CallbackQuery *ext.CallbackQuery `json:"callback_query"` ShippingQuery *ext.ShippingQuery `json:"shipping_query"` PreCheckoutQuery *ext.PreCheckoutQuery `json:"pre_checkout_query"` Poll *ext.Poll `json:"poll"` // Self added type EffectiveMessage *ext.Message `json:"effective_message"` EffectiveChat *ext.Chat `json:"effective_chat"` EffectiveUser *ext.User `json:"effective_user"` Data map[string]string }
Update Incoming updates from telegram servers (including extra, internally used fields added for convenience)
type Updater ¶
type Updater struct { Bot *ext.Bot Updates chan *RawUpdate Dispatcher *Dispatcher UpdateGetter *ext.TgBotGetter }
Updater The main updater process. Receives incoming updates, then sends them to the dispatcher goroutine via an update channel for them to be handled.
func NewUpdater ¶
NewUpdater Creates a new updater struct, paired with the necessary dispatcher and bot structs.
func (Updater) GetWebhookInfo ¶
func (u Updater) GetWebhookInfo() (*WebhookInfo, error)
GetWebhookInfo Get webhook info from telegram servers
func (Updater) Idle ¶
func (u Updater) Idle()
Idle sets the main thread to idle, allowing the background processes to run as expected (dispatcher and update handlers)
func (Updater) RemoveWebhook ¶
RemoveWebhook remove the webhook url from telegram servers
func (Updater) SetWebhook ¶
SetWebhook Set the webhook url for telegram to contact with updates
func (Updater) StartCleanPolling ¶
StartCleanPolling Starts clean polling (ignoring stale updates)
func (Updater) StartPolling ¶
StartPolling Starts the polling logic
func (Updater) StartWebhook ¶
StartWebhook Start the webhook server
type Webhook ¶
type Webhook struct { Serve string // base url to where you listen ServePath string // path you listen to ServePort int // port you listen on URL string // where you set the webhook to send to // CertPath string // TODO MaxConnections int // max connections; max 100, default 40 AllowedUpdates []string // which updates to allow }
func (Webhook) GetListenUrl ¶
type WebhookInfo ¶
type WebhookInfo struct { URL string `json:"url"` HasCustomCertificate bool `json:"has_custom_certificate"` PendingUpdateCount int `json:"pending_update_count"` LastErrorDate int `json:"last_error_date"` LastErrorMessage int `json:"last_error_message"` MaxConnections int `json:"max_connections"` AllowedUpdates []string `json:"allowed_updates"` }