A modular Twitch bot made in Go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
635 B

2 years ago
  1. package main
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "io/ioutil"
  6. "log"
  7. "twitch/twitchbot"
  8. )
  9. type Config struct {
  10. Bot struct {
  11. Token string `json:"token"`
  12. Nick string `json:"nick"`
  13. } `json:"bot"`
  14. }
  15. func main() {
  16. var config Config
  17. data, _ := ioutil.ReadFile("config.json")
  18. err := json.Unmarshal(data, &config)
  19. if err != nil {
  20. log.Panicln(err)
  21. }
  22. bot := twitchbot.NewBot(config.Bot.Token, config.Bot.Nick, []string{"witer33"})
  23. bot.OnMessage(func(bot *twitchbot.Bot, message *twitchbot.Message) {
  24. fmt.Println(message)
  25. if message.Message == "!ping" {
  26. message.Reply("pong")
  27. message.Delete()
  28. }
  29. })
  30. bot.Run()
  31. }