мини фиксы
This commit is contained in:
@@ -20,28 +20,11 @@ type exec struct {
|
||||
}
|
||||
|
||||
var botUsername string
|
||||
var botUsernameOnce sync.Once
|
||||
|
||||
func SetBotUsername(username string) { botUsername = username }
|
||||
|
||||
func BotUsername() string { return botUsername }
|
||||
|
||||
func ensureBotUsername(api echotron.API) {
|
||||
if botUsername != "" {
|
||||
return
|
||||
}
|
||||
botUsernameOnce.Do(func() {
|
||||
me, err := api.GetMe()
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("GetMe failed, bot username will be empty")
|
||||
return
|
||||
}
|
||||
if me.Result != nil {
|
||||
botUsername = me.Result.Username
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
type lastRender struct {
|
||||
textHash string
|
||||
kbHash string
|
||||
@@ -77,7 +60,6 @@ func NewBot(chatID int64, token string, commandRouter func(string) State, backen
|
||||
}
|
||||
|
||||
api := echotron.NewAPI(token)
|
||||
ensureBotUsername(api)
|
||||
|
||||
return &Bot{
|
||||
ChatID: chatID,
|
||||
|
||||
Reference in New Issue
Block a user