Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Validate ¶
Validate validates passed init data. This method expects initData to be passed in the exact raw format as it could be found in window.Telegram.WebApp.initData. Returns true in case init data is signed correctly, and it is allowed to trust it.
Current code is implementation of algorithmic code described in official docs: https://core.telegram.org/bots/webapps#validating-data-received-via-the-web-app
initData - init data passed from application; token - TWA bot secret token which was used to create init data; expIn - maximum init data lifetime. It is strongly recommended using this parameter. In case, zero duration is less than 0, function does not check if parameters are expired.
Types ¶
type Chat ¶
type Chat struct { Id int64 `json:"id"` Type string `json:"type"` Title string `json:"title"` Username string `json:"username"` PhotoUrl string `json:"photo_url"` }
Chat describes chat information: https://core.telegram.org/bots/webapps#webappchat
type InitData ¶
type InitData struct { QueryId string `json:"query_id"` User *User `json:"user"` Receiver *User `json:"receiver"` Chat *Chat `json:"chat"` StartParam string `json:"start_param"` CanSendAfterRaw int `json:"can_send_after"` AuthDateRaw int `json:"auth_date"` Hash string `json:"hash"` }
InitData describes parsed initial data sent from TWA application. You can find specification for all the parameters in the official documentation: https://core.telegram.org/bots/webapps#webappinitdata
func (*InitData) CanSendAfter ¶
CanSendAfter returns CanSendAfterRaw as time.Duration.
type User ¶
type User struct { Id int64 `json:"id"` IsBot bool `json:"is_bot"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Username string `json:"username"` LanguageCode string `json:"language_code"` IsPremium bool `json:"is_premium"` PhotoUrl string `json:"photo_url"` }
User describes user information: https://core.telegram.org/bots/webapps#webappuser