From f6d8d064ed1dee50a989ec22dccb2459fab11f8c Mon Sep 17 00:00:00 2001 From: Vladimir Hodakov Date: Sat, 23 Dec 2017 21:08:57 +0400 Subject: [PATCH] PokememBroInstinkt chat bans fix --- lib/chatter/restricters.go | 6 ++++++ lib/users/users.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/chatter/restricters.go b/lib/chatter/restricters.go index 5611f53..ae7bec9 100644 --- a/lib/chatter/restricters.go +++ b/lib/chatter/restricters.go @@ -12,8 +12,14 @@ import ( func (ct *Chatter) userPrivilegesCheck(update *tgbotapi.Update, user *tgbotapi.User) bool { // There are two special chats, pointed by config, where any member of league may be + defaultChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.DefaultID, 10, 64) bastionChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.BastionID, 10, 64) academyChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.AcademyID, 10, 64) + + if update.Message.Chat.ID == defaultChatID { + return true + } + // There are special users, which will bypass these checks specialUsers := []string{"gantz_yaka", "agentpb", "pbhelp"} diff --git a/lib/users/users.go b/lib/users/users.go index 64ec4e0..3339934 100644 --- a/lib/users/users.go +++ b/lib/users/users.go @@ -50,7 +50,7 @@ func (u *Users) getUsersWithProfiles() ([]dbmapping.PlayerProfile, bool) { func (u *Users) findUserByName(pattern string) ([]dbmapping.ProfileWithAddons, bool) { selectedUsers := []dbmapping.ProfileWithAddons{} - err := c.Db.Select(&selectedUsers, c.Db.Rebind("SELECT * FROM (SELECT p.*, l.symbol AS league_symbol, l.id AS league_id, pl.telegram_id FROM players pl, profiles p, leagues l WHERE p.player_id = pl.id AND l.id = pl.league_id AND (p.nickname LIKE ? OR p.telegram_nickname LIKE ?) ORDER BY p.id desc LIMIT 100000) AS find_users_table GROUP BY player_id"), "%"+pattern+"%", "%"+pattern+"%") + err := c.Db.Select(&selectedUsers, c.Db.Rebind("SELECT * FROM (SELECT p.*, l.symbol AS league_symbol, l.id AS league_id, pl.telegram_id FROM players pl, profiles p, leagues l WHERE p.player_id = pl.id AND l.id = pl.league_id AND (p.nickname LIKE ? OR p.telegram_nickname LIKE ?) ORDER BY p.id DESC LIMIT 100000) AS find_users_table GROUP BY player_id"), "%"+pattern+"%", "%"+pattern+"%") if err != nil { c.Log.Error(err.Error()) return selectedUsers, false