hdkv
/
i2_bot
Archived
1
Fork 0

Add debug to restrictions workflow

master
Vladimir Hodakov 2018-03-31 17:44:12 +04:00
parent 8af3e5b03a
commit e12cada4c4
1 changed files with 6 additions and 2 deletions

View File

@ -4,10 +4,11 @@
package chatter package chatter
import ( import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"strconv" "strconv"
"strings" "strings"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
) )
func (ct *Chatter) userPrivilegesCheck(update *tgbotapi.Update, user *tgbotapi.User) bool { func (ct *Chatter) userPrivilegesCheck(update *tgbotapi.Update, user *tgbotapi.User) bool {
@ -116,9 +117,11 @@ func (ct *Chatter) ProtectChat(update *tgbotapi.Update, playerRaw *dbmapping.Pla
if update.Message.NewChatMembers != nil { if update.Message.NewChatMembers != nil {
newUsers := *update.Message.NewChatMembers newUsers := *update.Message.NewChatMembers
if len(newUsers) > 0 { if len(newUsers) > 0 {
c.Log.Debug("New users joined/added to chat. Checking rights for them.")
for i := range newUsers { for i := range newUsers {
newUserPassed := ct.userPrivilegesCheck(update, &newUsers[i]) newUserPassed := ct.userPrivilegesCheck(update, &newUsers[i])
if !newUserPassed { if !newUserPassed {
c.Log.Debug("This user can't be here: removing from chat...")
ct.BanUserFromChat(&newUsers[i], chatRaw) ct.BanUserFromChat(&newUsers[i], chatRaw)
} }
} }
@ -127,6 +130,7 @@ func (ct *Chatter) ProtectChat(update *tgbotapi.Update, playerRaw *dbmapping.Pla
existingUserPassed := ct.userPrivilegesCheck(update, update.Message.From) existingUserPassed := ct.userPrivilegesCheck(update, update.Message.From)
if !existingUserPassed { if !existingUserPassed {
c.Log.Debug("Existing chat user can't be here. Vanishing...")
ct.BanUserFromChat(update.Message.From, chatRaw) ct.BanUserFromChat(update.Message.From, chatRaw)
return "fail" return "fail"
} }