Skip to content

Commit

Permalink
only accept commands in groups from admins
Browse files Browse the repository at this point in the history
  • Loading branch information
radiantspace committed May 4, 2024
1 parent d569dac commit e6afecd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions backend/app/telegram/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ func handleMessage(bot *telego.Bot, message telego.Message) {
log.Infof("Ignoring public command w/o @mention in channel: %s", chatIDString)
return
}
chatMember, err := bot.GetChatMember(&telego.GetChatMemberParams{
ChatID: chatID,
UserID: message.From.ID,
})
if err != nil {
log.Errorf("Error getting chat member: %v", err)
return
}
if err == nil && !isPrivate && chatMember.MemberStatus() != telego.MemberStatusCreator && chatMember.MemberStatus() != telego.MemberStatusAdministrator {
log.Infof("Ignoring public command from non-admin in channel: %s", chatIDString)
return
}
AllCommandHandlers.handleCommand(ctx, BOT, &message)
return
}
Expand Down

0 comments on commit e6afecd

Please sign in to comment.