make banlist consistent, fixes #57

This commit is contained in:
Aine
2023-02-13 22:05:48 +02:00
parent 19e2047a2b
commit 3e0ecc1c02
3 changed files with 17 additions and 18 deletions

View File

@@ -334,6 +334,10 @@ func (b *Bot) runBanlistAdd(ctx context.Context, commandSlice []string) {
b.runBanlist(ctx, commandSlice)
return
}
if !b.cfg.GetBot().BanlistEnabled() {
b.SendNotice(ctx, evt.RoomID, "banlist is disabled, you have to enable it first, kupo")
return
}
banlist := b.cfg.GetBanlist()
ips := commandSlice[1:]
@@ -361,6 +365,10 @@ func (b *Bot) runBanlistRemove(ctx context.Context, commandSlice []string) {
b.runBanlist(ctx, commandSlice)
return
}
if !b.cfg.GetBot().BanlistEnabled() {
b.SendNotice(ctx, evt.RoomID, "banlist is disabled, you have to enable it first, kupo")
return
}
banlist := b.cfg.GetBanlist()
ips := commandSlice[1:]
@@ -384,6 +392,10 @@ func (b *Bot) runBanlistRemove(ctx context.Context, commandSlice []string) {
func (b *Bot) runBanlistReset(ctx context.Context) {
evt := eventFromContext(ctx)
if !b.cfg.GetBot().BanlistEnabled() {
b.SendNotice(ctx, evt.RoomID, "banlist is disabled, you have to enable it first, kupo")
return
}
err := b.cfg.SetBanlist(config.List{})
if err != nil {