Merge pull request #96 from ffenix113/layer-133

Layer 133
This commit is contained in:
Arman Safikhani 2022-01-14 12:03:52 +00:00 committed by GitHub
commit 3b65411f19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
249 changed files with 7395 additions and 1666 deletions

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetAccountTTL Returns the period of inactivity after which the account of the current user will automatically be deleted
@ -20,7 +19,7 @@ func (client *Client) GetAccountTTL() (*tdlib.AccountTTL, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var accountTTL tdlib.AccountTTL

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetSavedAnimations Returns saved animations
@ -20,7 +19,7 @@ func (client *Client) GetSavedAnimations() (*tdlib.Animations, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var animations tdlib.Animations

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/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
@ -24,7 +23,7 @@ func (client *Client) ChangePhoneNumber(phoneNumber string, settings *tdlib.Phon
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var authenticationCodeInfo tdlib.AuthenticationCodeInfo
@ -33,7 +32,7 @@ func (client *Client) ChangePhoneNumber(phoneNumber string, settings *tdlib.Phon
}
// 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
// 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",
@ -44,7 +43,7 @@ func (client *Client) ResendChangePhoneNumberCode() (*tdlib.AuthenticationCodeIn
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var authenticationCodeInfo tdlib.AuthenticationCodeInfo
@ -68,7 +67,7 @@ func (client *Client) SendPhoneNumberVerificationCode(phoneNumber string, settin
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var authenticationCodeInfo tdlib.AuthenticationCodeInfo
@ -88,7 +87,7 @@ func (client *Client) ResendPhoneNumberVerificationCode() (*tdlib.Authentication
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var authenticationCodeInfo tdlib.AuthenticationCodeInfo
@ -97,9 +96,9 @@ func (client *Client) ResendPhoneNumberVerificationCode() (*tdlib.Authentication
}
// 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
// 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{
@ -114,7 +113,7 @@ func (client *Client) SendPhoneNumberConfirmationCode(hash string, phoneNumber s
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var authenticationCodeInfo tdlib.AuthenticationCodeInfo
@ -134,7 +133,7 @@ func (client *Client) ResendPhoneNumberConfirmationCode() (*tdlib.Authentication
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var authenticationCodeInfo tdlib.AuthenticationCodeInfo

View File

@ -6,7 +6,7 @@ import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/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
@ -20,7 +20,7 @@ func (client *Client) GetAuthorizationState() (tdlib.AuthorizationState, error)
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
switch tdlib.AuthorizationStateEnum(result.Data["@type"].(string)) {

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetAutoDownloadSettingsPresets Returns auto-download settings presets for the current user
@ -20,7 +19,7 @@ func (client *Client) GetAutoDownloadSettingsPresets() (*tdlib.AutoDownloadSetti
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var autoDownloadSettingsPresets tdlib.AutoDownloadSettingsPresets

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// SearchBackground Searches for a background by its name
@ -22,7 +21,7 @@ func (client *Client) SearchBackground(name string) (*tdlib.Background, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var background tdlib.Background
@ -32,8 +31,8 @@ func (client *Client) SearchBackground(name string) (*tdlib.Background, error) {
}
// 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 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{
@ -48,7 +47,7 @@ func (client *Client) SetBackground(background tdlib.InputBackground, typeParam
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var backgroundDummy tdlib.Background

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetBackgrounds Returns backgrounds installed by the user
@ -22,7 +21,7 @@ func (client *Client) GetBackgrounds(forDarkTheme bool) (*tdlib.Backgrounds, err
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var backgrounds tdlib.Backgrounds

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetBankCardInfo Returns information about a bank card
@ -22,7 +21,7 @@ func (client *Client) GetBankCardInfo(bankCardNumber string) (*tdlib.BankCardInf
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var bankCardInfo tdlib.BankCardInfo

View File

@ -4,14 +4,13 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetBasicGroup Returns information about a basic group by its identifier. This is an offline request if the current user is not a bot
// @param basicGroupID Basic group identifier
func (client *Client) GetBasicGroup(basicGroupID int32) (*tdlib.BasicGroup, error) {
func (client *Client) GetBasicGroup(basicGroupID int64) (*tdlib.BasicGroup, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getBasicGroup",
"basic_group_id": basicGroupID,
@ -22,7 +21,7 @@ func (client *Client) GetBasicGroup(basicGroupID int32) (*tdlib.BasicGroup, erro
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var basicGroupDummy tdlib.BasicGroup

View File

@ -4,14 +4,13 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetBasicGroupFullInfo Returns full information about a basic group by its identifier
// @param basicGroupID Basic group identifier
func (client *Client) GetBasicGroupFullInfo(basicGroupID int32) (*tdlib.BasicGroupFullInfo, error) {
func (client *Client) GetBasicGroupFullInfo(basicGroupID int64) (*tdlib.BasicGroupFullInfo, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getBasicGroupFullInfo",
"basic_group_id": basicGroupID,
@ -22,7 +21,7 @@ func (client *Client) GetBasicGroupFullInfo(basicGroupID int32) (*tdlib.BasicGro
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var basicGroupFullInfo tdlib.BasicGroupFullInfo

33
client/botCommands.go Executable file
View File

@ -0,0 +1,33 @@
// AUTOGENERATED - DO NOT EDIT
package client
import (
"encoding/json"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetCommands Returns the list of commands supported by the bot for the given user scope and language; for bots only
// @param scope The scope to which the commands are relevant
// @param languageCode A two-letter ISO 639-1 country code or an empty string
func (client *Client) GetCommands(scope tdlib.BotCommandScope, languageCode string) (*tdlib.BotCommands, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getCommands",
"scope": scope,
"language_code": languageCode,
})
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 botCommands tdlib.BotCommands
err = json.Unmarshal(result.Raw, &botCommands)
return &botCommands, err
}

View File

@ -4,16 +4,15 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// CreateCall Creates a new call
// @param userID Identifier of the user to be called
// @param protocol Description of the call protocols supported by the application
// @param isVideo True, if a video call needs to be created
func (client *Client) CreateCall(userID int32, protocol *tdlib.CallProtocol, isVideo bool) (*tdlib.CallID, error) {
func (client *Client) CreateCall(userID int64, protocol *tdlib.CallProtocol, isVideo bool) (*tdlib.CallID, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "createCall",
"user_id": userID,
@ -26,7 +25,7 @@ func (client *Client) CreateCall(userID int32, protocol *tdlib.CallProtocol, isV
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var callID tdlib.CallID

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetCallbackQueryAnswer Sends a callback query to a bot and returns an answer. Returns an error with code 502 if the bot fails to answer the query before the query timeout expires
@ -26,7 +25,7 @@ func (client *Client) GetCallbackQueryAnswer(chatID int64, messageID int64, payl
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var callbackQueryAnswer tdlib.CallbackQueryAnswer

View File

@ -6,7 +6,7 @@ import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// CanTransferOwnership Checks whether the current session can be used to transfer a chat ownership to another user
@ -20,7 +20,7 @@ func (client *Client) CanTransferOwnership() (tdlib.CanTransferOwnershipResult,
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
switch tdlib.CanTransferOwnershipResultEnum(result.Data["@type"].(string)) {

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetChat Returns information about a chat by its identifier, this is an offline request if the current user is not a bot
@ -22,7 +21,7 @@ func (client *Client) GetChat(chatID int64) (*tdlib.Chat, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chatDummy tdlib.Chat
@ -44,7 +43,7 @@ func (client *Client) SearchPublicChat(username string) (*tdlib.Chat, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chat tdlib.Chat
@ -56,7 +55,7 @@ func (client *Client) SearchPublicChat(username string) (*tdlib.Chat, error) {
// CreatePrivateChat Returns an existing chat corresponding to a given user
// @param userID User identifier
// @param force If true, the chat will be created without network request. In this case all information about the chat except its type, title and photo can be incorrect
func (client *Client) CreatePrivateChat(userID int32, force bool) (*tdlib.Chat, error) {
func (client *Client) CreatePrivateChat(userID int64, force bool) (*tdlib.Chat, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "createPrivateChat",
"user_id": userID,
@ -68,7 +67,7 @@ func (client *Client) CreatePrivateChat(userID int32, force bool) (*tdlib.Chat,
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chat tdlib.Chat
@ -80,7 +79,7 @@ func (client *Client) CreatePrivateChat(userID int32, force bool) (*tdlib.Chat,
// CreateBasicGroupChat Returns an existing chat corresponding to a known basic group
// @param basicGroupID Basic group identifier
// @param force If true, the chat will be created without network request. In this case all information about the chat except its type, title and photo can be incorrect
func (client *Client) CreateBasicGroupChat(basicGroupID int32, force bool) (*tdlib.Chat, error) {
func (client *Client) CreateBasicGroupChat(basicGroupID int64, force bool) (*tdlib.Chat, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "createBasicGroupChat",
"basic_group_id": basicGroupID,
@ -92,7 +91,7 @@ func (client *Client) CreateBasicGroupChat(basicGroupID int32, force bool) (*tdl
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chat tdlib.Chat
@ -104,7 +103,7 @@ func (client *Client) CreateBasicGroupChat(basicGroupID int32, force bool) (*tdl
// CreateSupergroupChat Returns an existing chat corresponding to a known supergroup or channel
// @param supergroupID Supergroup or channel identifier
// @param force If true, the chat will be created without network request. In this case all information about the chat except its type, title and photo can be incorrect
func (client *Client) CreateSupergroupChat(supergroupID int32, force bool) (*tdlib.Chat, error) {
func (client *Client) CreateSupergroupChat(supergroupID int64, force bool) (*tdlib.Chat, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "createSupergroupChat",
"supergroup_id": supergroupID,
@ -116,7 +115,7 @@ func (client *Client) CreateSupergroupChat(supergroupID int32, force bool) (*tdl
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chat tdlib.Chat
@ -138,7 +137,7 @@ func (client *Client) CreateSecretChat(secretChatID int32) (*tdlib.Chat, error)
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chatDummy tdlib.Chat
@ -150,7 +149,7 @@ func (client *Client) CreateSecretChat(secretChatID int32) (*tdlib.Chat, error)
// CreateNewBasicGroupChat Creates a new basic group and sends a corresponding messageBasicGroupChatCreate. Returns the newly created chat
// @param userIDs Identifiers of users to be added to the basic group
// @param title Title of the new basic group; 1-128 characters
func (client *Client) CreateNewBasicGroupChat(userIDs []int32, title string) (*tdlib.Chat, error) {
func (client *Client) CreateNewBasicGroupChat(userIDs []int64, title string) (*tdlib.Chat, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "createNewBasicGroupChat",
"user_ids": userIDs,
@ -162,7 +161,7 @@ func (client *Client) CreateNewBasicGroupChat(userIDs []int32, title string) (*t
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chat tdlib.Chat
@ -173,16 +172,18 @@ func (client *Client) CreateNewBasicGroupChat(userIDs []int32, title string) (*t
// CreateNewSupergroupChat Creates a new supergroup or channel and sends a corresponding messageSupergroupChatCreate. Returns the newly created chat
// @param title Title of the new chat; 1-128 characters
// @param isChannel True, if a channel chat should be created
// @param isChannel True, if a channel chat needs to be created
// @param description Chat description; 0-255 characters
// @param location Chat location if a location-based supergroup is being created
func (client *Client) CreateNewSupergroupChat(title string, isChannel bool, description string, location *tdlib.ChatLocation) (*tdlib.Chat, error) {
// @param forImport True, if the supergroup is created for importing messages using importMessage
func (client *Client) CreateNewSupergroupChat(title string, isChannel bool, description string, location *tdlib.ChatLocation, forImport bool) (*tdlib.Chat, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "createNewSupergroupChat",
"title": title,
"is_channel": isChannel,
"description": description,
"location": location,
"for_import": forImport,
})
if err != nil {
@ -190,7 +191,7 @@ func (client *Client) CreateNewSupergroupChat(title string, isChannel bool, desc
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chat tdlib.Chat
@ -201,7 +202,7 @@ func (client *Client) CreateNewSupergroupChat(title string, isChannel bool, desc
// CreateNewSecretChat Creates a new secret chat. Returns the newly created chat
// @param userID Identifier of the target user
func (client *Client) CreateNewSecretChat(userID int32) (*tdlib.Chat, error) {
func (client *Client) CreateNewSecretChat(userID int64) (*tdlib.Chat, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "createNewSecretChat",
"user_id": userID,
@ -212,7 +213,7 @@ func (client *Client) CreateNewSecretChat(userID int32) (*tdlib.Chat, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chat tdlib.Chat
@ -234,7 +235,7 @@ func (client *Client) UpgradeBasicGroupChatToSupergroupChat(chatID int64) (*tdli
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chatDummy tdlib.Chat
@ -243,8 +244,8 @@ func (client *Client) UpgradeBasicGroupChatToSupergroupChat(chatID int64) (*tdli
}
// JoinChatByInviteLink Uses an invite link to add the current user to the chat if possible. The new member will not be added until the chat state has been synchronized with the server
// @param inviteLink Invite link to import; should begin with "https://t.me/joinchat/", "https://telegram.me/joinchat/", or "https://telegram.dog/joinchat/"
// JoinChatByInviteLink Uses an invite link to add the current user to the chat if possible
// @param inviteLink Invite link to use
func (client *Client) JoinChatByInviteLink(inviteLink string) (*tdlib.Chat, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "joinChatByInviteLink",
@ -256,7 +257,7 @@ func (client *Client) JoinChatByInviteLink(inviteLink string) (*tdlib.Chat, erro
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chat tdlib.Chat

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetChatAdministrators Returns a list of administrators of the chat with their custom titles
@ -22,7 +21,7 @@ func (client *Client) GetChatAdministrators(chatID int64) (*tdlib.ChatAdministra
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chatAdministrators tdlib.ChatAdministrators

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// 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)
@ -16,7 +15,7 @@ import (
// @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 *tdlib.JSONInt64, limit int32, filters *tdlib.ChatEventLogFilters, userIDs []int32) (*tdlib.ChatEvents, error) {
func (client *Client) GetChatEventLog(chatID int64, query string, fromEventID *tdlib.JSONInt64, limit int32, filters *tdlib.ChatEventLogFilters, userIDs []int64) (*tdlib.ChatEvents, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getChatEventLog",
"chat_id": chatID,
@ -32,7 +31,7 @@ func (client *Client) GetChatEventLog(chatID int64, query string, fromEventID *t
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chatEvents tdlib.ChatEvents

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetChatFilter Returns information about a chat filter by its identifier
@ -22,7 +21,7 @@ func (client *Client) GetChatFilter(chatFilterID int32) (*tdlib.ChatFilter, erro
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chatFilterDummy tdlib.ChatFilter

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// CreateChatFilter Creates new chat filter. Returns information about the created chat filter
@ -22,7 +21,7 @@ func (client *Client) CreateChatFilter(filter *tdlib.ChatFilter) (*tdlib.ChatFil
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chatFilterInfo tdlib.ChatFilterInfo
@ -46,7 +45,7 @@ func (client *Client) EditChatFilter(chatFilterID int32, filter *tdlib.ChatFilte
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chatFilterInfo tdlib.ChatFilterInfo

View File

@ -4,16 +4,15 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GenerateChatInviteLink Generates a new invite link for a chat; the previously generated link is revoked. Available for basic groups, supergroups, and channels. Requires administrator privileges and can_invite_users right
// ReplacePrimaryChatInviteLink Replaces current primary invite link for a chat with a new primary invite link. Available for basic groups, supergroups, and channels. Requires administrator privileges and can_invite_users right
// @param chatID Chat identifier
func (client *Client) GenerateChatInviteLink(chatID int64) (*tdlib.ChatInviteLink, error) {
func (client *Client) ReplacePrimaryChatInviteLink(chatID int64) (*tdlib.ChatInviteLink, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "generateChatInviteLink",
"@type": "replacePrimaryChatInviteLink",
"chat_id": chatID,
})
@ -22,7 +21,85 @@ func (client *Client) GenerateChatInviteLink(chatID int64) (*tdlib.ChatInviteLin
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chatInviteLink tdlib.ChatInviteLink
err = json.Unmarshal(result.Raw, &chatInviteLink)
return &chatInviteLink, err
}
// CreateChatInviteLink Creates a new invite link for a chat. Available for basic groups, supergroups, and channels. Requires administrator privileges and can_invite_users right in the chat
// @param chatID Chat identifier
// @param expireDate Point in time (Unix timestamp) when the link will expire; pass 0 if never
// @param memberLimit The maximum number of chat members that can join the chat by the link simultaneously; 0-99999; pass 0 if not limited
func (client *Client) CreateChatInviteLink(chatID int64, expireDate int32, memberLimit int32) (*tdlib.ChatInviteLink, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "createChatInviteLink",
"chat_id": chatID,
"expire_date": expireDate,
"member_limit": memberLimit,
})
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 chatInviteLink tdlib.ChatInviteLink
err = json.Unmarshal(result.Raw, &chatInviteLink)
return &chatInviteLink, err
}
// EditChatInviteLink Edits a non-primary invite link for a chat. Available for basic groups, supergroups, and channels. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links
// @param chatID Chat identifier
// @param inviteLink Invite link to be edited
// @param expireDate Point in time (Unix timestamp) when the link will expire; pass 0 if never
// @param memberLimit The maximum number of chat members that can join the chat by the link simultaneously; 0-99999; pass 0 if not limited
func (client *Client) EditChatInviteLink(chatID int64, inviteLink string, expireDate int32, memberLimit int32) (*tdlib.ChatInviteLink, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "editChatInviteLink",
"chat_id": chatID,
"invite_link": inviteLink,
"expire_date": expireDate,
"member_limit": memberLimit,
})
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 chatInviteLink tdlib.ChatInviteLink
err = json.Unmarshal(result.Raw, &chatInviteLink)
return &chatInviteLink, err
}
// GetChatInviteLink Returns information about an invite link. Requires administrator privileges and can_invite_users right in the chat to get own links and owner privileges to get other links
// @param chatID Chat identifier
// @param inviteLink Invite link to get
func (client *Client) GetChatInviteLink(chatID int64, inviteLink string) (*tdlib.ChatInviteLink, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getChatInviteLink",
"chat_id": chatID,
"invite_link": inviteLink,
})
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 chatInviteLink tdlib.ChatInviteLink

31
client/chatInviteLinkCounts.go Executable file
View File

@ -0,0 +1,31 @@
// AUTOGENERATED - DO NOT EDIT
package client
import (
"encoding/json"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetChatInviteLinkCounts Returns list of chat administrators with number of their invite links. Requires owner privileges in the chat
// @param chatID Chat identifier
func (client *Client) GetChatInviteLinkCounts(chatID int64) (*tdlib.ChatInviteLinkCounts, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getChatInviteLinkCounts",
"chat_id": chatID,
})
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 chatInviteLinkCounts tdlib.ChatInviteLinkCounts
err = json.Unmarshal(result.Raw, &chatInviteLinkCounts)
return &chatInviteLinkCounts, err
}

View File

@ -4,13 +4,12 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// CheckChatInviteLink Checks the validity of an invite link for a chat and returns information about the corresponding chat
// @param inviteLink Invite link to be checked; should begin with "https://t.me/joinchat/", "https://telegram.me/joinchat/", or "https://telegram.dog/joinchat/"
// @param inviteLink Invite link to be checked
func (client *Client) CheckChatInviteLink(inviteLink string) (*tdlib.ChatInviteLinkInfo, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "checkChatInviteLink",
@ -22,7 +21,7 @@ func (client *Client) CheckChatInviteLink(inviteLink string) (*tdlib.ChatInviteL
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chatInviteLinkInfo tdlib.ChatInviteLinkInfo

37
client/chatInviteLinkMembers.go Executable file
View File

@ -0,0 +1,37 @@
// AUTOGENERATED - DO NOT EDIT
package client
import (
"encoding/json"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetChatInviteLinkMembers Returns chat members joined a chat by an invite link. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links
// @param chatID Chat identifier
// @param inviteLink Invite link for which to return chat members
// @param offsetMember A chat member from which to return next chat members; use null to get results from the beginning
// @param limit The maximum number of chat members to return
func (client *Client) GetChatInviteLinkMembers(chatID int64, inviteLink string, offsetMember *tdlib.ChatInviteLinkMember, limit int32) (*tdlib.ChatInviteLinkMembers, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getChatInviteLinkMembers",
"chat_id": chatID,
"invite_link": inviteLink,
"offset_member": offsetMember,
"limit": limit,
})
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 chatInviteLinkMembers tdlib.ChatInviteLinkMembers
err = json.Unmarshal(result.Raw, &chatInviteLinkMembers)
return &chatInviteLinkMembers, err
}

65
client/chatInviteLinks.go Executable file
View File

@ -0,0 +1,65 @@
// AUTOGENERATED - DO NOT EDIT
package client
import (
"encoding/json"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetChatInviteLinks Returns invite links for a chat created by specified administrator. Requires administrator privileges and can_invite_users right in the chat to get own links and owner privileges to get other links
// @param chatID Chat identifier
// @param creatorUserID User identifier of a chat administrator. Must be an identifier of the current user for non-owner
// @param isRevoked Pass true if revoked links needs to be returned instead of active or expired
// @param offsetDate Creation date of an invite link starting after which to return invite links; use 0 to get results from the beginning
// @param offsetInviteLink Invite link starting after which to return invite links; use empty string to get results from the beginning
// @param limit The maximum number of invite links to return
func (client *Client) GetChatInviteLinks(chatID int64, creatorUserID int64, isRevoked bool, offsetDate int32, offsetInviteLink string, limit int32) (*tdlib.ChatInviteLinks, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getChatInviteLinks",
"chat_id": chatID,
"creator_user_id": creatorUserID,
"is_revoked": isRevoked,
"offset_date": offsetDate,
"offset_invite_link": offsetInviteLink,
"limit": limit,
})
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 chatInviteLinks tdlib.ChatInviteLinks
err = json.Unmarshal(result.Raw, &chatInviteLinks)
return &chatInviteLinks, err
}
// RevokeChatInviteLink Revokes invite link for a chat. Available for basic groups, supergroups, and channels. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links. If a primary link is revoked, then additionally to the revoked link returns new primary link
// @param chatID Chat identifier
// @param inviteLink Invite link to be revoked
func (client *Client) RevokeChatInviteLink(chatID int64, inviteLink string) (*tdlib.ChatInviteLinks, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "revokeChatInviteLink",
"chat_id": chatID,
"invite_link": inviteLink,
})
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 chatInviteLinks tdlib.ChatInviteLinks
err = json.Unmarshal(result.Raw, &chatInviteLinks)
return &chatInviteLinks, err
}

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetChatListsToAddChat Returns chat lists to which the chat can be added. This is an offline request
@ -22,7 +21,7 @@ func (client *Client) GetChatListsToAddChat(chatID int64) (*tdlib.ChatLists, err
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chatLists tdlib.ChatLists

View File

@ -4,19 +4,18 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetChatMember Returns information about a single member of a chat
// @param chatID Chat identifier
// @param userID User identifier
func (client *Client) GetChatMember(chatID int64, userID int32) (*tdlib.ChatMember, error) {
// @param memberID Member identifier
func (client *Client) GetChatMember(chatID int64, memberID tdlib.MessageSender) (*tdlib.ChatMember, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getChatMember",
"chat_id": chatID,
"user_id": userID,
"@type": "getChatMember",
"chat_id": chatID,
"member_id": memberID,
})
if err != nil {
@ -24,7 +23,7 @@ func (client *Client) GetChatMember(chatID int64, userID int32) (*tdlib.ChatMemb
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chatMember tdlib.ChatMember

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// SearchChatMembers Searches for a specified query in the first name, last name and username of the members of a specified chat. Requires administrator rights in channels
@ -28,7 +27,7 @@ func (client *Client) SearchChatMembers(chatID int64, query string, limit int32,
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chatMembers tdlib.ChatMembers
@ -42,7 +41,7 @@ func (client *Client) SearchChatMembers(chatID int64, query string, limit int32,
// @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 tdlib.SupergroupMembersFilter, offset int32, limit int32) (*tdlib.ChatMembers, error) {
func (client *Client) GetSupergroupMembers(supergroupID int64, filter tdlib.SupergroupMembersFilter, offset int32, limit int32) (*tdlib.ChatMembers, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getSupergroupMembers",
"supergroup_id": supergroupID,
@ -56,7 +55,7 @@ func (client *Client) GetSupergroupMembers(supergroupID int32, filter tdlib.Supe
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chatMembers tdlib.ChatMembers

View File

@ -4,16 +4,15 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetUserProfilePhotos Returns the profile photos of a user. The result of this query may be outdated: some photos might have been deleted already
// @param userID User identifier
// @param offset The number of photos to skip; must be non-negative
// @param limit The maximum number of photos to be returned; up to 100
func (client *Client) GetUserProfilePhotos(userID int32, offset int32, limit int32) (*tdlib.ChatPhotos, error) {
func (client *Client) GetUserProfilePhotos(userID int64, offset int32, limit int32) (*tdlib.ChatPhotos, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getUserProfilePhotos",
"user_id": userID,
@ -26,7 +25,7 @@ func (client *Client) GetUserProfilePhotos(userID int32, offset int32, limit int
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chatPhotos tdlib.ChatPhotos

View File

@ -6,7 +6,7 @@ import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// 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
@ -24,7 +24,7 @@ func (client *Client) GetChatStatistics(chatID int64, isDark bool) (tdlib.ChatSt
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
switch tdlib.ChatStatisticsEnum(result.Data["@type"].(string)) {

View File

@ -4,23 +4,18 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetChats Returns an ordered list of chats in a chat list. Chats are sorted by the pair (chat.position.order, chat.id) in descending order. (For example, to get a list of chats from the beginning, the offset_order should be equal to a biggest signed 64-bit number 9223372036854775807 == 2^63 - 1). For optimal performance the number of returned chats is chosen by the library
// GetChats Returns an ordered list of chats from the beginning of a chat list. For informational purposes only. Use loadChats instead to maintain chat lists
// @param chatList The chat list in which to return chats
// @param offsetOrder Chat order to return chats from
// @param offsetChatID Chat identifier to return chats from
// @param limit The maximum number of chats to be returned. It is possible that fewer chats than the limit are returned even if the end of the list is not reached
func (client *Client) GetChats(chatList tdlib.ChatList, offsetOrder *tdlib.JSONInt64, offsetChatID int64, limit int32) (*tdlib.Chats, error) {
// @param limit The maximum number of chats to be returned
func (client *Client) GetChats(chatList tdlib.ChatList, limit int32) (*tdlib.Chats, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getChats",
"chat_list": chatList,
"offset_order": offsetOrder,
"offset_chat_id": offsetChatID,
"limit": limit,
"@type": "getChats",
"chat_list": chatList,
"limit": limit,
})
if err != nil {
@ -28,7 +23,7 @@ func (client *Client) GetChats(chatList tdlib.ChatList, offsetOrder *tdlib.JSONI
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chats tdlib.Chats
@ -50,7 +45,7 @@ func (client *Client) SearchPublicChats(query string) (*tdlib.Chats, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chats tdlib.Chats
@ -60,7 +55,7 @@ func (client *Client) SearchPublicChats(query string) (*tdlib.Chats, error) {
}
// SearchChats Searches for the specified query in the title and username of already known chats, this is an offline request. Returns chats in the order seen in the main chat list
// @param query Query to search for. If the query is empty, returns up to 20 recently found chats
// @param query Query to search for. If the query is empty, returns up to 50 recently found chats
// @param limit The maximum number of chats to be returned
func (client *Client) SearchChats(query string, limit int32) (*tdlib.Chats, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
@ -74,7 +69,7 @@ func (client *Client) SearchChats(query string, limit int32) (*tdlib.Chats, erro
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chats tdlib.Chats
@ -98,7 +93,7 @@ func (client *Client) SearchChatsOnServer(query string, limit int32) (*tdlib.Cha
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chats tdlib.Chats
@ -122,7 +117,29 @@ func (client *Client) GetTopChats(category tdlib.TopChatCategory, limit int32) (
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chats tdlib.Chats
err = json.Unmarshal(result.Raw, &chats)
return &chats, err
}
// GetRecentlyOpenedChats Returns recently opened chats, this is an offline request. Returns chats in the order of last opening
// @param limit The maximum number of chats to be returned
func (client *Client) GetRecentlyOpenedChats(limit int32) (*tdlib.Chats, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getRecentlyOpenedChats",
"limit": limit,
})
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 chats tdlib.Chats
@ -144,7 +161,7 @@ func (client *Client) GetCreatedPublicChats(typeParam tdlib.PublicChatType) (*td
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chats tdlib.Chats
@ -164,7 +181,7 @@ func (client *Client) GetSuitableDiscussionChats() (*tdlib.Chats, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chats tdlib.Chats
@ -184,7 +201,7 @@ func (client *Client) GetInactiveSupergroupChats() (*tdlib.Chats, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chats tdlib.Chats
@ -197,7 +214,7 @@ func (client *Client) GetInactiveSupergroupChats() (*tdlib.Chats, error) {
// @param userID User identifier
// @param offsetChatID Chat identifier starting from which to return chats; use 0 for the first request
// @param limit The maximum number of chats to be returned; up to 100
func (client *Client) GetGroupsInCommon(userID int32, offsetChatID int64, limit int32) (*tdlib.Chats, error) {
func (client *Client) GetGroupsInCommon(userID int64, offsetChatID int64, limit int32) (*tdlib.Chats, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getGroupsInCommon",
"user_id": userID,
@ -210,7 +227,7 @@ func (client *Client) GetGroupsInCommon(userID int32, offsetChatID int64, limit
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chats tdlib.Chats
@ -234,7 +251,7 @@ func (client *Client) GetChatNotificationSettingsExceptions(scope tdlib.Notifica
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chats tdlib.Chats

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// SearchChatsNearby Returns a list of users and location-based supergroups nearby. The list of users nearby will be updated for 60 seconds after the request by the updates updateUsersNearby. The request should be sent again every 25 seconds with adjusted location to not miss new chats
@ -22,7 +21,7 @@ func (client *Client) SearchChatsNearby(location *tdlib.Location) (*tdlib.ChatsN
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var chatsNearby tdlib.ChatsNearby

View File

@ -6,11 +6,11 @@ import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// 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 chatID Chat identifier; should be identifier of a supergroup chat, or a channel chat, or a private chat with self, or zero if the chat is being created
// @param username Username to be checked
func (client *Client) CheckChatUsername(chatID int64, username string) (tdlib.CheckChatUsernameResult, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
@ -24,7 +24,7 @@ func (client *Client) CheckChatUsername(chatID int64, username string) (tdlib.Ch
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
switch tdlib.CheckChatUsernameResultEnum(result.Data["@type"].(string)) {

View File

@ -0,0 +1,48 @@
// AUTOGENERATED - DO NOT EDIT
package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// CheckStickerSetName Checks whether a name can be used for a new sticker set
// @param name Name to be checked
func (client *Client) CheckStickerSetName(name string) (tdlib.CheckStickerSetNameResult, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "checkStickerSetName",
"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)}
}
switch tdlib.CheckStickerSetNameResultEnum(result.Data["@type"].(string)) {
case tdlib.CheckStickerSetNameResultOkType:
var checkStickerSetNameResult tdlib.CheckStickerSetNameResultOk
err = json.Unmarshal(result.Raw, &checkStickerSetNameResult)
return &checkStickerSetNameResult, err
case tdlib.CheckStickerSetNameResultNameInvalidType:
var checkStickerSetNameResult tdlib.CheckStickerSetNameResultNameInvalid
err = json.Unmarshal(result.Raw, &checkStickerSetNameResult)
return &checkStickerSetNameResult, err
case tdlib.CheckStickerSetNameResultNameOccupiedType:
var checkStickerSetNameResult tdlib.CheckStickerSetNameResultNameOccupied
err = json.Unmarshal(result.Raw, &checkStickerSetNameResult)
return &checkStickerSetNameResult, err
default:
return nil, fmt.Errorf("Invalid type")
}
}

View File

@ -21,7 +21,7 @@ import (
"time"
"unsafe"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// EventFilterFunc used to filter out unwanted messages in receiver channels

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetConnectedWebsites Returns all website where the current user used Telegram to log in
@ -20,7 +19,7 @@ func (client *Client) GetConnectedWebsites() (*tdlib.ConnectedWebsites, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var connectedWebsites tdlib.ConnectedWebsites

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetChatMessageCount Returns approximate number of messages of the specified type in the chat
@ -26,7 +25,7 @@ func (client *Client) GetChatMessageCount(chatID int64, filter tdlib.SearchMessa
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var count tdlib.Count
@ -35,7 +34,7 @@ func (client *Client) GetChatMessageCount(chatID int64, filter tdlib.SearchMessa
}
// GetFileDownloadedPrefixSize Returns file downloaded prefix size from a given offset
// GetFileDownloadedPrefixSize Returns file downloaded prefix size from a given offset, in bytes
// @param fileID Identifier of the file
// @param offset Offset from which downloaded prefix size should be calculated
func (client *Client) GetFileDownloadedPrefixSize(fileID int32, offset int32) (*tdlib.Count, error) {
@ -50,7 +49,7 @@ func (client *Client) GetFileDownloadedPrefixSize(fileID int32, offset int32) (*
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var count tdlib.Count
@ -70,7 +69,7 @@ func (client *Client) GetImportedContactCount() (*tdlib.Count, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var count tdlib.Count

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetCountries Returns information about existing countries. Can be called before authorization
@ -20,7 +19,7 @@ func (client *Client) GetCountries() (*tdlib.Countries, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var countries tdlib.Countries

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// SendCustomRequest Sends a custom request; for bots only
@ -24,7 +23,7 @@ func (client *Client) SendCustomRequest(method string, parameters string) (*tdli
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var customRequestResult tdlib.CustomRequestResult

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetDatabaseStatistics Returns database statistics
@ -20,7 +19,7 @@ func (client *Client) GetDatabaseStatistics() (*tdlib.DatabaseStatistics, error)
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var databaseStatistics tdlib.DatabaseStatistics

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// 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
@ -22,7 +21,7 @@ func (client *Client) GetDeepLinkInfo(link string) (*tdlib.DeepLinkInfo, error)
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var deepLinkInfo tdlib.DeepLinkInfo

View File

@ -4,12 +4,11 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// RequestPasswordRecovery Requests to send a password recovery code to an email address that was previously set up
// RequestPasswordRecovery Requests to send a 2-step verification password recovery code to an email address that was previously set up
func (client *Client) RequestPasswordRecovery() (*tdlib.EmailAddressAuthenticationCodeInfo, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "requestPasswordRecovery",
@ -20,7 +19,7 @@ func (client *Client) RequestPasswordRecovery() (*tdlib.EmailAddressAuthenticati
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var emailAddressAuthenticationCodeInfo tdlib.EmailAddressAuthenticationCodeInfo
@ -42,7 +41,7 @@ func (client *Client) SendEmailAddressVerificationCode(emailAddress string) (*td
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var emailAddressAuthenticationCodeInfo tdlib.EmailAddressAuthenticationCodeInfo
@ -62,7 +61,7 @@ func (client *Client) ResendEmailAddressVerificationCode() (*tdlib.EmailAddressA
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var emailAddressAuthenticationCodeInfo tdlib.EmailAddressAuthenticationCodeInfo

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// 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
@ -22,7 +21,7 @@ func (client *Client) GetStickerEmojis(sticker tdlib.InputFile) (*tdlib.Emojis,
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var emojis tdlib.Emojis
@ -48,7 +47,7 @@ func (client *Client) SearchEmojis(text string, exactMatch bool, inputLanguageCo
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var emojis tdlib.Emojis

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// TestReturnError Returns the specified error and ensures that the Error object is used; for testing only. Can be called synchronously
@ -22,7 +21,7 @@ func (client *Client) TestReturnError(error *tdlib.Error) (*tdlib.Error, error)
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var errorDummy tdlib.Error

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetFile Returns information about a file; this is an offline request
@ -22,7 +21,7 @@ func (client *Client) GetFile(fileID int32) (*tdlib.File, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var fileDummy tdlib.File
@ -46,7 +45,7 @@ func (client *Client) GetRemoteFile(remoteFileID string, fileType tdlib.FileType
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var fileDummy tdlib.File
@ -59,8 +58,8 @@ func (client *Client) GetRemoteFile(remoteFileID string, fileType tdlib.FileType
// @param fileID Identifier of the file to download
// @param priority Priority of the download (1-32). The higher the priority, the earlier the file will be downloaded. If the priorities of two files are equal, then the last one for which downloadFile was called will be downloaded first
// @param offset The starting position from which the file should be downloaded
// @param limit Number of bytes which should be downloaded starting from the "offset" position before the download will be automatically cancelled; use 0 to download without a limit
// @param synchronous If false, this request returns file state just after the download has been started. If true, this request returns file state only after the download has succeeded, has failed, has been cancelled or a new downloadFile request with different offset/limit parameters was sent
// @param limit Number of bytes which should be downloaded starting from the "offset" position before the download will be automatically canceled; use 0 to download without a limit
// @param synchronous If false, this request returns file state just after the download has been started. If true, this request returns file state only after the download has succeeded, has failed, has been canceled or a new downloadFile request with different offset/limit parameters was sent
func (client *Client) DownloadFile(fileID int32, priority int32, offset int32, limit int32, synchronous bool) (*tdlib.File, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "downloadFile",
@ -76,7 +75,7 @@ func (client *Client) DownloadFile(fileID int32, priority int32, offset int32, l
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var fileDummy tdlib.File
@ -102,7 +101,7 @@ func (client *Client) UploadFile(file tdlib.InputFile, fileType tdlib.FileType,
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var fileDummy tdlib.File
@ -111,14 +110,14 @@ func (client *Client) UploadFile(file tdlib.InputFile, fileType tdlib.FileType,
}
// 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 tdlib.InputFile) (*tdlib.File, error) {
// UploadStickerFile Uploads a PNG image with a sticker; returns the uploaded file
// @param userID Sticker file owner; ignored for regular users
// @param sticker Sticker file to upload
func (client *Client) UploadStickerFile(userID int64, sticker tdlib.InputSticker) (*tdlib.File, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "uploadStickerFile",
"user_id": userID,
"png_sticker": pngSticker,
"@type": "uploadStickerFile",
"user_id": userID,
"sticker": sticker,
})
if err != nil {
@ -126,7 +125,7 @@ func (client *Client) UploadStickerFile(userID int32, pngSticker tdlib.InputFile
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var file tdlib.File
@ -158,7 +157,7 @@ func (client *Client) GetMapThumbnailFile(location *tdlib.Location, zoom int32,
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var file tdlib.File

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// ReadFilePart Reads a part of a file from the TDLib file cache and returns read bytes. This method is intended to be used only if the application has no direct access to TDLib's file system, because it is usually slower than a direct read from the file
@ -26,7 +25,37 @@ func (client *Client) ReadFilePart(fileID int32, offset int32, count int32) (*td
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var filePart tdlib.FilePart
err = json.Unmarshal(result.Raw, &filePart)
return &filePart, err
}
// GetGroupCallStreamSegment Returns a file with a segment of a group call stream in a modified OGG format for audio or MPEG-4 format for video
// @param groupCallID Group call identifier
// @param timeOffset Point in time when the stream segment begins; Unix timestamp in milliseconds
// @param scale Segment duration scale; 0-1. Segment's duration is 1000/(2**scale) milliseconds
// @param channelID Identifier of an audio/video channel to get as received from tgcalls
// @param videoQuality Video quality as received from tgcalls
func (client *Client) GetGroupCallStreamSegment(groupCallID int32, timeOffset int64, scale int32, channelID int32, videoQuality tdlib.GroupCallVideoQuality) (*tdlib.FilePart, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getGroupCallStreamSegment",
"group_call_id": groupCallID,
"time_offset": timeOffset,
"scale": scale,
"channel_id": channelID,
"video_quality": videoQuality,
})
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 filePart tdlib.FilePart

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// ParseTextEntities Parses Bold, Italic, Underline, Strikethrough, Code, Pre, PreCode, TextUrl and MentionName entities contained in the text. Can be called synchronously
@ -24,7 +23,7 @@ func (client *Client) ParseTextEntities(text string, parseMode tdlib.TextParseMo
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var formattedText tdlib.FormattedText
@ -46,7 +45,7 @@ func (client *Client) ParseMarkdown(text *tdlib.FormattedText) (*tdlib.Formatted
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var formattedText tdlib.FormattedText
@ -68,7 +67,7 @@ func (client *Client) GetMarkdownText(text *tdlib.FormattedText) (*tdlib.Formatt
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var formattedText tdlib.FormattedText

View File

@ -4,16 +4,15 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// SearchSecretMessages Searches for messages in secret chats. Returns the results in reverse chronological order. For optimal performance the number of returned messages is chosen by the library
// SearchSecretMessages Searches for messages in secret chats. Returns the results in reverse chronological order. For optimal performance, the number of returned messages is chosen by TDLib
// @param chatID Identifier of the chat in which to search. Specify 0 to search in all secret chats
// @param query Query to search for. If empty, searchChatMessages should be used instead
// @param offset Offset of the first entry to return as received from the previous request; use empty string to get first chunk of results
// @param limit The maximum number of messages to be returned; up to 100. Fewer messages may be returned than specified by the limit, even if the end of the message history has not been reached
// @param limit The maximum number of messages to be returned; up to 100. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
// @param filter A filter for message content in the search results
func (client *Client) SearchSecretMessages(chatID int64, query string, offset string, limit int32, filter tdlib.SearchMessagesFilter) (*tdlib.FoundMessages, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
@ -30,7 +29,7 @@ func (client *Client) SearchSecretMessages(chatID int64, query string, offset st
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var foundMessages tdlib.FoundMessages
@ -39,11 +38,11 @@ func (client *Client) SearchSecretMessages(chatID int64, query string, offset st
}
// GetMessagePublicForwards Returns forwarded copies of a channel message to different public channels. For optimal performance the number of returned messages is chosen by the library
// GetMessagePublicForwards Returns forwarded copies of a channel message to different public channels. For optimal performance, the number of returned messages is chosen by TDLib
// @param chatID Chat identifier of the message
// @param messageID Message identifier
// @param offset Offset of the first entry to return as received from the previous request; use empty string to get first chunk of results
// @param limit The maximum number of messages to be returned; must be positive and can't be greater than 100. Fewer messages may be returned than specified by the limit, even if the end of the list has not been reached
// @param limit The maximum number of messages to be returned; must be positive and can't be greater than 100. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
func (client *Client) GetMessagePublicForwards(chatID int64, messageID int64, offset string, limit int32) (*tdlib.FoundMessages, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getMessagePublicForwards",
@ -58,7 +57,7 @@ func (client *Client) GetMessagePublicForwards(chatID int64, messageID int64, of
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var foundMessages tdlib.FoundMessages

View File

@ -4,16 +4,15 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetGameHighScores Returns the high scores for a game and some part of the high score table in the range of the specified user; for bots only
// @param chatID The chat that contains the message with the game
// @param messageID Identifier of the message
// @param userID User identifier
func (client *Client) GetGameHighScores(chatID int64, messageID int64, userID int32) (*tdlib.GameHighScores, error) {
func (client *Client) GetGameHighScores(chatID int64, messageID int64, userID int64) (*tdlib.GameHighScores, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getGameHighScores",
"chat_id": chatID,
@ -26,7 +25,7 @@ func (client *Client) GetGameHighScores(chatID int64, messageID int64, userID in
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var gameHighScores tdlib.GameHighScores
@ -38,7 +37,7 @@ func (client *Client) GetGameHighScores(chatID int64, messageID int64, userID in
// GetInlineGameHighScores Returns game high scores and some part of the high score table in the range of the specified user; for bots only
// @param inlineMessageID Inline message identifier
// @param userID User identifier
func (client *Client) GetInlineGameHighScores(inlineMessageID string, userID int32) (*tdlib.GameHighScores, error) {
func (client *Client) GetInlineGameHighScores(inlineMessageID string, userID int64) (*tdlib.GameHighScores, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getInlineGameHighScores",
"inline_message_id": inlineMessageID,
@ -50,7 +49,7 @@ func (client *Client) GetInlineGameHighScores(inlineMessageID string, userID int
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var gameHighScores tdlib.GameHighScores

31
client/groupCall.go Executable file
View File

@ -0,0 +1,31 @@
// AUTOGENERATED - DO NOT EDIT
package client
import (
"encoding/json"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetGroupCall Returns information about a group call
// @param groupCallID Group call identifier
func (client *Client) GetGroupCall(groupCallID int32) (*tdlib.GroupCall, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getGroupCall",
"group_call_id": groupCallID,
})
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 groupCallDummy tdlib.GroupCall
err = json.Unmarshal(result.Raw, &groupCallDummy)
return &groupCallDummy, err
}

35
client/groupCallID.go Executable file
View File

@ -0,0 +1,35 @@
// AUTOGENERATED - DO NOT EDIT
package client
import (
"encoding/json"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// CreateVoiceChat Creates a voice chat (a group call bound to a chat). Available only for basic groups, supergroups and channels; requires can_manage_voice_chats rights
// @param chatID Chat identifier, in which the voice chat will be created
// @param title Group call title; if empty, chat title will be used
// @param startDate Point in time (Unix timestamp) when the group call is supposed to be started by an administrator; 0 to start the voice chat immediately. The date must be at least 10 seconds and at most 8 days in the future
func (client *Client) CreateVoiceChat(chatID int64, title string, startDate int32) (*tdlib.GroupCallID, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "createVoiceChat",
"chat_id": chatID,
"title": title,
"start_date": startDate,
})
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 groupCallID tdlib.GroupCallID
err = json.Unmarshal(result.Raw, &groupCallID)
return &groupCallID, err
}

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// SearchHashtags Searches for recently used hashtags by their prefix
@ -24,7 +23,7 @@ func (client *Client) SearchHashtags(prefix string, limit int32) (*tdlib.Hashtag
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var hashtags tdlib.Hashtags

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetLoginURL Returns an HTTP URL which can be used to automatically authorize the user on a website after clicking an inline button of type inlineKeyboardButtonTypeLoginUrl. Use the method getLoginUrlInfo to find whether a prior user confirmation is needed. If an error is returned, then the button must be handled as an ordinary URL button
@ -14,7 +13,7 @@ import (
// @param messageID Message identifier of the message with the button
// @param buttonID Button identifier
// @param allowWriteAccess True, if the user allowed the bot to send them messages
func (client *Client) GetLoginURL(chatID int64, messageID int64, buttonID int32, allowWriteAccess bool) (*tdlib.HttpURL, error) {
func (client *Client) GetLoginURL(chatID int64, messageID int64, buttonID int64, allowWriteAccess bool) (*tdlib.HttpURL, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getLoginUrl",
"chat_id": chatID,
@ -28,7 +27,55 @@ func (client *Client) GetLoginURL(chatID int64, messageID int64, buttonID int32,
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var httpURL tdlib.HttpURL
err = json.Unmarshal(result.Raw, &httpURL)
return &httpURL, err
}
// GetExternalLink Returns an HTTP URL which can be used to automatically authorize the current user on a website after clicking an HTTP link. Use the method getExternalLinkInfo to find whether a prior user confirmation is needed
// @param link The HTTP link
// @param allowWriteAccess True, if the current user allowed the bot, returned in getExternalLinkInfo, to send them messages
func (client *Client) GetExternalLink(link string, allowWriteAccess bool) (*tdlib.HttpURL, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getExternalLink",
"link": link,
"allow_write_access": allowWriteAccess,
})
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 httpURL tdlib.HttpURL
err = json.Unmarshal(result.Raw, &httpURL)
return &httpURL, err
}
// GetGroupCallInviteLink Returns invite link to a voice chat in a public chat
// @param groupCallID Group call identifier
// @param canSelfUnmute Pass true if the invite_link should contain an invite hash, passing which to joinGroupCall would allow the invited user to unmute themselves. Requires groupCall.can_be_managed group call flag
func (client *Client) GetGroupCallInviteLink(groupCallID int32, canSelfUnmute bool) (*tdlib.HttpURL, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getGroupCallInviteLink",
"group_call_id": groupCallID,
"can_self_unmute": canSelfUnmute,
})
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 httpURL tdlib.HttpURL
@ -50,7 +97,7 @@ func (client *Client) GetEmojiSuggestionsURL(languageCode string) (*tdlib.HttpUR
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var httpURL tdlib.HttpURL
@ -74,7 +121,7 @@ func (client *Client) GetBackgroundURL(name string, typeParam tdlib.BackgroundTy
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var httpURL tdlib.HttpURL
@ -85,7 +132,7 @@ func (client *Client) GetBackgroundURL(name string, typeParam tdlib.BackgroundTy
// 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 parameters Parameters for the request
// @param isDark Pass true if a URL with the dark theme must be returned
func (client *Client) GetChatStatisticsURL(chatID int64, parameters string, isDark bool) (*tdlib.HttpURL, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
@ -100,7 +147,49 @@ func (client *Client) GetChatStatisticsURL(chatID int64, parameters string, isDa
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var httpURL tdlib.HttpURL
err = json.Unmarshal(result.Raw, &httpURL)
return &httpURL, err
}
// GetApplicationDownloadLink Returns the link for downloading official Telegram application to be used when the current user invites friends to Telegram
func (client *Client) GetApplicationDownloadLink() (*tdlib.HttpURL, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getApplicationDownloadLink",
})
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 httpURL tdlib.HttpURL
err = json.Unmarshal(result.Raw, &httpURL)
return &httpURL, err
}
// GetProxyLink Returns an HTTPS link, which can be used to add a proxy. Available only for SOCKS5 and MTProto proxies. Can be called before authorization
// @param proxyID Proxy identifier
func (client *Client) GetProxyLink(proxyID int32) (*tdlib.HttpURL, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getProxyLink",
"proxy_id": proxyID,
})
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 httpURL tdlib.HttpURL

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// ImportContacts Adds new contacts or edits existing contacts by their phone numbers; contacts' user identifiers are ignored
@ -22,7 +21,7 @@ func (client *Client) ImportContacts(contacts []tdlib.Contact) (*tdlib.ImportedC
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var importedContacts tdlib.ImportedContacts
@ -31,7 +30,7 @@ func (client *Client) ImportContacts(contacts []tdlib.Contact) (*tdlib.ImportedC
}
// ChangeImportedContacts Changes imported contacts using the list of current user contacts saved on the device. Imports newly added contacts and, if at least the file database is enabled, deletes recently deleted contacts. Query result depends on the result of the previous query, so only one query is possible at the same time
// ChangeImportedContacts Changes imported contacts using the list of contacts saved on the device. Imports newly added contacts and, if at least the file database is enabled, deletes recently deleted contacts. Query result depends on the result of the previous query, so only one query is possible at the same time
// @param contacts The new list of contacts, contact's vCard are ignored and are not imported
func (client *Client) ChangeImportedContacts(contacts []tdlib.Contact) (*tdlib.ImportedContacts, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
@ -44,7 +43,7 @@ func (client *Client) ChangeImportedContacts(contacts []tdlib.Contact) (*tdlib.I
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var importedContacts tdlib.ImportedContacts

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetInlineQueryResults Sends an inline query to a bot and returns its results. Returns an error with code 502 if the bot fails to answer the query before the query timeout expires
@ -15,7 +14,7 @@ import (
// @param userLocation Location of the user, only if needed
// @param query Text of the query
// @param offset Offset of the first entry to return
func (client *Client) GetInlineQueryResults(botUserID int32, chatID int64, userLocation *tdlib.Location, query string, offset string) (*tdlib.InlineQueryResults, error) {
func (client *Client) GetInlineQueryResults(botUserID int64, chatID int64, userLocation *tdlib.Location, query string, offset string) (*tdlib.InlineQueryResults, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getInlineQueryResults",
"bot_user_id": botUserID,
@ -30,7 +29,7 @@ func (client *Client) GetInlineQueryResults(botUserID int32, chatID int64, userL
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var inlineQueryResults tdlib.InlineQueryResults

148
client/internalLinkType.go Executable file
View File

@ -0,0 +1,148 @@
// AUTOGENERATED - DO NOT EDIT
package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetInternalLinkType Returns information about the type of an internal link. Returns a 404 error if the link is not internal. Can be called before authorization
// @param link The link
func (client *Client) GetInternalLinkType(link string) (tdlib.InternalLinkType, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getInternalLinkType",
"link": link,
})
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.InternalLinkTypeEnum(result.Data["@type"].(string)) {
case tdlib.InternalLinkTypeActiveSessionsType:
var internalLinkType tdlib.InternalLinkTypeActiveSessions
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypeAuthenticationCodeType:
var internalLinkType tdlib.InternalLinkTypeAuthenticationCode
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypeBackgroundType:
var internalLinkType tdlib.InternalLinkTypeBackground
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypeBotStartType:
var internalLinkType tdlib.InternalLinkTypeBotStart
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypeBotStartInGroupType:
var internalLinkType tdlib.InternalLinkTypeBotStartInGroup
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypeChangePhoneNumberType:
var internalLinkType tdlib.InternalLinkTypeChangePhoneNumber
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypeChatInviteType:
var internalLinkType tdlib.InternalLinkTypeChatInvite
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypeFilterSettingsType:
var internalLinkType tdlib.InternalLinkTypeFilterSettings
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypeGameType:
var internalLinkType tdlib.InternalLinkTypeGame
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypeLanguagePackType:
var internalLinkType tdlib.InternalLinkTypeLanguagePack
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypeMessageType:
var internalLinkType tdlib.InternalLinkTypeMessage
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypeMessageDraftType:
var internalLinkType tdlib.InternalLinkTypeMessageDraft
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypePassportDataRequestType:
var internalLinkType tdlib.InternalLinkTypePassportDataRequest
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypePhoneNumberConfirmationType:
var internalLinkType tdlib.InternalLinkTypePhoneNumberConfirmation
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypeProxyType:
var internalLinkType tdlib.InternalLinkTypeProxy
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypePublicChatType:
var internalLinkType tdlib.InternalLinkTypePublicChat
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypeQrCodeAuthenticationType:
var internalLinkType tdlib.InternalLinkTypeQrCodeAuthentication
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypeSettingsType:
var internalLinkType tdlib.InternalLinkTypeSettings
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypeStickerSetType:
var internalLinkType tdlib.InternalLinkTypeStickerSet
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypeThemeType:
var internalLinkType tdlib.InternalLinkTypeTheme
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypeThemeSettingsType:
var internalLinkType tdlib.InternalLinkTypeThemeSettings
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypeUnknownDeepLinkType:
var internalLinkType tdlib.InternalLinkTypeUnknownDeepLink
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
case tdlib.InternalLinkTypeVoiceChatType:
var internalLinkType tdlib.InternalLinkTypeVoiceChat
err = json.Unmarshal(result.Raw, &internalLinkType)
return &internalLinkType, err
default:
return nil, fmt.Errorf("Invalid type")
}
}

View File

@ -6,7 +6,7 @@ import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetJsonValue Converts a JSON-serialized string to corresponding JsonValue object. Can be called synchronously
@ -22,7 +22,7 @@ func (client *Client) GetJsonValue(jsonString string) (tdlib.JsonValue, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
switch tdlib.JsonValueEnum(result.Data["@type"].(string)) {
@ -73,7 +73,7 @@ func (client *Client) GetApplicationConfig() (tdlib.JsonValue, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
switch tdlib.JsonValueEnum(result.Data["@type"].(string)) {

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetLanguagePackInfo Returns information about a language pack. Returned language pack identifier may be different from a provided one. Can be called before authorization
@ -22,7 +21,7 @@ func (client *Client) GetLanguagePackInfo(languagePackID string) (*tdlib.Languag
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var languagePackInfo tdlib.LanguagePackInfo

View File

@ -6,7 +6,7 @@ import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// 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
@ -28,7 +28,7 @@ func (client *Client) GetLanguagePackString(languagePackDatabasePath string, loc
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
switch tdlib.LanguagePackStringValueEnum(result.Data["@type"].(string)) {

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetLanguagePackStrings Returns strings from a language pack in the current localization target by their keys. Can be called before authorization
@ -24,7 +23,7 @@ func (client *Client) GetLanguagePackStrings(languagePackID string, keys []strin
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var languagePackStrings tdlib.LanguagePackStrings

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetLocalizationTargetInfo Returns information about the current localization target. This is an offline request if only_local is true. Can be called before authorization
@ -22,7 +21,7 @@ func (client *Client) GetLocalizationTargetInfo(onlyLocal bool) (*tdlib.Localiza
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var localizationTargetInfo tdlib.LocalizationTargetInfo

View File

@ -6,7 +6,7 @@ import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetLogStream Returns information about currently used log stream for internal logging of TDLib. Can be called synchronously
@ -20,7 +20,7 @@ func (client *Client) GetLogStream() (tdlib.LogStream, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
switch tdlib.LogStreamEnum(result.Data["@type"].(string)) {

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetLogTags Returns list of available TDLib internal log tags, for example, ["actor", "binlog", "connections", "notifications", "proxy"]. Can be called synchronously
@ -20,7 +19,7 @@ func (client *Client) GetLogTags() (*tdlib.LogTags, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var logTags tdlib.LogTags

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetLogVerbosityLevel Returns current verbosity level of the internal logging of TDLib. Can be called synchronously
@ -20,7 +19,7 @@ func (client *Client) GetLogVerbosityLevel() (*tdlib.LogVerbosityLevel, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var logVerbosityLevel tdlib.LogVerbosityLevel
@ -42,7 +41,7 @@ func (client *Client) GetLogTagVerbosityLevel(tag string) (*tdlib.LogVerbosityLe
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var logVerbosityLevel tdlib.LogVerbosityLevel

View File

@ -5,14 +5,14 @@ package client
import (
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetLoginURLInfo Returns information about a button of type inlineKeyboardButtonTypeLoginUrl. The method needs to be called when the user presses the button
// @param chatID Chat identifier of the message with the button
// @param messageID Message identifier of the message with the button
// @param buttonID Button identifier
func (client *Client) GetLoginURLInfo(chatID int64, messageID int64, buttonID int32) (tdlib.LoginURLInfo, error) {
func (client *Client) GetLoginURLInfo(chatID int64, messageID int64, buttonID int64) (tdlib.LoginURLInfo, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getLoginUrlInfo",
"chat_id": chatID,
@ -25,7 +25,30 @@ func (client *Client) GetLoginURLInfo(chatID int64, messageID int64, buttonID in
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
switch tdlib.LoginURLInfoEnum(result.Data["@type"].(string)) {
default:
return nil, fmt.Errorf("Invalid type")
}
}
// GetExternalLinkInfo Returns information about an action to be done when the current user clicks an external link. Don't use this method for links from secret chats if web page preview is disabled in secret chats
// @param link The link
func (client *Client) GetExternalLinkInfo(link string) (tdlib.LoginURLInfo, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getExternalLinkInfo",
"link": link,
})
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.LoginURLInfoEnum(result.Data["@type"].(string)) {

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetMessage Returns information about a message
@ -24,7 +23,7 @@ func (client *Client) GetMessage(chatID int64, messageID int64) (*tdlib.Message,
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messageDummy tdlib.Message
@ -48,7 +47,7 @@ func (client *Client) GetMessageLocally(chatID int64, messageID int64) (*tdlib.M
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messageDummy tdlib.Message
@ -72,7 +71,7 @@ func (client *Client) GetRepliedMessage(chatID int64, messageID int64) (*tdlib.M
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messageDummy tdlib.Message
@ -94,7 +93,7 @@ func (client *Client) GetChatPinnedMessage(chatID int64) (*tdlib.Message, error)
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var message tdlib.Message
@ -120,7 +119,7 @@ func (client *Client) GetCallbackQueryMessage(chatID int64, messageID int64, cal
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messageDummy tdlib.Message
@ -144,7 +143,7 @@ func (client *Client) GetChatMessageByDate(chatID int64, date int32) (*tdlib.Mes
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var message tdlib.Message
@ -176,7 +175,7 @@ func (client *Client) SendMessage(chatID int64, messageThreadID int64, replyToMe
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messageDummy tdlib.Message
@ -189,7 +188,7 @@ func (client *Client) SendMessage(chatID int64, messageThreadID int64, replyToMe
// @param botUserID Identifier of the bot
// @param chatID Identifier of the target chat
// @param parameter A hidden parameter sent to the bot for deep linking purposes (https://core.telegram.org/bots#deep-linking)
func (client *Client) SendBotStartMessage(botUserID int32, chatID int64, parameter string) (*tdlib.Message, error) {
func (client *Client) SendBotStartMessage(botUserID int64, chatID int64, parameter string) (*tdlib.Message, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "sendBotStartMessage",
"bot_user_id": botUserID,
@ -202,7 +201,7 @@ func (client *Client) SendBotStartMessage(botUserID int32, chatID int64, paramet
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var message tdlib.Message
@ -236,7 +235,7 @@ func (client *Client) SendInlineQueryResultMessage(chatID int64, messageThreadID
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messageDummy tdlib.Message
@ -245,30 +244,6 @@ func (client *Client) SendInlineQueryResultMessage(chatID int64, messageThreadID
}
// SendChatSetTTLMessage Changes the current TTL setting (sets a new self-destruct timer) in a secret chat and sends the corresponding message
// @param chatID Chat identifier
// @param tTL New TTL value, in seconds
func (client *Client) SendChatSetTTLMessage(chatID int64, tTL int32) (*tdlib.Message, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "sendChatSetTtlMessage",
"chat_id": chatID,
"ttl": tTL,
})
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 message tdlib.Message
err = json.Unmarshal(result.Raw, &message)
return &message, err
}
// AddLocalMessage Adds a local message to a chat. The message is persistent across application restarts only if the message database is used. Returns the added message
// @param chatID Target chat
// @param sender The sender sender of the message
@ -290,7 +265,7 @@ func (client *Client) AddLocalMessage(chatID int64, sender tdlib.MessageSender,
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messageDummy tdlib.Message
@ -303,7 +278,7 @@ func (client *Client) AddLocalMessage(chatID int64, sender tdlib.MessageSender,
// @param chatID The chat the message belongs to
// @param messageID Identifier of the message
// @param replyMarkup The new message reply markup; for bots only
// @param inputMessageContent New text content of the message. Should be of type InputMessageText
// @param inputMessageContent New text content of the message. Should be of type inputMessageText
func (client *Client) EditMessageText(chatID int64, messageID int64, replyMarkup tdlib.ReplyMarkup, inputMessageContent tdlib.InputMessageContent) (*tdlib.Message, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "editMessageText",
@ -318,7 +293,7 @@ func (client *Client) EditMessageText(chatID int64, messageID int64, replyMarkup
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messageDummy tdlib.Message
@ -350,7 +325,7 @@ func (client *Client) EditMessageLiveLocation(chatID int64, messageID int64, rep
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messageDummy tdlib.Message
@ -359,11 +334,11 @@ func (client *Client) EditMessageLiveLocation(chatID int64, messageID int64, rep
}
// EditMessageMedia Edits the content of a message with an animation, an audio, a document, a photo or a video. The media in the message can't be replaced if the message was set to self-destruct. Media can't be replaced by self-destructing media. Media in an album can be edited only to contain a photo or a video. Returns the edited message after the edit is completed on the server side
// EditMessageMedia Edits the content of a message with an animation, an audio, a document, a photo or a video, including message caption. If only the caption needs to be edited, use editMessageCaption instead. The media can't be edited if the message was set to self-destruct or to a self-destructing media. The type of message content in an album can't be changed with exception of replacing a photo with a video or vice versa. Returns the edited message after the edit is completed on the server side
// @param chatID The chat the message belongs to
// @param messageID Identifier of the message
// @param replyMarkup The new message reply markup; for bots only
// @param inputMessageContent New content of the message. Must be one of the following types: InputMessageAnimation, InputMessageAudio, InputMessageDocument, InputMessagePhoto or InputMessageVideo
// @param inputMessageContent New content of the message. Must be one of the following types: inputMessageAnimation, inputMessageAudio, inputMessageDocument, inputMessagePhoto or inputMessageVideo
func (client *Client) EditMessageMedia(chatID int64, messageID int64, replyMarkup tdlib.ReplyMarkup, inputMessageContent tdlib.InputMessageContent) (*tdlib.Message, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "editMessageMedia",
@ -378,7 +353,7 @@ func (client *Client) EditMessageMedia(chatID int64, messageID int64, replyMarku
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messageDummy tdlib.Message
@ -406,7 +381,7 @@ func (client *Client) EditMessageCaption(chatID int64, messageID int64, replyMar
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messageDummy tdlib.Message
@ -432,7 +407,7 @@ func (client *Client) EditMessageReplyMarkup(chatID int64, messageID int64, repl
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messageDummy tdlib.Message
@ -448,7 +423,7 @@ func (client *Client) EditMessageReplyMarkup(chatID int64, messageID int64, repl
// @param userID User identifier
// @param score The new score
// @param force Pass true to update the score even if it decreases. If the score is 0, the user will be deleted from the high score table
func (client *Client) SetGameScore(chatID int64, messageID int64, editMessage bool, userID int32, score int32, force bool) (*tdlib.Message, error) {
func (client *Client) SetGameScore(chatID int64, messageID int64, editMessage bool, userID int64, score int32, force bool) (*tdlib.Message, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "setGameScore",
"chat_id": chatID,
@ -464,7 +439,7 @@ func (client *Client) SetGameScore(chatID int64, messageID int64, editMessage bo
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messageDummy tdlib.Message

48
client/messageFileType.go Executable file
View File

@ -0,0 +1,48 @@
// AUTOGENERATED - DO NOT EDIT
package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetMessageFileType Returns information about a file with messages exported from another app
// @param messageFileHead Beginning of the message file; up to 100 first lines
func (client *Client) GetMessageFileType(messageFileHead string) (tdlib.MessageFileType, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getMessageFileType",
"message_file_head": messageFileHead,
})
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.MessageFileTypeEnum(result.Data["@type"].(string)) {
case tdlib.MessageFileTypePrivateType:
var messageFileType tdlib.MessageFileTypePrivate
err = json.Unmarshal(result.Raw, &messageFileType)
return &messageFileType, err
case tdlib.MessageFileTypeGroupType:
var messageFileType tdlib.MessageFileTypeGroup
err = json.Unmarshal(result.Raw, &messageFileType)
return &messageFileType, err
case tdlib.MessageFileTypeUnknownType:
var messageFileType tdlib.MessageFileTypeUnknown
err = json.Unmarshal(result.Raw, &messageFileType)
return &messageFileType, err
default:
return nil, fmt.Errorf("Invalid type")
}
}

View File

@ -4,23 +4,24 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetMessageLink Returns an HTTPS link to a message in a chat. Available only for already sent messages in supergroups and channels. This is an offline request
// GetMessageLink Returns an HTTPS link to a message in a chat. Available only for already sent messages in supergroups and channels, or if message.can_get_media_timestamp_links and a media timestamp link is generated. This is an offline request
// @param chatID Identifier of the chat to which the message belongs
// @param messageID Identifier of the message
// @param mediaTimestamp If not 0, timestamp from which the video/audio/video note/voice note playing should start, in seconds. The media can be in the message content or in its web page preview
// @param forAlbum Pass true to create a link for the whole media album
// @param forComment Pass true to create a link to the message as a channel post comment, or from a message thread
func (client *Client) GetMessageLink(chatID int64, messageID int64, forAlbum bool, forComment bool) (*tdlib.MessageLink, error) {
func (client *Client) GetMessageLink(chatID int64, messageID int64, mediaTimestamp int32, forAlbum bool, forComment bool) (*tdlib.MessageLink, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getMessageLink",
"chat_id": chatID,
"message_id": messageID,
"for_album": forAlbum,
"for_comment": forComment,
"@type": "getMessageLink",
"chat_id": chatID,
"message_id": messageID,
"media_timestamp": mediaTimestamp,
"for_album": forAlbum,
"for_comment": forComment,
})
if err != nil {
@ -28,7 +29,7 @@ func (client *Client) GetMessageLink(chatID int64, messageID int64, forAlbum boo
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messageLink tdlib.MessageLink

View File

@ -4,13 +4,12 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetMessageLinkInfo Returns information about a public or private message link
// @param uRL The message link in the format "https://t.me/c/...", or "tg://privatepost?...", or "https://t.me/username/...", or "tg://resolve?..."
// GetMessageLinkInfo Returns information about a public or private message link. Can be called for any internal link of the type internalLinkTypeMessage
// @param uRL The message link
func (client *Client) GetMessageLinkInfo(uRL string) (*tdlib.MessageLinkInfo, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getMessageLinkInfo",
@ -22,7 +21,7 @@ func (client *Client) GetMessageLinkInfo(uRL string) (*tdlib.MessageLinkInfo, er
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messageLinkInfo tdlib.MessageLinkInfo

View File

@ -4,11 +4,32 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetVoiceChatAvailableParticipants Returns list of participant identifiers, which can be used to join voice chats in a chat
// @param chatID Chat identifier
func (client *Client) GetVoiceChatAvailableParticipants(chatID int64) (*tdlib.MessageSenders, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getVoiceChatAvailableParticipants",
"chat_id": chatID,
})
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 messageSenders tdlib.MessageSenders
err = json.Unmarshal(result.Raw, &messageSenders)
return &messageSenders, err
}
// GetBlockedMessageSenders Returns users and chats that were blocked by the current user
// @param offset Number of users and chats to skip in the result; must be non-negative
// @param limit The maximum number of users and chats to return; up to 100
@ -24,7 +45,7 @@ func (client *Client) GetBlockedMessageSenders(offset int32, limit int32) (*tdli
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messageSenders tdlib.MessageSenders

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetMessageStatistics Returns detailed statistics about a message. Can be used only if Message.can_get_statistics == true
@ -26,7 +25,7 @@ func (client *Client) GetMessageStatistics(chatID int64, messageID int64, isDark
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messageStatistics tdlib.MessageStatistics

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetMessageThread Returns information about a message thread. Can be used only if message.can_get_message_thread == true
@ -24,7 +23,7 @@ func (client *Client) GetMessageThread(chatID int64, messageID int64) (*tdlib.Me
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messageThreadInfo tdlib.MessageThreadInfo

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetMessages Returns information about messages. If a message is not found, returns null on the corresponding position of the result
@ -24,7 +23,7 @@ func (client *Client) GetMessages(chatID int64, messageIDs []int64) (*tdlib.Mess
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messages tdlib.Messages
@ -33,11 +32,11 @@ func (client *Client) GetMessages(chatID int64, messageIDs []int64) (*tdlib.Mess
}
// GetChatHistory Returns messages in a chat. The messages are returned in a reverse chronological order (i.e., in order of decreasing message_id). For optimal performance the number of returned messages is chosen by the library. This is an offline request if only_local is true
// GetChatHistory Returns messages in a chat. The messages are returned in a reverse chronological order (i.e., in order of decreasing message_id). For optimal performance, the number of returned messages is chosen by TDLib. This is an offline request if only_local is true
// @param chatID Chat identifier
// @param fromMessageID Identifier of the message starting from which history must be fetched; use 0 to get results from the last message
// @param offset Specify 0 to get results from exactly the from_message_id or a negative offset up to 99 to get additionally some newer messages
// @param limit The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than or equal to -offset. Fewer messages may be returned than specified by the limit, even if the end of the message history has not been reached
// @param limit The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than or equal to -offset. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
// @param onlyLocal If true, returns only messages that are available locally without sending network requests
func (client *Client) GetChatHistory(chatID int64, fromMessageID int64, offset int32, limit int32, onlyLocal bool) (*tdlib.Messages, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
@ -54,7 +53,7 @@ func (client *Client) GetChatHistory(chatID int64, fromMessageID int64, offset i
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messages tdlib.Messages
@ -63,12 +62,12 @@ func (client *Client) GetChatHistory(chatID int64, fromMessageID int64, offset i
}
// GetMessageThreadHistory Returns messages in a message thread of a message. Can be used only if message.can_get_message_thread == true. Message thread of a channel message is in the channel's linked supergroup. The messages are returned in a reverse chronological order (i.e., in order of decreasing message_id). For optimal performance the number of returned messages is chosen by the library
// GetMessageThreadHistory Returns messages in a message thread of a message. Can be used only if message.can_get_message_thread == true. Message thread of a channel message is in the channel's linked supergroup. The messages are returned in a reverse chronological order (i.e., in order of decreasing message_id). For optimal performance, the number of returned messages is chosen by TDLib
// @param chatID Chat identifier
// @param messageID Message identifier, which thread history needs to be returned
// @param fromMessageID Identifier of the message starting from which history must be fetched; use 0 to get results from the last message
// @param offset Specify 0 to get results from exactly the from_message_id or a negative offset up to 99 to get additionally some newer messages
// @param limit The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than or equal to -offset. Fewer messages may be returned than specified by the limit, even if the end of the message thread history has not been reached
// @param limit The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than or equal to -offset. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
func (client *Client) GetMessageThreadHistory(chatID int64, messageID int64, fromMessageID int64, offset int32, limit int32) (*tdlib.Messages, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getMessageThreadHistory",
@ -84,7 +83,7 @@ func (client *Client) GetMessageThreadHistory(chatID int64, messageID int64, fro
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messages tdlib.Messages
@ -93,13 +92,13 @@ func (client *Client) GetMessageThreadHistory(chatID int64, messageID int64, fro
}
// SearchChatMessages Searches for messages with given words in the chat. Returns the results in reverse chronological order, i.e. in order of decreasing message_id. Cannot be used in secret chats with a non-empty query (searchSecretMessages should be used instead), or without an enabled message database. For optimal performance the number of returned messages is chosen by the library
// SearchChatMessages Searches for messages with given words in the chat. Returns the results in reverse chronological order, i.e. in order of decreasing message_id. Cannot be used in secret chats with a non-empty query (searchSecretMessages should be used instead), or without an enabled message database. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
// @param chatID Identifier of the chat in which to search messages
// @param query Query to search for
// @param sender If not null, only messages sent by the specified sender will be returned. Not supported in secret chats
// @param fromMessageID Identifier of the message starting from which history must be fetched; use 0 to get results from the last message
// @param offset Specify 0 to get results from exactly the from_message_id or a negative offset to get the specified message and some newer messages
// @param limit The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than -offset. Fewer messages may be returned than specified by the limit, even if the end of the message history has not been reached
// @param limit The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than -offset. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
// @param filter Filter for message content in the search results
// @param messageThreadID If not 0, only messages in the specified thread will be returned; supergroups only
func (client *Client) SearchChatMessages(chatID int64, query string, sender tdlib.MessageSender, fromMessageID int64, offset int32, limit int32, filter tdlib.SearchMessagesFilter, messageThreadID int64) (*tdlib.Messages, error) {
@ -120,7 +119,7 @@ func (client *Client) SearchChatMessages(chatID int64, query string, sender tdli
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messages tdlib.Messages
@ -129,13 +128,13 @@ func (client *Client) SearchChatMessages(chatID int64, query string, sender tdli
}
// SearchMessages Searches for messages in all chats except secret chats. Returns the results in reverse chronological order (i.e., in order of decreasing (date, chat_id, message_id)). For optimal performance the number of returned messages is chosen by the library
// @param chatList Chat list in which to search messages; pass null to search in all chats regardless of their chat list
// SearchMessages Searches for messages in all chats except secret chats. Returns the results in reverse chronological order (i.e., in order of decreasing (date, chat_id, message_id)). For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
// @param chatList Chat list in which to search messages; pass null to search in all chats regardless of their chat list. Only Main and Archive chat lists are supported
// @param query Query to search for
// @param offsetDate The date of the message starting from which the results should be fetched. Use 0 or any date in the future to get results from the last message
// @param offsetChatID The chat identifier of the last found message, or 0 for the first request
// @param offsetMessageID The message identifier of the last found message, or 0 for the first request
// @param limit The maximum number of messages to be returned; up to 100. Fewer messages may be returned than specified by the limit, even if the end of the message history has not been reached
// @param limit The maximum number of messages to be returned; up to 100. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
// @param filter Filter for message content in the search results; searchMessagesFilterCall, searchMessagesFilterMissedCall, searchMessagesFilterMention, searchMessagesFilterUnreadMention, searchMessagesFilterFailedToSend and searchMessagesFilterPinned are unsupported in this function
// @param minDate If not 0, the minimum date of the messages to return
// @param maxDate If not 0, the maximum date of the messages to return
@ -158,7 +157,7 @@ func (client *Client) SearchMessages(chatList tdlib.ChatList, query string, offs
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messages tdlib.Messages
@ -167,9 +166,9 @@ func (client *Client) SearchMessages(chatList tdlib.ChatList, query string, offs
}
// SearchCallMessages Searches for call messages. Returns the results in reverse chronological order (i. e., in order of decreasing message_id). For optimal performance the number of returned messages is chosen by the library
// SearchCallMessages Searches for call messages. Returns the results in reverse chronological order (i. e., in order of decreasing message_id). For optimal performance, the number of returned messages is chosen by TDLib
// @param fromMessageID Identifier of the message from which to search; use 0 to get results from the last message
// @param limit The maximum number of messages to be returned; up to 100. Fewer messages may be returned than specified by the limit, even if the end of the message history has not been reached
// @param limit The maximum number of messages to be returned; up to 100. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
// @param onlyMissed If true, returns only messages with missed calls
func (client *Client) SearchCallMessages(fromMessageID int64, limit int32, onlyMissed bool) (*tdlib.Messages, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
@ -184,7 +183,7 @@ func (client *Client) SearchCallMessages(fromMessageID int64, limit int32, onlyM
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messages tdlib.Messages
@ -208,7 +207,7 @@ func (client *Client) SearchChatRecentLocationMessages(chatID int64, limit int32
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messages tdlib.Messages
@ -228,7 +227,7 @@ func (client *Client) GetActiveLiveLocationMessages() (*tdlib.Messages, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messages tdlib.Messages
@ -250,7 +249,7 @@ func (client *Client) GetChatScheduledMessages(chatID int64) (*tdlib.Messages, e
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messages tdlib.Messages
@ -259,12 +258,12 @@ func (client *Client) GetChatScheduledMessages(chatID int64) (*tdlib.Messages, e
}
// SendMessageAlbum Sends messages grouped together into an album. Currently only audio, document, photo and video messages can be grouped into an album. Documents and audio files can be only grouped in an album with messages of the same type. Returns sent messages
// SendMessageAlbum Sends 2-10 messages grouped together into an album. Currently only audio, document, photo and video messages can be grouped into an album. Documents and audio files can be only grouped in an album with messages of the same type. Returns sent messages
// @param chatID Target chat
// @param messageThreadID If not 0, a message thread identifier in which the messages will be sent
// @param replyToMessageID Identifier of a message to reply to or 0
// @param options Options to be used to send the messages
// @param inputMessageContents Contents of messages to be sent
// @param inputMessageContents Contents of messages to be sent. At most 10 messages can be added to an album
func (client *Client) SendMessageAlbum(chatID int64, messageThreadID int64, replyToMessageID int64, options *tdlib.MessageSendOptions, inputMessageContents []tdlib.InputMessageContent) (*tdlib.Messages, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "sendMessageAlbum",
@ -280,7 +279,7 @@ func (client *Client) SendMessageAlbum(chatID int64, messageThreadID int64, repl
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messages tdlib.Messages
@ -292,11 +291,12 @@ func (client *Client) SendMessageAlbum(chatID int64, messageThreadID int64, repl
// ForwardMessages Forwards previously sent messages. Returns the forwarded messages in the same order as the message identifiers passed in message_ids. If a message can't be forwarded, null will be returned instead of the message
// @param chatID Identifier of the chat to which to forward messages
// @param fromChatID Identifier of the chat from which to forward messages
// @param messageIDs Identifiers of the messages to forward. Message identifiers must be in a strictly increasing order
// @param messageIDs Identifiers of the messages to forward. Message identifiers must be in a strictly increasing order. At most 100 messages can be forwarded simultaneously
// @param options Options to be used to send the messages
// @param sendCopy True, if content of the messages needs to be copied without links to the original messages. Always true if the messages are forwarded to a secret chat
// @param removeCaption True, if media caption of message copies needs to be removed. Ignored if send_copy is false
func (client *Client) ForwardMessages(chatID int64, fromChatID int64, messageIDs []int64, options *tdlib.MessageSendOptions, sendCopy bool, removeCaption bool) (*tdlib.Messages, error) {
// @param sendCopy If true, content of the messages will be copied without links to the original messages. Always true if the messages are forwarded to a secret chat
// @param removeCaption If true, media caption of message copies will be removed. Ignored if send_copy is false
// @param onlyPreview If true, messages will not be forwarded and instead fake messages will be returned
func (client *Client) ForwardMessages(chatID int64, fromChatID int64, messageIDs []int64, options *tdlib.MessageSendOptions, sendCopy bool, removeCaption bool, onlyPreview bool) (*tdlib.Messages, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "forwardMessages",
"chat_id": chatID,
@ -305,6 +305,7 @@ func (client *Client) ForwardMessages(chatID int64, fromChatID int64, messageIDs
"options": options,
"send_copy": sendCopy,
"remove_caption": removeCaption,
"only_preview": onlyPreview,
})
if err != nil {
@ -312,7 +313,7 @@ func (client *Client) ForwardMessages(chatID int64, fromChatID int64, messageIDs
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messages tdlib.Messages
@ -336,7 +337,7 @@ func (client *Client) ResendMessages(chatID int64, messageIDs []int64) (*tdlib.M
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var messages tdlib.Messages

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetNetworkStatistics Returns network data usage statistics. Can be called before authorization
@ -22,7 +21,7 @@ func (client *Client) GetNetworkStatistics(onlyCurrent bool) (*tdlib.NetworkStat
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var networkStatistics tdlib.NetworkStatistics

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@ import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// 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
@ -22,7 +22,7 @@ func (client *Client) GetOption(name string) (tdlib.OptionValue, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
switch tdlib.OptionValueEnum(result.Data["@type"].(string)) {

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetSavedOrderInfo Returns saved order info, if any
@ -20,7 +19,7 @@ func (client *Client) GetSavedOrderInfo() (*tdlib.OrderInfo, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var orderInfo tdlib.OrderInfo

View File

@ -4,17 +4,16 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetPassportAuthorizationForm Returns a Telegram Passport authorization form for sharing data with a service
// @param botUserID User identifier of the service's bot
// @param scope Telegram Passport element types requested by the service
// @param publicKey Service's public_key
// @param nonce Authorization form nonce provided by the service
func (client *Client) GetPassportAuthorizationForm(botUserID int32, scope string, publicKey string, nonce string) (*tdlib.PassportAuthorizationForm, error) {
// @param publicKey Service's public key
// @param nonce Unique request identifier provided by the service
func (client *Client) GetPassportAuthorizationForm(botUserID int64, scope string, publicKey string, nonce string) (*tdlib.PassportAuthorizationForm, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getPassportAuthorizationForm",
"bot_user_id": botUserID,
@ -28,7 +27,7 @@ func (client *Client) GetPassportAuthorizationForm(botUserID int32, scope string
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var passportAuthorizationForm tdlib.PassportAuthorizationForm

View File

@ -6,7 +6,7 @@ import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetPassportElement Returns one of the available Telegram Passport elements
@ -24,7 +24,7 @@ func (client *Client) GetPassportElement(typeParam tdlib.PassportElementType, pa
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
switch tdlib.PassportElementEnum(result.Data["@type"].(string)) {
@ -114,7 +114,7 @@ func (client *Client) SetPassportElement(element tdlib.InputPassportElement, pas
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
switch tdlib.PassportElementEnum(result.Data["@type"].(string)) {

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetAllPassportElements Returns all available Telegram Passport elements
@ -22,7 +21,7 @@ func (client *Client) GetAllPassportElements(password string) (*tdlib.PassportEl
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var passportElements tdlib.PassportElements

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetPassportAuthorizationFormAvailableElements Returns already available Telegram Passport elements suitable for completing a Telegram Passport authorization form. Result can be received only once for each authorization form
@ -24,7 +23,7 @@ func (client *Client) GetPassportAuthorizationFormAvailableElements(autorization
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var passportElementsWithErrors tdlib.PassportElementsWithErrors

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetPasswordState Returns the current state of 2-step verification
@ -20,7 +19,7 @@ func (client *Client) GetPasswordState() (*tdlib.PasswordState, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var passwordState tdlib.PasswordState
@ -29,7 +28,7 @@ func (client *Client) GetPasswordState() (*tdlib.PasswordState, error) {
}
// SetPassword Changes the password for the user. If a new recovery email address is specified, then the change will not be applied until the new recovery email address is confirmed
// SetPassword Changes the password for the current user. If a new recovery email address is specified, then the change will not be applied until the new recovery email address is confirmed
// @param oldPassword Previous password of the user
// @param newPassword New password of the user; may be empty to remove the password
// @param newHint New password hint; may be empty
@ -50,7 +49,7 @@ func (client *Client) SetPassword(oldPassword string, newPassword string, newHin
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var passwordState tdlib.PasswordState
@ -74,7 +73,7 @@ func (client *Client) SetRecoveryEmailAddress(password string, newRecoveryEmailA
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var passwordState tdlib.PasswordState
@ -96,7 +95,7 @@ func (client *Client) CheckRecoveryEmailAddressCode(code string) (*tdlib.Passwor
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var passwordState tdlib.PasswordState
@ -116,7 +115,7 @@ func (client *Client) ResendRecoveryEmailAddressCode() (*tdlib.PasswordState, er
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var passwordState tdlib.PasswordState
@ -125,12 +124,16 @@ func (client *Client) ResendRecoveryEmailAddressCode() (*tdlib.PasswordState, er
}
// RecoverPassword Recovers the password using a recovery code sent to an email address that was previously set up
// RecoverPassword Recovers the 2-step verification password using a recovery code sent to an email address that was previously set up
// @param recoveryCode Recovery code to check
func (client *Client) RecoverPassword(recoveryCode string) (*tdlib.PasswordState, error) {
// @param newPassword New password of the user; may be empty to remove the password
// @param newHint New password hint; may be empty
func (client *Client) RecoverPassword(recoveryCode string, newPassword string, newHint string) (*tdlib.PasswordState, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "recoverPassword",
"recovery_code": recoveryCode,
"new_password": newPassword,
"new_hint": newHint,
})
if err != nil {
@ -138,7 +141,7 @@ func (client *Client) RecoverPassword(recoveryCode string) (*tdlib.PasswordState
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var passwordState tdlib.PasswordState

View File

@ -4,19 +4,20 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetPaymentForm Returns an invoice payment form. This method should be called when the user presses inlineKeyboardButtonBuy
// @param chatID Chat identifier of the Invoice message
// @param messageID Message identifier
func (client *Client) GetPaymentForm(chatID int64, messageID int64) (*tdlib.PaymentForm, error) {
// @param theme Preferred payment form theme
func (client *Client) GetPaymentForm(chatID int64, messageID int64, theme *tdlib.PaymentFormTheme) (*tdlib.PaymentForm, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getPaymentForm",
"chat_id": chatID,
"message_id": messageID,
"theme": theme,
})
if err != nil {
@ -24,7 +25,7 @@ func (client *Client) GetPaymentForm(chatID int64, messageID int64) (*tdlib.Paym
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var paymentForm tdlib.PaymentForm

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetPaymentReceipt Returns information about a successful payment
@ -24,7 +23,7 @@ func (client *Client) GetPaymentReceipt(chatID int64, messageID int64) (*tdlib.P
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var paymentReceipt tdlib.PaymentReceipt

View File

@ -4,25 +4,28 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// SendPaymentForm Sends a filled-out payment form to the bot for final verification
// @param chatID Chat identifier of the Invoice message
// @param messageID Message identifier
// @param orderInfoID Identifier returned by ValidateOrderInfo, or an empty string
// @param paymentFormID Payment form identifier returned by getPaymentForm
// @param orderInfoID Identifier returned by validateOrderInfo, or an empty string
// @param shippingOptionID Identifier of a chosen shipping option, if applicable
// @param credentials The credentials chosen by user for payment
func (client *Client) SendPaymentForm(chatID int64, messageID int64, orderInfoID string, shippingOptionID string, credentials tdlib.InputCredentials) (*tdlib.PaymentResult, error) {
// @param tipAmount Chosen by the user amount of tip in the smallest units of the currency
func (client *Client) SendPaymentForm(chatID int64, messageID int64, paymentFormID *tdlib.JSONInt64, orderInfoID string, shippingOptionID string, credentials tdlib.InputCredentials, tipAmount int64) (*tdlib.PaymentResult, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "sendPaymentForm",
"chat_id": chatID,
"message_id": messageID,
"payment_form_id": paymentFormID,
"order_info_id": orderInfoID,
"shipping_option_id": shippingOptionID,
"credentials": credentials,
"tip_amount": tipAmount,
})
if err != nil {
@ -30,7 +33,7 @@ func (client *Client) SendPaymentForm(chatID int64, messageID int64, orderInfoID
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var paymentResult tdlib.PaymentResult

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetPhoneNumberInfo Returns information about a phone number by its prefix. Can be called before authorization
@ -22,7 +21,31 @@ func (client *Client) GetPhoneNumberInfo(phoneNumberPrefix string) (*tdlib.Phone
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var phoneNumberInfo tdlib.PhoneNumberInfo
err = json.Unmarshal(result.Raw, &phoneNumberInfo)
return &phoneNumberInfo, err
}
// GetPhoneNumberInfoSync Returns information about a phone number by its prefix synchronously. getCountries must be called at least once after changing localization to the specified language if properly localized country information is expected. Can be called synchronously
// @param languageCode A two-letter ISO 639-1 country code for country information localization
// @param phoneNumberPrefix The phone number prefix
func (client *Client) GetPhoneNumberInfoSync(languageCode string, phoneNumberPrefix string) (*tdlib.PhoneNumberInfo, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getPhoneNumberInfoSync",
"language_code": languageCode,
"phone_number_prefix": phoneNumberPrefix,
})
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 phoneNumberInfo tdlib.PhoneNumberInfo

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetProxies Returns list of proxies that are currently set up. Can be called before authorization
@ -20,7 +19,7 @@ func (client *Client) GetProxies() (*tdlib.Proxies, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var proxies tdlib.Proxies

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// AddProxy Adds a proxy server for network requests. Can be called before authorization
@ -28,7 +27,7 @@ func (client *Client) AddProxy(server string, port int32, enable bool, typeParam
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var proxy tdlib.Proxy
@ -58,7 +57,7 @@ func (client *Client) EditProxy(proxyID int32, server string, port int32, enable
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var proxyDummy tdlib.Proxy

View File

@ -4,15 +4,14 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// RegisterDevice Registers the currently used device for receiving push notifications. Returns a globally unique identifier of the push notification subscription
// @param deviceToken Device token
// @param otherUserIDs List of user identifiers of other users currently using the application
func (client *Client) RegisterDevice(deviceToken tdlib.DeviceToken, otherUserIDs []int32) (*tdlib.PushReceiverID, error) {
func (client *Client) RegisterDevice(deviceToken tdlib.DeviceToken, otherUserIDs []int64) (*tdlib.PushReceiverID, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "registerDevice",
"device_token": deviceToken,
@ -24,7 +23,7 @@ func (client *Client) RegisterDevice(deviceToken tdlib.DeviceToken, otherUserIDs
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var pushReceiverID tdlib.PushReceiverID
@ -46,7 +45,7 @@ func (client *Client) GetPushReceiverID(payload string) (*tdlib.PushReceiverID,
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var pushReceiverID tdlib.PushReceiverID

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetRecommendedChatFilters Returns recommended chat filters for the current user
@ -20,7 +19,7 @@ func (client *Client) GetRecommendedChatFilters() (*tdlib.RecommendedChatFilters
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var recommendedChatFilters tdlib.RecommendedChatFilters

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetRecoveryEmailAddress Returns a 2-step verification recovery email address that was previously set up. This method can be used to verify a password provided by the user
@ -22,7 +21,7 @@ func (client *Client) GetRecoveryEmailAddress(password string) (*tdlib.RecoveryE
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var recoveryEmailAddress tdlib.RecoveryEmailAddress

46
client/resetPasswordResult.go Executable file
View File

@ -0,0 +1,46 @@
// AUTOGENERATED - DO NOT EDIT
package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// ResetPassword Removes 2-step verification password without previous password and access to recovery email address. The password can't be reset immediately and the request needs to be repeated after the specified time
func (client *Client) ResetPassword() (tdlib.ResetPasswordResult, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "resetPassword",
})
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.ResetPasswordResultEnum(result.Data["@type"].(string)) {
case tdlib.ResetPasswordResultOkType:
var resetPasswordResult tdlib.ResetPasswordResultOk
err = json.Unmarshal(result.Raw, &resetPasswordResult)
return &resetPasswordResult, err
case tdlib.ResetPasswordResultPendingType:
var resetPasswordResult tdlib.ResetPasswordResultPending
err = json.Unmarshal(result.Raw, &resetPasswordResult)
return &resetPasswordResult, err
case tdlib.ResetPasswordResultDeclinedType:
var resetPasswordResult tdlib.ResetPasswordResultDeclined
err = json.Unmarshal(result.Raw, &resetPasswordResult)
return &resetPasswordResult, err
default:
return nil, fmt.Errorf("Invalid type")
}
}

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetScopeNotificationSettings Returns the notification settings for chats of a given type
@ -22,7 +21,7 @@ func (client *Client) GetScopeNotificationSettings(scope tdlib.NotificationSetti
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var scopeNotificationSettings tdlib.ScopeNotificationSettings

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// PingProxy Computes time needed to receive a response from a Telegram server through a proxy. Can be called before authorization
@ -22,7 +21,7 @@ func (client *Client) PingProxy(proxyID int32) (*tdlib.Seconds, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var seconds tdlib.Seconds

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetSecretChat Returns information about a secret chat by its identifier. This is an offline request
@ -22,7 +21,7 @@ func (client *Client) GetSecretChat(secretChatID int32) (*tdlib.SecretChat, erro
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var secretChatDummy tdlib.SecretChat

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// ConfirmQrCodeAuthentication Confirms QR code authentication on another device. Returns created session on success
@ -22,7 +21,7 @@ func (client *Client) ConfirmQrCodeAuthentication(link string) (*tdlib.Session,
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var session tdlib.Session

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetActiveSessions Returns all active sessions of the current user
@ -20,7 +19,7 @@ func (client *Client) GetActiveSessions() (*tdlib.Sessions, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var sessions tdlib.Sessions

31
client/sponsoredMessages.go Executable file
View File

@ -0,0 +1,31 @@
// AUTOGENERATED - DO NOT EDIT
package client
import (
"encoding/json"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetChatSponsoredMessages Returns sponsored messages to be shown in a chat; for channel chats only
// @param chatID Identifier of the chat
func (client *Client) GetChatSponsoredMessages(chatID int64) (*tdlib.SponsoredMessages, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getChatSponsoredMessages",
"chat_id": chatID,
})
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 sponsoredMessages tdlib.SponsoredMessages
err = json.Unmarshal(result.Raw, &sponsoredMessages)
return &sponsoredMessages, err
}

View File

@ -6,7 +6,7 @@ import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetStatisticalGraph Loads an asynchronous or a zoomed in statistical graph
@ -26,7 +26,7 @@ func (client *Client) GetStatisticalGraph(chatID int64, token string, x int64) (
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
switch tdlib.StatisticalGraphEnum(result.Data["@type"].(string)) {

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetStickerSet Returns information about a sticker set by its identifier
@ -22,7 +21,7 @@ func (client *Client) GetStickerSet(setID *tdlib.JSONInt64) (*tdlib.StickerSet,
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var stickerSet tdlib.StickerSet
@ -44,7 +43,7 @@ func (client *Client) SearchStickerSet(name string) (*tdlib.StickerSet, error) {
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var stickerSet tdlib.StickerSet
@ -53,13 +52,14 @@ func (client *Client) SearchStickerSet(name string) (*tdlib.StickerSet, error) {
}
// CreateNewStickerSet Creates a new sticker set; for bots only. Returns the newly created sticker set
// @param userID Sticker set owner
// CreateNewStickerSet Creates a new sticker set. Returns the newly created sticker set
// @param userID Sticker set owner; ignored for regular users
// @param title Sticker set title; 1-64 characters
// @param name Sticker set name. Can contain only English letters, digits and underscores. Must end with *"_by_<bot username>"* (*<bot_username>* is case insensitive); 1-64 characters
// @param name Sticker set name. Can contain only English letters, digits and underscores. Must end with *"_by_<bot username>"* (*<bot_username>* is case insensitive) for bots; 1-64 characters
// @param isMasks True, if stickers are masks. Animated stickers can't be masks
// @param stickers List of stickers to be added to the set; must be non-empty. All stickers must be of the same type
func (client *Client) CreateNewStickerSet(userID int32, title string, name string, isMasks bool, stickers []tdlib.InputSticker) (*tdlib.StickerSet, error) {
// @param stickers List of stickers to be added to the set; must be non-empty. All stickers must be of the same type. For animated stickers, uploadStickerFile must be used before the sticker is shown
// @param source Source of the sticker set; may be empty if unknown
func (client *Client) CreateNewStickerSet(userID int64, title string, name string, isMasks bool, stickers []tdlib.InputSticker, source string) (*tdlib.StickerSet, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "createNewStickerSet",
"user_id": userID,
@ -67,6 +67,7 @@ func (client *Client) CreateNewStickerSet(userID int32, title string, name strin
"name": name,
"is_masks": isMasks,
"stickers": stickers,
"source": source,
})
if err != nil {
@ -74,7 +75,7 @@ func (client *Client) CreateNewStickerSet(userID int32, title string, name strin
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var stickerSet tdlib.StickerSet
@ -87,7 +88,7 @@ func (client *Client) CreateNewStickerSet(userID int32, title string, name strin
// @param userID Sticker set owner
// @param name Sticker set name
// @param sticker Sticker to add to the set
func (client *Client) AddStickerToSet(userID int32, name string, sticker tdlib.InputSticker) (*tdlib.StickerSet, error) {
func (client *Client) AddStickerToSet(userID int64, name string, sticker tdlib.InputSticker) (*tdlib.StickerSet, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "addStickerToSet",
"user_id": userID,
@ -100,7 +101,7 @@ func (client *Client) AddStickerToSet(userID int32, name string, sticker tdlib.I
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var stickerSet tdlib.StickerSet
@ -113,7 +114,7 @@ func (client *Client) AddStickerToSet(userID int32, name string, sticker tdlib.I
// @param userID Sticker set owner
// @param name Sticker set name
// @param thumbnail Thumbnail to set in PNG or TGS format. Animated thumbnail must be set for animated sticker sets and only for them. Pass a zero InputFileId to delete the thumbnail
func (client *Client) SetStickerSetThumbnail(userID int32, name string, thumbnail tdlib.InputFile) (*tdlib.StickerSet, error) {
func (client *Client) SetStickerSetThumbnail(userID int64, name string, thumbnail tdlib.InputFile) (*tdlib.StickerSet, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "setStickerSetThumbnail",
"user_id": userID,
@ -126,7 +127,7 @@ func (client *Client) SetStickerSetThumbnail(userID int32, name string, thumbnai
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var stickerSet tdlib.StickerSet

View File

@ -4,9 +4,8 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/tdlib"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// GetInstalledStickerSets Returns a list of installed sticker sets
@ -22,7 +21,7 @@ func (client *Client) GetInstalledStickerSets(isMasks bool) (*tdlib.StickerSets,
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var stickerSets tdlib.StickerSets
@ -48,7 +47,7 @@ func (client *Client) GetArchivedStickerSets(isMasks bool, offsetStickerSetID *t
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var stickerSets tdlib.StickerSets
@ -57,9 +56,9 @@ func (client *Client) GetArchivedStickerSets(isMasks bool, offsetStickerSetID *t
}
// GetTrendingStickerSets Returns a list of trending sticker sets. For the optimal performance the number of returned sticker sets is chosen by the library
// GetTrendingStickerSets Returns a list of trending sticker sets. For optimal performance, the number of returned sticker sets is chosen by TDLib
// @param offset The offset from which to return the sticker sets; must be non-negative
// @param limit The maximum number of sticker sets to be returned; must be non-negative. Fewer sticker sets may be returned than specified by the limit, even if the end of the list has not been reached
// @param limit The maximum number of sticker sets to be returned; must be non-negative. For optimal performance, the number of returned sticker sets is chosen by TDLib and can be smaller than the specified limit, even if the end of the list has not been reached
func (client *Client) GetTrendingStickerSets(offset int32, limit int32) (*tdlib.StickerSets, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "getTrendingStickerSets",
@ -72,7 +71,7 @@ func (client *Client) GetTrendingStickerSets(offset int32, limit int32) (*tdlib.
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var stickerSets tdlib.StickerSets
@ -94,7 +93,7 @@ func (client *Client) GetAttachedStickerSets(fileID int32) (*tdlib.StickerSets,
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var stickerSets tdlib.StickerSets
@ -120,7 +119,7 @@ func (client *Client) SearchInstalledStickerSets(isMasks bool, query string, lim
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var stickerSets tdlib.StickerSets
@ -142,7 +141,7 @@ func (client *Client) SearchStickerSets(query string) (*tdlib.StickerSets, error
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %d msg: %s", result.Data["code"], result.Data["message"])
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var stickerSets tdlib.StickerSets

Some files were not shown because too many files have changed in this diff Show More