-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.go
48 lines (38 loc) · 1.2 KB
/
user.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
package main
import (
"flag"
"fmt"
"log"
"os"
"time"
"github.com/Lukaesebrot/mojango"
)
func User() {
client := mojango.New()
if flag.NArg() == 0 {
flag.Usage()
os.Exit(1)
}
uuid, err := client.FetchUUID(flag.Arg(0))
if err != nil {
log.Fatalf("\033[33mFailed to fetch user %v !", flag.Arg(0))
}
profile, err := client.FetchProfile(uuid, true)
if err != nil {
log.Fatalf("\033[33mFailed to fetch user %v !", flag.Arg(0))
}
hist, err := client.FetchNameHistory(uuid)
if err != nil {
log.Fatalf("\033[33mFailed to fetch user %v !", flag.Arg(0))
}
fmt.Printf("┏━━━━━━━━━━━━━━━ Profile ━━━━━━━━━━━━━━━\n┃ Name: %v\n┃ UUID: %v\n┣━━━━━━━━━━━━━ Name History ━━━━━━━━━━━━",
profile.Name, profile.UUID)
for i, v := range hist {
var changeTime = ""
if v.ChangedToAt != 0 {
changeTime = time.Unix(0, v.ChangedToAt*int64(time.Millisecond)).Format("(2 January 2006 15:04)")
}
fmt.Printf("\n┃ %v. %v %v", i+1, v.Name, changeTime)
}
fmt.Println("\n┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
}