Archived
1

New Year 2018 preparations

This commit is contained in:
Vladimir Hodakov 2017-12-28 05:57:51 +04:00
parent bbb0b8afe1
commit 880810d90c
4 changed files with 78 additions and 2 deletions

View File

@ -6,6 +6,7 @@ package talkers
import ( import (
"github.com/go-telegram-bot-api/telegram-bot-api" "github.com/go-telegram-bot-api/telegram-bot-api"
"math/rand" "math/rand"
"strconv"
"time" "time"
) )
@ -67,3 +68,70 @@ func (t *Talkers) MatMessage(update *tgbotapi.Update) string {
return "ok" return "ok"
} }
// NewYearMessage2018 pins new year 2018 message to bastion, default and academy chats.
func (t *Talkers) NewYearMessage2018() {
academyChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.AcademyID, 10, 64)
bastionChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.BastionID, 10, 64)
defaultChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.DefaultID, 10, 64)
message := "*Совет лиги Инстинкт поздравляет вас, дорогие игроки, с Новым 2018 Годом!*\n"
message += "*Важное сообщение от* Совета лиги Инстинкт (коллективное сознательное)\n\n"
message += "*Д*орогие бойцы Инстинкта!\n"
message += "*А* как насчет новогоднего поздравления?\n"
message += "*С*корее наполните бокалы!\n"
message += "*К*онечно, хочется пожелать отличного кача...\n"
message += "*А*, и про удачный дроп элиток не забыть!\n"
message += "*Л*иберах побольше в охотах.\n"
message += "*Л*овите отвагу с мистик в БО, спуску не давайте)\n"
message += "*О*днажды мы станем топ не только по очкам, но и по атаке;\n"
message += "*Х*уй им, в общем, всем — с бантиком!"
msg := tgbotapi.NewMessage(defaultChatID, message)
msg.ParseMode = "Markdown"
pinnableMessage, _ := c.Bot.Send(msg)
pinChatMessageConfig := tgbotapi.PinChatMessageConfig{
ChatID: pinnableMessage.Chat.ID,
MessageID: pinnableMessage.MessageID,
DisableNotification: false,
}
_, err := c.Bot.PinChatMessage(pinChatMessageConfig)
if err != nil {
c.Log.Error(err.Error())
}
msg = tgbotapi.NewMessage(bastionChatID, message)
msg.ParseMode = "Markdown"
pinnableMessage, _ = c.Bot.Send(msg)
pinChatMessageConfig = tgbotapi.PinChatMessageConfig{
ChatID: pinnableMessage.Chat.ID,
MessageID: pinnableMessage.MessageID,
DisableNotification: false,
}
_, err = c.Bot.PinChatMessage(pinChatMessageConfig)
if err != nil {
c.Log.Error(err.Error())
}
msg = tgbotapi.NewMessage(academyChatID, message)
msg.ParseMode = "Markdown"
pinnableMessage, _ = c.Bot.Send(msg)
pinChatMessageConfig = tgbotapi.PinChatMessageConfig{
ChatID: pinnableMessage.Chat.ID,
MessageID: pinnableMessage.MessageID,
DisableNotification: false,
}
_, err = c.Bot.PinChatMessage(pinChatMessageConfig)
if err != nil {
c.Log.Error(err.Error())
}
}

View File

@ -25,4 +25,6 @@ func New(ac *appcontext.Context) {
// Init is an initialization function for talkers // Init is an initialization function for talkers
func (t *Talkers) Init() { func (t *Talkers) Init() {
c.Log.Info("Initializing common Responders...") c.Log.Info("Initializing common Responders...")
c.Cron.AddFunc("0 0 0 1 1 *", t.NewYearMessage2018)
} }

View File

@ -23,4 +23,6 @@ type TalkersInterface interface {
LongMessage(update *tgbotapi.Update) string LongMessage(update *tgbotapi.Update) string
DurakMessage(update *tgbotapi.Update) string DurakMessage(update *tgbotapi.Update) string
MatMessage(update *tgbotapi.Update) string MatMessage(update *tgbotapi.Update) string
NewYearMessage2018()
} }

View File

@ -284,8 +284,8 @@ func (u *Users) ParseProfile(update *tgbotapi.Update, playerRaw *dbmapping.Playe
return "fail" return "fail"
} }
for n_meme, attack := range pokememes { for nMeme, attack := range pokememes {
memeAry := strings.Split(n_meme, "_") memeAry := strings.Split(nMeme, "_")
meme := memeAry[1] meme := memeAry[1]
rarity := "common" rarity := "common"
if strings.HasPrefix(meme, "🔸") { if strings.HasPrefix(meme, "🔸") {
@ -304,6 +304,10 @@ func (u *Users) ParseProfile(update *tgbotapi.Update, playerRaw *dbmapping.Playe
rarity = "super liber" rarity = "super liber"
meme = strings.Replace(meme, "🔷", "", 1) meme = strings.Replace(meme, "🔷", "", 1)
} }
if strings.HasPrefix(meme, "❄️") {
rarity = "new year"
meme = strings.Replace(meme, "❄️", "", 1)
}
u.fillProfilePokememe(profileRaw.ID, meme, attack, rarity) u.fillProfilePokememe(profileRaw.ID, meme, attack, rarity)
} }