mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
cleanup
This commit is contained in:
parent
bf8f7943fb
commit
3bcef5b48a
3 changed files with 12 additions and 8 deletions
|
@ -28,12 +28,13 @@ type banphraseData struct {
|
|||
Permanent bool `json:"permanent"`
|
||||
}
|
||||
|
||||
// CheckMessage checks if a message contains
|
||||
// banphrased content.
|
||||
// If a message is allowed it returns
|
||||
// false, "okay"
|
||||
// If a message is not allowed it returns:
|
||||
// true, "[banphrased] monkaS"
|
||||
var (
|
||||
banPhraseUrl = "https://pajlada.pajbot.com/api/v1/banphrases/test"
|
||||
)
|
||||
|
||||
// CheckMessage checks a message against a banphrase api..
|
||||
// returns false, "okay" if a message was allowed
|
||||
// returns true, "[banphrased] monkaS" and the reason if not.
|
||||
// More information:
|
||||
// https://gist.github.com/pajlada/57464e519ba8d195a97ddcd0755f9715
|
||||
func CheckMessage(text string) (bool, string) {
|
||||
|
@ -47,7 +48,7 @@ func CheckMessage(text string) (bool, string) {
|
|||
log.Error(err)
|
||||
}
|
||||
|
||||
resp, err := http.Post("https://pajlada.pajbot.com/api/v1/banphrases/test", "application/json", bytes.NewBuffer(reqBody))
|
||||
resp, err := http.Post(banPhraseUrl, "application/json", bytes.NewBuffer(reqBody))
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
|
|
@ -45,8 +45,10 @@ func (b *Bot) Send(target, text string) {
|
|||
if len(text) > 500 {
|
||||
firstMessage := text[0:499]
|
||||
secondMessage := text[499:]
|
||||
|
||||
b.TwitchClient.Say(target, firstMessage)
|
||||
b.TwitchClient.Say(target, secondMessage)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ func main() {
|
|||
}
|
||||
|
||||
nb.TwitchClient.OnPrivateMessage(func(message twitch.PrivateMessage) {
|
||||
|
||||
// If channelID is missing something must have gone wrong.
|
||||
channelID := message.Tags["room-id"]
|
||||
if channelID == "" {
|
||||
|
@ -28,7 +29,7 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
// So that the bot doesn't repeat itself.
|
||||
// Don't act on bots own messages.
|
||||
if message.Tags["user-id"] == "596581605" {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue