Fix send message as user

This commit is contained in:
erroneousboat 2016-09-29 19:40:09 +02:00
parent a0603698f9
commit d59bbced84
5 changed files with 6 additions and 7 deletions

View File

@ -4,9 +4,9 @@ Bugs:
channel, the Buffer() in Chat will probably not go further than the channel, the Buffer() in Chat will probably not go further than the
latest message. Could be that items are added to List and not cleared latest message. Could be that items are added to List and not cleared
when switching channels when switching channels
- [x] send message as user, now it will send it as a bot
- [ ] GetMessages for a channel can result in `json: cannot unmarshal number - [ ] GetMessages for a channel can result in `json: cannot unmarshal number
into Go value of type string` https://github.com/nlopes/slack/issues/92 into Go value of type string` https://github.com/nlopes/slack/issues/92
- [ ] send message as user, now it will send it as a bot
- [ ] alot of usernames 'unknown' should be a better way to uncover this - [ ] alot of usernames 'unknown' should be a better way to uncover this
- [ ] uncovering usernames takes too long, should find a better way - [ ] uncovering usernames takes too long, should find a better way
- [ ] docs at exported functions - [ ] docs at exported functions
@ -19,4 +19,5 @@ Features:
- [ ] scrolling in chat pane - [ ] scrolling in chat pane
- [ ] scrolling in channel pane - [ ] scrolling in channel pane
- [ ] private chats
- [x] channel name in chat pane - [x] channel name in chat pane

View File

@ -62,8 +62,8 @@ func (i *Input) SetY(y int) {
i.Par.SetY(y) i.Par.SetY(y)
} }
func (i *Input) SendMessage(svc *service.SlackService, channel string, user string, message string) { func (i *Input) SendMessage(svc *service.SlackService, channel string, message string) {
svc.SendMessage(channel, user, message) svc.SendMessage(channel, message)
} }
// Insert will insert a given key at the place of the current CursorPosition // Insert will insert a given key at the place of the current CursorPosition

View File

@ -7,7 +7,6 @@ import (
type Config struct { type Config struct {
SlackToken string `json:"slack_token"` SlackToken string `json:"slack_token"`
User string `json:"user"`
} }
func NewConfig(filepath string) (*Config, error) { func NewConfig(filepath string) (*Config, error) {

View File

@ -157,7 +157,6 @@ func actionSend(ctx *context.AppContext) {
ctx.View.Input.SendMessage( ctx.View.Input.SendMessage(
ctx.Service, ctx.Service,
ctx.View.Channels.SlackChannels[ctx.View.Channels.SelectedChannel].ID, ctx.View.Channels.SlackChannels[ctx.View.Channels.SelectedChannel].ID,
ctx.Config.User,
ctx.View.Input.Text(), ctx.View.Input.Text(),
) )
ctx.View.Input.Clear() ctx.View.Input.Clear()

View File

@ -52,10 +52,10 @@ func (s *SlackService) GetChannels() []Channel {
return chans return chans
} }
func (s *SlackService) SendMessage(channel string, user string, message string) { func (s *SlackService) SendMessage(channel string, message string) {
// https://godoc.org/github.com/nlopes/slack#PostMessageParameters // https://godoc.org/github.com/nlopes/slack#PostMessageParameters
postParams := slack.PostMessageParameters{ postParams := slack.PostMessageParameters{
Username: user, AsUser: true,
} }
// https://godoc.org/github.com/nlopes/slack#Client.PostMessage // https://godoc.org/github.com/nlopes/slack#Client.PostMessage