|
|
@@ -14,7 +14,30 @@ func WriteMessage(v *tview.TextView, m *discordgo.Message, clientID string) {
|
|
|
var b strings.Builder
|
|
|
switch m.Type {
|
|
|
case discordgo.MessageTypeDefault, discordgo.MessageTypeReply:
|
|
|
- parseMessage(v, &b, m, clientID)
|
|
|
+ parseReferencedMessage(&b, m.ReferencedMessage, clientID)
|
|
|
+
|
|
|
+ parseAuthor(&b, m.Author, clientID)
|
|
|
+
|
|
|
+ if m.Content != "" {
|
|
|
+ m.Content = parseMessageMentions(m.Content, m.Mentions, clientID)
|
|
|
+ b.WriteString(m.Content)
|
|
|
+ }
|
|
|
+
|
|
|
+ if m.EditedTimestamp != "" {
|
|
|
+ b.WriteString(" [::d](edited)[::-]")
|
|
|
+ }
|
|
|
+
|
|
|
+ for range m.Embeds {
|
|
|
+ b.WriteString("\n<EMBED>")
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, a := range m.Attachments {
|
|
|
+ b.WriteString("\n[")
|
|
|
+ b.WriteString(a.Filename)
|
|
|
+ b.WriteString("]: ")
|
|
|
+ b.WriteString(a.URL)
|
|
|
+ }
|
|
|
+
|
|
|
fmt.Fprintln(v, b.String())
|
|
|
case discordgo.MessageTypeGuildMemberJoin:
|
|
|
b.WriteString("[#5865F2]")
|
|
|
@@ -25,34 +48,6 @@ func WriteMessage(v *tview.TextView, m *discordgo.Message, clientID string) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func parseMessage(v *tview.TextView, b *strings.Builder, m *discordgo.Message, clientID string) {
|
|
|
- // $ ╭ AUTHOR_USERNAME (BOT) MESSAGE_CONTENT*linebreak*
|
|
|
- parseReferencedMessage(b, m.ReferencedMessage, clientID)
|
|
|
- // $ AUTHOR_USERNAME (BOT)*spacee*
|
|
|
- parseAuthor(b, m.Author, clientID)
|
|
|
- // $ MESSAGE_CONTENT
|
|
|
- parseContent(b, m, clientID)
|
|
|
- // $ *space*(edited)
|
|
|
- parseEditedTimestamp(b, m.EditedTimestamp)
|
|
|
- // $ *linebreak*EMBED
|
|
|
- parseEmbeds(b, m.Embeds)
|
|
|
- // $ *linebreak*ATTACHMENT_URL
|
|
|
- parseAttachments(b, m.Attachments)
|
|
|
-}
|
|
|
-
|
|
|
-func parseContent(b *strings.Builder, m *discordgo.Message, clientID string) {
|
|
|
- if m.Content != "" {
|
|
|
- m.Content = parseMessageMentions(m.Content, m.Mentions, clientID)
|
|
|
- b.WriteString(m.Content)
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-func parseEditedTimestamp(b *strings.Builder, t discordgo.Timestamp) {
|
|
|
- if t != "" {
|
|
|
- b.WriteString(" [::d](edited)[::-]")
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
func parseMessageMentions(content string, mentions []*discordgo.User, clientID string) string {
|
|
|
for _, mUser := range mentions {
|
|
|
var color string
|
|
|
@@ -75,21 +70,6 @@ func parseMessageMentions(content string, mentions []*discordgo.User, clientID s
|
|
|
return content
|
|
|
}
|
|
|
|
|
|
-func parseEmbeds(b *strings.Builder, embeds []*discordgo.MessageEmbed) {
|
|
|
- for range embeds {
|
|
|
- b.WriteString("\n<EMBED>")
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-func parseAttachments(b *strings.Builder, attachments []*discordgo.MessageAttachment) {
|
|
|
- for _, a := range attachments {
|
|
|
- b.WriteString("\n[")
|
|
|
- b.WriteString(a.Filename)
|
|
|
- b.WriteString("]: ")
|
|
|
- b.WriteString(a.URL)
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
func parseAuthor(b *strings.Builder, u *discordgo.User, clientID string) {
|
|
|
if u.ID == clientID {
|
|
|
b.WriteString("[#57F287]")
|
|
|
@@ -108,19 +88,8 @@ func parseAuthor(b *strings.Builder, u *discordgo.User, clientID string) {
|
|
|
func parseReferencedMessage(b *strings.Builder, rm *discordgo.Message, clientID string) {
|
|
|
if rm != nil {
|
|
|
b.WriteString(" ╭ ")
|
|
|
-
|
|
|
- if rm.Author.ID == clientID {
|
|
|
- b.WriteString("[#57F287::d]")
|
|
|
- } else {
|
|
|
- b.WriteString("[#ED4245::d]")
|
|
|
- }
|
|
|
-
|
|
|
- b.WriteString(rm.Author.Username)
|
|
|
- b.WriteString("[-] ")
|
|
|
-
|
|
|
- if rm.Author.Bot {
|
|
|
- b.WriteString("[#EB459E]BOT[-] ")
|
|
|
- }
|
|
|
+ b.WriteString("[::d]")
|
|
|
+ parseAuthor(b, rm.Author, clientID)
|
|
|
|
|
|
if rm.Content != "" {
|
|
|
rm.Content = parseMessageMentions(rm.Content, rm.Mentions, clientID)
|
|
|
@@ -167,8 +136,8 @@ func TOTP(s *discordgo.Session, code, ticket string) (*loginResponse, error) {
|
|
|
data.Code = code
|
|
|
data.Ticket = ticket
|
|
|
|
|
|
- endpoint := discordgo.EndpointAuth + "mfa/totp"
|
|
|
- resp, err := s.RequestWithBucketID("POST", endpoint, data, endpoint)
|
|
|
+ e := discordgo.EndpointAuth + "mfa/totp"
|
|
|
+ resp, err := s.RequestWithBucketID("POST", e, data, e)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|