@@ -2,10 +2,12 @@ package commands
2
2
3
3
import (
4
4
"fmt"
5
+ "log"
5
6
"os"
6
7
"ret/config"
7
8
"ret/theme"
8
9
"ret/util"
10
+ "strings"
9
11
)
10
12
11
13
func init () {
@@ -30,46 +32,61 @@ func ShareHelp() string {
30
32
}
31
33
32
34
func Share (args []string ) {
35
+ path , err := os .Getwd ()
36
+ if err != nil {
37
+ log .Fatalln ("💥 " + theme .ColorRed + "error" + theme .ColorReset + ": %v" , err )
38
+ }
39
+
40
+ splits := strings .Split (path , "/" )
41
+ dir := splits [len (splits )- 1 ]
42
+
33
43
flag , err := util .GetCurrentFlag ()
34
44
if err != nil {
35
45
flag = config .FlagFormat
36
46
}
37
47
38
48
gistUrl := ""
39
49
40
- if len (config .GistToken ) > 0 {
41
- files := map [string ]interface {}{}
50
+ if len (config .GistToken ) == 0 {
51
+ Chat ([]string {fmt .Sprintf ("🏁 `%s` **%s**" , flag , dir )})
52
+ return
53
+ }
42
54
43
- buffer , err := os .ReadFile (config .PwnScriptName )
44
- if err == nil {
45
- files [config .PwnScriptName ] = map [string ]interface {}{
46
- "content" : string (buffer ),
47
- }
48
- }
55
+ files := map [string ]interface {}{}
49
56
50
- buffer , err = os .ReadFile (config .CryptoScriptName )
51
- if err == nil {
52
- files [config .CryptoScriptName ] = map [string ]interface {}{
53
- "content" : string (buffer ),
54
- }
57
+ buffer , err := os .ReadFile (config .PwnScriptName )
58
+ if err == nil {
59
+ files [config .PwnScriptName ] = map [string ]interface {}{
60
+ "content" : string (buffer ),
55
61
}
62
+ }
56
63
57
- buffer , err = os .ReadFile (config .NotesFileName )
58
- if err == nil {
59
- // does not like .ret/notes.json
60
- files ["notes.json" ] = map [string ]interface {}{
61
- "content" : string (buffer ),
62
- }
64
+ buffer , err = os .ReadFile (config .CryptoScriptName )
65
+ if err == nil {
66
+ files [config .CryptoScriptName ] = map [string ]interface {}{
67
+ "content" : string (buffer ),
63
68
}
69
+ }
64
70
65
- files ["flag.txt" ] = map [string ]interface {}{
66
- "content" : string (flag ),
71
+ buffer , err = os .ReadFile (config .NotesFileName )
72
+ if err == nil {
73
+ // does not like .ret/notes.json
74
+ files ["notes.json" ] = map [string ]interface {}{
75
+ "content" : string (buffer ),
67
76
}
77
+ }
68
78
69
- if len (files ) > 0 {
70
- gistUrl = "**" + util .Gist (files ) + "**"
71
- }
79
+ files ["flag.txt" ] = map [string ]interface {}{
80
+ "content" : string (flag ),
81
+ }
82
+
83
+ files ["path.txt" ] = map [string ]interface {}{
84
+ "content" : path ,
85
+ }
86
+
87
+ if len (files ) > 0 {
88
+ gistUrl = util .Gist (files )
72
89
}
73
90
74
- Chat ([]string {fmt .Sprintf ("🏁 `%s`\n %s " , flag , gistUrl )})
91
+ Chat ([]string {fmt .Sprintf ("🏁 `%s` **[%s](%s)** " , flag , dir , gistUrl )})
75
92
}
0 commit comments