Просмотр исходного кода

Updated ChannelMessageSend to reflect new mention method used by Discord, closes #9

Bruce Marriner 9 лет назад
Родитель
Сommit
850901a5dc
1 измененных файлов с 4 добавлено и 18 удалено
  1. 4 18
      restapi.go

+ 4 - 18
restapi.go

@@ -16,7 +16,6 @@ import (
 	"fmt"
 	"io/ioutil"
 	"net/http"
-	"regexp"
 	"time"
 )
 
@@ -501,24 +500,11 @@ func (s *Session) ChannelMessageAck(channelID, messageID string) (err error) {
 // NOTE, mention and tts parameters may be added in 2.x branch.
 func (s *Session) ChannelMessageSend(channelID string, content string) (st Message, err error) {
 
-	// TOD: nonce string ?
+	// TODO: nonce string ?
 	data := struct {
-		Content  string   `json:"content"`
-		Mentions []string `json:"mentions"`
-		TTS      bool     `json:"tts"`
-	}{content, nil, false}
-
-	// If true, search for <@ID> tags and add those IDs to mention list.
-	if s.AutoMention {
-		re := regexp.MustCompile(`<@(\d+)>`)
-		match := re.FindAllStringSubmatch(content, -1)
-
-		mentions := make([]string, len(match))
-		for i, m := range match {
-			mentions[i] = m[1]
-		}
-		data.Mentions = mentions
-	}
+		Content string `json:"content"`
+		TTS     bool   `json:"tts"`
+	}{content, false}
 
 	// Send the message to the given channel
 	response, err := s.Request("POST", CHANNEL_MESSAGES(channelID), data)