bot should respond to alive queries in public channels now
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
0b76d0269a
commit
21c4316fc8
35
bot/bot.go
35
bot/bot.go
|
@ -165,6 +165,17 @@ func (b *Bot) CreateBotDebuggingChannelIfNeeded() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Bot) SendMsgToChannel(msg string, replyToId string, channelId string) {
|
||||||
|
post := &model.Post{}
|
||||||
|
post.ChannelId = ChannelId
|
||||||
|
post.Message = msg
|
||||||
|
post.RootId = replyToId
|
||||||
|
if _, resp := b.client.CreatePost(post); resp.Error != nil {
|
||||||
|
println("We failed to send a message to the logging channel")
|
||||||
|
PrintError(resp.Error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (b *Bot) SendMsgToDebuggingChannel(msg string, replyToId string) {
|
func (b *Bot) SendMsgToDebuggingChannel(msg string, replyToId string) {
|
||||||
post := &model.Post{}
|
post := &model.Post{}
|
||||||
post.ChannelId = b.debuggingChannel.Id
|
post.ChannelId = b.debuggingChannel.Id
|
||||||
|
@ -196,7 +207,7 @@ func (b *Bot) HandleMsgFromAnyChannel(event *model.WebSocketEvent) {
|
||||||
|
|
||||||
pretty.Print(post)
|
pretty.Print(post)
|
||||||
|
|
||||||
// FIXME find out what channel it came from so can respond appropriately
|
channel := post.ChannelId
|
||||||
|
|
||||||
// ignore my events
|
// ignore my events
|
||||||
if post.UserId == b.botUser.Id {
|
if post.UserId == b.botUser.Id {
|
||||||
|
@ -205,29 +216,11 @@ func (b *Bot) HandleMsgFromAnyChannel(event *model.WebSocketEvent) {
|
||||||
|
|
||||||
// if you see any word matching 'alive' then respond
|
// if you see any word matching 'alive' then respond
|
||||||
if matched, _ := regexp.MatchString(`(?:^|\W)alive(?:$|\W)`, post.Message); matched {
|
if matched, _ := regexp.MatchString(`(?:^|\W)alive(?:$|\W)`, post.Message); matched {
|
||||||
b.SendMsgToDebuggingChannel("Yes I'm running", post.Id)
|
b.SendMsgToChannel("Yes I'm running", "", channel)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// if you see any word matching 'up' then respond
|
//b.SendMsgToDebuggingChannel("I did not understand you!", post.Id)
|
||||||
if matched, _ := regexp.MatchString(`(?:^|\W)up(?:$|\W)`, post.Message); matched {
|
|
||||||
b.SendMsgToDebuggingChannel("Yes I'm running", post.Id)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// if you see any word matching 'running' then respond
|
|
||||||
if matched, _ := regexp.MatchString(`(?:^|\W)running(?:$|\W)`, post.Message); matched {
|
|
||||||
b.SendMsgToDebuggingChannel("Yes I'm running", post.Id)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// if you see any word matching 'hello' then respond
|
|
||||||
if matched, _ := regexp.MatchString(`(?:^|\W)hello(?:$|\W)`, post.Message); matched {
|
|
||||||
b.SendMsgToDebuggingChannel("Yes I'm running", post.Id)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
b.SendMsgToDebuggingChannel("I did not understand you!", post.Id)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue