我正在使用go-tdlib收集 Telegram 中的消息。当我第三次重新启动服务时。它停止工作。所以我打印了这些消息。它不断给我authorizationsStateWaitPhoneNumber
地位。我什至无法在控制台中输入我的电话号码。下面是代码:
package main
import (
"fmt"
"log"
"math"
"os"
"os/signal"
"syscall"
"time"
"github.com/Arman92/go-tdlib"
"github.com/joho/godotenv"
)
const (
MaxAttempt = 10
)
var (
apiID string
apiHash string
)
var allChats []*tdlib.Chat
var haveFullChatList bool
func main() {
log.Println("Start Service")
log.Printf("API ID: %+v\n", apiID)
log.Printf("API HASH: %+v\n", apiHash)
tdlib.SetLogVerbosityLevel(1)
tdlib.SetFilePath("./errors.txt")
// Create new instance of client
client := tdlib.NewClient(tdlib.Config{
APIID: apiID,
APIHash: apiHash,
SystemLanguageCode: "en",
DeviceModel: "Server",
SystemVersion: "1.0.0",
ApplicationVersion: "1.0.0",
UseMessageDatabase: true,
UseFileDatabase: true,
UseChatInfoDatabase: true,
UseTestDataCenter: false,
DatabaseDirectory: "./tdlib-db",
FileDirectory: "./tdlib-files",
IgnoreFileNames: false,
})
log.Println("Starting auth")
// Wait while we get AuthorizationReady!
// Note: See authorization example for complete authorization sequence example
currentState, err := client.Authorize()
if err != nil {
log.Fatalf("Authorize error: %+v\n", err)
}
attempt := 0
for ; currentState.GetAuthorizationStateEnum() != tdlib.AuthorizationStateReadyType; currentState, err = client.Authorize() {
if err != nil {
log.Fatalf("Authorize error: %+v\n", err)
}
fmt.Printf("Current auth state: %+v\n", currentState)
attempt += 1
time.Sleep(5000 * time.Millisecond)
}
以前有人遇到过这个问题吗?我究竟做错了什么?
茅侃侃
相关分类