2019-12-29 03:45:12 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/Arman92/go-tdlib"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
ownUserID64 = int64(0)
|
|
|
|
ownUserID32 = int32(0)
|
2019-12-29 04:03:06 +01:00
|
|
|
chtwrsID64 = int64(408101137)
|
2019-12-29 03:45:12 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
|
|
tdlib.SetLogVerbosityLevel(1)
|
|
|
|
tdlib.SetFilePath("./errors.txt")
|
|
|
|
|
|
|
|
// Create new instance of client
|
|
|
|
client := tdlib.NewClient(tdlib.Config{
|
|
|
|
APIID: "187786",
|
|
|
|
APIHash: "e782045df67ba48e441ccb105da8fc85",
|
|
|
|
SystemLanguageCode: "en",
|
|
|
|
DeviceModel: "ChatWarsExport",
|
|
|
|
SystemVersion: "0.1",
|
|
|
|
ApplicationVersion: "0.1",
|
|
|
|
UseMessageDatabase: true,
|
|
|
|
UseFileDatabase: true,
|
|
|
|
UseChatInfoDatabase: true,
|
|
|
|
UseTestDataCenter: false,
|
|
|
|
DatabaseDirectory: "./tdlib-db",
|
|
|
|
FileDirectory: "./tdlib-files",
|
|
|
|
IgnoreFileNames: false,
|
|
|
|
})
|
|
|
|
|
|
|
|
for {
|
|
|
|
currentState, _ := client.Authorize()
|
|
|
|
if currentState.GetAuthorizationStateEnum() == tdlib.AuthorizationStateWaitPhoneNumberType {
|
|
|
|
fmt.Print("Enter phone: ")
|
|
|
|
var number string
|
|
|
|
fmt.Scanln(&number)
|
|
|
|
_, err := client.SendPhoneNumber(number)
|
|
|
|
logOnError(err, "Error sending phone number.")
|
|
|
|
} else if currentState.GetAuthorizationStateEnum() == tdlib.AuthorizationStateWaitCodeType {
|
|
|
|
fmt.Print("Enter code: ")
|
|
|
|
var code string
|
|
|
|
fmt.Scanln(&code)
|
|
|
|
_, err := client.SendAuthCode(code)
|
|
|
|
logOnError(err, "Error sending auth code.")
|
|
|
|
} else if currentState.GetAuthorizationStateEnum() == tdlib.AuthorizationStateWaitPasswordType {
|
|
|
|
fmt.Print("Enter Password: ")
|
|
|
|
var password string
|
|
|
|
fmt.Scanln(&password)
|
|
|
|
_, err := client.SendAuthPassword(password)
|
|
|
|
logOnError(err, "Error sending auth password.")
|
|
|
|
} else if currentState.GetAuthorizationStateEnum() == tdlib.AuthorizationStateReadyType {
|
|
|
|
fmt.Println("Authorization Ready! Let's rock")
|
|
|
|
break
|
|
|
|
}
|
|
|
|
time.Sleep(1 * time.Second)
|
|
|
|
}
|
|
|
|
|
|
|
|
ownUserID32 = OwnUserID(client)
|
|
|
|
ownUserID64 = int64(OwnUserID(client))
|
|
|
|
|
2019-12-29 04:06:34 +01:00
|
|
|
getHistory(client, chtwrsID64)
|
2019-12-29 03:45:12 +01:00
|
|
|
|
|
|
|
}
|