mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-30 08:31:16 +00:00
Knut Ahlers
acf96c31ad
as client is assigned after plugins are initialized Signed-off-by: Knut Ahlers <knut@ahlers.me>
52 lines
884 B
Go
52 lines
884 B
Go
package nuke
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
type (
|
|
actionFn func(channel, match, msgid, user string) error
|
|
)
|
|
|
|
func actionBan(channel, match, _, user string) error {
|
|
return errors.Wrap(
|
|
botTwitchClient().BanUser(
|
|
context.Background(),
|
|
channel,
|
|
user,
|
|
0,
|
|
fmt.Sprintf("Nuke issued for %q", match),
|
|
),
|
|
"executing ban",
|
|
)
|
|
}
|
|
|
|
func actionDelete(channel, _, msgid, _ string) (err error) {
|
|
return errors.Wrap(
|
|
botTwitchClient().DeleteMessage(
|
|
context.Background(),
|
|
channel,
|
|
msgid,
|
|
),
|
|
"deleting message",
|
|
)
|
|
}
|
|
|
|
func getActionTimeout(duration time.Duration) actionFn {
|
|
return func(channel, match, _, user string) error {
|
|
return errors.Wrap(
|
|
botTwitchClient().BanUser(
|
|
context.Background(),
|
|
channel,
|
|
user,
|
|
duration,
|
|
fmt.Sprintf("Nuke issued for %q", match),
|
|
),
|
|
"executing timeout",
|
|
)
|
|
}
|
|
}
|