diff --git a/lib/talkers/easter.go b/lib/talkers/easter.go index 05659c5..02afdef 100644 --- a/lib/talkers/easter.go +++ b/lib/talkers/easter.go @@ -6,6 +6,7 @@ package talkers import ( "github.com/go-telegram-bot-api/telegram-bot-api" "math/rand" + "strconv" "time" ) @@ -67,3 +68,70 @@ func (t *Talkers) MatMessage(update *tgbotapi.Update) string { 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()) + } +} diff --git a/lib/talkers/exported.go b/lib/talkers/exported.go index c5672d1..0829fe4 100644 --- a/lib/talkers/exported.go +++ b/lib/talkers/exported.go @@ -25,4 +25,6 @@ func New(ac *appcontext.Context) { // Init is an initialization function for talkers func (t *Talkers) Init() { c.Log.Info("Initializing common Responders...") + + c.Cron.AddFunc("0 0 0 1 1 *", t.NewYearMessage2018) } diff --git a/lib/talkers/talkersinterface/talkersinterface.go b/lib/talkers/talkersinterface/talkersinterface.go index 0d6b228..c40ff38 100644 --- a/lib/talkers/talkersinterface/talkersinterface.go +++ b/lib/talkers/talkersinterface/talkersinterface.go @@ -23,4 +23,6 @@ type TalkersInterface interface { LongMessage(update *tgbotapi.Update) string DurakMessage(update *tgbotapi.Update) string MatMessage(update *tgbotapi.Update) string + + NewYearMessage2018() } diff --git a/lib/users/parsers.go b/lib/users/parsers.go index b181fe9..317a8e5 100644 --- a/lib/users/parsers.go +++ b/lib/users/parsers.go @@ -284,8 +284,8 @@ func (u *Users) ParseProfile(update *tgbotapi.Update, playerRaw *dbmapping.Playe return "fail" } - for n_meme, attack := range pokememes { - memeAry := strings.Split(n_meme, "_") + for nMeme, attack := range pokememes { + memeAry := strings.Split(nMeme, "_") meme := memeAry[1] rarity := "common" if strings.HasPrefix(meme, "🔸") { @@ -304,6 +304,10 @@ func (u *Users) ParseProfile(update *tgbotapi.Update, playerRaw *dbmapping.Playe rarity = "super liber" meme = strings.Replace(meme, "🔷", "", 1) } + if strings.HasPrefix(meme, "❄️") { + rarity = "new year" + meme = strings.Replace(meme, "❄️", "", 1) + } u.fillProfilePokememe(profileRaw.ID, meme, attack, rarity) }