Skip to content
This repository was archived by the owner on Mar 22, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 41 additions & 10 deletions bot/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ package client

import (
"fmt"
//"slices"
"strings"
"sync"

"selfbotat-v2/bot"
"selfbotat-v2/bot/config"
"selfbotat-v2/bot/database"
"selfbotat-v2/bot/logger"
"selfbotat-v2/bot/types"
"selfbotat-v2/bot/utils"

//"slices"
"strings"
"sync"

db "selfbotat-v2/bot/database"
Log "selfbotat-v2/bot/logger"

"github.com/Potat-Industries/go-potatFilters"
"github.com/douglascdev/buttifier"

"github.com/gempir/go-twitch-irc/v4"
)

Expand Down Expand Up @@ -62,7 +66,6 @@ func ensurePool() {
}

func createClient(clientID int) *ChatClient {

client := &ChatClient{
twitch.NewClient(
config.Config.Twitch.Login,
Expand Down Expand Up @@ -113,7 +116,7 @@ func joinChannels() {
return
}

Join("notohh")
// Join("hash_table")

for _, channel := range channels {
Join(channel.Login)
Expand Down Expand Up @@ -167,6 +170,12 @@ func Say(channel, message string) {
message = message[:maxMessageSize]
}

if potatFilters.Test(message, potatFilters.FilterAll) {
Log.Warn.Printf("Message filtered in channel '%s': '%s'", channel, message)
client.Say(channel, "⚠ Message withheld for containing a banned phrase...")
return
}

client.Say(channel, message)
}

Expand Down Expand Up @@ -212,18 +221,40 @@ func parseMessage(msg twitch.PrivateMessage) {

// temp handler while I figure some structure
func handleMessage(msg *types.MessageData) {
if config.Config.Buttsbot.Enabled && msg.User.ID != config.Config.Twitch.Id {
butter, err := buttifier.New()
if err != nil {
Log.Error.Fatal(err)
}
butter.ButtificationProbability = config.Config.Buttsbot.ButtificationProbability
butter.ButtificationRate = config.Config.Buttsbot.ButtificationRate
butter.ButtWord = config.Config.Buttsbot.ButtWord
buttedMsg, buttHasButted := butter.ButtifySentence(msg.Text)

if buttHasButted {
// prefix with invisible character to avoid running other bot commands with mod privilege
Say(msg.Channel.Login, "󠀀�"+buttedMsg)
}
}

if msg.User.ID != config.Config.Twitch.Id {
return
}

// check prefix
if !strings.HasPrefix(msg.Text, config.Config.Prefix) {
return
}

// find command
cmd := bot.FindCmd(msg.Command)
if cmd == nil { return }
if cmd == nil {
return
}

// ignore self and non-whitelisted users
isSelf := msg.User.ID == config.Config.Twitch.Id
//isWhitelisted := slices.Contains(cmd.Whitelist, msg.User.ID)
// isWhitelisted := slices.Contains(cmd.Whitelist, msg.User.ID)
if !isSelf {
return
}
Expand Down
10 changes: 9 additions & 1 deletion bot/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,22 @@ type TwitchConfig struct {
TLAHeaders map[string]string `json:"tlaHeaders"`
}

type ButtsbotConfig struct {
Enabled bool `json:"enabled"`
ButtificationProbability float64 `json:"buttificationProbability"`
ButtificationRate float64 `json:"buttificationRate"`
ButtWord string `json:"buttWord"`
}

type URIs struct {
PubSub string `json:"pubsub"`
TLA string `json:"tla"`
}

type BotConfig struct {
Prefix string `json:"prefix"`
Buttsbot ButtsbotConfig `json:"buttsbot"`
Postgres PostgresConfig `json:"postgres"`
Twitch TwitchConfig `json:"twitch"`
URIs URIs `json:"uris"`
}
}
8 changes: 7 additions & 1 deletion example-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@
"password": "twitch oauth",
"client_id": "twitch client id"
},
"buttsbot": {
"enabled": true,
"buttificationProbability": 0.05,
"buttificationRate": 0.15,
"buttWord": "butt"
},
"prefix": "go",
"postgres": {
"user": "postgres",
"host": "localhost",
"database": "postgres",
"password": ""
}
}
}
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module selfbotat-v2

go 1.18
go 1.23.0

require (
github.com/fatih/color v1.16.0
Expand All @@ -10,8 +10,11 @@ require (
)

require (
github.com/Potat-Industries/go-potatFilters v0.1.1 // indirect
github.com/douglascdev/buttifier v0.0.4 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/speedata/hyphenation v1.0.2 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.14.0 // indirect
)
14 changes: 14 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
github.com/Potat-Industries/go-potatFilters v0.1.0 h1:0Cji7RSpF90hHVWngp5Ckw+SpZ4b1kKgGVV8wGj5cwM=
github.com/Potat-Industries/go-potatFilters v0.1.0/go.mod h1:sbz39k2QTCzF51Ar1FP/GfPMu2YvoCb4Xa1ytxZ9XZ4=
github.com/Potat-Industries/go-potatFilters v0.1.1 h1:QhVVRjvdyEPdWNyi9cgYIzxaRLErlahu2icsANVhm8w=
github.com/Potat-Industries/go-potatFilters v0.1.1/go.mod h1:sbz39k2QTCzF51Ar1FP/GfPMu2YvoCb4Xa1ytxZ9XZ4=
github.com/douglascdev/buttifier v0.0.1 h1:ZYTNYwPlVVTS10U2lmxdMkPKBMwU9rHCxPlxR7YC67Q=
github.com/douglascdev/buttifier v0.0.1/go.mod h1:NwWm2htIvguVOd+IJPZYlIH9Y5x6969bbswtFmPsZ0E=
github.com/douglascdev/buttifier v0.0.2 h1:5p79OS8zlf7eqpjCD/warnphPCBl0UJG0DALqyj46yc=
github.com/douglascdev/buttifier v0.0.2/go.mod h1:NwWm2htIvguVOd+IJPZYlIH9Y5x6969bbswtFmPsZ0E=
github.com/douglascdev/buttifier v0.0.3 h1:nc/xx9CMPyYPWD+Nd91OPKhNlOssvdlc+5b9P3njJDc=
github.com/douglascdev/buttifier v0.0.3/go.mod h1:63K7DrkoTEDVSZglPZI2uu31eqybpUtpJFUnBA1Tf8k=
github.com/douglascdev/buttifier v0.0.4 h1:CPeAOYdRPCwTpT5gI5P+6DQohkCOGUbiLqjC3QP6bkA=
github.com/douglascdev/buttifier v0.0.4/go.mod h1:NwWm2htIvguVOd+IJPZYlIH9Y5x6969bbswtFmPsZ0E=
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/gempir/go-twitch-irc/v4 v4.0.0 h1:sHVIvbWOv9nHXGEErilclxASv0AaQEr/r/f9C0B9aO8=
Expand All @@ -11,6 +23,8 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/speedata/hyphenation v1.0.2 h1:2rDCtAqNfbf+E56SsqbmNApsVx9CH+4fwIh1RZuu3B8=
github.com/speedata/hyphenation v1.0.2/go.mod h1:vwrKKvBvJWFll0sVZw99hyWS/+r4YlMI7MAYjnje0nM=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down