mirror of https://github.com/velour/catbase.git
commit
87487a518e
|
@ -4,14 +4,14 @@ package config
|
|||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"regexp"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
sqlite3 "github.com/mattn/go-sqlite3"
|
||||
"github.com/yuin/gluamapper"
|
||||
lua "github.com/yuin/gopher-lua"
|
||||
)
|
||||
|
||||
// Config stores any system-wide startup information that cannot be easily configured via
|
||||
|
@ -64,7 +64,7 @@ type Config struct {
|
|||
Hosts []string
|
||||
}
|
||||
Your struct {
|
||||
MaxLength int
|
||||
MaxLength int
|
||||
Replacements []Replacement
|
||||
}
|
||||
LeftPad struct {
|
||||
|
@ -91,12 +91,12 @@ type Config struct {
|
|||
Chance float64
|
||||
}
|
||||
Reaction struct {
|
||||
GeneralChance float64
|
||||
HarrassChance float64
|
||||
GeneralChance float64
|
||||
HarrassChance float64
|
||||
NegativeHarrassmentMultiplier int
|
||||
HarrassList []string
|
||||
PositiveReactions []string
|
||||
NegativeReactions []string
|
||||
HarrassList []string
|
||||
PositiveReactions []string
|
||||
NegativeReactions []string
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,24 +113,24 @@ func init() {
|
|||
}
|
||||
|
||||
type Replacement struct {
|
||||
This string
|
||||
That string
|
||||
This string
|
||||
That string
|
||||
Frequency float64
|
||||
}
|
||||
|
||||
// Readconfig loads the config data out of a JSON file located in cfile
|
||||
func Readconfig(version, cfile string) *Config {
|
||||
fmt.Printf("Using %s as config file.\n", cfile)
|
||||
file, e := ioutil.ReadFile(cfile)
|
||||
if e != nil {
|
||||
panic("Couldn't read config file!")
|
||||
L := lua.NewState()
|
||||
if err := L.DoFile(cfile); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var c Config
|
||||
err := json.Unmarshal(file, &c)
|
||||
if err != nil {
|
||||
if err := gluamapper.Map(L.GetGlobal("config").(*lua.LTable), &c); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
c.Version = version
|
||||
|
||||
if c.Type == "" {
|
||||
|
|
|
@ -1,86 +0,0 @@
|
|||
{
|
||||
"DB": {
|
||||
"File": "catbase.db",
|
||||
"Server": "127.0.0.1"
|
||||
},
|
||||
"Channels": ["#CatBaseTest"],
|
||||
"MainChannel": "#CatBaseTest",
|
||||
"Plugins": [],
|
||||
"Type": "slack",
|
||||
"Irc": {
|
||||
"Server": "ircserver:6697",
|
||||
"Pass": "CatBaseTest:test"
|
||||
},
|
||||
"Slack": {
|
||||
"Token": "<your slack token>"
|
||||
},
|
||||
"Nick": "CatBaseTest",
|
||||
"FullName": "CatBase",
|
||||
"CommandChar": ["!", "¡"],
|
||||
"RatePerSec": 10.0,
|
||||
"LogLength": 50,
|
||||
"Admins": ["<Admin Nick>"],
|
||||
"HttpAddr": "127.0.0.1:1337",
|
||||
|
||||
"Untappd": {
|
||||
"Token": "<Your Token>",
|
||||
"Freq": 3600,
|
||||
"Channels": []
|
||||
},
|
||||
|
||||
"TwitterConsumerKey": "<Consumer Key>",
|
||||
"TwitterConsumerSecret": "<Consumer Secret>",
|
||||
"TwitterUserKey": "<User Key>",
|
||||
"TwitterUserSecret": "<User Secret>",
|
||||
|
||||
"WelcomeMsgs": [
|
||||
"Real men use screen, %s.",
|
||||
"Joins upset the hivemind's OCD, %s.",
|
||||
"Joins upset the hivemind's CDO, %s.",
|
||||
"%s, I WILL CUT YOU!"
|
||||
],
|
||||
"Bad": {
|
||||
"Msgs": [],
|
||||
"Nicks": [],
|
||||
"Hosts": []
|
||||
},
|
||||
"Your": {
|
||||
"MaxLength": 140,
|
||||
"Replacements": [
|
||||
{ "This": "this", "That": "that", "Frequency": 1.0 },
|
||||
]
|
||||
},
|
||||
"LeftPad": {
|
||||
"MaxLen": 50,
|
||||
"Who": "person"
|
||||
},
|
||||
"Factoid": {
|
||||
"QuoteChance": 0.99,
|
||||
"QuoteTime": 1,
|
||||
"StartupFact": "speed test",
|
||||
"MinLen": 5
|
||||
},
|
||||
"Babbler": {
|
||||
"DefaultUsers": [
|
||||
"seabass"
|
||||
]
|
||||
},
|
||||
"Reminder": {
|
||||
"MaxBatchAdd" : 10
|
||||
},
|
||||
"Stats": {
|
||||
"DBPath": "stats.db",
|
||||
"Sightings": ["user"]
|
||||
},
|
||||
"Emojify": {
|
||||
"Chance": 0.02
|
||||
},
|
||||
"Reaction" : {
|
||||
"GeneralChance": 0.01,
|
||||
"HarrassChance": 0.05,
|
||||
"NegativeHarrassmentMultiplier": 2,
|
||||
"HarrassList": ["msherms"],
|
||||
"PositiveReactions": ["+1", "authorized", "aw_yea","joy"],
|
||||
"NegativeReactions": ["bullshit","fake","tableflip","vomit"]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
config = {
|
||||
Channels = {
|
||||
"#CatBaseTest"
|
||||
},
|
||||
TwitterConsumerSecret = "<Consumer Secret>",
|
||||
Reminder = {
|
||||
MaxBatchAdd = 10
|
||||
},
|
||||
Nick = "CatBaseTest",
|
||||
LeftPad = {
|
||||
Who = "person",
|
||||
MaxLen = 50
|
||||
},
|
||||
Factoid = {
|
||||
StartupFact = "speed test",
|
||||
QuoteTime = 1,
|
||||
QuoteChance = 0.99,
|
||||
MinLen = 5
|
||||
},
|
||||
CommandChar = {
|
||||
"!",
|
||||
"¡"
|
||||
},
|
||||
FullName = "CatBase",
|
||||
Your = {
|
||||
MaxLength = 140,
|
||||
DuckingChance = 0.5,
|
||||
FuckingChance = 0.15,
|
||||
YourChance = 0.4
|
||||
},
|
||||
Emojify = {
|
||||
Chance = 0.02
|
||||
},
|
||||
DB = {
|
||||
File = "catbase.db",
|
||||
Server = "127.0.0.1"
|
||||
},
|
||||
Plugins = {
|
||||
},
|
||||
Untappd = {
|
||||
Freq = 3600,
|
||||
Channels = {
|
||||
},
|
||||
Token = "<Your Token>"
|
||||
},
|
||||
LogLength = 50,
|
||||
RatePerSec = 10,
|
||||
Reaction = {
|
||||
HarrassChance = 0.05,
|
||||
GeneralChance = 0.01,
|
||||
NegativeHarrassmentMultiplier = 2,
|
||||
HarrassList = {
|
||||
"msherms"
|
||||
},
|
||||
NegativeReactions = {
|
||||
"bullshit",
|
||||
"fake",
|
||||
"tableflip",
|
||||
"vomit"
|
||||
},
|
||||
PositiveReactions = {
|
||||
"+1",
|
||||
"authorized",
|
||||
"aw_yea",
|
||||
"joy"
|
||||
}
|
||||
},
|
||||
TwitterUserKey = "<User Key>",
|
||||
MainChannel = "#CatBaseTest",
|
||||
TwitterUserSecret = "<User Secret>",
|
||||
WelcomeMsgs = {
|
||||
"Real men use screen, %s.",
|
||||
"Joins upset the hivemind's OCD, %s.",
|
||||
"Joins upset the hivemind's CDO, %s.",
|
||||
"%s, I WILL CUT YOU!"
|
||||
},
|
||||
Bad = {
|
||||
Msgs = {
|
||||
},
|
||||
Hosts = {
|
||||
},
|
||||
Nicks = {
|
||||
}
|
||||
},
|
||||
Irc = {
|
||||
Server = "ircserver:6697",
|
||||
Pass = "CatBaseTest:test"
|
||||
},
|
||||
Slack = {
|
||||
Token = "<your slack token>"
|
||||
},
|
||||
TwitterConsumerKey = "<Consumer Key>",
|
||||
Babbler = {
|
||||
DefaultUsers = {
|
||||
"seabass"
|
||||
}
|
||||
},
|
||||
Type = "slack",
|
||||
Admins = {
|
||||
"<Admin Nick>"
|
||||
},
|
||||
Stats = {
|
||||
Sightings = {
|
||||
"user"
|
||||
},
|
||||
DBPath = "stats.db"
|
||||
},
|
||||
HttpAddr = "127.0.0.1:1337"
|
||||
}
|
Loading…
Reference in New Issue