Archived
1

Fixed fuckup with broadcast author's name

This commit is contained in:
Vladimir Hodakov 2018-01-30 20:38:00 +04:00
parent f3110ab391
commit 5b13b6479a

View File

@ -4,8 +4,8 @@
package broadcaster package broadcaster
import ( import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"git.wtfteam.pro/fat0troll/i2_bot/lib/dbmapping" "git.wtfteam.pro/fat0troll/i2_bot/lib/dbmapping"
"github.com/go-telegram-bot-api/telegram-bot-api"
"strconv" "strconv"
) )
@ -26,6 +26,14 @@ func (b *Broadcaster) AdminBroadcastMessageSend(update *tgbotapi.Update, playerR
broadcastingMessageBody := messageRaw.Text broadcastingMessageBody := messageRaw.Text
profileRaw, err := c.DataCache.GetProfileByPlayerID(playerRaw.ID)
if err != nil {
c.Log.Error(err.Error())
return "fail"
}
prettyName := profileRaw.Nickname + "(@" + profileRaw.TelegramNickname + ")"
privateChats := []dbmapping.Chat{} privateChats := []dbmapping.Chat{}
switch messageRaw.BroadcastType { switch messageRaw.BroadcastType {
case "all": case "all":
@ -43,7 +51,7 @@ func (b *Broadcaster) AdminBroadcastMessageSend(update *tgbotapi.Update, playerR
for i := range privateChats { for i := range privateChats {
chat := privateChats[i] chat := privateChats[i]
broadcastingMessage := "*Привет, " + chat.Name + "!*\n\n" broadcastingMessage := "*Привет, " + chat.Name + "!*\n\n"
broadcastingMessage += "*Важное сообщение от администратора *" + c.Users.GetPrettyName(update.Message.From) + "\n\n" broadcastingMessage += "*Важное сообщение от администратора *" + prettyName + "\n\n"
broadcastingMessage += broadcastingMessageBody broadcastingMessage += broadcastingMessageBody
msg := tgbotapi.NewMessage(int64(chat.TelegramID), broadcastingMessage) msg := tgbotapi.NewMessage(int64(chat.TelegramID), broadcastingMessage)