Skip to content

Commit

Permalink
Add "respond as reply" functionality
Browse files Browse the repository at this point in the history
Signed-off-by: Knut Ahlers <[email protected]>
  • Loading branch information
Luzifer committed Jun 2, 2021
1 parent 9d2f770 commit d5ea1eb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
26 changes: 19 additions & 7 deletions action_respond.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,26 @@ func init() {
}
}

ircMessage := &irc.Message{
Command: "PRIVMSG",
Params: []string{
m.Params[0],
msg,
},
}

if r.RespondAsReply != nil && *r.RespondAsReply {
id, ok := m.GetTag("id")
if ok {
if ircMessage.Tags == nil {
ircMessage.Tags = make(irc.Tags)
}
ircMessage.Tags["reply-parent-msg-id"] = irc.TagValue(id)
}
}

return errors.Wrap(
c.WriteMessage(&irc.Message{
Command: "PRIVMSG",
Params: []string{
m.Params[0],
msg,
},
}),
c.WriteMessage(ircMessage),
"sending response",
)
})
Expand Down
1 change: 1 addition & 0 deletions rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ type ruleAction struct {
RawMessage *string `json:"raw_message" yaml:"raw_message"`

Respond *string `json:"respond" yaml:"respond"`
RespondAsReply *bool `json:"respond_as_reply" yaml:"respond_as_reply"`
RespondFallback *string `json:"respond_fallback" yaml:"respond_fallback"`

Timeout *time.Duration `json:"timeout" yaml:"timeout"`
Expand Down
1 change: 1 addition & 0 deletions wiki/Home.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ rules: # See below for examples

# Send responding message to the channel the original message was received in
- respond: 'Hello chatter' # String, applies templating
respond_as_reply: true # Boolean, optional, use Twitch-Reply feature in respond
respond_fallback: 'Oh noes' # String, text to send if the template function causes
# an error, applies templating (default: unset)

Expand Down

0 comments on commit d5ea1eb

Please sign in to comment.