diff options
| author | Christine Dodrill <me@christine.website> | 2018-10-04 19:01:51 -0700 |
|---|---|---|
| committer | Christine Dodrill <me@christine.website> | 2018-10-04 19:01:51 -0700 |
| commit | e36f755db2198a96e2b87781f5f5432fcee092dd (patch) | |
| tree | 067de16390e58ee37d4131e47c2f01f2d21c2fb6 /irc/splatbot | |
| parent | b1b91c49e75796aefb4b14f59bfa2ce44672903e (diff) | |
| download | x-e36f755db2198a96e2b87781f5f5432fcee092dd.tar.xz x-e36f755db2198a96e2b87781f5f5432fcee092dd.zip | |
fix build
Diffstat (limited to 'irc/splatbot')
| -rw-r--r-- | irc/splatbot/.gitignore | 1 | ||||
| -rw-r--r-- | irc/splatbot/Dockerfile | 6 | ||||
| -rw-r--r-- | irc/splatbot/doc.go | 4 | ||||
| -rw-r--r-- | irc/splatbot/handler.go | 53 | ||||
| -rw-r--r-- | irc/splatbot/main.go | 45 | ||||
| -rw-r--r-- | irc/splatbot/maps.go | 32 | ||||
| -rw-r--r-- | irc/splatbot/stage.go | 12 |
7 files changed, 0 insertions, 153 deletions
diff --git a/irc/splatbot/.gitignore b/irc/splatbot/.gitignore deleted file mode 100644 index d614448..0000000 --- a/irc/splatbot/.gitignore +++ /dev/null @@ -1 +0,0 @@ -splatbot diff --git a/irc/splatbot/Dockerfile b/irc/splatbot/Dockerfile deleted file mode 100644 index a54edf0..0000000 --- a/irc/splatbot/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM golang:1.4.2 - -ADD . /go/src/github.com/Xe/tools/irc/splatbot -RUN go get github.com/Xe/tools/irc/splatbot/... - -CMD splatbot diff --git a/irc/splatbot/doc.go b/irc/splatbot/doc.go deleted file mode 100644 index 99770f2..0000000 --- a/irc/splatbot/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -/* -Command splatbot is a simple IRC bot that lets you see the latest splatoon maps. -*/ -package main diff --git a/irc/splatbot/handler.go b/irc/splatbot/handler.go deleted file mode 100644 index 51ff843..0000000 --- a/irc/splatbot/handler.go +++ /dev/null @@ -1,53 +0,0 @@ -package main - -import ( - "encoding/json" - "io/ioutil" - "log" - "net/http" - "strings" - - "github.com/belak/irc" -) - -func handlePrivmsg(c *irc.Client, e *irc.Event) { - if strings.HasPrefix(e.Trailing(), "!splatoon") { - splatoonLookup(c, e) - } -} - -func splatoonLookup(c *irc.Client, e *irc.Event) { - resp, err := http.Get(url) - if err != nil { - c.Reply(e, "Couldn't look up splatoon maps: %s", err.Error()) - return - } - - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - c.Reply(e, "Couldn't look up splatoon maps: %s", err.Error()) - return - } - - defer resp.Body.Close() - - var sd []SplatoonData - err = json.Unmarshal(body, &sd) - if err != nil { - c.Reply(e, "Couldn't look up splatoon maps: %s", err.Error()) - return - } - - data := sd[0] - - stage1 := data.Stages[0] - stage2 := data.Stages[1] - c.Reply( - e, - "From %s to %s, the stage rotation is %s and %s", - data.DatetimeTermBegin, data.DatetimeTermEnd, - englishIfy(stage1), englishIfy(stage2), - ) - - log.Printf("%s asked me to look up data", e.Identity.Nick) -} diff --git a/irc/splatbot/main.go b/irc/splatbot/main.go deleted file mode 100644 index 442af6c..0000000 --- a/irc/splatbot/main.go +++ /dev/null @@ -1,45 +0,0 @@ -package main - -import ( - "flag" - "fmt" - - "github.com/belak/irc" -) - -var ( - nick = flag.String("nick", "Inkling", "Nickname to use") - user = flag.String("user", "xena", "Username to use") - channels = flag.String("channels", "#niichan", "Comma-separated list of channels to join") - server = flag.String("server", "irc.ponychat.net", "Server to connect to") - port = flag.Int("port", 6697, "port to connect to") - ssl = flag.Bool("ssl", true, "Use ssl?") -) - -func init() { - flag.Parse() -} - -func main() { - handler := irc.NewBasicMux() - - client := irc.NewClient(irc.HandlerFunc(handler.HandleEvent), *nick, *user, "SplatBot by Xena", "") - - handler.Event("001", func(c *irc.Client, e *irc.Event) { - c.Writef("MODE %s +B", c.CurrentNick()) - c.Writef("JOIN %s", *channels) - }) - - handler.Event("PRIVMSG", handlePrivmsg) - - var err error - - if *ssl { - err = client.DialTLS(fmt.Sprintf("%s:%d", *server, *port), nil) - } else { - err = client.Dial(fmt.Sprintf("%s:%d", *server, *port)) - } - if err != nil { - panic(err) - } -} diff --git a/irc/splatbot/maps.go b/irc/splatbot/maps.go deleted file mode 100644 index e3f9ff8..0000000 --- a/irc/splatbot/maps.go +++ /dev/null @@ -1,32 +0,0 @@ -package main - -import "fmt" - -const url = "https://s3-ap-northeast-1.amazonaws.com/splatoon-data.nintendo.net/stages_info.json" - -var mapNames map[string]string - -func init() { - mapNames = map[string]string{ - "eefffc33ee1956b7b70e250d5835aa67be9152d42bc76aa8874987ebdfc19944": "Urchin Underpass", - "b8067d2839476ec39072e371b4c59fa85454cdb618515af080ca6080772f3264": "Port Mackerel", - "50c01bca5b3117f4f7893df86d2e2d95435dbb1aae1da6831b8e74838859bc7d": "Saltspray Rig", - "9a1736540c3fde7e409cb9c7e333441157d88dfe8ce92bc6aafcb9f79c56cb3d": "Blackbelly Skatepark", - "d7bf0ca4466e980f994ef7b32faeb71d80611a28c5b9feef84a00e3c4c9d7bc1": "Walleye Warehouse", - "8c69b7c9a81369b5cfd22adbf41c13a8df01969ff3d0e531a8bcb042156bc549": "Arowana Mall", - "1ac0981d03c18576d9517f40461b66a472168a8f14f6a8714142af9805df7b8c": "Bluefin Depot", - "c52a7ab7202a576ee18d94be687d97190e90fdcc25fc4b1591c1a8e0c1c299a5": "Kelp Dome", - "6a6c3a958712adedcceb34f719e220ab0d840d8753e5f51b089d363bd1763c91": "Moray Towers", - "a54716422edf71ac0b3d20fbb4ba5970a7a78ba304fcf935aaf69254d61ca709": "Flounder Heights", - "fafe7416d363c7adc8c5c7b0f76586216ba86dcfe3fd89708d672e99bc822adc": "Camp Triggerfish", - } -} - -func englishIfy(s *Stage) string { - name, ok := mapNames[s.ID] - if !ok { - return fmt.Sprintf("Please tell Xena the name of stage id \"%s\" with jpn name %s", s.ID, s.Name) - } - - return name -} diff --git a/irc/splatbot/stage.go b/irc/splatbot/stage.go deleted file mode 100644 index 9898f53..0000000 --- a/irc/splatbot/stage.go +++ /dev/null @@ -1,12 +0,0 @@ -package main - -type SplatoonData struct { - DatetimeTermBegin string `json:"datetime_term_begin"` - DatetimeTermEnd string `json:"datetime_term_end"` - Stages []*Stage `json:"stages"` -} - -type Stage struct { - ID string `json:"id"` - Name string `json:"name"` -} |
