Skip to content

Commit

Permalink
If the command is not for the bot it does not respond
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelemusiani committed Jan 25, 2024
1 parent 9c14835 commit 77c3666
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions bot/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,14 @@ func handleUnknown(bot *tgbotapi.BotAPI, update *tgbotapi.Update, _ string) bool
func handleCommand(bot *tgbotapi.BotAPI, update *tgbotapi.Update) {
commandName := strings.ToLower(update.Message.Command())

if !update.Message.Chat.IsPrivate() {
// Check if the command is for me
commandWithAt := update.Message.CommandWithAt()
atIndex := strings.Index(commandWithAt, "@")
if atIndex != -1 {
forName := commandWithAt[atIndex+1:]
// Check if the command is for me
commandWithAt := update.Message.CommandWithAt()
atIndex := strings.Index(commandWithAt, "@")
if atIndex != -1 {
forName := commandWithAt[atIndex+1:]

if bot.Self.UserName != forName {
return
}
if bot.Self.UserName != forName {
return
}
}

Expand Down

0 comments on commit 77c3666

Please sign in to comment.