Skip to content

Commit

Permalink
Merge pull request #6 from imachug/emotes
Browse files Browse the repository at this point in the history
Bridge emote messages from sshchat
  • Loading branch information
podivilov authored Dec 29, 2021
2 parents 1aeefa2 + 0b6f8df commit 5ffd2f1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 12 additions & 3 deletions bridge/sshchat/sshchat.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,25 @@ func (b *Bsshchat) handleSSHChat() error {
continue
}
// skip our own messages
res := strings.Split(stripPrompt(b.r.Text()), ":")
text := stripPrompt(b.r.Text())
res := strings.Split(text, ":")
if res[0] == "-> Set theme" {
wait = false
b.Log.Debugf("mono found, allowing")
continue
}
if !wait {
b.Log.Debugf("<= Message %#v", res)
rmsg := config.Message{Username: res[0], Text: strings.TrimSpace(strings.Join(res[1:], ":")), Channel: "sshchat", Account: b.Account, UserID: "nick"}
b.Remote <- rmsg
if strings.HasPrefix(text, "** ") {
// Emote
res := strings.Split(text[3:], " ")
rmsg := config.Message{Username: res[0], Text: strings.TrimSpace(strings.Join(res[1:], " ")), Channel: "sshchat", Account: b.Account, UserID: "nick", Event: config.EventUserAction}
b.Remote <- rmsg
} else {
// Normal message
rmsg := config.Message{Username: res[0], Text: strings.TrimSpace(strings.Join(res[1:], ":")), Channel: "sshchat", Account: b.Account, UserID: "nick"}
b.Remote <- rmsg
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions bridge/telegram/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ func (b *Btelegram) Send(msg config.Message) (string, error) {
return b.cacheAvatar(&msg)
}

if msg.Event == config.EventUserAction {
msg.Text = "_" + msg.Text + "_"
}

if b.GetString("MessageFormat") == HTMLFormat {
msg.Text = makeHTML(msg.Text)
}
Expand Down

0 comments on commit 5ffd2f1

Please sign in to comment.