This repository has been archived by the owner on Dec 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
retweet.go
72 lines (65 loc) · 1.71 KB
/
retweet.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package cmd
import (
"github.com/arrow2nd/twnyan/twitter"
"github.com/gookit/color"
"gopkg.in/abiosoft/ishell.v2"
)
func init() {
rtCmd := &ishell.Cmd{
Name: "retweet",
Aliases: []string{"rt"},
Help: "retweet tweet",
LongHelp: createLongHelp(
"Retweet tweet.\nIf there is more than one, please separate them with a space.",
"rt",
"retweet [<tweetnumber>]...",
"retweet 0 1",
),
Func: func(c *ishell.Context) {
reactToTweet(c.Args, c.Cmd.Name, twitter.Retweet)
},
}
rtCmd.AddCmd(&ishell.Cmd{
Name: "quote",
Aliases: []string{"qt"},
Help: "quote tweet",
LongHelp: createLongHelp(
"Quote tweet.\nIf there is no tweet text, \"にゃーん\" will be posted.\nIf you are submitting an image, please add the file name separated by a space.",
"qt",
"retweet quote [<tweetnumber>] [text] [image]...",
"retweet quote 0 cute!! cat.png",
),
Func: func(c *ishell.Context) {
// 引数エラー
if len(c.Args) < 1 {
showWrongMsg(c.Cmd.Name)
return
}
// URL取得
uri, err := tweets.GetTweetURL(c.Args[0])
if err != nil {
color.Error.Prompt(err.Error())
return
}
// URLを付与してツイート
status, media := parseTweetCmdArgs(c.Args[1:])
status += " " + uri
twitter.PostTweet(status, "", media)
},
})
rtCmd.AddCmd(&ishell.Cmd{
Name: "remove",
Aliases: []string{"rm"},
Help: "un-retweet tweet",
LongHelp: createLongHelp(
"UnRetweet tweet.\nIf there is more than one, please separate them with a space.",
"rm",
"retweet remove [<tweetnumber>]...",
"retweet remove 0 1",
),
Func: func(c *ishell.Context) {
reactToTweet(c.Args, "retweet "+c.Cmd.Name, twitter.UnRetweet)
},
})
shell.AddCmd(rtCmd)
}