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