51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
|
package telegram
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"github.com/zelenin/go-tdlib/client"
|
||
|
)
|
||
|
|
||
|
type TelegramClient struct {
|
||
|
Client *client.Client
|
||
|
}
|
||
|
|
||
|
func NewTelegramClient(apiID int32, apiHash string) (*TelegramClient, error) {
|
||
|
authorizer := client.ClientAuthorizer()
|
||
|
go client.CliInteractor(authorizer)
|
||
|
|
||
|
authorizer.TdlibParameters <- &client.SetTdlibParametersRequest{
|
||
|
UseTestDc: false,
|
||
|
//DatabaseDirectory: filepath.Join(".tdlib", "database"),
|
||
|
//FilesDirectory: filepath.Join(".tdlib", "files"),
|
||
|
UseFileDatabase: false,
|
||
|
UseChatInfoDatabase: false,
|
||
|
UseMessageDatabase: false,
|
||
|
UseSecretChats: true,
|
||
|
ApiId: apiID,
|
||
|
ApiHash: apiHash,
|
||
|
SystemLanguageCode: "en",
|
||
|
DeviceModel: "Server",
|
||
|
SystemVersion: "1.0.0",
|
||
|
ApplicationVersion: "1.0.0",
|
||
|
}
|
||
|
|
||
|
tdlibClient, err := client.NewClient(authorizer)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
me, err := tdlibClient.GetMe()
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
fmt.Printf("Me: %s %s [%v]", me.FirstName, me.LastName, me.Usernames)
|
||
|
|
||
|
return &TelegramClient{
|
||
|
Client: tdlibClient,
|
||
|
}, nil
|
||
|
}
|
||
|
|
||
|
func (tg *TelegramClient) CreateChannel(channelName string, botID int64) (string, error) {
|
||
|
return "", nil
|
||
|
}
|