mirror of https://github.com/velour/catbase.git
bot: add icon and name to slack messages
This commit is contained in:
parent
5d9541ab3d
commit
bbe0cdd28e
|
@ -35,6 +35,7 @@ type Config struct {
|
|||
Token string
|
||||
}
|
||||
Nick string
|
||||
IconURL string
|
||||
FullName string
|
||||
Version string
|
||||
CommandChar []string
|
||||
|
|
|
@ -7,6 +7,7 @@ config = {
|
|||
MaxBatchAdd = 10
|
||||
},
|
||||
Nick = "CatBaseTest",
|
||||
IconURL = "http://placekitten.com/g/200/300",
|
||||
LeftPad = {
|
||||
Who = "person",
|
||||
MaxLen = 50
|
||||
|
|
|
@ -16,9 +16,10 @@ import (
|
|||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
// "sync/atomic"
|
||||
"time"
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/velour/catbase/bot"
|
||||
"github.com/velour/catbase/bot/msg"
|
||||
|
@ -209,9 +210,13 @@ func (s *Slack) SendMessageType(channel, message string, meMessage bool) (string
|
|||
postUrl = "https://slack.com/api/chat.meMessage"
|
||||
}
|
||||
|
||||
nick := s.config.Nick
|
||||
icon := s.config.IconURL
|
||||
|
||||
resp, err := http.PostForm(postUrl,
|
||||
url.Values{"token": {s.config.Slack.Token},
|
||||
"as_user": {"true"},
|
||||
"username": {nick},
|
||||
"icon_url": {icon},
|
||||
"channel": {channel},
|
||||
"text": {message},
|
||||
})
|
||||
|
@ -264,9 +269,13 @@ func (s *Slack) SendAction(channel, message string) string {
|
|||
}
|
||||
|
||||
func (s *Slack) ReplyToMessageIdentifier(channel, message, identifier string) (string, bool) {
|
||||
nick := s.config.Nick
|
||||
icon := s.config.IconURL
|
||||
|
||||
resp, err := http.PostForm("https://slack.com/api/chat.postMessage",
|
||||
url.Values{"token": {s.config.Slack.Token},
|
||||
"as_user": {"true"},
|
||||
"username": {nick},
|
||||
"icon_url": {icon},
|
||||
"channel": {channel},
|
||||
"text": {message},
|
||||
"thread_ts": {identifier},
|
||||
|
|
Loading…
Reference in New Issue