Add debugging statements to connection errors

This commit is contained in:
erroneousboat 2018-07-21 13:17:37 +02:00
parent 2c6da659fb
commit d326f4e3d0
2 changed files with 20 additions and 5 deletions

View File

@ -141,6 +141,10 @@ func messageHandler(ctx *context.AppContext) {
}
case *slack.PresenceChangeEvent:
actionSetPresence(ctx, ev.User, ev.Presence)
case *slack.RTMError:
ctx.View.Debug.Println(
ev.Error(),
)
}
}
}
@ -236,10 +240,15 @@ func actionSend(ctx *context.AppContext) {
ctx.View.Refresh()
// Send message
ctx.Service.SendMessage(
err := ctx.Service.SendMessage(
ctx.View.Channels.SelectedChannel,
message,
)
if err != nil {
ctx.View.Debug.Println(
err.Error(),
)
}
// Clear notification icon if there is any
ctx.Service.MarkAsRead(ctx.View.Channels.SelectedChannel)

View File

@ -332,16 +332,22 @@ func (s *SlackService) GetChannelName(channelID string) string {
}
// SendMessage will send a message to a particular channel
func (s *SlackService) SendMessage(channelID int, message string) {
func (s *SlackService) SendMessage(channelID int, message string) error {
// https://godoc.org/github.com/nlopes/slack#PostMessageParameters
postParams := slack.PostMessageParameters{
AsUser: true,
Username: s.CurrentUsername,
AsUser: true,
Username: s.CurrentUsername,
LinkNames: 1,
}
// https://godoc.org/github.com/nlopes/slack#Client.PostMessage
s.Client.PostMessage(s.Channels[channelID].ID, message, postParams)
_, _, err := s.Client.PostMessage(s.Channels[channelID].ID, message, postParams)
if err != nil {
return err
}
return nil
}
// GetMessages will get messages for a channel, group or im channel delimited