Fixed casing issue in types and enums
This commit is contained in:
parent
fc75487d07
commit
f141f4adb4
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// AccountTTL Contains information about the period of inactivity after which the current user's account will automatically be deleted
|
||||
type AccountTTL struct {
|
||||
tdCommon
|
||||
|
@ -24,3 +29,23 @@ func NewAccountTTL(days int32) *AccountTTL {
|
|||
|
||||
return &accountTTLTemp
|
||||
}
|
||||
|
||||
// GetAccountTTL Returns the period of inactivity after which the account of the current user will automatically be deleted
|
||||
func (client *Client) GetAccountTTL() (*AccountTTL, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getAccountTtl",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var accountTTL AccountTTL
|
||||
err = json.Unmarshal(result.Raw, &accountTTL)
|
||||
return &accountTTL, err
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Address Describes an address
|
||||
type Address struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// AnimatedChatPhoto Animated variant of a chat photo in MPEG4 format
|
||||
type AnimatedChatPhoto struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Animation Describes an animation file. The animation must be encoded in GIF or MPEG4 format
|
||||
type Animation struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Animations Represents a list of animations
|
||||
type Animations struct {
|
||||
tdCommon
|
||||
|
@ -24,3 +29,23 @@ func NewAnimations(animations []Animation) *Animations {
|
|||
|
||||
return &animationsTemp
|
||||
}
|
||||
|
||||
// GetSavedAnimations Returns saved animations
|
||||
func (client *Client) GetSavedAnimations() (*Animations, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getSavedAnimations",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var animations Animations
|
||||
err = json.Unmarshal(result.Raw, &animations)
|
||||
return &animations, err
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Audio Describes an audio file. Audio is usually in MP3 or M4A format
|
||||
type Audio struct {
|
||||
tdCommon
|
||||
|
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// AuthenticationCodeInfo Information about the authentication code that was sent
|
||||
|
@ -67,3 +68,137 @@ func (authenticationCodeInfo *AuthenticationCodeInfo) UnmarshalJSON(b []byte) er
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ChangePhoneNumber Changes the phone number of the user and sends an authentication code to the user's new phone number. On success, returns information about the sent code
|
||||
// @param phoneNumber The new phone number of the user in international format
|
||||
// @param settings Settings for the authentication of the user's phone number
|
||||
func (client *Client) ChangePhoneNumber(phoneNumber string, settings *PhoneNumberAuthenticationSettings) (*AuthenticationCodeInfo, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "changePhoneNumber",
|
||||
"phone_number": phoneNumber,
|
||||
"settings": settings,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var authenticationCodeInfo AuthenticationCodeInfo
|
||||
err = json.Unmarshal(result.Raw, &authenticationCodeInfo)
|
||||
return &authenticationCodeInfo, err
|
||||
|
||||
}
|
||||
|
||||
// ResendChangePhoneNumberCode Re-sends the authentication code sent to confirm a new phone number for the user. Works only if the previously received authenticationCodeInfo next_code_type was not null
|
||||
func (client *Client) ResendChangePhoneNumberCode() (*AuthenticationCodeInfo, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "resendChangePhoneNumberCode",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var authenticationCodeInfo AuthenticationCodeInfo
|
||||
err = json.Unmarshal(result.Raw, &authenticationCodeInfo)
|
||||
return &authenticationCodeInfo, err
|
||||
|
||||
}
|
||||
|
||||
// SendPhoneNumberVerificationCode Sends a code to verify a phone number to be added to a user's Telegram Passport
|
||||
// @param phoneNumber The phone number of the user, in international format
|
||||
// @param settings Settings for the authentication of the user's phone number
|
||||
func (client *Client) SendPhoneNumberVerificationCode(phoneNumber string, settings *PhoneNumberAuthenticationSettings) (*AuthenticationCodeInfo, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "sendPhoneNumberVerificationCode",
|
||||
"phone_number": phoneNumber,
|
||||
"settings": settings,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var authenticationCodeInfo AuthenticationCodeInfo
|
||||
err = json.Unmarshal(result.Raw, &authenticationCodeInfo)
|
||||
return &authenticationCodeInfo, err
|
||||
|
||||
}
|
||||
|
||||
// ResendPhoneNumberVerificationCode Re-sends the code to verify a phone number to be added to a user's Telegram Passport
|
||||
func (client *Client) ResendPhoneNumberVerificationCode() (*AuthenticationCodeInfo, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "resendPhoneNumberVerificationCode",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var authenticationCodeInfo AuthenticationCodeInfo
|
||||
err = json.Unmarshal(result.Raw, &authenticationCodeInfo)
|
||||
return &authenticationCodeInfo, err
|
||||
|
||||
}
|
||||
|
||||
// SendPhoneNumberConfirmationCode Sends phone number confirmation code. Should be called when user presses "https://t.me/confirmphone?phone=*******&hash=**********" or "tg://confirmphone?phone=*******&hash=**********" link
|
||||
// @param hash Value of the "hash" parameter from the link
|
||||
// @param phoneNumber Value of the "phone" parameter from the link
|
||||
// @param settings Settings for the authentication of the user's phone number
|
||||
func (client *Client) SendPhoneNumberConfirmationCode(hash string, phoneNumber string, settings *PhoneNumberAuthenticationSettings) (*AuthenticationCodeInfo, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "sendPhoneNumberConfirmationCode",
|
||||
"hash": hash,
|
||||
"phone_number": phoneNumber,
|
||||
"settings": settings,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var authenticationCodeInfo AuthenticationCodeInfo
|
||||
err = json.Unmarshal(result.Raw, &authenticationCodeInfo)
|
||||
return &authenticationCodeInfo, err
|
||||
|
||||
}
|
||||
|
||||
// ResendPhoneNumberConfirmationCode Resends phone number confirmation code
|
||||
func (client *Client) ResendPhoneNumberConfirmationCode() (*AuthenticationCodeInfo, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "resendPhoneNumberConfirmationCode",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var authenticationCodeInfo AuthenticationCodeInfo
|
||||
err = json.Unmarshal(result.Raw, &authenticationCodeInfo)
|
||||
return &authenticationCodeInfo, err
|
||||
|
||||
}
|
||||
|
|
|
@ -398,78 +398,82 @@ func (authorizationStateClosed *AuthorizationStateClosed) GetAuthorizationStateE
|
|||
return AuthorizationStateClosedType
|
||||
}
|
||||
|
||||
// GetAuthorizationState Returns the current authorization state; this is an offline request. For informational purposes only. Use updateAuthorizationState instead to maintain the current authorization state. Can be called before initialization
|
||||
func (client *Client) GetAuthorizationState() (AuthorizationState, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getAuthorizationState",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// GetAuthorizationState Returns the current authorization state; this is an offline request. For informational purposes only. Use updateAuthorizationState instead to maintain the current authorization state. Can be called before initialization
|
||||
func (client *Client) GetAuthorizationState() (AuthorizationState, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getAuthorizationState",
|
||||
|
||||
})
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
switch AuthorizationStateEnum(result.Data["@type"].(string)) {
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
case AuthorizationStateWaitTdlibParametersType:
|
||||
var authorizationState AuthorizationStateWaitTdlibParameters
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
case AuthorizationStateWaitEncryptionKeyType:
|
||||
var authorizationState AuthorizationStateWaitEncryptionKey
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
case AuthorizationStateWaitPhoneNumberType:
|
||||
var authorizationState AuthorizationStateWaitPhoneNumber
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
case AuthorizationStateWaitCodeType:
|
||||
var authorizationState AuthorizationStateWaitCode
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
case AuthorizationStateWaitOtherDeviceConfirmationType:
|
||||
var authorizationState AuthorizationStateWaitOtherDeviceConfirmation
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
case AuthorizationStateWaitRegistrationType:
|
||||
var authorizationState AuthorizationStateWaitRegistration
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
case AuthorizationStateWaitPasswordType:
|
||||
var authorizationState AuthorizationStateWaitPassword
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
case AuthorizationStateReadyType:
|
||||
var authorizationState AuthorizationStateReady
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
case AuthorizationStateLoggingOutType:
|
||||
var authorizationState AuthorizationStateLoggingOut
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
case AuthorizationStateClosingType:
|
||||
var authorizationState AuthorizationStateClosing
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
case AuthorizationStateClosedType:
|
||||
var authorizationState AuthorizationStateClosed
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid type")
|
||||
}
|
||||
}
|
||||
switch AuthorizationStateEnum(result.Data["@type"].(string)) {
|
||||
|
||||
case AuthorizationStateWaitTdlibParametersType:
|
||||
var authorizationState {authorizationStateWaitTdlibParameters AuthorizationStateWaitTdlibParameters}
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
case AuthorizationStateWaitEncryptionKeyType:
|
||||
var authorizationState {authorizationStateWaitEncryptionKey AuthorizationStateWaitEncryptionKey}
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
case AuthorizationStateWaitPhoneNumberType:
|
||||
var authorizationState {authorizationStateWaitPhoneNumber AuthorizationStateWaitPhoneNumber}
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
case AuthorizationStateWaitCodeType:
|
||||
var authorizationState {authorizationStateWaitCode AuthorizationStateWaitCode}
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
case AuthorizationStateWaitOtherDeviceConfirmationType:
|
||||
var authorizationState {authorizationStateWaitOtherDeviceConfirmation AuthorizationStateWaitOtherDeviceConfirmation}
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
case AuthorizationStateWaitRegistrationType:
|
||||
var authorizationState {authorizationStateWaitRegistration AuthorizationStateWaitRegistration}
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
case AuthorizationStateWaitPasswordType:
|
||||
var authorizationState {authorizationStateWaitPassword AuthorizationStateWaitPassword}
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
case AuthorizationStateReadyType:
|
||||
var authorizationState {authorizationStateReady AuthorizationStateReady}
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
case AuthorizationStateLoggingOutType:
|
||||
var authorizationState {authorizationStateLoggingOut AuthorizationStateLoggingOut}
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
case AuthorizationStateClosingType:
|
||||
var authorizationState {authorizationStateClosing AuthorizationStateClosing}
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
case AuthorizationStateClosedType:
|
||||
var authorizationState {authorizationStateClosed AuthorizationStateClosed}
|
||||
err = json.Unmarshal(result.Raw, &authorizationState)
|
||||
return &authorizationState, err
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid type")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// AutoDownloadSettings Contains auto-download settings
|
||||
type AutoDownloadSettings struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// AutoDownloadSettingsPresets Contains auto-download settings presets for the user
|
||||
type AutoDownloadSettingsPresets struct {
|
||||
tdCommon
|
||||
|
@ -30,3 +35,23 @@ func NewAutoDownloadSettingsPresets(low *AutoDownloadSettings, medium *AutoDownl
|
|||
|
||||
return &autoDownloadSettingsPresetsTemp
|
||||
}
|
||||
|
||||
// GetAutoDownloadSettingsPresets Returns auto-download settings presets for the current user
|
||||
func (client *Client) GetAutoDownloadSettingsPresets() (*AutoDownloadSettingsPresets, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getAutoDownloadSettingsPresets",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var autoDownloadSettingsPresets AutoDownloadSettingsPresets
|
||||
err = json.Unmarshal(result.Raw, &autoDownloadSettingsPresets)
|
||||
return &autoDownloadSettingsPresets, err
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Background Describes a chat background
|
||||
|
@ -77,3 +78,51 @@ func (background *Background) UnmarshalJSON(b []byte) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SearchBackground Searches for a background by its name
|
||||
// @param name The name of the background
|
||||
func (client *Client) SearchBackground(name string) (*Background, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "searchBackground",
|
||||
"name": name,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var background Background
|
||||
err = json.Unmarshal(result.Raw, &background)
|
||||
return &background, err
|
||||
|
||||
}
|
||||
|
||||
// SetBackground Changes the background selected by the user; adds background to the list of installed backgrounds
|
||||
// @param background The input background to use, null for filled backgrounds
|
||||
// @param typeParam Background type; null for default background. The method will return error 404 if type is null
|
||||
// @param forDarkTheme True, if the background is chosen for dark theme
|
||||
func (client *Client) SetBackground(background InputBackground, typeParam BackgroundType, forDarkTheme bool) (*Background, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "setBackground",
|
||||
"background": background,
|
||||
"type": typeParam,
|
||||
"for_dark_theme": forDarkTheme,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var backgroundDummy Background
|
||||
err = json.Unmarshal(result.Raw, &backgroundDummy)
|
||||
return &backgroundDummy, err
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Backgrounds Contains a list of backgrounds
|
||||
type Backgrounds struct {
|
||||
tdCommon
|
||||
|
@ -24,3 +29,25 @@ func NewBackgrounds(backgrounds []Background) *Backgrounds {
|
|||
|
||||
return &backgroundsTemp
|
||||
}
|
||||
|
||||
// GetBackgrounds Returns backgrounds installed by the user
|
||||
// @param forDarkTheme True, if the backgrounds must be ordered for dark theme
|
||||
func (client *Client) GetBackgrounds(forDarkTheme bool) (*Backgrounds, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getBackgrounds",
|
||||
"for_dark_theme": forDarkTheme,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var backgrounds Backgrounds
|
||||
err = json.Unmarshal(result.Raw, &backgrounds)
|
||||
return &backgrounds, err
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// BankCardActionOpenURL Describes an action associated with a bank card number
|
||||
type BankCardActionOpenURL struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// BankCardInfo Information about a bank card
|
||||
type BankCardInfo struct {
|
||||
tdCommon
|
||||
|
@ -27,3 +32,25 @@ func NewBankCardInfo(title string, actions []BankCardActionOpenURL) *BankCardInf
|
|||
|
||||
return &bankCardInfoTemp
|
||||
}
|
||||
|
||||
// GetBankCardInfo Returns information about a bank card
|
||||
// @param bankCardNumber The bank card number
|
||||
func (client *Client) GetBankCardInfo(bankCardNumber string) (*BankCardInfo, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getBankCardInfo",
|
||||
"bank_card_number": bankCardNumber,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var bankCardInfo BankCardInfo
|
||||
err = json.Unmarshal(result.Raw, &bankCardInfo)
|
||||
return &bankCardInfo, err
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// BotCommand Represents a command supported by a bot
|
||||
type BotCommand struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// BotInfo Provides information about a bot and its supported commands
|
||||
type BotInfo struct {
|
||||
tdCommon
|
||||
|
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Call Describes a call
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// CallProtocol Specifies the supported call protocols
|
||||
type CallProtocol struct {
|
||||
tdCommon
|
||||
|
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// CallServer Describes a server for relaying call data
|
||||
|
|
|
@ -166,43 +166,47 @@ func (canTransferOwnershipResultSessionTooFresh *CanTransferOwnershipResultSessi
|
|||
return CanTransferOwnershipResultSessionTooFreshType
|
||||
}
|
||||
|
||||
// CanTransferOwnership Checks whether the current session can be used to transfer a chat ownership to another user
|
||||
func (client *Client) CanTransferOwnership() (CanTransferOwnershipResult, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "canTransferOwnership",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// CanTransferOwnership Checks whether the current session can be used to transfer a chat ownership to another user
|
||||
func (client *Client) CanTransferOwnership() (CanTransferOwnershipResult, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "canTransferOwnership",
|
||||
|
||||
})
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
switch CanTransferOwnershipResultEnum(result.Data["@type"].(string)) {
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
case CanTransferOwnershipResultOkType:
|
||||
var canTransferOwnershipResult CanTransferOwnershipResultOk
|
||||
err = json.Unmarshal(result.Raw, &canTransferOwnershipResult)
|
||||
return &canTransferOwnershipResult, err
|
||||
|
||||
case CanTransferOwnershipResultPasswordNeededType:
|
||||
var canTransferOwnershipResult CanTransferOwnershipResultPasswordNeeded
|
||||
err = json.Unmarshal(result.Raw, &canTransferOwnershipResult)
|
||||
return &canTransferOwnershipResult, err
|
||||
|
||||
case CanTransferOwnershipResultPasswordTooFreshType:
|
||||
var canTransferOwnershipResult CanTransferOwnershipResultPasswordTooFresh
|
||||
err = json.Unmarshal(result.Raw, &canTransferOwnershipResult)
|
||||
return &canTransferOwnershipResult, err
|
||||
|
||||
case CanTransferOwnershipResultSessionTooFreshType:
|
||||
var canTransferOwnershipResult CanTransferOwnershipResultSessionTooFresh
|
||||
err = json.Unmarshal(result.Raw, &canTransferOwnershipResult)
|
||||
return &canTransferOwnershipResult, err
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid type")
|
||||
}
|
||||
}
|
||||
switch CanTransferOwnershipResultEnum(result.Data["@type"].(string)) {
|
||||
|
||||
case CanTransferOwnershipResultOkType:
|
||||
var canTransferOwnershipResult {canTransferOwnershipResultOk CanTransferOwnershipResultOk}
|
||||
err = json.Unmarshal(result.Raw, &canTransferOwnershipResult)
|
||||
return &canTransferOwnershipResult, err
|
||||
|
||||
case CanTransferOwnershipResultPasswordNeededType:
|
||||
var canTransferOwnershipResult {canTransferOwnershipResultPasswordNeeded CanTransferOwnershipResultPasswordNeeded}
|
||||
err = json.Unmarshal(result.Raw, &canTransferOwnershipResult)
|
||||
return &canTransferOwnershipResult, err
|
||||
|
||||
case CanTransferOwnershipResultPasswordTooFreshType:
|
||||
var canTransferOwnershipResult {canTransferOwnershipResultPasswordTooFresh CanTransferOwnershipResultPasswordTooFresh}
|
||||
err = json.Unmarshal(result.Raw, &canTransferOwnershipResult)
|
||||
return &canTransferOwnershipResult, err
|
||||
|
||||
case CanTransferOwnershipResultSessionTooFreshType:
|
||||
var canTransferOwnershipResult {canTransferOwnershipResultSessionTooFresh CanTransferOwnershipResultSessionTooFresh}
|
||||
err = json.Unmarshal(result.Raw, &canTransferOwnershipResult)
|
||||
return &canTransferOwnershipResult, err
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid type")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ChatAdministrator Contains information about a chat administrator
|
||||
type ChatAdministrator struct {
|
||||
tdCommon
|
||||
|
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ChatEvent Represents a chat event
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ChatEventLogFilters Represents a set of filters used to obtain a chat event log
|
||||
type ChatEventLogFilters struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ChatEvents Contains a list of chat events
|
||||
type ChatEvents struct {
|
||||
tdCommon
|
||||
|
@ -24,3 +29,35 @@ func NewChatEvents(events []ChatEvent) *ChatEvents {
|
|||
|
||||
return &chatEventsTemp
|
||||
}
|
||||
|
||||
// GetChatEventLog Returns a list of service actions taken by chat members and administrators in the last 48 hours. Available only for supergroups and channels. Requires administrator rights. Returns results in reverse chronological order (i. e., in order of decreasing event_id)
|
||||
// @param chatID Chat identifier
|
||||
// @param query Search query by which to filter events
|
||||
// @param fromEventID Identifier of an event from which to return results. Use 0 to get results from the latest events
|
||||
// @param limit The maximum number of events to return; up to 100
|
||||
// @param filters The types of events to return. By default, all types will be returned
|
||||
// @param userIDs User identifiers by which to filter events. By default, events relating to all users will be returned
|
||||
func (client *Client) GetChatEventLog(chatID int64, query string, fromEventID JSONInt64, limit int32, filters *ChatEventLogFilters, userIDs []int32) (*ChatEvents, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getChatEventLog",
|
||||
"chat_id": chatID,
|
||||
"query": query,
|
||||
"from_event_id": fromEventID,
|
||||
"limit": limit,
|
||||
"filters": filters,
|
||||
"user_ids": userIDs,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var chatEvents ChatEvents
|
||||
err = json.Unmarshal(result.Raw, &chatEvents)
|
||||
return &chatEvents, err
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ChatLocation Represents a location to which a chat is connected
|
||||
type ChatLocation struct {
|
||||
tdCommon
|
||||
|
|
|
@ -60,3 +60,31 @@ func (client *Client) SearchChatMembers(chatID int64, query string, limit int32,
|
|||
return &chatMembers, err
|
||||
|
||||
}
|
||||
|
||||
// GetSupergroupMembers Returns information about members or banned users in a supergroup or channel. Can be used only if SupergroupFullInfo.can_get_members == true; additionally, administrator privileges may be required for some filters
|
||||
// @param supergroupID Identifier of the supergroup or channel
|
||||
// @param filter The type of users to return. By default, supergroupMembersFilterRecent
|
||||
// @param offset Number of users to skip
|
||||
// @param limit The maximum number of users be returned; up to 200
|
||||
func (client *Client) GetSupergroupMembers(supergroupID int32, filter SupergroupMembersFilter, offset int32, limit int32) (*ChatMembers, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getSupergroupMembers",
|
||||
"supergroup_id": supergroupID,
|
||||
"filter": filter,
|
||||
"offset": offset,
|
||||
"limit": limit,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var chatMembers ChatMembers
|
||||
err = json.Unmarshal(result.Raw, &chatMembers)
|
||||
return &chatMembers, err
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ChatNearby Describes a chat located nearby
|
||||
type ChatNearby struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ChatNotificationSettings Contains information about notification settings for a chat
|
||||
type ChatNotificationSettings struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ChatPermissions Describes actions that a user is allowed to take in a chat
|
||||
type ChatPermissions struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ChatPhoto Describes a chat or user profile photo
|
||||
type ChatPhoto struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ChatPhotoInfo Contains basic information about the photo of a chat
|
||||
type ChatPhotoInfo struct {
|
||||
tdCommon
|
||||
|
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ChatPosition Describes a position of a chat in a chat list
|
||||
|
|
|
@ -309,3 +309,41 @@ func (chatStatisticsChannel *ChatStatisticsChannel) UnmarshalJSON(b []byte) erro
|
|||
func (chatStatisticsChannel *ChatStatisticsChannel) GetChatStatisticsEnum() ChatStatisticsEnum {
|
||||
return ChatStatisticsChannelType
|
||||
}
|
||||
|
||||
|
||||
// GetChatStatistics Returns detailed statistics about a chat. Currently this method can be used only for supergroups and channels. Can be used only if SupergroupFullInfo.can_get_statistics == true
|
||||
// @param chatID Chat identifier
|
||||
// @param isDark Pass true if a dark theme is used by the application
|
||||
func (client *Client) GetChatStatistics(chatID int64, isDark bool) (ChatStatistics, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getChatStatistics",
|
||||
"chat_id": chatID,
|
||||
"is_dark": isDark,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
switch ChatStatisticsEnum(result.Data["@type"].(string)) {
|
||||
|
||||
case ChatStatisticsSupergroupType:
|
||||
var chatStatistics {chatStatisticsSupergroup ChatStatisticsSupergroup}
|
||||
err = json.Unmarshal(result.Raw, &chatStatistics)
|
||||
return &chatStatistics, err
|
||||
|
||||
case ChatStatisticsChannelType:
|
||||
var chatStatistics {chatStatisticsChannel ChatStatisticsChannel}
|
||||
err = json.Unmarshal(result.Raw, &chatStatistics)
|
||||
return &chatStatistics, err
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid type")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ChatStatisticsAdministratorActionsInfo Contains statistics about administrator actions done by a user
|
||||
type ChatStatisticsAdministratorActionsInfo struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ChatStatisticsInviterInfo Contains statistics about number of new members invited by a user
|
||||
type ChatStatisticsInviterInfo struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ChatStatisticsMessageInteractionInfo Contains statistics about interactions with a message
|
||||
type ChatStatisticsMessageInteractionInfo struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ChatStatisticsMessageSenderInfo Contains statistics about messages sent by a user
|
||||
type ChatStatisticsMessageSenderInfo struct {
|
||||
tdCommon
|
||||
|
|
|
@ -191,52 +191,55 @@ func (checkChatUsernameResultPublicGroupsUnavailable *CheckChatUsernameResultPub
|
|||
return CheckChatUsernameResultPublicGroupsUnavailableType
|
||||
}
|
||||
|
||||
// CheckChatUsername Checks whether a username can be set for a chat
|
||||
|
||||
// CheckChatUsername Checks whether a username can be set for a chat
|
||||
// @param chatID Chat identifier; should be identifier of a supergroup chat, or a channel chat, or a private chat with self, or zero if chat is being created
|
||||
// @param username Username to be checked
|
||||
func (client *Client) CheckChatUsername(chatID int64, username string) (CheckChatUsernameResult, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "checkChatUsername",
|
||||
"chat_id": chatID,
|
||||
"username": username,
|
||||
})
|
||||
func (client *Client) CheckChatUsername(chatID int64, username string) (CheckChatUsernameResult, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "checkChatUsername",
|
||||
"chat_id": chatID,
|
||||
"username": username,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
switch CheckChatUsernameResultEnum(result.Data["@type"].(string)) {
|
||||
|
||||
case CheckChatUsernameResultOkType:
|
||||
var checkChatUsernameResult CheckChatUsernameResultOk
|
||||
err = json.Unmarshal(result.Raw, &checkChatUsernameResult)
|
||||
return &checkChatUsernameResult, err
|
||||
|
||||
case CheckChatUsernameResultUsernameInvalidType:
|
||||
var checkChatUsernameResult CheckChatUsernameResultUsernameInvalid
|
||||
err = json.Unmarshal(result.Raw, &checkChatUsernameResult)
|
||||
return &checkChatUsernameResult, err
|
||||
|
||||
case CheckChatUsernameResultUsernameOccupiedType:
|
||||
var checkChatUsernameResult CheckChatUsernameResultUsernameOccupied
|
||||
err = json.Unmarshal(result.Raw, &checkChatUsernameResult)
|
||||
return &checkChatUsernameResult, err
|
||||
|
||||
case CheckChatUsernameResultPublicChatsTooMuchType:
|
||||
var checkChatUsernameResult CheckChatUsernameResultPublicChatsTooMuch
|
||||
err = json.Unmarshal(result.Raw, &checkChatUsernameResult)
|
||||
return &checkChatUsernameResult, err
|
||||
|
||||
case CheckChatUsernameResultPublicGroupsUnavailableType:
|
||||
var checkChatUsernameResult CheckChatUsernameResultPublicGroupsUnavailable
|
||||
err = json.Unmarshal(result.Raw, &checkChatUsernameResult)
|
||||
return &checkChatUsernameResult, err
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid type")
|
||||
}
|
||||
}
|
||||
switch CheckChatUsernameResultEnum(result.Data["@type"].(string)) {
|
||||
|
||||
case CheckChatUsernameResultOkType:
|
||||
var checkChatUsernameResult {checkChatUsernameResultOk CheckChatUsernameResultOk}
|
||||
err = json.Unmarshal(result.Raw, &checkChatUsernameResult)
|
||||
return &checkChatUsernameResult, err
|
||||
|
||||
case CheckChatUsernameResultUsernameInvalidType:
|
||||
var checkChatUsernameResult {checkChatUsernameResultUsernameInvalid CheckChatUsernameResultUsernameInvalid}
|
||||
err = json.Unmarshal(result.Raw, &checkChatUsernameResult)
|
||||
return &checkChatUsernameResult, err
|
||||
|
||||
case CheckChatUsernameResultUsernameOccupiedType:
|
||||
var checkChatUsernameResult {checkChatUsernameResultUsernameOccupied CheckChatUsernameResultUsernameOccupied}
|
||||
err = json.Unmarshal(result.Raw, &checkChatUsernameResult)
|
||||
return &checkChatUsernameResult, err
|
||||
|
||||
case CheckChatUsernameResultPublicChatsTooMuchType:
|
||||
var checkChatUsernameResult {checkChatUsernameResultPublicChatsTooMuch CheckChatUsernameResultPublicChatsTooMuch}
|
||||
err = json.Unmarshal(result.Raw, &checkChatUsernameResult)
|
||||
return &checkChatUsernameResult, err
|
||||
|
||||
case CheckChatUsernameResultPublicGroupsUnavailableType:
|
||||
var checkChatUsernameResult {checkChatUsernameResultPublicGroupsUnavailable CheckChatUsernameResultPublicGroupsUnavailable}
|
||||
err = json.Unmarshal(result.Raw, &checkChatUsernameResult)
|
||||
return &checkChatUsernameResult, err
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid type")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3,6 +3,8 @@
|
|||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ConnectedWebsite Contains information about one website the current user is logged in with Telegram
|
||||
type ConnectedWebsite struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ConnectedWebsites Contains a list of websites the current user is logged in with Telegram
|
||||
type ConnectedWebsites struct {
|
||||
tdCommon
|
||||
|
@ -24,3 +29,23 @@ func NewConnectedWebsites(websites []ConnectedWebsite) *ConnectedWebsites {
|
|||
|
||||
return &connectedWebsitesTemp
|
||||
}
|
||||
|
||||
// GetConnectedWebsites Returns all website where the current user used Telegram to log in
|
||||
func (client *Client) GetConnectedWebsites() (*ConnectedWebsites, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getConnectedWebsites",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var connectedWebsites ConnectedWebsites
|
||||
err = json.Unmarshal(result.Raw, &connectedWebsites)
|
||||
return &connectedWebsites, err
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Contact Describes a user contact
|
||||
type Contact struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Countries Contains information about countries
|
||||
type Countries struct {
|
||||
tdCommon
|
||||
|
@ -24,3 +29,23 @@ func NewCountries(countries []CountryInfo) *Countries {
|
|||
|
||||
return &countriesTemp
|
||||
}
|
||||
|
||||
// GetCountries Returns information about existing countries. Can be called before authorization
|
||||
func (client *Client) GetCountries() (*Countries, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getCountries",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var countries Countries
|
||||
err = json.Unmarshal(result.Raw, &countries)
|
||||
return &countries, err
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// CountryInfo Contains information about a country
|
||||
type CountryInfo struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// CustomRequestResult Contains the result of a custom request
|
||||
type CustomRequestResult struct {
|
||||
tdCommon
|
||||
|
@ -24,3 +29,27 @@ func NewCustomRequestResult(result string) *CustomRequestResult {
|
|||
|
||||
return &customRequestResultTemp
|
||||
}
|
||||
|
||||
// SendCustomRequest Sends a custom request; for bots only
|
||||
// @param method The method name
|
||||
// @param parameters JSON-serialized method parameters
|
||||
func (client *Client) SendCustomRequest(method string, parameters string) (*CustomRequestResult, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "sendCustomRequest",
|
||||
"method": method,
|
||||
"parameters": parameters,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var customRequestResult CustomRequestResult
|
||||
err = json.Unmarshal(result.Raw, &customRequestResult)
|
||||
return &customRequestResult, err
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// DatabaseStatistics Contains database statistics
|
||||
type DatabaseStatistics struct {
|
||||
tdCommon
|
||||
|
@ -24,3 +29,23 @@ func NewDatabaseStatistics(statistics string) *DatabaseStatistics {
|
|||
|
||||
return &databaseStatisticsTemp
|
||||
}
|
||||
|
||||
// GetDatabaseStatistics Returns database statistics
|
||||
func (client *Client) GetDatabaseStatistics() (*DatabaseStatistics, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getDatabaseStatistics",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var databaseStatistics DatabaseStatistics
|
||||
err = json.Unmarshal(result.Raw, &databaseStatistics)
|
||||
return &databaseStatistics, err
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Date Represents a date according to the Gregorian calendar
|
||||
type Date struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// DateRange Represents a date range
|
||||
type DateRange struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// DatedFile File with the date it was uploaded
|
||||
type DatedFile struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// DeepLinkInfo Contains information about a tg:// deep link
|
||||
type DeepLinkInfo struct {
|
||||
tdCommon
|
||||
|
@ -27,3 +32,25 @@ func NewDeepLinkInfo(text *FormattedText, needUpdateApplication bool) *DeepLinkI
|
|||
|
||||
return &deepLinkInfoTemp
|
||||
}
|
||||
|
||||
// GetDeepLinkInfo Returns information about a tg:// deep link. Use "tg://need_update_for_some_feature" or "tg:some_unsupported_feature" for testing. Returns a 404 error for unknown links. Can be called before authorization
|
||||
// @param link The link
|
||||
func (client *Client) GetDeepLinkInfo(link string) (*DeepLinkInfo, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getDeepLinkInfo",
|
||||
"link": link,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var deepLinkInfo DeepLinkInfo
|
||||
err = json.Unmarshal(result.Raw, &deepLinkInfo)
|
||||
return &deepLinkInfo, err
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Document Describes a document of any type
|
||||
type Document struct {
|
||||
tdCommon
|
||||
|
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// DraftMessage Contains information about a message draft
|
||||
|
|
|
@ -52,3 +52,45 @@ func (client *Client) RequestPasswordRecovery() (*EmailAddressAuthenticationCode
|
|||
return &emailAddressAuthenticationCodeInfo, err
|
||||
|
||||
}
|
||||
|
||||
// SendEmailAddressVerificationCode Sends a code to verify an email address to be added to a user's Telegram Passport
|
||||
// @param emailAddress Email address
|
||||
func (client *Client) SendEmailAddressVerificationCode(emailAddress string) (*EmailAddressAuthenticationCodeInfo, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "sendEmailAddressVerificationCode",
|
||||
"email_address": emailAddress,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var emailAddressAuthenticationCodeInfo EmailAddressAuthenticationCodeInfo
|
||||
err = json.Unmarshal(result.Raw, &emailAddressAuthenticationCodeInfo)
|
||||
return &emailAddressAuthenticationCodeInfo, err
|
||||
|
||||
}
|
||||
|
||||
// ResendEmailAddressVerificationCode Re-sends the code to verify an email address to be added to a user's Telegram Passport
|
||||
func (client *Client) ResendEmailAddressVerificationCode() (*EmailAddressAuthenticationCodeInfo, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "resendEmailAddressVerificationCode",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var emailAddressAuthenticationCodeInfo EmailAddressAuthenticationCodeInfo
|
||||
err = json.Unmarshal(result.Raw, &emailAddressAuthenticationCodeInfo)
|
||||
return &emailAddressAuthenticationCodeInfo, err
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Emojis Represents a list of emoji
|
||||
type Emojis struct {
|
||||
tdCommon
|
||||
|
@ -24,3 +29,51 @@ func NewEmojis(emojis []string) *Emojis {
|
|||
|
||||
return &emojisTemp
|
||||
}
|
||||
|
||||
// GetStickerEmojis Returns emoji corresponding to a sticker. The list is only for informational purposes, because a sticker is always sent with a fixed emoji from the corresponding Sticker object
|
||||
// @param sticker Sticker file identifier
|
||||
func (client *Client) GetStickerEmojis(sticker InputFile) (*Emojis, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getStickerEmojis",
|
||||
"sticker": sticker,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var emojis Emojis
|
||||
err = json.Unmarshal(result.Raw, &emojis)
|
||||
return &emojis, err
|
||||
|
||||
}
|
||||
|
||||
// SearchEmojis Searches for emojis by keywords. Supported only if the file database is enabled
|
||||
// @param text Text to search for
|
||||
// @param exactMatch True, if only emojis, which exactly match text needs to be returned
|
||||
// @param inputLanguageCodes List of possible IETF language tags of the user's input language; may be empty if unknown
|
||||
func (client *Client) SearchEmojis(text string, exactMatch bool, inputLanguageCodes []string) (*Emojis, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "searchEmojis",
|
||||
"text": text,
|
||||
"exact_match": exactMatch,
|
||||
"input_language_codes": inputLanguageCodes,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var emojis Emojis
|
||||
err = json.Unmarshal(result.Raw, &emojis)
|
||||
return &emojis, err
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// EncryptedCredentials Contains encrypted Telegram Passport data credentials
|
||||
type EncryptedCredentials struct {
|
||||
tdCommon
|
||||
|
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// EncryptedPassportElement Contains information about an encrypted Telegram Passport element; for bots only
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Error An object of this type can be returned on every function call, in case of an error
|
||||
type Error struct {
|
||||
tdCommon
|
||||
|
@ -27,3 +32,25 @@ func NewError(code int32, message string) *Error {
|
|||
|
||||
return &errorTemp
|
||||
}
|
||||
|
||||
// TestReturnError Returns the specified error and ensures that the Error object is used; for testing only. Can be called synchronously
|
||||
// @param error The error to be returned
|
||||
func (client *Client) TestReturnError(error *Error) (*Error, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "testReturnError",
|
||||
"error": error,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var errorDummy Error
|
||||
err = json.Unmarshal(result.Raw, &errorDummy)
|
||||
return &errorDummy, err
|
||||
|
||||
}
|
||||
|
|
|
@ -143,3 +143,59 @@ func (client *Client) UploadFile(file InputFile, fileType FileType, priority int
|
|||
return &fileDummy, err
|
||||
|
||||
}
|
||||
|
||||
// UploadStickerFile Uploads a PNG image with a sticker; for bots only; returns the uploaded file
|
||||
// @param userID Sticker file owner
|
||||
// @param pngSticker PNG image with the sticker; must be up to 512 KB in size and fit in 512x512 square
|
||||
func (client *Client) UploadStickerFile(userID int32, pngSticker InputFile) (*File, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "uploadStickerFile",
|
||||
"user_id": userID,
|
||||
"png_sticker": pngSticker,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var file File
|
||||
err = json.Unmarshal(result.Raw, &file)
|
||||
return &file, err
|
||||
|
||||
}
|
||||
|
||||
// GetMapThumbnailFile Returns information about a file with a map thumbnail in PNG format. Only map thumbnail files with size less than 1MB can be downloaded
|
||||
// @param location Location of the map center
|
||||
// @param zoom Map zoom level; 13-20
|
||||
// @param width Map width in pixels before applying scale; 16-1024
|
||||
// @param height Map height in pixels before applying scale; 16-1024
|
||||
// @param scale Map scale; 1-3
|
||||
// @param chatID Identifier of a chat, in which the thumbnail will be shown. Use 0 if unknown
|
||||
func (client *Client) GetMapThumbnailFile(location *Location, zoom int32, width int32, height int32, scale int32, chatID int64) (*File, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getMapThumbnailFile",
|
||||
"location": location,
|
||||
"zoom": zoom,
|
||||
"width": width,
|
||||
"height": height,
|
||||
"scale": scale,
|
||||
"chat_id": chatID,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var file File
|
||||
err = json.Unmarshal(result.Raw, &file)
|
||||
return &file, err
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Game Describes a game
|
||||
type Game struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// GameHighScore Contains one row of the game high score table
|
||||
type GameHighScore struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Hashtags Contains a list of hashtags
|
||||
type Hashtags struct {
|
||||
tdCommon
|
||||
|
@ -24,3 +29,27 @@ func NewHashtags(hashtags []string) *Hashtags {
|
|||
|
||||
return &hashtagsTemp
|
||||
}
|
||||
|
||||
// SearchHashtags Searches for recently used hashtags by their prefix
|
||||
// @param prefix Hashtag prefix to search for
|
||||
// @param limit The maximum number of hashtags to be returned
|
||||
func (client *Client) SearchHashtags(prefix string, limit int32) (*Hashtags, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "searchHashtags",
|
||||
"prefix": prefix,
|
||||
"limit": limit,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var hashtags Hashtags
|
||||
err = json.Unmarshal(result.Raw, &hashtags)
|
||||
return &hashtags, err
|
||||
|
||||
}
|
||||
|
|
|
@ -57,3 +57,75 @@ func (client *Client) GetLoginURL(chatID int64, messageID int64, buttonID int32,
|
|||
return &httpURL, err
|
||||
|
||||
}
|
||||
|
||||
// GetEmojiSuggestionsURL Returns an HTTP URL which can be used to automatically log in to the translation platform and suggest new emoji replacements. The URL will be valid for 30 seconds after generation
|
||||
// @param languageCode Language code for which the emoji replacements will be suggested
|
||||
func (client *Client) GetEmojiSuggestionsURL(languageCode string) (*HttpURL, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getEmojiSuggestionsUrl",
|
||||
"language_code": languageCode,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var httpURL HttpURL
|
||||
err = json.Unmarshal(result.Raw, &httpURL)
|
||||
return &httpURL, err
|
||||
|
||||
}
|
||||
|
||||
// GetBackgroundURL Constructs a persistent HTTP URL for a background
|
||||
// @param name Background name
|
||||
// @param typeParam Background type
|
||||
func (client *Client) GetBackgroundURL(name string, typeParam BackgroundType) (*HttpURL, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getBackgroundUrl",
|
||||
"name": name,
|
||||
"type": typeParam,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var httpURL HttpURL
|
||||
err = json.Unmarshal(result.Raw, &httpURL)
|
||||
return &httpURL, err
|
||||
|
||||
}
|
||||
|
||||
// GetChatStatisticsURL Returns an HTTP URL with the chat statistics. Currently this method of getting the statistics are disabled and can be deleted in the future
|
||||
// @param chatID Chat identifier
|
||||
// @param parameters Parameters from "tg://statsrefresh?params=******" link
|
||||
// @param isDark Pass true if a URL with the dark theme must be returned
|
||||
func (client *Client) GetChatStatisticsURL(chatID int64, parameters string, isDark bool) (*HttpURL, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getChatStatisticsUrl",
|
||||
"chat_id": chatID,
|
||||
"parameters": parameters,
|
||||
"is_dark": isDark,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var httpURL HttpURL
|
||||
err = json.Unmarshal(result.Raw, &httpURL)
|
||||
return &httpURL, err
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// IDentityDocument An identity document
|
||||
type IDentityDocument struct {
|
||||
tdCommon
|
||||
|
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// InlineKeyboardButton Represents a single button in an inline keyboard
|
||||
|
|
|
@ -17,8 +17,8 @@ type InlineKeyboardButtonTypeEnum string
|
|||
|
||||
// InlineKeyboardButtonType enums
|
||||
const (
|
||||
InlineKeyboardButtonTypeURLType InlineKeyboardButtonTypeEnum = "inlineKeyboardButtonTypeURL"
|
||||
InlineKeyboardButtonTypeLoginURLType InlineKeyboardButtonTypeEnum = "inlineKeyboardButtonTypeLoginURL"
|
||||
InlineKeyboardButtonTypeURLType InlineKeyboardButtonTypeEnum = "inlineKeyboardButtonTypeUrl"
|
||||
InlineKeyboardButtonTypeLoginURLType InlineKeyboardButtonTypeEnum = "inlineKeyboardButtonTypeLoginUrl"
|
||||
InlineKeyboardButtonTypeCallbackType InlineKeyboardButtonTypeEnum = "inlineKeyboardButtonTypeCallback"
|
||||
InlineKeyboardButtonTypeCallbackWithPasswordType InlineKeyboardButtonTypeEnum = "inlineKeyboardButtonTypeCallbackWithPassword"
|
||||
InlineKeyboardButtonTypeCallbackGameType InlineKeyboardButtonTypeEnum = "inlineKeyboardButtonTypeCallbackGame"
|
||||
|
|
|
@ -17,7 +17,7 @@ type InputFileEnum string
|
|||
|
||||
// InputFile enums
|
||||
const (
|
||||
InputFileIDType InputFileEnum = "inputFileID"
|
||||
InputFileIDType InputFileEnum = "inputFileId"
|
||||
InputFileRemoteType InputFileEnum = "inputFileRemote"
|
||||
InputFileLocalType InputFileEnum = "inputFileLocal"
|
||||
InputFileGeneratedType InputFileEnum = "inputFileGenerated"
|
||||
|
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// InputIDentityDocument An identity document to be saved to Telegram Passport
|
||||
|
|
|
@ -20,7 +20,7 @@ const (
|
|||
InputPassportElementPersonalDetailsType InputPassportElementEnum = "inputPassportElementPersonalDetails"
|
||||
InputPassportElementPassportType InputPassportElementEnum = "inputPassportElementPassport"
|
||||
InputPassportElementDriverLicenseType InputPassportElementEnum = "inputPassportElementDriverLicense"
|
||||
InputPassportElementIDentityCardType InputPassportElementEnum = "inputPassportElementIDentityCard"
|
||||
InputPassportElementIDentityCardType InputPassportElementEnum = "inputPassportElementIdentityCard"
|
||||
InputPassportElementInternalPassportType InputPassportElementEnum = "inputPassportElementInternalPassport"
|
||||
InputPassportElementAddressType InputPassportElementEnum = "inputPassportElementAddress"
|
||||
InputPassportElementUtilityBillType InputPassportElementEnum = "inputPassportElementUtilityBill"
|
||||
|
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// InputPassportElementError Contains the description of an error in a Telegram Passport element; for bots only
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// InputPersonalDocument A personal document to be saved to Telegram Passport
|
||||
type InputPersonalDocument struct {
|
||||
tdCommon
|
||||
|
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// InputThumbnail A thumbnail to be sent along with a file; must be in JPEG or WEBP format for stickers, and less than 200 KB in size
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Invoice Product invoice
|
||||
type Invoice struct {
|
||||
tdCommon
|
||||
|
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// JsonObjectMember Represents one member of a JSON object
|
||||
|
|
|
@ -237,55 +237,112 @@ func (jsonValueObject *JsonValueObject) GetJsonValueEnum() JsonValueEnum {
|
|||
return JsonValueObjectType
|
||||
}
|
||||
|
||||
// GetJsonValue Converts a JSON-serialized string to corresponding JsonValue object. Can be called synchronously
|
||||
|
||||
// GetJsonValue Converts a JSON-serialized string to corresponding JsonValue object. Can be called synchronously
|
||||
// @param jsonString The JSON-serialized string
|
||||
func (client *Client) GetJsonValue(jsonString string) (JsonValue, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getJsonValue",
|
||||
"json": jsonString,
|
||||
})
|
||||
func (client *Client) GetJsonValue(jsonString string) (JsonValue, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getJsonValue",
|
||||
"json": jsonString,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
switch JsonValueEnum(result.Data["@type"].(string)) {
|
||||
switch JsonValueEnum(result.Data["@type"].(string)) {
|
||||
|
||||
case JsonValueNullType:
|
||||
var jsonValue {jsonValueNull JsonValueNull}
|
||||
err = json.Unmarshal(result.Raw, &jsonValue)
|
||||
return &jsonValue, err
|
||||
|
||||
case JsonValueBooleanType:
|
||||
var jsonValue {jsonValueBoolean JsonValueBoolean}
|
||||
err = json.Unmarshal(result.Raw, &jsonValue)
|
||||
return &jsonValue, err
|
||||
|
||||
case JsonValueNumberType:
|
||||
var jsonValue {jsonValueNumber JsonValueNumber}
|
||||
err = json.Unmarshal(result.Raw, &jsonValue)
|
||||
return &jsonValue, err
|
||||
|
||||
case JsonValueStringType:
|
||||
var jsonValue {jsonValueString JsonValueString}
|
||||
err = json.Unmarshal(result.Raw, &jsonValue)
|
||||
return &jsonValue, err
|
||||
|
||||
case JsonValueArrayType:
|
||||
var jsonValue {jsonValueArray JsonValueArray}
|
||||
err = json.Unmarshal(result.Raw, &jsonValue)
|
||||
return &jsonValue, err
|
||||
|
||||
case JsonValueObjectType:
|
||||
var jsonValue {jsonValueObject JsonValueObject}
|
||||
err = json.Unmarshal(result.Raw, &jsonValue)
|
||||
return &jsonValue, err
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid type")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
case JsonValueNullType:
|
||||
var jsonValue JsonValueNull
|
||||
err = json.Unmarshal(result.Raw, &jsonValue)
|
||||
return &jsonValue, err
|
||||
// GetApplicationConfig Returns application config, provided by the server. Can be called before authorization
|
||||
func (client *Client) GetApplicationConfig() (JsonValue, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getApplicationConfig",
|
||||
|
||||
})
|
||||
|
||||
case JsonValueBooleanType:
|
||||
var jsonValue JsonValueBoolean
|
||||
err = json.Unmarshal(result.Raw, &jsonValue)
|
||||
return &jsonValue, err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
case JsonValueNumberType:
|
||||
var jsonValue JsonValueNumber
|
||||
err = json.Unmarshal(result.Raw, &jsonValue)
|
||||
return &jsonValue, err
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
case JsonValueStringType:
|
||||
var jsonValue JsonValueString
|
||||
err = json.Unmarshal(result.Raw, &jsonValue)
|
||||
return &jsonValue, err
|
||||
|
||||
case JsonValueArrayType:
|
||||
var jsonValue JsonValueArray
|
||||
err = json.Unmarshal(result.Raw, &jsonValue)
|
||||
return &jsonValue, err
|
||||
|
||||
case JsonValueObjectType:
|
||||
var jsonValue JsonValueObject
|
||||
err = json.Unmarshal(result.Raw, &jsonValue)
|
||||
return &jsonValue, err
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid type")
|
||||
}
|
||||
}
|
||||
switch JsonValueEnum(result.Data["@type"].(string)) {
|
||||
|
||||
case JsonValueNullType:
|
||||
var jsonValue {jsonValueNull JsonValueNull}
|
||||
err = json.Unmarshal(result.Raw, &jsonValue)
|
||||
return &jsonValue, err
|
||||
|
||||
case JsonValueBooleanType:
|
||||
var jsonValue {jsonValueBoolean JsonValueBoolean}
|
||||
err = json.Unmarshal(result.Raw, &jsonValue)
|
||||
return &jsonValue, err
|
||||
|
||||
case JsonValueNumberType:
|
||||
var jsonValue {jsonValueNumber JsonValueNumber}
|
||||
err = json.Unmarshal(result.Raw, &jsonValue)
|
||||
return &jsonValue, err
|
||||
|
||||
case JsonValueStringType:
|
||||
var jsonValue {jsonValueString JsonValueString}
|
||||
err = json.Unmarshal(result.Raw, &jsonValue)
|
||||
return &jsonValue, err
|
||||
|
||||
case JsonValueArrayType:
|
||||
var jsonValue {jsonValueArray JsonValueArray}
|
||||
err = json.Unmarshal(result.Raw, &jsonValue)
|
||||
return &jsonValue, err
|
||||
|
||||
case JsonValueObjectType:
|
||||
var jsonValue {jsonValueObject JsonValueObject}
|
||||
err = json.Unmarshal(result.Raw, &jsonValue)
|
||||
return &jsonValue, err
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid type")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// KeyboardButton Represents a single button in a bot keyboard
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// LabeledPricePart Portion of the price of a product (e.g., "delivery cost", "tax amount")
|
||||
type LabeledPricePart struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// LanguagePackInfo Contains information about a language pack
|
||||
type LanguagePackInfo struct {
|
||||
tdCommon
|
||||
|
@ -60,3 +65,25 @@ func NewLanguagePackInfo(iD string, baseLanguagePackID string, name string, nati
|
|||
|
||||
return &languagePackInfoTemp
|
||||
}
|
||||
|
||||
// GetLanguagePackInfo Returns information about a language pack. Returned language pack identifier may be different from a provided one. Can be called before authorization
|
||||
// @param languagePackID Language pack identifier
|
||||
func (client *Client) GetLanguagePackInfo(languagePackID string) (*LanguagePackInfo, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getLanguagePackInfo",
|
||||
"language_pack_id": languagePackID,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var languagePackInfo LanguagePackInfo
|
||||
err = json.Unmarshal(result.Raw, &languagePackInfo)
|
||||
return &languagePackInfo, err
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// LanguagePackString Represents one language pack string
|
||||
|
|
|
@ -150,46 +150,49 @@ func (languagePackStringValueDeleted *LanguagePackStringValueDeleted) GetLanguag
|
|||
return LanguagePackStringValueDeletedType
|
||||
}
|
||||
|
||||
// GetLanguagePackString Returns a string stored in the local database from the specified localization target and language pack by its key. Returns a 404 error if the string is not found. Can be called synchronously
|
||||
|
||||
// GetLanguagePackString Returns a string stored in the local database from the specified localization target and language pack by its key. Returns a 404 error if the string is not found. Can be called synchronously
|
||||
// @param languagePackDatabasePath Path to the language pack database in which strings are stored
|
||||
// @param localizationTarget Localization target to which the language pack belongs
|
||||
// @param languagePackID Language pack identifier
|
||||
// @param key Language pack key of the string to be returned
|
||||
func (client *Client) GetLanguagePackString(languagePackDatabasePath string, localizationTarget string, languagePackID string, key string) (LanguagePackStringValue, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getLanguagePackString",
|
||||
"language_pack_database_path": languagePackDatabasePath,
|
||||
"localization_target": localizationTarget,
|
||||
"language_pack_id": languagePackID,
|
||||
"key": key,
|
||||
})
|
||||
func (client *Client) GetLanguagePackString(languagePackDatabasePath string, localizationTarget string, languagePackID string, key string) (LanguagePackStringValue, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getLanguagePackString",
|
||||
"language_pack_database_path": languagePackDatabasePath,
|
||||
"localization_target": localizationTarget,
|
||||
"language_pack_id": languagePackID,
|
||||
"key": key,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
switch LanguagePackStringValueEnum(result.Data["@type"].(string)) {
|
||||
|
||||
case LanguagePackStringValueOrdinaryType:
|
||||
var languagePackStringValue LanguagePackStringValueOrdinary
|
||||
err = json.Unmarshal(result.Raw, &languagePackStringValue)
|
||||
return &languagePackStringValue, err
|
||||
|
||||
case LanguagePackStringValuePluralizedType:
|
||||
var languagePackStringValue LanguagePackStringValuePluralized
|
||||
err = json.Unmarshal(result.Raw, &languagePackStringValue)
|
||||
return &languagePackStringValue, err
|
||||
|
||||
case LanguagePackStringValueDeletedType:
|
||||
var languagePackStringValue LanguagePackStringValueDeleted
|
||||
err = json.Unmarshal(result.Raw, &languagePackStringValue)
|
||||
return &languagePackStringValue, err
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid type")
|
||||
}
|
||||
}
|
||||
switch LanguagePackStringValueEnum(result.Data["@type"].(string)) {
|
||||
|
||||
case LanguagePackStringValueOrdinaryType:
|
||||
var languagePackStringValue {languagePackStringValueOrdinary LanguagePackStringValueOrdinary}
|
||||
err = json.Unmarshal(result.Raw, &languagePackStringValue)
|
||||
return &languagePackStringValue, err
|
||||
|
||||
case LanguagePackStringValuePluralizedType:
|
||||
var languagePackStringValue {languagePackStringValuePluralized LanguagePackStringValuePluralized}
|
||||
err = json.Unmarshal(result.Raw, &languagePackStringValue)
|
||||
return &languagePackStringValue, err
|
||||
|
||||
case LanguagePackStringValueDeletedType:
|
||||
var languagePackStringValue {languagePackStringValueDeleted LanguagePackStringValueDeleted}
|
||||
err = json.Unmarshal(result.Raw, &languagePackStringValue)
|
||||
return &languagePackStringValue, err
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid type")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// LanguagePackStrings Contains a list of language pack strings
|
||||
type LanguagePackStrings struct {
|
||||
tdCommon
|
||||
|
@ -24,3 +29,27 @@ func NewLanguagePackStrings(strings []LanguagePackString) *LanguagePackStrings {
|
|||
|
||||
return &languagePackStringsTemp
|
||||
}
|
||||
|
||||
// GetLanguagePackStrings Returns strings from a language pack in the current localization target by their keys. Can be called before authorization
|
||||
// @param languagePackID Language pack identifier of the strings to be returned
|
||||
// @param keys Language pack keys of the strings to be returned; leave empty to request all available strings
|
||||
func (client *Client) GetLanguagePackStrings(languagePackID string, keys []string) (*LanguagePackStrings, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getLanguagePackStrings",
|
||||
"language_pack_id": languagePackID,
|
||||
"keys": keys,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var languagePackStrings LanguagePackStrings
|
||||
err = json.Unmarshal(result.Raw, &languagePackStrings)
|
||||
return &languagePackStrings, err
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// LocalFile Represents a local file
|
||||
type LocalFile struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// LocalizationTargetInfo Contains information about the current localization target
|
||||
type LocalizationTargetInfo struct {
|
||||
tdCommon
|
||||
|
@ -24,3 +29,25 @@ func NewLocalizationTargetInfo(languagePacks []LanguagePackInfo) *LocalizationTa
|
|||
|
||||
return &localizationTargetInfoTemp
|
||||
}
|
||||
|
||||
// GetLocalizationTargetInfo Returns information about the current localization target. This is an offline request if only_local is true. Can be called before authorization
|
||||
// @param onlyLocal If true, returns only locally available information without sending network requests
|
||||
func (client *Client) GetLocalizationTargetInfo(onlyLocal bool) (*LocalizationTargetInfo, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getLocalizationTargetInfo",
|
||||
"only_local": onlyLocal,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var localizationTargetInfo LocalizationTargetInfo
|
||||
err = json.Unmarshal(result.Raw, &localizationTargetInfo)
|
||||
return &localizationTargetInfo, err
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Location Describes a location on planet Earth
|
||||
type Location struct {
|
||||
tdCommon
|
||||
|
|
|
@ -137,3 +137,43 @@ func NewLogStreamEmpty() *LogStreamEmpty {
|
|||
func (logStreamEmpty *LogStreamEmpty) GetLogStreamEnum() LogStreamEnum {
|
||||
return LogStreamEmptyType
|
||||
}
|
||||
|
||||
|
||||
// GetLogStream Returns information about currently used log stream for internal logging of TDLib. Can be called synchronously
|
||||
func (client *Client) GetLogStream() (LogStream, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getLogStream",
|
||||
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
switch LogStreamEnum(result.Data["@type"].(string)) {
|
||||
|
||||
case LogStreamDefaultType:
|
||||
var logStream {logStreamDefault LogStreamDefault}
|
||||
err = json.Unmarshal(result.Raw, &logStream)
|
||||
return &logStream, err
|
||||
|
||||
case LogStreamFileType:
|
||||
var logStream {logStreamFile LogStreamFile}
|
||||
err = json.Unmarshal(result.Raw, &logStream)
|
||||
return &logStream, err
|
||||
|
||||
case LogStreamEmptyType:
|
||||
var logStream {logStreamEmpty LogStreamEmpty}
|
||||
err = json.Unmarshal(result.Raw, &logStream)
|
||||
return &logStream, err
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid type")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// LogTags Contains a list of available TDLib internal log tags
|
||||
type LogTags struct {
|
||||
tdCommon
|
||||
|
@ -24,3 +29,23 @@ func NewLogTags(tags []string) *LogTags {
|
|||
|
||||
return &logTagsTemp
|
||||
}
|
||||
|
||||
// GetLogTags Returns list of available TDLib internal log tags, for example, ["actor", "binlog", "connections", "notifications", "proxy"]. Can be called synchronously
|
||||
func (client *Client) GetLogTags() (*LogTags, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getLogTags",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var logTags LogTags
|
||||
err = json.Unmarshal(result.Raw, &logTags)
|
||||
return &logTags, err
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// LogVerbosityLevel Contains a TDLib internal log verbosity level
|
||||
type LogVerbosityLevel struct {
|
||||
tdCommon
|
||||
|
@ -24,3 +29,45 @@ func NewLogVerbosityLevel(verbosityLevel int32) *LogVerbosityLevel {
|
|||
|
||||
return &logVerbosityLevelTemp
|
||||
}
|
||||
|
||||
// GetLogVerbosityLevel Returns current verbosity level of the internal logging of TDLib. Can be called synchronously
|
||||
func (client *Client) GetLogVerbosityLevel() (*LogVerbosityLevel, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getLogVerbosityLevel",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var logVerbosityLevel LogVerbosityLevel
|
||||
err = json.Unmarshal(result.Raw, &logVerbosityLevel)
|
||||
return &logVerbosityLevel, err
|
||||
|
||||
}
|
||||
|
||||
// GetLogTagVerbosityLevel Returns current verbosity level for a specified TDLib internal log tag. Can be called synchronously
|
||||
// @param tag Logging tag to change verbosity level
|
||||
func (client *Client) GetLogTagVerbosityLevel(tag string) (*LogVerbosityLevel, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getLogTagVerbosityLevel",
|
||||
"tag": tag,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var logVerbosityLevel LogVerbosityLevel
|
||||
err = json.Unmarshal(result.Raw, &logVerbosityLevel)
|
||||
return &logVerbosityLevel, err
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// MaskPosition Position on a photo where a mask should be placed
|
||||
|
|
|
@ -48,7 +48,7 @@ const (
|
|||
MessageChatUpgradeFromType MessageContentEnum = "messageChatUpgradeFrom"
|
||||
MessagePinMessageType MessageContentEnum = "messagePinMessage"
|
||||
MessageScreenshotTakenType MessageContentEnum = "messageScreenshotTaken"
|
||||
MessageChatSetTTLType MessageContentEnum = "messageChatSetTTL"
|
||||
MessageChatSetTTLType MessageContentEnum = "messageChatSetTtl"
|
||||
MessageCustomServiceActionType MessageContentEnum = "messageCustomServiceAction"
|
||||
MessageGameScoreType MessageContentEnum = "messageGameScore"
|
||||
MessagePaymentSuccessfulType MessageContentEnum = "messagePaymentSuccessful"
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// MessageCopyOptions Options to be used when a message content is copied without a link to the original message
|
||||
type MessageCopyOptions struct {
|
||||
tdCommon
|
||||
|
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// MessageForwardInfo Contains information about a forwarded message
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// MessageInteractionInfo Contains information about interactions with a message
|
||||
type MessageInteractionInfo struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// MessageReplyInfo Contains information about replies to a message
|
||||
type MessageReplyInfo struct {
|
||||
tdCommon
|
||||
|
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// MessageSendOptions Options to be used when a message is sent
|
||||
|
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// MessageStatistics A detailed statistics about a message
|
||||
|
@ -51,3 +52,29 @@ func (messageStatistics *MessageStatistics) UnmarshalJSON(b []byte) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetMessageStatistics Returns detailed statistics about a message. Can be used only if Message.can_get_statistics == true
|
||||
// @param chatID Chat identifier
|
||||
// @param messageID Message identifier
|
||||
// @param isDark Pass true if a dark theme is used by the application
|
||||
func (client *Client) GetMessageStatistics(chatID int64, messageID int64, isDark bool) (*MessageStatistics, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getMessageStatistics",
|
||||
"chat_id": chatID,
|
||||
"message_id": messageID,
|
||||
"is_dark": isDark,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var messageStatistics MessageStatistics
|
||||
err = json.Unmarshal(result.Raw, &messageStatistics)
|
||||
return &messageStatistics, err
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Minithumbnail Thumbnail image of a very poor quality and low resolution
|
||||
type Minithumbnail struct {
|
||||
tdCommon
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
package tdlib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// NetworkStatistics A full list of available network statistic entries
|
||||
type NetworkStatistics struct {
|
||||
tdCommon
|
||||
|
@ -27,3 +32,25 @@ func NewNetworkStatistics(sinceDate int32, entries []NetworkStatisticsEntry) *Ne
|
|||
|
||||
return &networkStatisticsTemp
|
||||
}
|
||||
|
||||
// GetNetworkStatistics Returns network data usage statistics. Can be called before authorization
|
||||
// @param onlyCurrent If true, returns only data for the current library launch
|
||||
func (client *Client) GetNetworkStatistics(onlyCurrent bool) (*NetworkStatistics, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getNetworkStatistics",
|
||||
"only_current": onlyCurrent,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
var networkStatistics NetworkStatistics
|
||||
err = json.Unmarshal(result.Raw, &networkStatistics)
|
||||
return &networkStatistics, err
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Notification Contains information about a notification
|
||||
|
|
|
@ -4,6 +4,7 @@ package tdlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// NotificationGroup Describes a group of notifications
|
||||
|
|
1530
tdlib/ok.go
1530
tdlib/ok.go
File diff suppressed because it is too large
Load Diff
|
@ -168,3 +168,49 @@ func NewOptionValueString(value string) *OptionValueString {
|
|||
func (optionValueString *OptionValueString) GetOptionValueEnum() OptionValueEnum {
|
||||
return OptionValueStringType
|
||||
}
|
||||
|
||||
|
||||
// GetOption Returns the value of an option by its name. (Check the list of available options on https://core.telegram.org/tdlib/options.) Can be called before authorization
|
||||
// @param name The name of the option
|
||||
func (client *Client) GetOption(name string) (OptionValue, error) {
|
||||
result, err := client.SendAndCatch(UpdateData{
|
||||
"@type": "getOption",
|
||||
"name": name,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Data["@type"].(string) == "error" {
|
||||
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
|
||||
}
|
||||
|
||||
switch OptionValueEnum(result.Data["@type"].(string)) {
|
||||
|
||||
case OptionValueBooleanType:
|
||||
var optionValue {optionValueBoolean OptionValueBoolean}
|
||||
err = json.Unmarshal(result.Raw, &optionValue)
|
||||
return &optionValue, err
|
||||
|
||||
case OptionValueEmptyType:
|
||||
var optionValue {optionValueEmpty OptionValueEmpty}
|
||||
err = json.Unmarshal(result.Raw, &optionValue)
|
||||
return &optionValue, err
|
||||
|
||||
case OptionValueIntegerType:
|
||||
var optionValue {optionValueInteger OptionValueInteger}
|
||||
err = json.Unmarshal(result.Raw, &optionValue)
|
||||
return &optionValue, err
|
||||
|
||||
case OptionValueStringType:
|
||||
var optionValue {optionValueString OptionValueString}
|
||||
err = json.Unmarshal(result.Raw, &optionValue)
|
||||
return &optionValue, err
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid type")
|
||||
}
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue