Browse Source

Add lore search function

master
Matthew Faltys 7 years ago
parent
commit
4b3e779872
  1. 2
      config.gcfg
  2. 13
      lorebot/lorebot.go

2
config.gcfg

@ -1,7 +1,7 @@
[lorebot] [lorebot]
loglevel = "debug" loglevel = "debug"
bootstrapdelay = 1 bootstrapdelay = 1
APIToken = "" APIToken = "xoxb-189788161987-7FK5NKnBtrFGGtv4yszr2URb"
[redis] [redis]
host = "localhost:6379" host = "localhost:6379"

13
lorebot/lorebot.go

@ -70,8 +70,11 @@ Loop:
if ev.Text == "test" { if ev.Text == "test" {
rtm.SendMessage(rtm.NewOutgoingMessage("MY NAME IS ..JHEFFFFF", ev.Channel)) rtm.SendMessage(rtm.NewOutgoingMessage("MY NAME IS ..JHEFFFFF", ev.Channel))
} }
if strings.Contains(ev.Text, "lore") { if strings.Contains(ev.Text, ".lore") {
rtm.SendMessage(rtm.NewOutgoingMessage("THA LORE", ev.Channel)) //rtm.SendMessage(rtm.NewOutgoingMessage("THA LORE", ev.Channel))
s := strings.SplitN(string(ev.Text), " ", 2)
//command, content := s[0], s[1]
lorehandler(rtm, ev, s[1])
} }
} }
case *slack.RTMError: case *slack.RTMError:
@ -119,3 +122,9 @@ func initRedisConnection() (*redis.Client, error) {
_, redisErr := redisClient.Ping().Result() _, redisErr := redisClient.Ping().Result()
return redisClient, redisErr return redisClient, redisErr
} }
func lorehandler(rtm *slack.RTM, ev *slack.MessageEvent, rawMessage string) {
loreTerm := strings.Replace(rawMessage, ".lore", "", -1)
println("searching for:", loreTerm)
rtm.SendMessage(rtm.NewOutgoingMessage(fmt.Sprintf("searching for '%s'\n", loreTerm), ev.Channel))
}

Loading…
Cancel
Save