author | Mikael Berthe <mikael@lilotux.net> |
Tue, 23 Aug 2022 22:31:08 +0200 | |
changeset 258 | eb656dbdd75a |
parent 239 | 605a00e9d1ab |
child 265 | 05c40b36d3b2 |
child 267 | 5b91a65ba95a |
permissions | -rw-r--r-- |
185 | 1 |
// Copyright © 2017-2018 Mikael Berthe <mikael@lilotux.net> |
0 | 2 |
// |
3 |
// Licensed under the MIT license. |
|
4 |
// Please see the LICENSE file is this directory. |
|
5 |
||
6 |
package cmd |
|
7 |
||
8 |
import ( |
|
129
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
9 |
"strings" |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
10 |
|
45
b58a7ea1aeb2
Use github.com/pkg/errors
Mikael Berthe <mikael@lilotux.net>
parents:
44
diff
changeset
|
11 |
"github.com/pkg/errors" |
0 | 12 |
"github.com/spf13/cobra" |
176
7efbbed5cf3c
Fix duplicate usage of updateFlags variable name
Mikael Berthe <mikael@lilotux.net>
parents:
168
diff
changeset
|
13 |
flag "github.com/spf13/pflag" |
79
bca27c55be9f
Add default visibility setting
Mikael Berthe <mikael@lilotux.net>
parents:
71
diff
changeset
|
14 |
"github.com/spf13/viper" |
0 | 15 |
|
239
605a00e9d1ab
Switch to Go modules (and bump Go version requirement)
Mikael Berthe <mikael@lilotux.net>
parents:
221
diff
changeset
|
16 |
"github.com/McKael/madon/v2" |
0 | 17 |
) |
18 |
||
19 |
// toot is a kind of alias for status post |
|
20 |
||
176
7efbbed5cf3c
Fix duplicate usage of updateFlags variable name
Mikael Berthe <mikael@lilotux.net>
parents:
168
diff
changeset
|
21 |
var tootAliasFlags *flag.FlagSet |
7efbbed5cf3c
Fix duplicate usage of updateFlags variable name
Mikael Berthe <mikael@lilotux.net>
parents:
168
diff
changeset
|
22 |
|
0 | 23 |
func init() { |
24 |
RootCmd.AddCommand(tootAliasCmd) |
|
25 |
||
26 |
tootAliasCmd.Flags().BoolVar(&statusOpts.sensitive, "sensitive", false, "Mark post as sensitive (NSFW)") |
|
27 |
tootAliasCmd.Flags().StringVar(&statusOpts.visibility, "visibility", "", "Visibility (direct|private|unlisted|public)") |
|
28 |
tootAliasCmd.Flags().StringVar(&statusOpts.spoiler, "spoiler", "", "Spoiler warning (CW)") |
|
29 |
tootAliasCmd.Flags().StringVar(&statusOpts.mediaIDs, "media-ids", "", "Comma-separated list of media IDs") |
|
15
8ac069eaa817
Add option --text-file to send content from a file
Mikael Berthe <mikael@lilotux.net>
parents:
0
diff
changeset
|
30 |
tootAliasCmd.Flags().StringVarP(&statusOpts.mediaFilePath, "file", "f", "", "Media attachment file name") |
8ac069eaa817
Add option --text-file to send content from a file
Mikael Berthe <mikael@lilotux.net>
parents:
0
diff
changeset
|
31 |
tootAliasCmd.Flags().StringVar(&statusOpts.textFilePath, "text-file", "", "Text file name (message content)") |
44
6da40ca4534c
Sync with Madon; switch IDs to int64 integers
Mikael Berthe <mikael@lilotux.net>
parents:
35
diff
changeset
|
32 |
tootAliasCmd.Flags().Int64VarP(&statusOpts.inReplyToID, "in-reply-to", "r", 0, "Status ID to reply to") |
71
67e3234c26a9
Add --stdin to send a message from standard input
Mikael Berthe <mikael@lilotux.net>
parents:
70
diff
changeset
|
33 |
tootAliasCmd.Flags().BoolVar(&statusOpts.stdin, "stdin", false, "Read message content from standard input") |
129
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
34 |
tootAliasCmd.Flags().BoolVar(&statusOpts.addMentions, "add-mentions", false, "Add mentions when replying") |
168
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
35 |
tootAliasCmd.Flags().BoolVar(&statusOpts.sameVisibility, "same-visibility", false, "Use same visibility as original message (for replies)") |
35
61ed03c3f134
Add flag shell completion (values for --output and --visibility)
Mikael Berthe <mikael@lilotux.net>
parents:
17
diff
changeset
|
36 |
|
61ed03c3f134
Add flag shell completion (values for --output and --visibility)
Mikael Berthe <mikael@lilotux.net>
parents:
17
diff
changeset
|
37 |
// Flag completion |
61ed03c3f134
Add flag shell completion (values for --output and --visibility)
Mikael Berthe <mikael@lilotux.net>
parents:
17
diff
changeset
|
38 |
annotation := make(map[string][]string) |
61ed03c3f134
Add flag shell completion (values for --output and --visibility)
Mikael Berthe <mikael@lilotux.net>
parents:
17
diff
changeset
|
39 |
annotation[cobra.BashCompCustom] = []string{"__madonctl_visibility"} |
61ed03c3f134
Add flag shell completion (values for --output and --visibility)
Mikael Berthe <mikael@lilotux.net>
parents:
17
diff
changeset
|
40 |
|
61ed03c3f134
Add flag shell completion (values for --output and --visibility)
Mikael Berthe <mikael@lilotux.net>
parents:
17
diff
changeset
|
41 |
tootAliasCmd.Flags().Lookup("visibility").Annotations = annotation |
168
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
42 |
|
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
43 |
// This one will be used to check if the options were explicitly set or not |
176
7efbbed5cf3c
Fix duplicate usage of updateFlags variable name
Mikael Berthe <mikael@lilotux.net>
parents:
168
diff
changeset
|
44 |
tootAliasFlags = tootAliasCmd.Flags() |
0 | 45 |
} |
46 |
||
47 |
var tootAliasCmd = &cobra.Command{ |
|
48 |
Use: "toot", |
|
49 |
Aliases: []string{"post", "pouet"}, |
|
50 |
Short: "Post a message (toot)", |
|
51 |
Example: ` madonctl toot message |
|
221
970c319e1f7c
Update toot online examples
Mikael Berthe <mikael@lilotux.net>
parents:
220
diff
changeset
|
52 |
madonctl toot --visibility private "To my followers only" |
0 | 53 |
madonctl toot --spoiler Warning "Hello, World" |
54 |
madonctl status post --media-ids ID1,ID2 "Here are the photos" |
|
15
8ac069eaa817
Add option --text-file to send content from a file
Mikael Berthe <mikael@lilotux.net>
parents:
0
diff
changeset
|
55 |
madonctl post --sensitive --file image.jpg Image |
71
67e3234c26a9
Add --stdin to send a message from standard input
Mikael Berthe <mikael@lilotux.net>
parents:
70
diff
changeset
|
56 |
madonctl toot --text-file message.txt |
129
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
57 |
madonctl toot --in-reply-to STATUSID "@user response" |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
58 |
madonctl toot --in-reply-to STATUSID --add-mentions "response" |
79
bca27c55be9f
Add default visibility setting
Mikael Berthe <mikael@lilotux.net>
parents:
71
diff
changeset
|
59 |
echo "Hello from #madonctl" | madonctl toot --visibility unlisted --stdin |
bca27c55be9f
Add default visibility setting
Mikael Berthe <mikael@lilotux.net>
parents:
71
diff
changeset
|
60 |
|
bca27c55be9f
Add default visibility setting
Mikael Berthe <mikael@lilotux.net>
parents:
71
diff
changeset
|
61 |
The default visibility can be set in the configuration file with the option |
bca27c55be9f
Add default visibility setting
Mikael Berthe <mikael@lilotux.net>
parents:
71
diff
changeset
|
62 |
'default_visibility' (or with an environmnent variable).`, |
0 | 63 |
RunE: func(cmd *cobra.Command, args []string) error { |
64 |
if err := madonInit(true); err != nil { |
|
65 |
return err |
|
66 |
} |
|
67 |
return statusSubcommandRunE("post", args) |
|
68 |
}, |
|
69 |
} |
|
70 |
||
71 |
func toot(tootText string) (*madon.Status, error) { |
|
72 |
opt := statusOpts |
|
73 |
||
79
bca27c55be9f
Add default visibility setting
Mikael Berthe <mikael@lilotux.net>
parents:
71
diff
changeset
|
74 |
// Get default visibility from configuration |
bca27c55be9f
Add default visibility setting
Mikael Berthe <mikael@lilotux.net>
parents:
71
diff
changeset
|
75 |
if opt.visibility == "" { |
bca27c55be9f
Add default visibility setting
Mikael Berthe <mikael@lilotux.net>
parents:
71
diff
changeset
|
76 |
if v := viper.GetString("default_visibility"); v != "" { |
bca27c55be9f
Add default visibility setting
Mikael Berthe <mikael@lilotux.net>
parents:
71
diff
changeset
|
77 |
opt.visibility = v |
bca27c55be9f
Add default visibility setting
Mikael Berthe <mikael@lilotux.net>
parents:
71
diff
changeset
|
78 |
} |
bca27c55be9f
Add default visibility setting
Mikael Berthe <mikael@lilotux.net>
parents:
71
diff
changeset
|
79 |
} |
bca27c55be9f
Add default visibility setting
Mikael Berthe <mikael@lilotux.net>
parents:
71
diff
changeset
|
80 |
|
0 | 81 |
switch opt.visibility { |
82 |
case "", "direct", "private", "unlisted", "public": |
|
83 |
// OK |
|
84 |
default: |
|
79
bca27c55be9f
Add default visibility setting
Mikael Berthe <mikael@lilotux.net>
parents:
71
diff
changeset
|
85 |
return nil, errors.Errorf("invalid visibility argument value '%s'", opt.visibility) |
0 | 86 |
} |
87 |
||
88 |
if opt.inReplyToID < 0 { |
|
89 |
return nil, errors.New("invalid in-reply-to argument value") |
|
90 |
} |
|
91 |
||
92 |
ids, err := splitIDs(opt.mediaIDs) |
|
93 |
if err != nil { |
|
94 |
return nil, errors.New("cannot parse media IDs") |
|
95 |
} |
|
96 |
||
129
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
97 |
if tootText == "" && len(ids) == 0 && opt.spoiler == "" && opt.mediaFilePath == "" { |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
98 |
return nil, errors.New("toot is empty") |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
99 |
} |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
100 |
|
168
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
101 |
if opt.inReplyToID > 0 { |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
102 |
var initialStatus *madon.Status |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
103 |
var preserveVis bool |
176
7efbbed5cf3c
Fix duplicate usage of updateFlags variable name
Mikael Berthe <mikael@lilotux.net>
parents:
168
diff
changeset
|
104 |
if opt.sameVisibility && |
7efbbed5cf3c
Fix duplicate usage of updateFlags variable name
Mikael Berthe <mikael@lilotux.net>
parents:
168
diff
changeset
|
105 |
!tootAliasFlags.Lookup("visibility").Changed && |
7efbbed5cf3c
Fix duplicate usage of updateFlags variable name
Mikael Berthe <mikael@lilotux.net>
parents:
168
diff
changeset
|
106 |
!statusPostFlags.Lookup("visibility").Changed { |
168
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
107 |
// Preserve visibility unless the --visibility flag |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
108 |
// has been used in the command line. |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
109 |
preserveVis = true |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
110 |
} |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
111 |
if preserveVis || opt.addMentions { |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
112 |
// Fetch original status message |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
113 |
initialStatus, err = gClient.GetStatus(opt.inReplyToID) |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
114 |
if err != nil { |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
115 |
return nil, errors.Wrap(err, "cannot get original message") |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
116 |
} |
129
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
117 |
} |
168
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
118 |
if preserveVis { |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
119 |
v := initialStatus.Visibility |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
120 |
// We do not set public visibility unless explicitly requested |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
121 |
if v == "public" { |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
122 |
opt.visibility = "unlisted" |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
123 |
} else { |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
124 |
opt.visibility = v |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
125 |
} |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
126 |
} |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
127 |
if opt.addMentions { |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
128 |
mentions, err := mentionsList(initialStatus) |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
129 |
if err != nil { |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
130 |
return nil, err |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
131 |
} |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
132 |
tootText = mentions + tootText |
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
133 |
} |
129
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
134 |
} |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
135 |
|
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
136 |
// Uploading media file last |
15
8ac069eaa817
Add option --text-file to send content from a file
Mikael Berthe <mikael@lilotux.net>
parents:
0
diff
changeset
|
137 |
if opt.mediaFilePath != "" { |
0 | 138 |
if len(ids) > 3 { |
139 |
return nil, errors.New("too many media attachments") |
|
140 |
} |
|
141 |
||
15
8ac069eaa817
Add option --text-file to send content from a file
Mikael Berthe <mikael@lilotux.net>
parents:
0
diff
changeset
|
142 |
fileMediaID, err := uploadFile(opt.mediaFilePath) |
0 | 143 |
if err != nil { |
45
b58a7ea1aeb2
Use github.com/pkg/errors
Mikael Berthe <mikael@lilotux.net>
parents:
44
diff
changeset
|
144 |
return nil, errors.Wrap(err, "cannot attach media file") |
0 | 145 |
} |
146 |
if fileMediaID > 0 { |
|
147 |
ids = append(ids, fileMediaID) |
|
148 |
} |
|
149 |
} |
|
150 |
||
220
08a2ee738117
Update calls to madon's PostStatus & UpdateAccount
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
151 |
postParam := madon.PostStatusParams{ |
08a2ee738117
Update calls to madon's PostStatus & UpdateAccount
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
152 |
Text: tootText, |
08a2ee738117
Update calls to madon's PostStatus & UpdateAccount
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
153 |
InReplyTo: opt.inReplyToID, |
08a2ee738117
Update calls to madon's PostStatus & UpdateAccount
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
154 |
MediaIDs: ids, |
08a2ee738117
Update calls to madon's PostStatus & UpdateAccount
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
155 |
Sensitive: opt.sensitive, |
08a2ee738117
Update calls to madon's PostStatus & UpdateAccount
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
156 |
SpoilerText: opt.spoiler, |
08a2ee738117
Update calls to madon's PostStatus & UpdateAccount
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
157 |
Visibility: opt.visibility, |
08a2ee738117
Update calls to madon's PostStatus & UpdateAccount
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
158 |
} |
08a2ee738117
Update calls to madon's PostStatus & UpdateAccount
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
159 |
return gClient.PostStatus(postParam) |
129
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
160 |
} |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
161 |
|
168
ce4000ac7294
Add flag to reply with same visibility as original message
Mikael Berthe <mikael@lilotux.net>
parents:
129
diff
changeset
|
162 |
func mentionsList(s *madon.Status) (string, error) { |
129
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
163 |
a, err := gClient.GetCurrentAccount() |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
164 |
if err != nil { |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
165 |
return "", errors.Wrap(err, "cannot check account details") |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
166 |
} |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
167 |
|
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
168 |
var mentions []string |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
169 |
// Add the sender if she is not the connected user |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
170 |
if s.Account.Acct != a.Acct { |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
171 |
mentions = append(mentions, "@"+s.Account.Acct) |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
172 |
} |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
173 |
for _, m := range s.Mentions { |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
174 |
if m.Acct != a.Acct { |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
175 |
mentions = append(mentions, "@"+m.Acct) |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
176 |
} |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
177 |
} |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
178 |
mentionsStr := strings.Join(mentions, " ") |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
179 |
if len(mentionsStr) > 0 { |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
180 |
return mentionsStr + " ", nil |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
181 |
} |
11966471aac3
toot: Add flag --add-mentions to add mentions when replying
Mikael Berthe <mikael@lilotux.net>
parents:
79
diff
changeset
|
182 |
return "", nil |
0 | 183 |
} |