2022-10-25 16:47:30 +00:00
|
|
|
package nuke
|
|
|
|
|
|
|
|
import (
|
2024-01-01 16:52:18 +00:00
|
|
|
"context"
|
2022-10-25 16:47:30 +00:00
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
actionFn func(channel, match, msgid, user string) error
|
|
|
|
)
|
|
|
|
|
2023-03-24 21:32:00 +00:00
|
|
|
func actionBan(channel, match, _, user string) error {
|
2022-10-25 16:47:30 +00:00
|
|
|
return errors.Wrap(
|
2024-04-05 10:19:22 +00:00
|
|
|
botTwitchClient().BanUser(
|
2024-01-01 16:52:18 +00:00
|
|
|
context.Background(),
|
2022-10-25 16:47:30 +00:00
|
|
|
channel,
|
|
|
|
user,
|
|
|
|
0,
|
|
|
|
fmt.Sprintf("Nuke issued for %q", match),
|
|
|
|
),
|
|
|
|
"executing ban",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-03-24 21:32:00 +00:00
|
|
|
func actionDelete(channel, _, msgid, _ string) (err error) {
|
2022-10-25 16:47:30 +00:00
|
|
|
return errors.Wrap(
|
2024-04-05 10:19:22 +00:00
|
|
|
botTwitchClient().DeleteMessage(
|
2024-01-01 16:52:18 +00:00
|
|
|
context.Background(),
|
2022-10-25 16:47:30 +00:00
|
|
|
channel,
|
|
|
|
msgid,
|
|
|
|
),
|
|
|
|
"deleting message",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func getActionTimeout(duration time.Duration) actionFn {
|
2024-02-18 12:42:00 +00:00
|
|
|
return func(channel, match, _, user string) error {
|
2022-10-25 16:47:30 +00:00
|
|
|
return errors.Wrap(
|
2024-04-05 10:19:22 +00:00
|
|
|
botTwitchClient().BanUser(
|
2024-01-01 16:52:18 +00:00
|
|
|
context.Background(),
|
2022-10-25 16:47:30 +00:00
|
|
|
channel,
|
|
|
|
user,
|
|
|
|
duration,
|
|
|
|
fmt.Sprintf("Nuke issued for %q", match),
|
|
|
|
),
|
|
|
|
"executing timeout",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|