Add "respond as reply" functionality

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-06-02 15:31:16 +02:00
parent 9d2f770aa9
commit d5ea1eb79f
Signed by: luzifer
GPG Key ID: 0066F03ED215AD7D
3 changed files with 21 additions and 7 deletions

View File

@ -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",
)
})

View File

@ -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"`

View File

@ -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)