slack: Change case of some struct names

This commit is contained in:
cws 2017-07-25 10:56:30 -04:00
parent 8c90bde6fa
commit 760ee1ca94
1 changed files with 26 additions and 20 deletions

View File

@ -53,7 +53,7 @@ type slackUserInfoResp struct {
type slackChannelInfoResp struct {
Ok bool `json:"ok"`
Channel struct {
Id string `json:"id"`
ID string `json:"id"`
Name string `json:"name"`
Created int64 `json:"created"`
@ -70,9 +70,10 @@ type slackChannelInfoResp struct {
}
type slackMessage struct {
Id uint64 `json:"id"`
ID uint64 `json:"id"`
Type string `json:"type"`
SubType string `json:"subtype"`
Hidden bool `json:"hidden"`
Channel string `json:"channel"`
Text string `json:"text"`
User string `json:"user"`
@ -93,9 +94,9 @@ type slackReaction struct {
type rtmStart struct {
Ok bool `json:"ok"`
Error string `json:"error"`
Url string `json:"url"`
URL string `json:"url"`
Self struct {
Id string `json:"id"`
ID string `json:"id"`
} `json:"self"`
}
@ -117,7 +118,7 @@ func (s *Slack) RegisterMessageReceived(f func(msg.Message)) {
func (s *Slack) SendMessageType(channel, messageType, subType, message string) error {
m := slackMessage{
Id: atomic.AddUint64(&idCounter, 1),
ID: atomic.AddUint64(&idCounter, 1),
Type: messageType,
SubType: subType,
Channel: channel,
@ -211,7 +212,12 @@ func (s *Slack) Serve() {
}
switch msg.Type {
case "message":
log.Printf("msg: %+v", msg)
if !msg.Hidden {
s.messageReceived(s.buildMessage(msg))
} else {
log.Printf("THAT MESSAGE WAS HIDDEN: %+v", msg.ID)
}
case "error":
log.Printf("Slack error, code: %d, message: %s", msg.Error.Code, msg.Error.Msg)
case "": // what even is this?
@ -264,7 +270,7 @@ func (s *Slack) buildMessage(m slackMessage) msg.Message {
Channel: m.Channel,
Command: isCmd,
Action: isAction,
Host: string(m.Id),
Host: string(m.ID),
Time: tstamp,
AdditionalData: map[string]string{
"RAW_SLACK_TIMESTAMP": m.Ts,
@ -298,9 +304,9 @@ func (s *Slack) connect() {
}
s.url = "https://slack.com/api/"
s.id = rtm.Self.Id
s.id = rtm.Self.ID
s.ws, err = websocket.Dial(rtm.Url, "", s.url)
s.ws, err = websocket.Dial(rtm.URL, "", s.url)
if err != nil {
log.Fatal(err)
}