Updated to latest tl schema, updated the proxy example
This commit is contained in:
parent
9c93ddf88a
commit
3ea3923bfb
|
@ -14,9 +14,6 @@ func main() {
|
|||
tdlib.SetLogVerbosityLevel(1)
|
||||
tdlib.SetFilePath("./errors.txt")
|
||||
|
||||
// You can set username and password if needed
|
||||
socksProxy := tdlib.ProxySocks5{Server: "127.0.0.1", Port: 1112}
|
||||
|
||||
// Create new instance of client
|
||||
client := tdlib.NewClient(tdlib.Config{
|
||||
APIID: "187786",
|
||||
|
@ -32,9 +29,16 @@ func main() {
|
|||
DatabaseDirectory: "./tdlib-db",
|
||||
FileDirectory: "./tdlib-files",
|
||||
IgnoreFileNames: false,
|
||||
SocksProxy: &socksProxy, // Set the socks proxy
|
||||
})
|
||||
|
||||
// You can set user-name and password to empty of don't need it
|
||||
// Socks5
|
||||
client.AddProxy("127.0.0.1", 1234, true, tdlib.NewProxyTypeSocks5("user-name", "password"))
|
||||
// HTTP - HTTPS proxy
|
||||
client.AddProxy("127.0.0.1", 1234, true, tdlib.NewProxyTypeHttp("user-name", "password", false))
|
||||
// MtProto Proxy
|
||||
client.AddProxy("127.0.0.1", 1234, true, tdlib.NewProxyTypeMtproto("MTPROTO-SECRET"))
|
||||
|
||||
// Handle Ctrl+C
|
||||
ch := make(chan os.Signal, 2)
|
||||
signal.Notify(ch, os.Interrupt, syscall.SIGTERM)
|
||||
|
|
1484
methods.go
1484
methods.go
File diff suppressed because it is too large
Load Diff
27
tdlib.go
27
tdlib.go
|
@ -60,16 +60,15 @@ type Config struct {
|
|||
SystemVersion string // Version of the operating system the application is being run on; must be non-empty.
|
||||
ApplicationVersion string // Application version; must be non-empty.
|
||||
// Optional fields
|
||||
UseTestDataCenter bool // if set to true, the Telegram test environment will be used instead of the production environment.
|
||||
DatabaseDirectory string // The path to the directory for the persistent database; if empty, the current working directory will be used.
|
||||
FileDirectory string // The path to the directory for storing files; if empty, database_directory will be used.
|
||||
UseFileDatabase bool // If set to true, information about downloaded and uploaded files will be saved between application restarts.
|
||||
UseChatInfoDatabase bool // If set to true, the library will maintain a cache of users, basic groups, supergroups, channels and secret chats. Implies use_file_database.
|
||||
UseMessageDatabase bool // If set to true, the library will maintain a cache of chats and messages. Implies use_chat_info_database.
|
||||
UseSecretChats bool // If set to true, support for secret chats will be enabled.
|
||||
EnableStorageOptimizer bool // If set to true, old files will automatically be deleted.
|
||||
IgnoreFileNames bool // If set to true, original file names will be ignored. Otherwise, downloaded files will be saved under names as close as possible to the original name.
|
||||
SocksProxy *ProxySocks5 // Pass a ProxySocks5 if you need socks5 proxy. Username and password can be nil
|
||||
UseTestDataCenter bool // if set to true, the Telegram test environment will be used instead of the production environment.
|
||||
DatabaseDirectory string // The path to the directory for the persistent database; if empty, the current working directory will be used.
|
||||
FileDirectory string // The path to the directory for storing files; if empty, database_directory will be used.
|
||||
UseFileDatabase bool // If set to true, information about downloaded and uploaded files will be saved between application restarts.
|
||||
UseChatInfoDatabase bool // If set to true, the library will maintain a cache of users, basic groups, supergroups, channels and secret chats. Implies use_file_database.
|
||||
UseMessageDatabase bool // If set to true, the library will maintain a cache of chats and messages. Implies use_chat_info_database.
|
||||
UseSecretChats bool // If set to true, support for secret chats will be enabled.
|
||||
EnableStorageOptimizer bool // If set to true, old files will automatically be deleted.
|
||||
IgnoreFileNames bool // If set to true, original file names will be ignored. Otherwise, downloaded files will be saved under names as close as possible to the original name.
|
||||
}
|
||||
|
||||
// NewClient Creates a new instance of TDLib.
|
||||
|
@ -303,14 +302,6 @@ func (client *Client) Authorize() (AuthorizationState, error) {
|
|||
if ok == nil || err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if client.Config.SocksProxy != nil {
|
||||
ok, err = client.SetProxy(NewProxySocks5(client.Config.SocksProxy.Server, client.Config.SocksProxy.Port,
|
||||
client.Config.SocksProxy.Username, client.Config.SocksProxy.Password))
|
||||
if ok == nil || err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
authState, err := client.GetAuthorizationState()
|
||||
|
|
Loading…
Reference in New Issue