Compare commits
2 Commits
e300f71370
...
91b0e21b7a
Author | SHA1 | Date | |
---|---|---|---|
91b0e21b7a | |||
dfe7deff72 |
@ -1,4 +1,5 @@
|
|||||||
watbot:
|
watbot:
|
||||||
|
database: wat.db # wat.db (in the working directory) is the default
|
||||||
server:
|
server:
|
||||||
host: irc.casa # mandatory, no default
|
host: irc.casa # mandatory, no default
|
||||||
port: 6697
|
port: 6697
|
||||||
|
2
main.go
2
main.go
@ -20,6 +20,7 @@ type Config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type watConfig struct {
|
type watConfig struct {
|
||||||
|
Database string `default:"wat.db" yaml:"database"`
|
||||||
Nick string `yaml:"nick"`
|
Nick string `yaml:"nick"`
|
||||||
Pass string `yaml:"pass"`
|
Pass string `yaml:"pass"`
|
||||||
User string `yaml:"user"`
|
User string `yaml:"user"`
|
||||||
@ -99,6 +100,7 @@ func main() {
|
|||||||
Name: config.Name,
|
Name: config.Name,
|
||||||
}
|
}
|
||||||
watConfig := wat.WatConfig{
|
watConfig := wat.WatConfig{
|
||||||
|
DatabasePath: config.Database,
|
||||||
AutoJoinChannels: config.Channels.Join,
|
AutoJoinChannels: config.Channels.Join,
|
||||||
PermittedChannels: config.Channels.Permitted,
|
PermittedChannels: config.Channels.Permitted,
|
||||||
IgnoredHosts: config.Ignores.Hosts,
|
IgnoredHosts: config.Ignores.Hosts,
|
||||||
|
@ -20,6 +20,7 @@ type WatBot struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type WatConfig struct {
|
type WatConfig struct {
|
||||||
|
DatabasePath string
|
||||||
BotHosts []string
|
BotHosts []string
|
||||||
BotGames BotGameConfig
|
BotGames BotGameConfig
|
||||||
AdminHosts []string
|
AdminHosts []string
|
||||||
@ -30,7 +31,7 @@ type WatConfig struct {
|
|||||||
|
|
||||||
func NewWatBot(config *irc.ClientConfig, watConfig *WatConfig, serverConn *tls.Conn) *WatBot {
|
func NewWatBot(config *irc.ClientConfig, watConfig *WatConfig, serverConn *tls.Conn) *WatBot {
|
||||||
wat := WatBot{conn: serverConn, Nick: config.Nick, c: watConfig}
|
wat := WatBot{conn: serverConn, Nick: config.Nick, c: watConfig}
|
||||||
wat.Db = NewWatDb()
|
wat.Db = NewWatDb(watConfig.DatabasePath)
|
||||||
wat.game = NewWatGame(&wat, wat.Db)
|
wat.game = NewWatGame(&wat, wat.Db)
|
||||||
wat.integration = NewWatIntegration(&wat, wat.Db, &WatIntegrationConfig{BotHosts: watConfig.BotHosts, BotGames: watConfig.BotGames})
|
wat.integration = NewWatIntegration(&wat, wat.Db, &WatIntegrationConfig{BotHosts: watConfig.BotHosts, BotGames: watConfig.BotGames})
|
||||||
config.Handler = irc.HandlerFunc(wat.HandleIrcMsg)
|
config.Handler = irc.HandlerFunc(wat.HandleIrcMsg)
|
||||||
|
@ -52,10 +52,10 @@ type WatDb struct {
|
|||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWatDb() *WatDb {
|
func NewWatDb(dbpath string) *WatDb {
|
||||||
w := WatDb{}
|
w := WatDb{}
|
||||||
var err error
|
var err error
|
||||||
w.db, err = gorm.Open(sqlite.Open("wat.db"), &gorm.Config{})
|
w.db, err = gorm.Open(sqlite.Open(dbpath), &gorm.Config{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user