Skip to content

Commit

Permalink
[NEW] update to layeer 133 and update lib to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
KaoriEl committed Dec 23, 2021
1 parent 2277d0f commit 9da5185
Show file tree
Hide file tree
Showing 434 changed files with 53,949 additions and 82 deletions.
29 changes: 29 additions & 0 deletions client/accountTTL.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// AUTOGENERATED - DO NOT EDIT

package client

import (
"encoding/json"

"github.com/kaoriEl/go-tdlib/tdlib"
)

// GetAccountTTL Returns the period of inactivity after which the account of the current user will automatically be deleted
func (client *Client) GetAccountTTL() (*tdlib.AccountTTL, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getAccountTtl",
})

if err != nil {
return nil, err
}

if result.Data["@type"].(string) == "error" {
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}

var accountTTL tdlib.AccountTTL
err = json.Unmarshal(result.Raw, &accountTTL)
return &accountTTL, err

}
29 changes: 29 additions & 0 deletions client/animations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// AUTOGENERATED - DO NOT EDIT

package client

import (
"encoding/json"

"github.com/kaoriEl/go-tdlib/tdlib"
)

// GetSavedAnimations Returns saved animations
func (client *Client) GetSavedAnimations() (*tdlib.Animations, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getSavedAnimations",
})

if err != nil {
return nil, err
}

if result.Data["@type"].(string) == "error" {
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}

var animations tdlib.Animations
err = json.Unmarshal(result.Raw, &animations)
return &animations, err

}
143 changes: 143 additions & 0 deletions client/authenticationCodeInfo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
// AUTOGENERATED - DO NOT EDIT

package client

import (
"encoding/json"

"github.com/kaoriEl/go-tdlib/tdlib"
)

// 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 *tdlib.PhoneNumberAuthenticationSettings) (*tdlib.AuthenticationCodeInfo, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "changePhoneNumber",
"phone_number": phoneNumber,
"settings": settings,
})

if err != nil {
return nil, err
}

if result.Data["@type"].(string) == "error" {
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}

var authenticationCodeInfo tdlib.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 current user. Works only if the previously received authenticationCodeInfo next_code_type was not null and the server-specified timeout has passed
func (client *Client) ResendChangePhoneNumberCode() (*tdlib.AuthenticationCodeInfo, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "resendChangePhoneNumberCode",
})

if err != nil {
return nil, err
}

if result.Data["@type"].(string) == "error" {
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}

var authenticationCodeInfo tdlib.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 *tdlib.PhoneNumberAuthenticationSettings) (*tdlib.AuthenticationCodeInfo, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "sendPhoneNumberVerificationCode",
"phone_number": phoneNumber,
"settings": settings,
})

if err != nil {
return nil, err
}

if result.Data["@type"].(string) == "error" {
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}

var authenticationCodeInfo tdlib.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() (*tdlib.AuthenticationCodeInfo, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "resendPhoneNumberVerificationCode",
})

if err != nil {
return nil, err
}

if result.Data["@type"].(string) == "error" {
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}

var authenticationCodeInfo tdlib.AuthenticationCodeInfo
err = json.Unmarshal(result.Raw, &authenticationCodeInfo)
return &authenticationCodeInfo, err

}

// SendPhoneNumberConfirmationCode Sends phone number confirmation code to handle links of the type internalLinkTypePhoneNumberConfirmation
// @param hash Hash value from the link
// @param phoneNumber Phone number value from the link
// @param settings Settings for the authentication of the user's phone number
func (client *Client) SendPhoneNumberConfirmationCode(hash string, phoneNumber string, settings *tdlib.PhoneNumberAuthenticationSettings) (*tdlib.AuthenticationCodeInfo, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "sendPhoneNumberConfirmationCode",
"hash": hash,
"phone_number": phoneNumber,
"settings": settings,
})

if err != nil {
return nil, err
}

if result.Data["@type"].(string) == "error" {
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}

var authenticationCodeInfo tdlib.AuthenticationCodeInfo
err = json.Unmarshal(result.Raw, &authenticationCodeInfo)
return &authenticationCodeInfo, err

}

// ResendPhoneNumberConfirmationCode Resends phone number confirmation code
func (client *Client) ResendPhoneNumberConfirmationCode() (*tdlib.AuthenticationCodeInfo, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "resendPhoneNumberConfirmationCode",
})

if err != nil {
return nil, err
}

if result.Data["@type"].(string) == "error" {
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}

var authenticationCodeInfo tdlib.AuthenticationCodeInfo
err = json.Unmarshal(result.Raw, &authenticationCodeInfo)
return &authenticationCodeInfo, err

}
86 changes: 86 additions & 0 deletions client/authorizationState.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// AUTOGENERATED - DO NOT EDIT

package client

import (
"encoding/json"
"fmt"

"github.com/kaoriEl/go-tdlib/tdlib"
)

// 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() (tdlib.AuthorizationState, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getAuthorizationState",
})

if err != nil {
return nil, err
}

if result.Data["@type"].(string) == "error" {
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}

switch tdlib.AuthorizationStateEnum(result.Data["@type"].(string)) {

case tdlib.AuthorizationStateWaitTdlibParametersType:
var authorizationState tdlib.AuthorizationStateWaitTdlibParameters
err = json.Unmarshal(result.Raw, &authorizationState)
return &authorizationState, err

case tdlib.AuthorizationStateWaitEncryptionKeyType:
var authorizationState tdlib.AuthorizationStateWaitEncryptionKey
err = json.Unmarshal(result.Raw, &authorizationState)
return &authorizationState, err

case tdlib.AuthorizationStateWaitPhoneNumberType:
var authorizationState tdlib.AuthorizationStateWaitPhoneNumber
err = json.Unmarshal(result.Raw, &authorizationState)
return &authorizationState, err

case tdlib.AuthorizationStateWaitCodeType:
var authorizationState tdlib.AuthorizationStateWaitCode
err = json.Unmarshal(result.Raw, &authorizationState)
return &authorizationState, err

case tdlib.AuthorizationStateWaitOtherDeviceConfirmationType:
var authorizationState tdlib.AuthorizationStateWaitOtherDeviceConfirmation
err = json.Unmarshal(result.Raw, &authorizationState)
return &authorizationState, err

case tdlib.AuthorizationStateWaitRegistrationType:
var authorizationState tdlib.AuthorizationStateWaitRegistration
err = json.Unmarshal(result.Raw, &authorizationState)
return &authorizationState, err

case tdlib.AuthorizationStateWaitPasswordType:
var authorizationState tdlib.AuthorizationStateWaitPassword
err = json.Unmarshal(result.Raw, &authorizationState)
return &authorizationState, err

case tdlib.AuthorizationStateReadyType:
var authorizationState tdlib.AuthorizationStateReady
err = json.Unmarshal(result.Raw, &authorizationState)
return &authorizationState, err

case tdlib.AuthorizationStateLoggingOutType:
var authorizationState tdlib.AuthorizationStateLoggingOut
err = json.Unmarshal(result.Raw, &authorizationState)
return &authorizationState, err

case tdlib.AuthorizationStateClosingType:
var authorizationState tdlib.AuthorizationStateClosing
err = json.Unmarshal(result.Raw, &authorizationState)
return &authorizationState, err

case tdlib.AuthorizationStateClosedType:
var authorizationState tdlib.AuthorizationStateClosed
err = json.Unmarshal(result.Raw, &authorizationState)
return &authorizationState, err

default:
return nil, fmt.Errorf("Invalid type")
}
}
29 changes: 29 additions & 0 deletions client/autoDownloadSettingsPresets.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// AUTOGENERATED - DO NOT EDIT

package client

import (
"encoding/json"

"github.com/kaoriEl/go-tdlib/tdlib"
)

// GetAutoDownloadSettingsPresets Returns auto-download settings presets for the current user
func (client *Client) GetAutoDownloadSettingsPresets() (*tdlib.AutoDownloadSettingsPresets, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getAutoDownloadSettingsPresets",
})

if err != nil {
return nil, err
}

if result.Data["@type"].(string) == "error" {
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}

var autoDownloadSettingsPresets tdlib.AutoDownloadSettingsPresets
err = json.Unmarshal(result.Raw, &autoDownloadSettingsPresets)
return &autoDownloadSettingsPresets, err

}
57 changes: 57 additions & 0 deletions client/background.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// AUTOGENERATED - DO NOT EDIT

package client

import (
"encoding/json"

"github.com/kaoriEl/go-tdlib/tdlib"
)

// SearchBackground Searches for a background by its name
// @param name The name of the background
func (client *Client) SearchBackground(name string) (*tdlib.Background, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "searchBackground",
"name": name,
})

if err != nil {
return nil, err
}

if result.Data["@type"].(string) == "error" {
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}

var background tdlib.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. Pass null to create a new filled backgrounds. Pass null to remove the current background
// @param typeParam Background type. Pass null to use default type of the remote background. Pass null to remove the current background
// @param forDarkTheme True, if the background is chosen for dark theme
func (client *Client) SetBackground(background tdlib.InputBackground, typeParam tdlib.BackgroundType, forDarkTheme bool) (*tdlib.Background, error) {
result, err := client.SendAndCatch(tdlib.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, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}

var backgroundDummy tdlib.Background
err = json.Unmarshal(result.Raw, &backgroundDummy)
return &backgroundDummy, err

}
Loading

0 comments on commit 9da5185

Please sign in to comment.