summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-03-22 08:10:09 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-03-22 08:10:09 +0100
commit4cbb6042235a29cfb07f0117dbcb92207dc0d8e3 (patch)
tree67758e8203c2d8538269de0c8d684afcf98163f1
parentb564888d72f5a09610f86d640089aceae3780f51 (diff)
Unexport
-rw-r--r--flood.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/flood.go b/flood.go
index 42b970e..986a85c 100644
--- a/flood.go
+++ b/flood.go
@@ -10,7 +10,7 @@ import (
irc "github.com/fluffle/goirc/client"
)
-func Entropy(s string) (e float64) {
+func entropy(s string) (e float64) {
n := make(map[rune]float64)
for _, r := range s {
n[r] += 1 / float64(len(s))
@@ -21,17 +21,17 @@ func Entropy(s string) (e float64) {
return
}
-func Flood(s string) bool {
+func isFlood(s string) bool {
if utf8.RuneCountInString(s) <= 6 {
return false
}
if v := strings.Fields(s); len(v) >= 6 {
- return CommonWord(v) >= len(v)/2
+ return commonWord(v) >= len(v)/2
}
- return Entropy(s) <= 1
+ return entropy(s) <= 1
}
-func CommonWord(v []string) int {
+func commonWord(v []string) int {
m := make(map[string]int)
for _, w := range v {
m[w]++
@@ -45,7 +45,7 @@ func CommonWord(v []string) int {
}
func DetectFlood(conn *irc.Conn, line *irc.Line) {
- if Flood(line.Text()) {
+ if isFlood(line.Text()) {
log.Println("flood", line.Nick)
conn.Kick(*room, line.Nick, "flood")
}