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.

40 lines
696 B

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