diff --git a/cmd/bot/bot.go b/cmd/bot/bot.go deleted file mode 100644 index 654c393..0000000 --- a/cmd/bot/bot.go +++ /dev/null @@ -1,26 +0,0 @@ -package main - -import ( - "github.com/gempir/go-twitch-irc/v3" - "github.com/sirupsen/logrus" -) - -func (nb *nourybot) connect() error { - nb.twitchClient.Join("nourybot") - - logrus.Info("Connecting to Twitch...") - err := nb.twitchClient.Connect() - if err != nil { - panic(err) - } - - return nil -} - -func (nb *nourybot) onConnect() { - nb.twitchClient.Say("nourybot", "xd") -} - -func (nb *nourybot) onPrivateMessage(message twitch.PrivateMessage) { - logrus.Info(message.Message) -} diff --git a/cmd/bot/command.go b/cmd/bot/command.go deleted file mode 100644 index 06ab7d0..0000000 --- a/cmd/bot/command.go +++ /dev/null @@ -1 +0,0 @@ -package main diff --git a/cmd/bot/main.go b/cmd/bot/main.go deleted file mode 100644 index 0b71705..0000000 --- a/cmd/bot/main.go +++ /dev/null @@ -1,63 +0,0 @@ -package main - -import ( - "database/sql" - "log" - "time" - - "github.com/gempir/go-twitch-irc/v3" - "github.com/lyx0/nourybot/internal/config" - "github.com/lyx0/nourybot/pkg/models/mysql" - "github.com/sirupsen/logrus" - - _ "github.com/go-sql-driver/mysql" -) - -type nourybot struct { - twitchClient *twitch.Client - uptime time.Time - channels *mysql.ChannelModel -} - -func main() { - cfg := config.LoadConfig() - logrus.Info(cfg.Username, cfg.Oauth) - - twitchClient := twitch.NewClient(cfg.Username, cfg.Oauth) - now := time.Now() - - db, err := openDB(cfg.MySQLURI) - if err != nil { - log.Fatal(err) - } - - defer db.Close() - nb := &nourybot{ - twitchClient: twitchClient, - uptime: now, - channels: &mysql.ChannelModel{DB: db}, - } - - nb.twitchClient.OnPrivateMessage(func(message twitch.PrivateMessage) { - nb.onPrivateMessage(message) - }) - - nb.twitchClient.OnConnect(nb.onConnect) - - err = nb.connect() - if err != nil { - panic(err) - } - -} - -func openDB(dsn string) (*sql.DB, error) { - db, err := sql.Open("mysql", dsn) - if err != nil { - return nil, err - } - if err = db.Ping(); err != nil { - return nil, err - } - return db, nil -} diff --git a/internal/bot/bot.go b/internal/bot/bot.go deleted file mode 100644 index 7e49431..0000000 --- a/internal/bot/bot.go +++ /dev/null @@ -1 +0,0 @@ -package bot diff --git a/internal/config/config.go b/internal/config/config.go deleted file mode 100644 index d122efa..0000000 --- a/internal/config/config.go +++ /dev/null @@ -1,49 +0,0 @@ -package config - -import ( - "os" - - "github.com/joho/godotenv" - log "github.com/sirupsen/logrus" -) - -type Config struct { - // Bot - Username string - BotUserId string - Oauth string - // Admin - AdminUsername string - AdminUserId string - - // DB - MySQLURI string - MongoURI string -} - -func LoadConfig() *Config { - err := godotenv.Load() - - if err != nil { - log.Fatal("Error loading .env") - } - - cfg := &Config{ - // Bot - Username: os.Getenv("BOT_USERNAME"), - Oauth: os.Getenv("BOT_PASS"), - BotUserId: os.Getenv("BOT_USER_ID"), - - // Admin - AdminUsername: os.Getenv("ADMIN_USER_NAME"), - AdminUserId: os.Getenv("ADMIN_USER_ID"), - - // DB - MySQLURI: os.Getenv("MYSQL_URI"), - MongoURI: os.Getenv("MONGO_URI"), - } - - log.Info("Config loaded succesfully") - - return cfg -} diff --git a/migrations/nourybot.sql b/migrations/nourybot.sql deleted file mode 100644 index ce28e5c..0000000 --- a/migrations/nourybot.sql +++ /dev/null @@ -1,39 +0,0 @@ -CREATE DATABASE nourybot CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; - -USE nourybot; - --- create a 'channel' table. -CREATE TABLE channel ( - id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, - username VARCHAR(50) NOT NULL, - twitchid VARCHAR(50) NOT NULL, - added DATETIME NOT NULL -); - --- add an index on the created column. -CREATE INDEX idx_channel_created ON channel(added); - --- add dummy records -INSERT INTO channel (username, twitchid, added) VALUES ( - 'whereismymnd', - '31437432', - UTC_TIMESTAMP() -); - -INSERT INTO channel (username, twitchid, added) VALUES ( - 'nourybot', - '596581605', - UTC_TIMESTAMP() -); - -INSERT INTO channel (username, twitchid, added) VALUES ( - 'xnoury', - '197780373', - UTC_TIMESTAMP() -); - --- Important: Make sure to swap 'pass' and 'username' with a password/user of your own choosing. -CREATE USER 'username'@'localhost'; -GRANT SELECT, INSERT ON nourybot.* TO 'username'@'localhost'; - -ALTER USER 'username'@'localhost' IDENTIFIED BY 'pass'; \ No newline at end of file diff --git a/pkg/models/models.go b/pkg/models/models.go deleted file mode 100644 index af97f62..0000000 --- a/pkg/models/models.go +++ /dev/null @@ -1,15 +0,0 @@ -package models - -import ( - "errors" - "time" -) - -var ErrNoRecord = errors.New("models: no matching record found") - -type Channel struct { - ID int - Username string - TwitchID string - Added time.Time -} diff --git a/pkg/models/mysql/channel.go b/pkg/models/mysql/channel.go deleted file mode 100644 index 87c3da6..0000000 --- a/pkg/models/mysql/channel.go +++ /dev/null @@ -1,23 +0,0 @@ -package mysql - -import ( - "database/sql" - - "github.com/lyx0/nourybot/pkg/models" -) - -type ChannelModel struct { - DB *sql.DB -} - -func (m *ChannelModel) Insert(username string, twitchid string) (int, error) { - return 0, nil -} - -func (m *ChannelModel) Get(id int) (*models.Channel, error) { - return nil, nil -} - -func (m *ChannelModel) Latest() ([]*models.Channel, error) { - return nil, nil -}