Browse Source

Update dockerfile to be based off of alpine

Add fortune function
feature/fortune
Matthew Faltys 5 years ago
parent
commit
616c058806
  1. 3
      Makefile
  2. 10
      deps/Dockerfile
  3. 14
      lorebot/lorebot.go

3
Makefile

@ -7,6 +7,9 @@ all: lorebot
depends:
go get github.com/nlopes/slack
go get github.com/unixvoid/glogger
go get gopkg.in/gcfg.v1
go get gopkg.in/redis.v5
lorebot:
$(GOC) lorebot/lorebot.go

10
deps/Dockerfile vendored

@ -1,8 +1,10 @@
FROM scratch
FROM alpine
#RUN apk --update add ca-certificates redis
#RUN mkdir /redisbackup/
ADD rootfs.tar.gz /
RUN apk --update add ca-certificates redis fortune
RUN mkdir /redisbackup/
#RUN apk --update add fortune
#ADD rootfs.tar.gz /
COPY redis.conf /
COPY config.gcfg /
COPY lorebot /

14
lorebot/lorebot.go

@ -10,6 +10,7 @@ import (
"net/http"
"net/textproto"
"os"
"os/exec"
"strconv"
"strings"
"time"
@ -238,6 +239,8 @@ func staticCommandHandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *r
dicerollhandler(rtm, ev)
case "ceelo":
ceelorollhandler(rtm, ev)
case "fortune":
fortunehandler(rtm, ev)
case "listen":
rtm.SendMessage(rtm.NewOutgoingMessage("*it's what you hearin*", ev.Channel))
case "lorelist":
@ -375,6 +378,17 @@ func ceelorollhandler(rtm *slack.RTM, ev *slack.MessageEvent) {
}
}
func fortunehandler(rtm *slack.RTM, ev *slack.MessageEvent) {
fortune, err := exec.Command("fortune").CombinedOutput()
if err != nil {
fmt.Printf("%v\n", err)
rtm.SendMessage(rtm.NewOutgoingMessage("Fortune 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*"}

Loading…
Cancel
Save