Prechádzať zdrojové kódy

Created message.go to store code related to the Message struct.

Bruce Marriner 9 rokov pred
rodič
commit
7fc9331e04
2 zmenil súbory, kde vykonal 26 pridanie a 10 odobranie
  1. 26 0
      message.go
  2. 0 10
      structs.go

+ 26 - 0
message.go

@@ -0,0 +1,26 @@
+// Discordgo - Discord bindings for Go
+// Available at https://github.com/bwmarrin/discordgo
+
+// Copyright 2015-2016 Bruce Marriner <bruce@sqls.net>.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// This file contains code related to the Message struct
+
+package discordgo
+
+import (
+	"fmt"
+	"strings"
+)
+
+// ContentWithMentionsReplaced will replace all @<id> mentions with the
+// username of the mention.
+func (m *Message) ContentWithMentionsReplaced() string {
+	content := m.Content
+	for _, user := range m.Mentions {
+		content = strings.Replace(content, fmt.Sprintf("<@%s>", user.ID),
+			fmt.Sprintf("@%s", user.Username), -1)
+	}
+	return content
+}

+ 0 - 10
structs.go

@@ -116,16 +116,6 @@ type Message struct {
 	ChannelID       string       `json:"channel_id"`
 }
 
-// ContentWithMentionsReplaced will replace all @<id> mentions with the
-// username of the mention.
-func (m *Message) ContentWithMentionsReplaced() string {
-	content := m.Content
-	for _, user := range m.Mentions {
-		content = strings.Replace(content, fmt.Sprintf("<@%s>", user.ID), fmt.Sprintf("@%s", user.Username), -1)
-	}
-	return content
-}
-
 // An Attachment stores data for message attachments.
 type Attachment struct { //TODO figure this out
 }