forked from an/flokati
Removed ModParams array
This commit is contained in:
parent
1aa1a2b6c0
commit
080ab0b19f
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue