Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Commit

Permalink
Reply to private queries
Browse files Browse the repository at this point in the history
- reply, but do not add anything to the corpus (closes #9)
  • Loading branch information
lidel committed Aug 15, 2015
1 parent 2e54fff commit feff271
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ run:
# dockerized build & container run (including redis)
docker-rebuild: docker-stop docker-clean
$(D) build -t meowkov .
$(D) run -d -v $(CURDIR)/data:/data --name meowkov_corpus redis
$(D) run -d -v $(CURDIR)/data:/data:rw --name meowkov_corpus redis
$(D) run -d -v $(CURDIR)/meowkov.conf:/meowkov/meowkov.conf:ro --link meowkov_corpus:redis -it --name meowkov_irc meowkov
docker-start:
$(D) start meowkov_corpus
Expand Down
2 changes: 1 addition & 1 deletion meowkov.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
"( ͡° ͜ʖ ͡°)"
],

"DontEndWith": ["of","po","by","from","on","for","przez","with","i","w","z","na","or","za","o","do","in","to","a","the","dla"],
"DontEndWith": ["as","of","po","by","from","on","for","przez","with","i","w","z","na","or","za","o","do","in","to","a","the","dla"],
"Blacklist": []
}
18 changes: 12 additions & 6 deletions meowkov.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func importLoop(newCorpus bool) {
wg.Add(1)
go func(line string) {
defer wg.Done()
processInput(line)
processInput(line, true)
}(line)
}
wg.Wait()
Expand Down Expand Up @@ -193,15 +193,21 @@ func ircLoop() {
})

con.AddCallback("PRIVMSG", func(e *irc.Event) {
words, seeds, chattiness := processInput(e.Message())
channel := strings.Split(e.Raw, " ")[2]
privateQuery := channel == con.GetNick()

if chattiness > rand.Float64() {
if privateQuery {
channel = strings.Split(e.Raw[1:], "!")[0]
}

words, seeds, chattiness := processInput(e.Message(), !privateQuery)

if privateQuery || chattiness > rand.Float64() {
response := generateResponse(words, seeds, int(config.MaxResponseTries))
if chattiness == always {
response = e.Nick + ": " + strings.TrimSpace(response)
}
typingDelay(response)
channel := e.Arguments[0]
con.Privmsg(channel, response)
}
})
Expand Down Expand Up @@ -243,10 +249,10 @@ func typingDelay(text string) {
time.Sleep(time.Duration(typing) * time.Second)
}

func processInput(message string) (words []string, seed [][]string, chattiness float64) {
func processInput(message string, learning bool) (words []string, seed [][]string, chattiness float64) {
words, chattiness = parseInput(message)
seed = createSeeds(words)
if int(config.ChainLength) < len(words) {
if learning && int(config.ChainLength) < len(words) {
addToCorpus(seed)
}
return
Expand Down
2 changes: 1 addition & 1 deletion meowkov_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func init() {
// run tests against config template
// run against config template
loadConfig("meowkov.conf.template")
}

Expand Down

0 comments on commit feff271

Please sign in to comment.