Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(replies): fix replies from Status and to Status messages #18

Merged
merged 1 commit into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bridge/discord/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func (b *Bdiscord) handleEventBotUser(msg *config.Message, channelID string) (st
}

m := discordgo.MessageSend{
Content: msg.Username + msg.Text,
Content: msg.Username + ": " + msg.Text,
AllowedMentions: b.getAllowedMentions(),
}

Expand Down
15 changes: 12 additions & 3 deletions bridge/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ func (b *Bstatus) propagateMessage(msg *common.Message) {
Text: msg.Text,
Channel: msg.ChatId,
ID: msg.ID,
ParentID: msg.ResponseTo,
Account: b.Account,
}
}
Expand All @@ -245,6 +246,10 @@ func (b *Bstatus) toStatusMsg(msg config.Message) *common.Message {
}
}

if msg.ParentID != "" {
originalParentID = msg.ParentID
}

message.Payload = &protobuf.ChatMessage_BridgeMessage{
BridgeMessage: &protobuf.BridgeMessage{
BridgeName: msg.Protocol,
Expand Down Expand Up @@ -297,6 +302,8 @@ func (b *Bstatus) Send(msg config.Message) (string, error) {
return "", errors.Wrap(err, "failed to get status message for bridge message")
}

sentMessageID := ""

if statusMessageID != "" {
decodedStatusMessageID, err := types.DecodeHex(statusMessageID)
if err != nil {
Expand All @@ -307,18 +314,20 @@ func (b *Bstatus) Send(msg config.Message) (string, error) {
Text: msg.Text,
ContentType: protobuf.ChatMessage_BRIDGE_MESSAGE,
}
_, err = b.messenger.EditMessage(context.Background(), editedMessage)
response, err := b.messenger.EditMessage(context.Background(), editedMessage)
if err != nil {
return "", errors.Wrap(err, "failed to edit message")
}
sentMessageID = response.Messages()[0].ID
} else {
_, err := b.messenger.SendChatMessage(context.Background(), statusMessageToSend)
response, err := b.messenger.SendChatMessage(context.Background(), statusMessageToSend)
if err != nil {
return "", errors.Wrap(err, "failed to send message")
}
sentMessageID = response.Messages()[0].ID
}

return "", nil
return sentMessageID, nil
}

func (b *Bstatus) Connect() error {
Expand Down
2 changes: 2 additions & 0 deletions status.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
RemoteNickFormat="{NICK}"
DataDir="path to status data dir"
NodeConfigFile="path to json with node config and fleets"
PreserveThreading=true

[discord]
[discord.mydiscord]
Token=""
Server=""
AutoWebhooks=true
RemoteNickFormat="{NICK}"
PreserveThreading=true

[[gateway]]
name="gateway3"
Expand Down
Loading