Change default logger for telego and use register instead of clear.
This commit is contained in:
parent
3523ffeba7
commit
6a55aa5ca0
2 changed files with 11 additions and 4 deletions
|
|
@ -52,6 +52,7 @@ func (a *App) loadCron() error {
|
|||
a.settings.System.TimeZone,
|
||||
a.settings.DailyScripture.Schedule), a.scripture)
|
||||
|
||||
fmt.Println("using schedule:", fmt.Sprintf("TZ=%s %s", a.settings.System.TimeZone, a.settings.DailyScripture.Schedule))
|
||||
a.cron.Start()
|
||||
fmt.Println("cron started")
|
||||
|
||||
|
|
@ -97,7 +98,7 @@ func (a *App) scripture() {
|
|||
|
||||
for _, chat := range chats {
|
||||
fmt.Println("chat:", chat)
|
||||
vv, err := a.db.Verses().RandomVerseForChat(chat.ID)
|
||||
vv, err := a.db.Verses().RandomVerseRotateTx(chat.ID)
|
||||
if err != nil {
|
||||
fmt.Println("error retrieving random verse:", err)
|
||||
fmt.Println("chat ID:", chat.ID)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/mymmrac/telego"
|
||||
th "github.com/mymmrac/telego/telegohandler"
|
||||
tu "github.com/mymmrac/telego/telegoutil"
|
||||
"go.destrealm.net/logging/v3"
|
||||
)
|
||||
|
||||
type bot struct {
|
||||
|
|
@ -42,7 +43,12 @@ func NewBot(ctx context.Context, conf *settings.Settings) *bot {
|
|||
}
|
||||
|
||||
func (b *bot) init() {
|
||||
tgbot, err := telego.NewBot(b.settings.Service.BotToken, telego.WithDefaultDebugLogger())
|
||||
logger := logging.Logger().Get("bot")
|
||||
logger.SetLevel(logging.Debug)
|
||||
|
||||
tgbot, err := telego.NewBot(b.settings.Service.BotToken,
|
||||
telego.WithLogger(logger))
|
||||
//telego.WithDefaultDebugLogger())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
@ -140,7 +146,7 @@ func (b *bot) SetCommands(ctx context.Context) (err error) {
|
|||
commands, err := b.tgbot.GetMyCommands(ctx, &telego.GetMyCommandsParams{})
|
||||
fmt.Println(commands)
|
||||
if len(commands) > 0 {
|
||||
if b.settings.Debug.Commands.Reset || b.settings.Debug.Commands.Clear {
|
||||
if b.settings.Debug.Commands.Reset {
|
||||
b.tgbot.DeleteMyCommands(ctx, &telego.DeleteMyCommandsParams{
|
||||
Scope: &telego.BotCommandScopeAllChatAdministrators{
|
||||
Type: "all_chat_administrators",
|
||||
|
|
@ -153,7 +159,7 @@ func (b *bot) SetCommands(ctx context.Context) (err error) {
|
|||
}
|
||||
return
|
||||
}
|
||||
if b.settings.Debug.Commands.Clear {
|
||||
if !b.settings.Debug.Commands.Register {
|
||||
return
|
||||
}
|
||||
b.tgbot.SetMyCommands(ctx, &telego.SetMyCommandsParams{
|
||||
|
|
|
|||
Loading…
Reference in a new issue