Skip to content

Commit

Permalink
chore: 规范tg模块
Browse files Browse the repository at this point in the history
  • Loading branch information
twbworld committed Jan 13, 2024
1 parent e4fedb3 commit 3332147
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 60 deletions.
2 changes: 1 addition & 1 deletion controller/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ func Tg(ctx *gin.Context) {
}()

service.IsTgSend = false
err = service.TgWebhookHandle(ctx)
err = service.Webhook(ctx)

}
2 changes: 1 addition & 1 deletion initialize/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func Init() {
global.Log.Panicln("服务关闭出错[oijojiud]", err)
}
service.TgSend("服务退出成功")
service.TgWebhookClear()
TgClear()
global.Log.Infoln("服务退出成功")

}
10 changes: 9 additions & 1 deletion initialize/tg.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,17 @@ func TgInit() {
}

if info.LastErrorDate != 0 {
global.Log.Errorln("Telegram callback failed[fosdjfoisj]: ", info.LastErrorMessage)
global.Log.Errorln("获取tg信息错误[fosdjfoisj]: ", info.LastErrorMessage)
return
}
global.Log.Printf("成功配置tg[doiasjo]: %s", global.Bot.Self.UserName)
}
}

func TgClear() (err error) {
if global.Bot == nil {
return
}
_, err = global.Bot.Request(tg.DeleteWebhookConfig{})
return
}
2 changes: 2 additions & 0 deletions initialize/userHandle.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func Clear() {
} else {
err = tx.Commit()
if err != nil {
tx.Rollback()
panic("错误[sgfjhios]: " + err.Error())
}
global.Log.Println("[Clear]成功")
Expand Down Expand Up @@ -105,6 +106,7 @@ func Expiry() {
} else {
err = tx.Commit()
if err != nil {
tx.Rollback()
panic("错误[opiakjf]: " + err.Error())
}
global.Log.Infoln("[Expiry]过期用户处理: ", ids)
Expand Down
Loading

0 comments on commit 3332147

Please sign in to comment.