Archived
1

Work on squads, alerts on new user with empty or spy profile

Closes #1
Closes #2
This commit is contained in:
2017-11-13 22:51:50 +04:00
parent 76b6245b8e
commit 5c08899d25
23 changed files with 338 additions and 19 deletions

View File

@@ -0,0 +1,49 @@
// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
package welcomer
import (
// stdlib
"strconv"
// 3rd party
"github.com/go-telegram-bot-api/telegram-bot-api"
)
func (w *Welcomer) alertUserWithoutProfile(update tgbotapi.Update) string {
alertGroupID, _ := strconv.ParseInt(c.Cfg.Notifications.GroupID, 10, 64)
chat, ok := c.Getters.GetOrCreateChat(&update)
if !ok {
return "fail"
}
message := "*Новый вход пользователя без профиля в чат с ботом!*\n"
message += "В чат _" + chat.Name + "_ вошёл некто @" + update.Message.NewChatMember.UserName
message += ". Он получил уведомление о том, что ему нужно создать профиль в боте."
msg := tgbotapi.NewMessage(alertGroupID, message)
msg.ParseMode = "Markdown"
c.Bot.Send(msg)
return "ok"
}
func (w *Welcomer) alertSpyUser(update tgbotapi.Update) string {
alertGroupID, _ := strconv.ParseInt(c.Cfg.Notifications.GroupID, 10, 64)
chat, ok := c.Getters.GetOrCreateChat(&update)
if !ok {
return "fail"
}
message := "*Шпион в деле!*\n"
message += "В чат _" + chat.Name + "_ вошёл некто @" + update.Message.NewChatMember.UserName
message += ". У него профиль другой лиги. Ждём обновлений."
msg := tgbotapi.NewMessage(alertGroupID, message)
msg.ParseMode = "Markdown"
c.Bot.Send(msg)
return "ok"
}