mirror-nourybot/cmd/bot/bot.go

37 lines
570 B
Go
Raw Normal View History

2021-10-13 21:30:31 +02:00
package bot
import (
2021-10-14 19:02:07 +02:00
"time"
2021-10-13 21:30:31 +02:00
twitch "github.com/gempir/go-twitch-irc/v2"
)
type Bot struct {
2021-10-19 22:25:47 +02:00
TwitchClient *twitch.Client
2021-10-14 19:02:07 +02:00
Uptime time.Time
2021-10-13 21:30:31 +02:00
}
2021-10-19 22:25:47 +02:00
type Channel struct {
Name string
2021-10-13 21:30:31 +02:00
}
2021-10-13 21:39:34 +02:00
2021-10-19 22:25:47 +02:00
func (b *Bot) Send(target, text string) {
if len(text) == 0 {
return
2021-10-13 21:39:34 +02:00
}
2021-10-19 22:25:47 +02:00
// if message[0] == '.' || message[0] == '/' {
// message = ". " + message
// }
2021-10-13 21:39:34 +02:00
2021-10-19 22:25:47 +02:00
if len(text) > 500 {
firstMessage := text[0:499]
secondMessage := text[499:]
b.TwitchClient.Say(target, firstMessage)
b.TwitchClient.Say(target, secondMessage)
return
2021-10-13 21:39:34 +02:00
}
2021-10-19 22:25:47 +02:00
b.TwitchClient.Say(target, text)
2021-10-13 23:29:29 +02:00
}