mirror of
https://github.com/cwinfo/matterbridge.git
synced 2024-11-22 07:00:27 +00:00
Add double newline if the message is markup and prefixed.
If the message is prefixed with the sender nick, it will break markup formatting on the same line. This commit introduces a very rudimentary markup checker, and if the message is deemed to be markup in those cases, the space between sender nick and message is replaced by a double newline.
This commit is contained in:
parent
a63433e41b
commit
f29822db02
@ -131,13 +131,32 @@ func (b *Bridge) Send(nick string, message string, channel string) error {
|
|||||||
return b.SendType(nick, message, channel, "")
|
return b.SendType(nick, message, channel, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsMarkup(message string) bool {
|
||||||
|
switch (message[0]) {
|
||||||
|
case '|': fallthrough
|
||||||
|
case '#': fallthrough
|
||||||
|
case '_': fallthrough
|
||||||
|
case '*': fallthrough
|
||||||
|
case '~': fallthrough
|
||||||
|
case '-': fallthrough
|
||||||
|
case ':': fallthrough
|
||||||
|
case '>': fallthrough
|
||||||
|
case '=': return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (b *Bridge) SendType(nick string, message string, channel string, mtype string) error {
|
func (b *Bridge) SendType(nick string, message string, channel string, mtype string) error {
|
||||||
matterMessage := matterhook.OMessage{IconURL: b.Config.Mattermost.IconURL}
|
matterMessage := matterhook.OMessage{IconURL: b.Config.Mattermost.IconURL}
|
||||||
matterMessage.Channel = channel
|
matterMessage.Channel = channel
|
||||||
matterMessage.UserName = nick
|
matterMessage.UserName = nick
|
||||||
matterMessage.Type = mtype
|
matterMessage.Type = mtype
|
||||||
if (b.Config.Mattermost.PrefixMessagesWithNick) {
|
if b.Config.Mattermost.PrefixMessagesWithNick {
|
||||||
matterMessage.Text = nick + ": " + message
|
if IsMarkup(message) {
|
||||||
|
matterMessage.Text = nick + ":\n\n" + message
|
||||||
|
} else {
|
||||||
|
matterMessage.Text = nick + ": " + message
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
matterMessage.Text = message
|
matterMessage.Text = message
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user