summaryrefslogtreecommitdiff
path: root/last.go
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 /last.go
parent01d5301e77b4054223d21289a17ace48539cbeb6 (diff)
remove unnecessary stuff
Diffstat (limited to 'last.go')
-rw-r--r--last.go49
1 files changed, 0 insertions, 49 deletions
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)
- }
- })
-}