2017-10-06 02:56:06 +04:00
|
|
|
|
// i2_bot – Instinct PokememBro Bot
|
|
|
|
|
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
|
|
|
|
|
|
2017-11-21 06:06:32 +04:00
|
|
|
|
package welcomer
|
2017-10-06 02:56:06 +04:00
|
|
|
|
|
|
|
|
|
import (
|
2017-10-07 19:58:14 +04:00
|
|
|
|
"github.com/go-telegram-bot-api/telegram-bot-api"
|
2017-10-26 18:17:58 +04:00
|
|
|
|
"lab.pztrn.name/fat0troll/i2_bot/lib/dbmapping"
|
2017-10-06 02:56:06 +04:00
|
|
|
|
)
|
|
|
|
|
|
2017-11-21 06:06:32 +04:00
|
|
|
|
// PrivateWelcomeMessageUnauthorized tell new user what to do.
|
|
|
|
|
func (w *Welcomer) PrivateWelcomeMessageUnauthorized(update *tgbotapi.Update) {
|
2017-10-18 09:39:50 +04:00
|
|
|
|
message := "*Бот Инстинкта приветствует тебя!*\n\n"
|
|
|
|
|
message += "Для начала работы с ботом, пожалуйста, перешли от бота игры @PokememBroBot профиль героя.\n"
|
|
|
|
|
message += "Все дальнейшие действия с ботом возможны лишь при наличии профиля игрока."
|
2017-10-06 02:56:06 +04:00
|
|
|
|
|
2017-10-18 09:39:50 +04:00
|
|
|
|
msg := tgbotapi.NewMessage(update.Message.Chat.ID, message)
|
2017-10-18 07:03:34 +04:00
|
|
|
|
msg.ParseMode = "Markdown"
|
2017-10-06 02:56:06 +04:00
|
|
|
|
|
2017-10-18 07:03:34 +04:00
|
|
|
|
c.Bot.Send(msg)
|
2017-10-06 02:56:06 +04:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-21 06:06:32 +04:00
|
|
|
|
// PrivateWelcomeMessageAuthorized greets existing user
|
|
|
|
|
func (w *Welcomer) PrivateWelcomeMessageAuthorized(update *tgbotapi.Update, playerRaw *dbmapping.Player) {
|
2017-10-18 09:39:50 +04:00
|
|
|
|
message := "*Бот Инстинкта приветствует тебя. Снова.*\n\n"
|
|
|
|
|
message += "Привет, " + update.Message.From.FirstName + " " + update.Message.From.LastName + "!\n"
|
|
|
|
|
message += "Последнее обновление информации о тебе: " + playerRaw.UpdatedAt.Format("02.01.2006 15:04:05 -0700")
|
|
|
|
|
message += "\nПосмотреть информацию о себе: /me"
|
|
|
|
|
msg := tgbotapi.NewMessage(update.Message.Chat.ID, message)
|
2017-10-18 07:03:34 +04:00
|
|
|
|
msg.ParseMode = "Markdown"
|
2017-10-06 02:56:06 +04:00
|
|
|
|
|
2017-10-18 07:03:34 +04:00
|
|
|
|
c.Bot.Send(msg)
|
2017-10-06 02:56:06 +04:00
|
|
|
|
}
|
2017-11-21 06:06:32 +04:00
|
|
|
|
|
|
|
|
|
// GroupWelcomeMessage welcomes new user on group or bot itself
|
|
|
|
|
func (w *Welcomer) GroupWelcomeMessage(update *tgbotapi.Update) string {
|
|
|
|
|
newUsers := *update.Message.NewChatMembers
|
|
|
|
|
for i := range newUsers {
|
|
|
|
|
if (newUsers[i].UserName == "i2_bot") || (newUsers[i].UserName == "i2_dev_bot") {
|
|
|
|
|
w.groupStartMessage(update)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
newUser := newUsers[i]
|
|
|
|
|
w.groupWelcomeUser(update, &newUser)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "ok"
|
|
|
|
|
}
|