Created
November 3, 2017 12:54
-
-
Save angch/09b44da2288d8be00e9e245f8f11f610 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"os" | |
"strings" | |
"github.com/nlopes/slack" | |
) | |
func main() { | |
slack_api_token := os.Getenv("SLACK_API_TOKEN") | |
api := slack.New(slack_api_token) | |
rtm := api.NewRTM() | |
go rtm.ManageConnection() | |
for msg := range rtm.IncomingEvents { | |
switch ev := msg.Data.(type) { | |
case *slack.MessageEvent: | |
if ev.Msg.Edited == nil && ev.Msg.Hidden == false && strings.Contains(strings.ToLower(ev.Msg.Text), "evil") { | |
rtm.AddReaction("smiling_imp", slack.ItemRef{ | |
Channel: ev.Msg.Channel, | |
Timestamp: ev.Msg.Timestamp, | |
}) | |
} | |
if ev.Msg.Edited == nil && ev.Msg.Hidden == false && strings.Contains(strings.ToLower(ev.Msg.Text), "bot") { | |
rtm.AddReaction("robot_face", slack.ItemRef{ | |
Channel: ev.Msg.Channel, | |
Timestamp: ev.Msg.Timestamp, | |
}) | |
} | |
default: | |
// Ignore other events.. | |
//fmt.Printf("Unexpected: %v\n", msg.Data) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment