diff --git a/main.go b/main.go index d88e2e0..eb0568e 100644 --- a/main.go +++ b/main.go @@ -131,6 +131,10 @@ func main() { Name: "username, u", Usage: "Stream messages as given bot user. Defaults to auth user", }, + cli.StringFlag{ + Name: "iconemoji, i", + Usage: "Stream messages as given bot icon emoji. Defaults to auth user's icon", + }, } app.Action = func(c *cli.Context) { @@ -150,6 +154,7 @@ func main() { noop = c.Bool("noop") username := c.String("username") + iconEmoji := c.String("iconemoji") fileName := c.String("filename") fileType := c.String("filetype") fileComment := c.String("comment") @@ -160,7 +165,7 @@ func main() { } InitAPI(token) - slackcat := newSlackcat(username, channel) + slackcat := newSlackcat(username, iconEmoji, channel) if c.Bool("list") { fmt.Println("channels:") diff --git a/slackcat.go b/slackcat.go index 234288e..b169bde 100644 --- a/slackcat.go +++ b/slackcat.go @@ -16,15 +16,17 @@ type Slackcat struct { queue *StreamQ shutdown chan os.Signal username string + iconEmoji string channelID string channelName string } -func newSlackcat(username, channelname string) *Slackcat { +func newSlackcat(username, iconEmoji, channelname string) *Slackcat { sc := &Slackcat{ queue: newStreamQ(), shutdown: make(chan os.Signal, 1), username: username, + iconEmoji: iconEmoji, channelName: channelname, } @@ -98,6 +100,9 @@ func (sc *Slackcat) postMsg(msglines []string) { msgOpts.AsUser = false msgOpts.Username = sc.username } + if sc.iconEmoji != "" { + msgOpts.IconEmoji = sc.iconEmoji + } err := api.ChatPostMessage(sc.channelID, msg, msgOpts) failOnError(err)