From 4d7f545c92e244f82bca44424abd06210ab8d6b2 Mon Sep 17 00:00:00 2001 From: Vladimir Hodakov Date: Wed, 29 Nov 2017 12:19:30 +0400 Subject: [PATCH] Ban politic lifted for a while --- lib/squader/squader.go | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/lib/squader/squader.go b/lib/squader/squader.go index 15d3371..ea08fb5 100644 --- a/lib/squader/squader.go +++ b/lib/squader/squader.go @@ -211,24 +211,28 @@ func (s *Squader) getCommandersForSquadViaChat(chatRaw *dbmapping.Chat) ([]dbmap } func (s *Squader) kickUserFromSquadChat(user *tgbotapi.User, chatRaw *dbmapping.Chat) { - chatUserConfig := tgbotapi.ChatMemberConfig{ - ChatID: chatRaw.TelegramID, - UserID: user.ID, - } + bastionChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.BastionID, 10, 64) + hqChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.HeadquartersID, 10, 64) + if chatRaw.TelegramID == bastionChatID { + chatUserConfig := tgbotapi.ChatMemberConfig{ + ChatID: chatRaw.TelegramID, + UserID: user.ID, + } - kickConfig := tgbotapi.KickChatMemberConfig{ - ChatMemberConfig: chatUserConfig, - UntilDate: 1893456000, - } + kickConfig := tgbotapi.KickChatMemberConfig{ + ChatMemberConfig: chatUserConfig, + UntilDate: 1893456000, + } - _, err := c.Bot.KickChatMember(kickConfig) - if err != nil { - c.Log.Error(err.Error()) - } + _, err := c.Bot.KickChatMember(kickConfig) + if err != nil { + c.Log.Error(err.Error()) + } - _, err = c.Bot.UnbanChatMember(chatUserConfig) - if err != nil { - c.Log.Error(err.Error()) + _, err = c.Bot.UnbanChatMember(chatUserConfig) + if err != nil { + c.Log.Error(err.Error()) + } } suerName := "" @@ -240,9 +244,6 @@ func (s *Squader) kickUserFromSquadChat(user *tgbotapi.User, chatRaw *dbmapping. suerName += " " + user.LastName } } - - bastionChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.BastionID, 10, 64) - hqChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.HeadquartersID, 10, 64) if chatRaw.TelegramID != bastionChatID { // In Bastion notifications are public in default chat commanders, ok := s.getCommandersForSquadViaChat(chatRaw)