mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-10 01:00:05 +00:00
Add delete action for single message
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
7047a2399b
commit
3a3959c79c
3 changed files with 41 additions and 5 deletions
32
action_delete.go
Normal file
32
action_delete.go
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/go-irc/irc"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
registerAction(func(c *irc.Client, m *irc.Message, ruleDef *rule, r *ruleAction) error {
|
||||||
|
if r.DeleteMessage == nil || !*r.DeleteMessage {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
msgID, ok := m.Tags.GetTag("id")
|
||||||
|
if !ok || msgID == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return errors.Wrap(
|
||||||
|
c.WriteMessage(&irc.Message{
|
||||||
|
Command: "PRIVMSG",
|
||||||
|
Params: []string{
|
||||||
|
m.Params[0],
|
||||||
|
fmt.Sprintf("/delete %s", msgID),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
"sending delete",
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
|
@ -172,6 +172,7 @@ type ruleAction struct {
|
||||||
Ban *string `yaml:"ban"`
|
Ban *string `yaml:"ban"`
|
||||||
CounterStep *int64 `yaml:"counter_step"`
|
CounterStep *int64 `yaml:"counter_step"`
|
||||||
Counter *string `yaml:"counter"`
|
Counter *string `yaml:"counter"`
|
||||||
|
DeleteMessage *bool `yaml:"delete_message"`
|
||||||
Respond *string `yaml:"respond"`
|
Respond *string `yaml:"respond"`
|
||||||
Timeout *time.Duration `yaml:"timeout"`
|
Timeout *time.Duration `yaml:"timeout"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,9 @@ rules: # See below for examples
|
||||||
- counter: "counterid" # String to identify the counter, applies templating
|
- counter: "counterid" # String to identify the counter, applies templating
|
||||||
counter_step: 1 # Integer, can be negative or positive, default: +1
|
counter_step: 1 # Integer, can be negative or positive, default: +1
|
||||||
|
|
||||||
|
# Issue a delete on the message caught
|
||||||
|
- delete_message: true # Bool, set to true to delete
|
||||||
|
|
||||||
# Send responding message to the channel the original message was received in
|
# Send responding message to the channel the original message was received in
|
||||||
- respond: 'Hello chatter' # String, applies templating
|
- respond: 'Hello chatter' # String, applies templating
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue