From 6f28849331c694054cdcce9f06f814a793a2a69c Mon Sep 17 00:00:00 2001 From: lyx0 <66651385+lyx0@users.noreply.github.com> Date: Sun, 3 Dec 2023 16:35:34 +0100 Subject: [PATCH] monitor forsen bans --- cmd/nourybot/commands.go | 4 ++++ cmd/nourybot/main.go | 23 +++++++++++++++++------ cmd/nourybot/send.go | 12 ++++++++++++ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/cmd/nourybot/commands.go b/cmd/nourybot/commands.go index a0962aa..57c94e9 100644 --- a/cmd/nourybot/commands.go +++ b/cmd/nourybot/commands.go @@ -16,6 +16,10 @@ import ( func (app *application) handleCommand(message twitch.PrivateMessage) { var reply string + if message.Channel == "forsen" { + return + } + // Increments the counter how many commands have been used, called in the ping command. go common.CommandUsed() diff --git a/cmd/nourybot/main.go b/cmd/nourybot/main.go index ecd405d..05ea5b0 100644 --- a/cmd/nourybot/main.go +++ b/cmd/nourybot/main.go @@ -4,6 +4,7 @@ import ( "context" "database/sql" "flag" + "fmt" "os" "time" @@ -134,12 +135,12 @@ func main() { // Received a PrivateMessage (normal chat message). app.TwitchClient.OnPrivateMessage(func(message twitch.PrivateMessage) { - sugar.Infow("New Twitch PrivateMessage", - "message.Channel", message.Channel, - "message.User.DisplayName", message.User.DisplayName, - "message.User.ID", message.User.ID, - "message.Message", message.Message, - ) + // sugar.Infow("New Twitch PrivateMessage", + // "message.Channel", message.Channel, + // "message.User.DisplayName", message.User.DisplayName, + // "message.User.ID", message.User.ID, + // "message.Message", message.Message, + // ) // roomId is the Twitch UserID of the channel the message originated from. // If there is no roomId something went really wrong. @@ -165,6 +166,16 @@ func main() { } }) + app.TwitchClient.OnClearChatMessage(func(message twitch.ClearChatMessage) { + if message.BanDuration == 0 && message.Channel == "forsen" { + app.TwitchClient.Say("nouryxd", fmt.Sprintf("MODS https://logs.ivr.fi/?channel=forsen&username=%v", message.TargetUsername)) + } + + if message.BanDuration >= 28700 && message.Channel == "forsen" { + app.TwitchClient.Say("nouryxd", fmt.Sprintf("MODS https://logs.ivr.fi/?channel=forsen&username=%v", message.TargetUsername)) + } + + }) app.TwitchClient.OnConnect(func() { common.StartTime() diff --git a/cmd/nourybot/send.go b/cmd/nourybot/send.go index 744242c..3584221 100644 --- a/cmd/nourybot/send.go +++ b/cmd/nourybot/send.go @@ -91,6 +91,10 @@ func (app *application) SendNoContext(target, message string) { return } + if target == "forsen" { + return + } + identifier := uuid.NewString() go app.Models.SentMessagesLogs.Insert(target, message, "unavailable", "unavailable", "unavailable", "unavailable", identifier, "unavailable") @@ -145,6 +149,10 @@ func (app *application) Send(target, message string, msgContext twitch.PrivateMe return } + if target == "forsen" { + return + } + commandName := strings.ToLower(strings.SplitN(msgContext.Message, " ", 3)[0][2:]) identifier := uuid.NewString() go app.Models.SentMessagesLogs.Insert(target, message, commandName, msgContext.User.Name, msgContext.User.ID, msgContext.Message, identifier, msgContext.Raw) @@ -200,6 +208,10 @@ func (app *application) SendNoBanphrase(target, message string) { return } + if target == "forsen" { + return + } + identifier := uuid.NewString() go app.Models.SentMessagesLogs.Insert(target, message, "unavailable", "unavailable", "unavailable", "unavailable", identifier, "unavailable")