|
|
@ -746,34 +746,51 @@ func (c *Client) countCharsInLines(lines *[]string) (count int) { |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Client) messageToPrefix(message *client.Message, previewString string, fileString string, replyMsg *client.Message) (string, int, int) { |
|
|
|
isPM, err := c.IsPM(message.ChatId) |
|
|
|
if err != nil { |
|
|
|
log.Errorf("Could not determine if chat is PM: %v", err) |
|
|
|
} |
|
|
|
|
|
|
|
var replyStart, replyEnd int |
|
|
|
prefix := []string{} |
|
|
|
// message direction
|
|
|
|
var directionChar string |
|
|
|
if c.Session.AsciiArrows { |
|
|
|
if message.IsOutgoing { |
|
|
|
directionChar = "> " |
|
|
|
} else { |
|
|
|
directionChar = "< " |
|
|
|
} |
|
|
|
} else { |
|
|
|
if message.IsOutgoing { |
|
|
|
directionChar = "➡ " |
|
|
|
if !isPM || !gateway.MessageOutgoingPermission || !c.Session.Carbons { |
|
|
|
if c.Session.AsciiArrows { |
|
|
|
if message.IsOutgoing { |
|
|
|
directionChar = "> " |
|
|
|
} else { |
|
|
|
directionChar = "< " |
|
|
|
} |
|
|
|
} else { |
|
|
|
directionChar = "⬅ " |
|
|
|
if message.IsOutgoing { |
|
|
|
directionChar = "➡ " |
|
|
|
} else { |
|
|
|
directionChar = "⬅ " |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
prefix = append(prefix, directionChar+strconv.FormatInt(message.Id, 10)) |
|
|
|
if !isPM || !c.Session.HideIds { |
|
|
|
prefix = append(prefix, directionChar+strconv.FormatInt(message.Id, 10)) |
|
|
|
} |
|
|
|
// show sender in group chats
|
|
|
|
if message.ChatId < 0 { |
|
|
|
prefix = append(prefix, c.formatSender(message)) |
|
|
|
if !isPM { |
|
|
|
sender := c.formatSender(message) |
|
|
|
if sender != "" { |
|
|
|
prefix = append(prefix, sender) |
|
|
|
} |
|
|
|
} |
|
|
|
// reply to
|
|
|
|
if message.ReplyToMessageId != 0 { |
|
|
|
replyStart = c.countCharsInLines(&prefix) + (len(prefix)-1)*len(messageHeaderSeparator) |
|
|
|
if len(prefix) > 0 { |
|
|
|
replyStart = c.countCharsInLines(&prefix) + (len(prefix)-1)*len(messageHeaderSeparator) |
|
|
|
} |
|
|
|
replyLine := "reply: " + c.formatMessage(message.ChatId, message.ReplyToMessageId, true, replyMsg) |
|
|
|
prefix = append(prefix, replyLine) |
|
|
|
replyEnd = replyStart + len(replyLine) + len(messageHeaderSeparator) |
|
|
|
replyEnd = replyStart + len(replyLine) |
|
|
|
if len(prefix) > 0 { |
|
|
|
replyEnd += len(messageHeaderSeparator) |
|
|
|
} |
|
|
|
} |
|
|
|
if message.ForwardInfo != nil { |
|
|
|
prefix = append(prefix, "fwd: "+c.formatForward(message.ForwardInfo)) |
|
|
@ -856,10 +873,12 @@ func (c *Client) ProcessIncomingMessage(chatId int64, message *client.Message) { |
|
|
|
|
|
|
|
if text != "" { |
|
|
|
// \n if it is groupchat and message is not empty
|
|
|
|
if chatId < 0 { |
|
|
|
newText.WriteString("\n") |
|
|
|
} else if chatId > 0 { |
|
|
|
newText.WriteString(" | ") |
|
|
|
if prefix != "" { |
|
|
|
if chatId < 0 { |
|
|
|
newText.WriteString("\n") |
|
|
|
} else if chatId > 0 { |
|
|
|
newText.WriteString(" | ") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
newText.WriteString(text) |
|
|
|