From 24a94e790aad05680413bf1bb6b90d199239394e Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Mon, 21 Mar 2016 20:34:04 +0100 Subject: Remvoe rotten code --- roulette.go | 61 ----------------------------------------------- theo.go | 20 ---------------- top/main.go | 79 ------------------------------------------------------------- uptime.go | 25 ------------------- weather.go | 43 --------------------------------- 5 files changed, 228 deletions(-) delete mode 100644 roulette.go delete mode 100644 theo.go delete mode 100644 top/main.go delete mode 100644 uptime.go delete mode 100644 weather.go diff --git a/roulette.go b/roulette.go deleted file mode 100644 index a09828e..0000000 --- a/roulette.go +++ /dev/null @@ -1,61 +0,0 @@ -package main - -import ( - "log" - "math/rand" - "time" - - irc "github.com/fluffle/goirc/client" -) - -type RR struct{ Command } - -const barrel = 6 - -var ( - bullet int - loaded int - played string -) - -func reload() { - bullet = 0 - loaded = rand.Intn(barrel) - played = "" -} - -func trigger() bool { - defer func() { - bullet++ - bullet %= barrel - }() - return bullet == loaded -} - -func (_ RR) Timeout(_ string) bool { return false } -func (_ RR) Handle(conn *irc.Conn, line *irc.Line) { - if !line.Public() { - return - } - log.Println(line.Nick, bullet, loaded) - if played == line.Nick { - conn.Notice(*room, line.Nick+", not your turn") - return - } - played = line.Nick - if trigger() { - conn.Kick(*room, line.Nick, "bang!") - conn.Notice(*room, "reload") - reload() - } -} - -func (_ RR) Help() string { - return "Russian roulette" -} - -func init() { - rand.Seed(time.Now().UnixNano()) - reload() - Register("ку", &RR{}) -} diff --git a/theo.go b/theo.go deleted file mode 100644 index cb1bc89..0000000 --- a/theo.go +++ /dev/null @@ -1,20 +0,0 @@ -package main - -import ( - "dim13.org/theo" - irc "github.com/fluffle/goirc/client" -) - -type Theo struct{ Command } - -func (_ Theo) Handle(conn *irc.Conn, line *irc.Line) { - conn.Notice(line.Target(), theo.Quote()) -} - -func (_ Theo) Help() string { - return "Quote Theo De Raadt" -} - -func init() { - Register("theo", &Theo{}) -} diff --git a/top/main.go b/top/main.go deleted file mode 100644 index 6632b8e..0000000 --- a/top/main.go +++ /dev/null @@ -1,79 +0,0 @@ -package main - -import ( - "bufio" - "encoding/gob" - "fmt" - "log" - "os" - "regexp" - "sort" -) - -const ( - logfile = `/home/demon/irclogs/RusNet/#lor.log` - gobfile = `score.gob` -) - -var ( - re = regexp.MustCompile(`[^ ]+ <.([^ ]+)> .*`) - score = make(map[string]int) -) - -type Score struct { - Nick string - Count int -} - -type Scores []Score - -func (s Scores) Len() int { return len(s) } -func (s Scores) Swap(i, j int) { s[i], s[j] = s[j], s[i] } -func (s Scores) Less(i, j int) bool { return s[i].Count < s[j].Count } - -func newScore(m map[string]int) (s Scores) { - for k, v := range m { - s = append(s, Score{ - Nick: k, - Count: v, - }) - } - sort.Sort(sort.Reverse(s)) - if len(s) > 10 { - s = s[:10] - } - return -} - -func main() { - fd, err := os.Open(logfile) - if err != nil { - log.Fatal(err) - } - defer fd.Close() - - scanner := bufio.NewScanner(fd) - for scanner.Scan() { - m := re.FindAllStringSubmatch(scanner.Text(), -1) - if m != nil { - user := m[0][1] - score[user]++ - } - } - if err := scanner.Err(); err != nil { - log.Fatal(err) - } - - for n, s := range newScore(score) { - fmt.Printf("%2d %v (%v)\n", n+1, s.Nick, s.Count) - } - - gd, err := os.Create(gobfile) - if err != nil { - log.Fatal(err) - } - defer gd.Close() - - g := gob.NewEncoder(gd) - g.Encode(score) -} diff --git a/uptime.go b/uptime.go deleted file mode 100644 index d0dd89e..0000000 --- a/uptime.go +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "time" - - irc "github.com/fluffle/goirc/client" -) - -type Uptime struct { - Command - boot time.Time -} - -func (u Uptime) Handle(conn *irc.Conn, line *irc.Line) { - conn.Notice(line.Nick, fmt.Sprint(time.Since(u.boot))) -} - -func (_ Uptime) Help() string { - return "Bot's uptime" -} - -func init() { - Register("uptime", &Uptime{boot: time.Now()}) -} diff --git a/weather.go b/weather.go deleted file mode 100644 index 312b330..0000000 --- a/weather.go +++ /dev/null @@ -1,43 +0,0 @@ -package main - -import ( - "fmt" - "strings" - - "dim13.org/weather" - irc "github.com/fluffle/goirc/client" -) - -type Weather struct { - Command - lastCity map[string]string -} - -func (_ Weather) WithArgs(_ int) bool { return true } - -func (w *Weather) Handle(conn *irc.Conn, line *irc.Line) { - var city string - q := strings.SplitN(line.Text(), " ", 2) - if len(q) == 2 { - city = q[1] - } else if l, ok := w.lastCity[line.Nick]; ok { - city = l - } else { - conn.Notice(line.Target(), "set your location first") - return - } - if c, err := weather.ByCityName(city); err != nil { - conn.Notice(line.Target(), err.Error()) - } else { - conn.Notice(line.Target(), fmt.Sprint(c)) - w.lastCity[line.Nick] = city - } -} - -func (_ Weather) Help() string { - return "Fetch current weather" -} - -func init() { - Register("weather", &Weather{lastCity: make(map[string]string)}) -} -- cgit v1.2.3