summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-12-31 23:43:39 +0100
committerDimitri Sokolyuk <demon@dim13.org>2017-12-31 23:43:39 +0100
commit0d651bca8901257683f5fe366e840bb59f8fd84d (patch)
tree1b6533b73886dc49f47666507972794bc7ba9a3d
parent01d5301e77b4054223d21289a17ace48539cbeb6 (diff)
remove unnecessary stuff
-rw-r--r--feeds.go30
-rw-r--r--last.go49
-rw-r--r--main.go16
-rw-r--r--re.go23
-rw-r--r--re_test.go27
5 files changed, 0 insertions, 145 deletions
diff --git a/feeds.go b/feeds.go
index 9e6412e..6950194 100644
--- a/feeds.go
+++ b/feeds.go
@@ -28,34 +28,4 @@ var Feeds = []Feed{
URL: `http://www.opennet.ru/opennews/opennews_all_noadv.rss`,
Every: 4 * time.Hour,
},
- {
- Name: "Undeadly",
- URL: `http://undeadly.org/cgi?action=rss`,
- Every: 2 * time.Hour,
- },
- {
- Name: "Kernel",
- URL: `https://www.kernel.org/feeds/kdist.xml`,
- Every: 6 * time.Hour,
- },
- {
- Name: "Ted Unangst",
- URL: `http://www.tedunangst.com/flak/rss`,
- Every: 6 * time.Hour,
- },
- {
- Name: "Calomel",
- URL: `https://calomel.org/calomel_rss.xml`,
- Every: 6 * time.Hour,
- },
- {
- Name: "Golang News",
- URL: `https://golangnews.com/index.xml`,
- Every: 6 * time.Hour,
- },
- {
- Name: "Golang Weekly",
- URL: `http://golangweekly.com/rss/1fg21ahk`,
- Every: 6 * time.Hour,
- },
}
diff --git a/last.go b/last.go
deleted file mode 100644
index 50524dd..0000000
--- a/last.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package main
-
-import (
- "container/ring"
- "fmt"
- "time"
-)
-
-type Msg struct {
- Time time.Time
- Nick string
- Text string
-}
-
-type Last struct {
- *ring.Ring
-}
-
-func NewLast(n int) *Last {
- return &Last{ring.New(n)}
-}
-
-func (v *Last) Push(t time.Time, nick, text string) {
- v.Value = Msg{Time: t, Nick: nick, Text: text}
- v.Ring = v.Next()
-}
-
-// walk through buffer and find last message
-func (v *Last) Last(nick string) string {
- var msg string
- v.Do(func(v interface{}) {
- if l, ok := v.(Msg); ok {
- if l.Nick == nick {
- msg = l.Text
- }
- }
- })
- return msg
-}
-
-func (v *Last) Dump(c chan string) {
- v.Do(func(v interface{}) {
- if l, ok := v.(Msg); ok {
- c <- fmt.Sprintf("%v <%v> %v",
- l.Time.UTC().Format(time.Kitchen),
- l.Nick, l.Text)
- }
- })
-}
diff --git a/main.go b/main.go
index 802fc8f..d7c6e38 100644
--- a/main.go
+++ b/main.go
@@ -2,9 +2,7 @@ package main
import (
"flag"
- "fmt"
"log"
- "strings"
irc "github.com/fluffle/goirc/client"
)
@@ -38,27 +36,13 @@ func kicker(conn *irc.Conn, channel string) chan string {
}
func privmsg(note, kick chan string) irc.HandlerFunc {
- last := NewLast(10)
links := linker(note)
return func(conn *irc.Conn, line *irc.Line) {
switch t := line.Text(); {
case isFlood(t):
kick <- line.Nick
- case t == "last":
- c := notify(conn, line.Nick)
- last.Dump(c)
- close(c)
- case strings.HasPrefix(t, "s/"):
- tofix := last.Last(line.Nick)
- if fixed := re(tofix, t); fixed != "" {
- note <- fmt.Sprintf("%v meant to say: %v",
- line.Nick, fixed)
- return
- }
- fallthrough
default:
links <- t
- last.Push(line.Time, line.Nick, t)
}
}
}
diff --git a/re.go b/re.go
deleted file mode 100644
index 9429ac8..0000000
--- a/re.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package main
-
-import (
- "regexp"
- "strings"
-)
-
-func re(s, r string) string {
- // min: s//
- if len(s) < 3 {
- return ""
- }
- z := strings.Split(r[2:], string(r[1]))
- // match s// and s///
- if len(z) < 2 || len(z) > 3 {
- return ""
- }
- re, err := regexp.Compile(z[0])
- if err != nil {
- return ""
- }
- return re.ReplaceAllString(s, z[1])
-}
diff --git a/re_test.go b/re_test.go
deleted file mode 100644
index ef89847..0000000
--- a/re_test.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package main
-
-import "testing"
-
-func TestRE(t *testing.T) {
- testCases := []struct {
- r, s, x string
- }{
- {"s/ddd/xxx/", "abd ddd xxx", "abd xxx xxx"},
- {"s,ddd,xxx,", "abd ddd xxx", "abd xxx xxx"},
- {"s/ddd/xxx", "abd ddd xxx", "abd xxx xxx"},
- {"s/x$/X", "abd ddd xxx", "abd ddd xxX"},
- {"s/ /A", "abd ddd xxx", "abdAdddAxxx"},
- {"s///", "abd ddd xxx", "abd ddd xxx"},
- {"s//", "abd ddd xxx", "abd ddd xxx"},
- {"s/", "abd ddd xxx", ""},
- {"s/^d/X", "abd ddd xxx", "abd ddd xxx"},
- }
- for _, tc := range testCases {
- t.Run(tc.r, func(t *testing.T) {
- res := re(tc.s, tc.r)
- if res != tc.x {
- t.Errorf("got %q, want %q", res, tc.x)
- }
- })
- }
-}