From a9a4c9274c20751bfb546bc578fb66364d02b4e0 Mon Sep 17 00:00:00 2001 From: Chris Sexton <3216719+chrissexton@users.noreply.github.com> Date: Wed, 7 Sep 2022 10:46:53 -0400 Subject: [PATCH] pagecomment: omit user if using slash --- plugins/pagecomment/pagecomment.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/plugins/pagecomment/pagecomment.go b/plugins/pagecomment/pagecomment.go index 3a345f3..38292ca 100644 --- a/plugins/pagecomment/pagecomment.go +++ b/plugins/pagecomment/pagecomment.go @@ -63,13 +63,8 @@ func (p *PageComment) handleURLCmd(conn bot.Connector) func(*discordgo.Session, return func(s *discordgo.Session, i *discordgo.InteractionCreate) { u := i.ApplicationCommandData().Options[0].StringValue() cmt := i.ApplicationCommandData().Options[1].StringValue() - who := i.Member.User.Username - profile, err := conn.Profile(i.Member.User.ID) - if err == nil { - who = profile.Name - } - msg := handleURL(u, cmt, who) - err = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ + msg := handleURL(u, cmt, "") + err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ Type: discordgo.InteractionResponseChannelMessageWithSource, Data: &discordgo.InteractionResponseData{ Content: msg, @@ -83,6 +78,9 @@ func (p *PageComment) handleURLCmd(conn bot.Connector) func(*discordgo.Session, } func handleURL(u, cmt, who string) string { + if who != "" { + who = who + ": " + } client := http.Client{} req, err := http.NewRequest(http.MethodGet, u, nil) if err != nil { @@ -101,10 +99,10 @@ func handleURL(u, cmt, who string) string { wait := make(chan string, 1) sel := doc.Find("title") if sel.Length() == 0 { - return fmt.Sprintf("> %s: %s\n(<%s>)", who, cmt, u) + return fmt.Sprintf("%s%s\n(<%s>)", who, cmt, u) } sel.First().Each(func(i int, s *goquery.Selection) { - wait <- fmt.Sprintf("> %s\n%s: %s\n(<%s>)", s.Text(), who, cmt, u) + wait <- fmt.Sprintf("> %s\n%s%s\n(<%s>)", s.Text(), who, cmt, u) }) return <-wait }