mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-09 00:30:02 +00:00
49 lines
806 B
Go
49 lines
806 B
Go
|
package nuke
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"time"
|
||
|
|
||
|
"github.com/pkg/errors"
|
||
|
)
|
||
|
|
||
|
type (
|
||
|
actionFn func(channel, match, msgid, user string) error
|
||
|
)
|
||
|
|
||
|
func actionBan(channel, match, msgid, user string) error {
|
||
|
return errors.Wrap(
|
||
|
botTwitchClient.BanUser(
|
||
|
channel,
|
||
|
user,
|
||
|
0,
|
||
|
fmt.Sprintf("Nuke issued for %q", match),
|
||
|
),
|
||
|
"executing ban",
|
||
|
)
|
||
|
}
|
||
|
|
||
|
func actionDelete(channel, match, msgid, user string) (err error) {
|
||
|
return errors.Wrap(
|
||
|
botTwitchClient.DeleteMessage(
|
||
|
channel,
|
||
|
msgid,
|
||
|
),
|
||
|
"deleting message",
|
||
|
)
|
||
|
}
|
||
|
|
||
|
func getActionTimeout(duration time.Duration) actionFn {
|
||
|
return func(channel, match, msgid, user string) error {
|
||
|
return errors.Wrap(
|
||
|
botTwitchClient.BanUser(
|
||
|
channel,
|
||
|
user,
|
||
|
duration,
|
||
|
fmt.Sprintf("Nuke issued for %q", match),
|
||
|
),
|
||
|
"executing timeout",
|
||
|
)
|
||
|
}
|
||
|
}
|