2017-11-13 22:51:50 +04:00
|
|
|
|
// i2_bot – Instinct PokememBro Bot
|
|
|
|
|
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
|
|
|
|
|
|
|
|
|
|
package welcomer
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/go-telegram-bot-api/telegram-bot-api"
|
2017-11-14 03:44:21 +04:00
|
|
|
|
"strconv"
|
2017-11-13 22:51:50 +04:00
|
|
|
|
)
|
|
|
|
|
|
2017-11-14 03:44:21 +04:00
|
|
|
|
func (w *Welcomer) alertUserWithoutProfile(update *tgbotapi.Update, newUser *tgbotapi.User) string {
|
2017-11-26 16:54:06 +04:00
|
|
|
|
alertGroupID, _ := strconv.ParseInt(c.Cfg.SpecialChats.HeadquartersID, 10, 64)
|
2018-02-17 07:03:58 +04:00
|
|
|
|
chat, err := c.DataCache.GetOrCreateChat(update)
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.Log.Error(err.Error())
|
2017-11-13 22:51:50 +04:00
|
|
|
|
return "fail"
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-01 10:55:18 +04:00
|
|
|
|
userName := ""
|
|
|
|
|
if newUser.UserName != "" {
|
|
|
|
|
userName += "@" + newUser.UserName
|
|
|
|
|
} else {
|
|
|
|
|
userName += newUser.FirstName
|
|
|
|
|
if newUser.LastName != "" {
|
|
|
|
|
userName += " " + newUser.LastName
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-13 22:51:50 +04:00
|
|
|
|
message := "*Новый вход пользователя без профиля в чат с ботом!*\n"
|
2017-12-01 10:55:18 +04:00
|
|
|
|
message += "В чат _" + chat.Name + "_ вошёл некто " + c.Users.FormatUsername(userName)
|
2017-11-13 22:51:50 +04:00
|
|
|
|
message += ". Он получил уведомление о том, что ему нужно создать профиль в боте."
|
|
|
|
|
|
|
|
|
|
msg := tgbotapi.NewMessage(alertGroupID, message)
|
|
|
|
|
msg.ParseMode = "Markdown"
|
|
|
|
|
|
|
|
|
|
c.Bot.Send(msg)
|
|
|
|
|
|
|
|
|
|
return "ok"
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-14 03:44:21 +04:00
|
|
|
|
func (w *Welcomer) alertSpyUser(update *tgbotapi.Update, newUser *tgbotapi.User) string {
|
2017-11-26 16:54:06 +04:00
|
|
|
|
alertGroupID, _ := strconv.ParseInt(c.Cfg.SpecialChats.HeadquartersID, 10, 64)
|
2018-02-17 07:03:58 +04:00
|
|
|
|
chat, err := c.DataCache.GetOrCreateChat(update)
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.Log.Error(err.Error())
|
2017-11-13 22:51:50 +04:00
|
|
|
|
return "fail"
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-01 10:55:18 +04:00
|
|
|
|
userName := ""
|
|
|
|
|
if newUser.UserName != "" {
|
|
|
|
|
userName += "@" + newUser.UserName
|
|
|
|
|
} else {
|
|
|
|
|
userName += newUser.FirstName
|
|
|
|
|
if newUser.LastName != "" {
|
|
|
|
|
userName += " " + newUser.LastName
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-13 22:51:50 +04:00
|
|
|
|
message := "*Шпион в деле!*\n"
|
2017-12-01 10:55:18 +04:00
|
|
|
|
message += "В чат _" + chat.Name + "_ вошёл некто " + c.Users.FormatUsername(userName)
|
2017-11-13 22:51:50 +04:00
|
|
|
|
message += ". У него профиль другой лиги. Ждём обновлений."
|
|
|
|
|
|
|
|
|
|
msg := tgbotapi.NewMessage(alertGroupID, message)
|
|
|
|
|
msg.ParseMode = "Markdown"
|
|
|
|
|
|
|
|
|
|
c.Bot.Send(msg)
|
|
|
|
|
|
|
|
|
|
return "ok"
|
|
|
|
|
}
|