Skip to content

Commit

Permalink
Bot builds and doesn't get caught in an infinite loop any more
Browse files Browse the repository at this point in the history
  • Loading branch information
pneisen committed Nov 5, 2016
1 parent da9e06d commit 7f10ac8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions bot_sample.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func CreateBotDebuggingChannelIfNeeded() {
PrintError(err)
} else {
channelList := channelsResult.Data.(*model.ChannelList)
for _, channel := range channelList.Channels {
for _, channel := range *channelList {

// The logging channel has alredy been created, lets just use it
if channel.Name == CHANNEL_LOG_NAME {
Expand Down Expand Up @@ -200,7 +200,7 @@ func HandleWebSocketResponse(event *model.WebSocketEvent) {

func HandleMsgFromDebuggingChannel(event *model.WebSocketEvent) {
// If this isn't the debugging channel then lets ingore it
if event.ChannelId != debuggingChannel.Id {
if event.Broadcast.ChannelId != debuggingChannel.Id {
return
}

Expand All @@ -209,16 +209,16 @@ func HandleMsgFromDebuggingChannel(event *model.WebSocketEvent) {
return
}

// Lets ignore if it's my own events just in case
if event.UserId == botUser.Id {
return
}

println("responding to debugging channel msg")

post := model.PostFromJson(strings.NewReader(event.Data["post"].(string)))
if post != nil {

// ignore my events
if post.UserId == botUser.Id {
return
}

// if you see any word matching 'alive' then respond
if matched, _ := regexp.MatchString(`(?:^|\W)alive(?:$|\W)`, post.Message); matched {
SendMsgToDebuggingChannel("Yes I'm running", post.Id)
Expand Down

0 comments on commit 7f10ac8

Please sign in to comment.