now with config files

This commit is contained in:
Horscchtey 2021-11-24 00:50:01 +00:00
commit 844578f217
6 changed files with 71 additions and 86 deletions

28
bot.go
View file

@ -2,31 +2,41 @@ package main
import (
"os"
"log"
"fmt"
"net"
"time"
configo "github.com/distributedio/configo"
_ "github.com/mattn/go-sqlite3"
)
var dead = true
type Config struct {
Name string `cfg:"name; boddle; printableascii; IRC nick of bot"`
Channels []string `cfg:"channels; required; printableascii; Channel list to join to"`
Server string `cfg:"server; required; netaddr; Server name to connect to"`
Database string `cfg:"database; ./boddle.db; path; Path to database"`
}
type bot struct {
name string
channel []string
port int
server string
Conf Config
conn net.Conn
}
func main() {
LOG_init()
boddle := bot {
name: "boddle",
channel: []string{"#faui2k16", "#fau", "#sigbike", "#sigfreibad"},
port: 6667,
server: "irc.fau.de",
var boddle bot
if err := configo.Load("./boddle.toml", &boddle.Conf); err != nil {
log.Fatal(err)
}
// boddle := bot {
// name: "boddle",
// channel: []string{"#faui2k16", "#fau", "#sigbike", "#sigfreibad"},
// port: 6667,
// server: "irc.fau.de",
// }
LOG_INFO.Println("bot started!")