mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-30 00:21:16 +00:00
Add "respond as reply" functionality
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
9d2f770aa9
commit
d5ea1eb79f
3 changed files with 21 additions and 7 deletions
|
@ -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",
|
||||
)
|
||||
})
|
||||
|
|
1
rule.go
1
rule.go
|
@ -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"`
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue