diff --git a/modules/gogs.go b/modules/gogs.go index 026c657..4207862 100644 --- a/modules/gogs.go +++ b/modules/gogs.go @@ -22,7 +22,7 @@ func init() { func gogsConfig() { time.Sleep(5 * time.Second) - gogsAPIKey = ModParams["gogs-api-key"] + //gogsAPIKey = ModParams["gogs-api-key"] } func gogsHandleMessage(m *irc.Message) { diff --git a/modules/markov.go b/modules/markov.go index b592429..48707f8 100644 --- a/modules/markov.go +++ b/modules/markov.go @@ -47,7 +47,7 @@ func markovHandleMessage(m *irc.Message) { } text = markovParseText(text) - if rand.Intn(100) <= *markovResponseChance || strings.Index(text, strings.ToLower(ModParams["_nick"])) != -1 { + if rand.Intn(100) <= *markovResponseChance || strings.Index(text, BotNick) != -1 { responseText := markovChain.Generate(*markovAnswerLen, text) if responseText != "" { go func() { @@ -153,7 +153,7 @@ func markovNewChain(prefixLen int) *MarkovChain { // Write parses the bytes into prefixes and suffixes that are stored in MarkovChain. func (c *MarkovChain) Write(in string) (int, error) { in = strings.ToLower(in) - if strings.HasPrefix(in, strings.ToLower(ModParams["_nick"])) { + if strings.HasPrefix(in, BotNick) { tok := strings.Split(in, " ") in = strings.Replace(in, tok[0]+" ", "", 1) } @@ -177,7 +177,7 @@ func (c *MarkovChain) Write(in string) (int, error) { // Generate returns a string of at most n words generated from MarkovChain. func (c *MarkovChain) Generate(n int, in string) string { in = strings.ToLower(in) - if strings.HasPrefix(in, strings.ToLower(ModParams["_nick"])) { + if strings.HasPrefix(in, BotNick) { tok := strings.Split(in, " ") in = strings.Replace(in, tok[0]+" ", "", 1) } diff --git a/modules/modules.go b/modules/modules.go index cdc02c1..9eb37a7 100644 --- a/modules/modules.go +++ b/modules/modules.go @@ -14,13 +14,13 @@ import ( ) var ( - SayCh chan string - MsgFuncs = make(map[string]func(*irc.Message)) - RunFuncs = make(map[string]func()) - ModParams = make(map[string]string) + SayCh chan string + MsgFuncs = make(map[string]func(*irc.Message)) + RunFuncs = make(map[string]func()) + BotNick string ) -func Init(ch chan string, mods, params string) { +func Init(ch chan string, mods string) { time.Sleep(5 * time.Second) SayCh = ch for mod, _ := range MsgFuncs { @@ -33,10 +33,6 @@ func Init(ch chan string, mods, params string) { delete(RunFuncs, mod) } } - for _, param := range strings.Split(params, "!") { - kv := strings.Split(param, ":") - ModParams[kv[0]] = kv[1] - } for _, fn := range RunFuncs { go fn() } diff --git a/modules/rss.go b/modules/rss.go index 62d76e7..ec7f3b5 100644 --- a/modules/rss.go +++ b/modules/rss.go @@ -9,6 +9,7 @@ package modules import ( "bufio" "errors" + "flag" "fmt" "io" "os" @@ -22,6 +23,7 @@ import ( ) var hideOutput = true +var rssFeeds = flag.String("rss_feeでs", "feeds.txt", "Feed list file") func init() { MsgFuncs["rss"] = rssHandleMessage @@ -30,8 +32,7 @@ func init() { func rssRun() { time.Sleep(5 * time.Second) - path := ModParams["rss-feeds"] - file, err := os.Open(path) + file, err := os.Open(*rssFeeds) if err != nil { xlog.Fatal(err.Error()) }