From dfda32396ac52bacab46cad2ee7a241ad9dae891 Mon Sep 17 00:00:00 2001 From: Vladimir Hodakov Date: Sun, 3 Dec 2017 00:40:30 +0400 Subject: [PATCH] Pinner fix for lost spaces --- lib/pinner/pinner.go | 2 +- lib/router/group_request.go | 14 ++++++++------ lib/talkers/easter.go | 12 +++++++++--- lib/talkers/talkersinterface/talkersinterface.go | 6 +++--- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/lib/pinner/pinner.go b/lib/pinner/pinner.go index 462f840..b2d511c 100644 --- a/lib/pinner/pinner.go +++ b/lib/pinner/pinner.go @@ -87,7 +87,7 @@ func (p *Pinner) PinMessageToSomeChats(update *tgbotapi.Update) string { if i == 0 { chatsToPin = commandArgsList[i] } else { - messageToPin += commandArgsList[i] + messageToPin += commandArgsList[i] + " " } } diff --git a/lib/router/group_request.go b/lib/router/group_request.go index 959b1df..07d2e18 100644 --- a/lib/router/group_request.go +++ b/lib/router/group_request.go @@ -62,22 +62,24 @@ func (r *Router) routeGroupRequest(update *tgbotapi.Update, playerRaw *dbmapping if trigger == 4 { switch { case huMsg.MatchString(text): - c.Talkers.MatMessage(update) + return c.Talkers.MatMessage(update) case blMsg.MatchString(text): - c.Talkers.MatMessage(update) + return c.Talkers.MatMessage(update) case ebMsg.MatchString(text): - c.Talkers.MatMessage(update) + return c.Talkers.MatMessage(update) case piMsg.MatchString(text): - c.Talkers.MatMessage(update) + return c.Talkers.MatMessage(update) case durakMsg.MatchString(text): - c.Talkers.DurakMessage(update) + return c.Talkers.DurakMessage(update) } } switch { case update.Message.Command() == "long": - c.Talkers.LongMessage(update) + return c.Talkers.LongMessage(update) } + // Ah, we're still here + return "ok" } diff --git a/lib/talkers/easter.go b/lib/talkers/easter.go index 7d90719..05659c5 100644 --- a/lib/talkers/easter.go +++ b/lib/talkers/easter.go @@ -10,7 +10,7 @@ import ( ) // LongMessage is an easter egg -func (t *Talkers) LongMessage(update *tgbotapi.Update) { +func (t *Talkers) LongMessage(update *tgbotapi.Update) string { message := "Я ТЕБЕ НЕ ЗЕЛЁНЫЙ АКСОЛОТЛЬ! А ТЫ - НЕ ЦИФЕРКА!" trigger := rand.Intn(5) if trigger > 3 { @@ -23,10 +23,12 @@ func (t *Talkers) LongMessage(update *tgbotapi.Update) { msg.ReplyToMessageID = update.Message.MessageID c.Bot.Send(msg) + + return "ok" } // DurakMessage is an easter egg -func (t *Talkers) DurakMessage(update *tgbotapi.Update) { +func (t *Talkers) DurakMessage(update *tgbotapi.Update) string { reactions := make([]string, 0) reactions = append(reactions, "Сам такой!", "А ты типа нет?", @@ -43,10 +45,12 @@ func (t *Talkers) DurakMessage(update *tgbotapi.Update) { msg.ReplyToMessageID = update.Message.MessageID c.Bot.Send(msg) + + return "ok" } // MatMessage is an easter rgg -func (t *Talkers) MatMessage(update *tgbotapi.Update) { +func (t *Talkers) MatMessage(update *tgbotapi.Update) string { reactions := make([]string, 0) reactions = append(reactions, "Фу, как некультурно!", "Иди рот с мылом помой", @@ -60,4 +64,6 @@ func (t *Talkers) MatMessage(update *tgbotapi.Update) { msg.ReplyToMessageID = update.Message.MessageID c.Bot.Send(msg) + + return "ok" } diff --git a/lib/talkers/talkersinterface/talkersinterface.go b/lib/talkers/talkersinterface/talkersinterface.go index 794809b..c7a3d5c 100644 --- a/lib/talkers/talkersinterface/talkersinterface.go +++ b/lib/talkers/talkersinterface/talkersinterface.go @@ -19,7 +19,7 @@ type TalkersInterface interface { AnyMessageUnauthorized(update *tgbotapi.Update) string BotError(update *tgbotapi.Update) string - LongMessage(update *tgbotapi.Update) - DurakMessage(update *tgbotapi.Update) - MatMessage(update *tgbotapi.Update) + LongMessage(update *tgbotapi.Update) string + DurakMessage(update *tgbotapi.Update) string + MatMessage(update *tgbotapi.Update) string }