EugenSleptsov / chatgpt

Simple telegram bot for openai GPT api in Golang
MIT License
5 stars 2 forks source link

Crash #13

Closed 0-BuTaJIuK-0 closed 1 year ago

0-BuTaJIuK-0 commented 1 year ago

A very wonderful repository! I use it for home purposes, I am very satisfied.

// If no authorized users are provided, make the bot public
        if len(config.AuthorizedUserIds) > 0 {
            if !util.IsIdInList(update.Message.From.ID, config.AuthorizedUserIds) {
                if update.Message.Chat.Type == "private" {
                    bot.Reply(chat.ChatID, update.Message.MessageID, "Sorry, you do not have access to this bot.", false)
                    log.Printf("Unauthorized access attempt by user %d: %s %s (%s)", update.Message.From.ID, update.Message.From.FirstName, update.Message.From.LastName, update.Message.From.UserName)
                    // Notify the admin
                    if config.AdminId > 0 {
                        adminMessage := fmt.Sprintf("Unauthorized access attempt by user %d: %s %s (%s)", update.Message.From.ID, update.Message.From.FirstName, update.Message.From.LastName, update.Message.From.UserName)
                        bot.Message(adminMessage, config.AdminId, false)
                    }
                }
                continue
            }
        }

The application crashes when an unauthorized user writes. I change, and all ok:

bot.Reply(chat.ChatID, update.Message.MessageID, "Sorry, you do not have access to this bot.", false) bot.Reply(chatID, update.Message.MessageID, "Sorry, you do not have access to this bot.", false)

EugenSleptsov commented 1 year ago

Hello, thanks, I will check soon why there is a crash

EugenSleptsov commented 1 year ago

The problem resolved, thanks for pointing out