diff --git a/Makefile b/Makefile index faa9bd0..774adb7 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,7 @@ docker: stat cp deps/redis.conf stage.tmp/ chmod +x deps/run.sh cp deps/run.sh stage.tmp/ + cp -R deps/fortune stage.tmp/ cp config.gcfg stage.tmp/ cd stage.tmp/ && \ sudo docker build -t $(IMAGE_NAME) . diff --git a/deps/Dockerfile b/deps/Dockerfile index 001fa25..22f611e 100644 --- a/deps/Dockerfile +++ b/deps/Dockerfile @@ -2,12 +2,18 @@ FROM alpine RUN apk --update add ca-certificates redis fortune RUN mkdir /redisbackup/ -#RUN apk --update add fortune +RUN rm -rf /usr/share/fortune +COPY fortune/ /usr/share/fortune +WORKDIR /usr/share/fortune/ +RUN strfile -c % fortunes fortunes.dat +RUN strfile -c % kenm kenm.dat +RUN strfile -c % showerthoughts showerthoughts.dat #ADD rootfs.tar.gz / COPY redis.conf / COPY config.gcfg / COPY lorebot / COPY run.sh / +WORKDIR / CMD ["/run.sh"] diff --git a/lorebot/lorebot.go b/lorebot/lorebot.go index e83a8c5..1f16233 100644 --- a/lorebot/lorebot.go +++ b/lorebot/lorebot.go @@ -241,6 +241,10 @@ func staticCommandHandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *r ceelorollhandler(rtm, ev) case "fortune": fortunehandler(rtm, ev) + case "kenm": + kenmhandler(rtm, ev) + case "showerthoughts": + showerthoughtshandler(rtm, ev) case "listen": rtm.SendMessage(rtm.NewOutgoingMessage("*it's what you hearin*", ev.Channel)) case "lorelist": @@ -379,7 +383,7 @@ func ceelorollhandler(rtm *slack.RTM, ev *slack.MessageEvent) { } func fortunehandler(rtm *slack.RTM, ev *slack.MessageEvent) { - fortune, err := exec.Command("fortune").CombinedOutput() + fortune, err := exec.Command("fortune", "-e", "fortunes").CombinedOutput() if err != nil { fmt.Printf("%v\n", err) rtm.SendMessage(rtm.NewOutgoingMessage("Fortune command is broken, contact HFIC", ev.Channel)) @@ -389,6 +393,28 @@ func fortunehandler(rtm *slack.RTM, ev *slack.MessageEvent) { rtm.SendMessage(rtm.NewOutgoingMessage(fmt.Sprintf("%s", fortune), ev.Channel)) } +func kenmhandler(rtm *slack.RTM, ev *slack.MessageEvent) { + fortune, err := exec.Command("fortune", "-e", "kenm").CombinedOutput() + if err != nil { + fmt.Printf("%v\n", err) + rtm.SendMessage(rtm.NewOutgoingMessage("kenm command is broken, contact HFIC", ev.Channel)) + return + } + + rtm.SendMessage(rtm.NewOutgoingMessage(fmt.Sprintf("%s", fortune), ev.Channel)) +} + +func showerthoughtshandler(rtm *slack.RTM, ev *slack.MessageEvent) { + fortune, err := exec.Command("fortune", "-e", "showerthoughts").CombinedOutput() + if err != nil { + fmt.Printf("%v\n", err) + rtm.SendMessage(rtm.NewOutgoingMessage("showerthoughts command is broken, contact HFIC", ev.Channel)) + return + } + + rtm.SendMessage(rtm.NewOutgoingMessage(fmt.Sprintf("%s", fortune), ev.Channel)) +} + func rrhandler(rtm *slack.RTM, ev *slack.MessageEvent) { //fmt.Print(rand.Intn(100)) dice := []string{"*click*", "*BANG*", "*click*", "*click*", "*click*", "*click*"}