forked from an/flokati
Removed ModParams array
This commit is contained in:
parent
1aa1a2b6c0
commit
080ab0b19f
|
@ -22,7 +22,7 @@ func init() {
|
||||||
|
|
||||||
func gogsConfig() {
|
func gogsConfig() {
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
gogsAPIKey = ModParams["gogs-api-key"]
|
//gogsAPIKey = ModParams["gogs-api-key"]
|
||||||
}
|
}
|
||||||
|
|
||||||
func gogsHandleMessage(m *irc.Message) {
|
func gogsHandleMessage(m *irc.Message) {
|
||||||
|
|
|
@ -47,7 +47,7 @@ func markovHandleMessage(m *irc.Message) {
|
||||||
}
|
}
|
||||||
text = markovParseText(text)
|
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)
|
responseText := markovChain.Generate(*markovAnswerLen, text)
|
||||||
if responseText != "" {
|
if responseText != "" {
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -153,7 +153,7 @@ func markovNewChain(prefixLen int) *MarkovChain {
|
||||||
// Write parses the bytes into prefixes and suffixes that are stored in MarkovChain.
|
// Write parses the bytes into prefixes and suffixes that are stored in MarkovChain.
|
||||||
func (c *MarkovChain) Write(in string) (int, error) {
|
func (c *MarkovChain) Write(in string) (int, error) {
|
||||||
in = strings.ToLower(in)
|
in = strings.ToLower(in)
|
||||||
if strings.HasPrefix(in, strings.ToLower(ModParams["_nick"])) {
|
if strings.HasPrefix(in, BotNick) {
|
||||||
tok := strings.Split(in, " ")
|
tok := strings.Split(in, " ")
|
||||||
in = strings.Replace(in, tok[0]+" ", "", 1)
|
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.
|
// Generate returns a string of at most n words generated from MarkovChain.
|
||||||
func (c *MarkovChain) Generate(n int, in string) string {
|
func (c *MarkovChain) Generate(n int, in string) string {
|
||||||
in = strings.ToLower(in)
|
in = strings.ToLower(in)
|
||||||
if strings.HasPrefix(in, strings.ToLower(ModParams["_nick"])) {
|
if strings.HasPrefix(in, BotNick) {
|
||||||
tok := strings.Split(in, " ")
|
tok := strings.Split(in, " ")
|
||||||
in = strings.Replace(in, tok[0]+" ", "", 1)
|
in = strings.Replace(in, tok[0]+" ", "", 1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,13 +14,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
SayCh chan string
|
SayCh chan string
|
||||||
MsgFuncs = make(map[string]func(*irc.Message))
|
MsgFuncs = make(map[string]func(*irc.Message))
|
||||||
RunFuncs = make(map[string]func())
|
RunFuncs = make(map[string]func())
|
||||||
ModParams = make(map[string]string)
|
BotNick string
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init(ch chan string, mods, params string) {
|
func Init(ch chan string, mods string) {
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
SayCh = ch
|
SayCh = ch
|
||||||
for mod, _ := range MsgFuncs {
|
for mod, _ := range MsgFuncs {
|
||||||
|
@ -33,10 +33,6 @@ func Init(ch chan string, mods, params string) {
|
||||||
delete(RunFuncs, mod)
|
delete(RunFuncs, mod)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, param := range strings.Split(params, "!") {
|
|
||||||
kv := strings.Split(param, ":")
|
|
||||||
ModParams[kv[0]] = kv[1]
|
|
||||||
}
|
|
||||||
for _, fn := range RunFuncs {
|
for _, fn := range RunFuncs {
|
||||||
go fn()
|
go fn()
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ package modules
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"errors"
|
"errors"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
@ -22,6 +23,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var hideOutput = true
|
var hideOutput = true
|
||||||
|
var rssFeeds = flag.String("rss_feeでs", "feeds.txt", "Feed list file")
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
MsgFuncs["rss"] = rssHandleMessage
|
MsgFuncs["rss"] = rssHandleMessage
|
||||||
|
@ -30,8 +32,7 @@ func init() {
|
||||||
|
|
||||||
func rssRun() {
|
func rssRun() {
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
path := ModParams["rss-feeds"]
|
file, err := os.Open(*rssFeeds)
|
||||||
file, err := os.Open(path)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
xlog.Fatal(err.Error())
|
xlog.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue