forked from earthboundkid/pomodoro
-
Notifications
You must be signed in to change notification settings - Fork 2
/
input.go
105 lines (95 loc) · 2.58 KB
/
input.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package main
import (
"bufio"
"fmt"
"net/http"
"net/url"
"os"
"strings"
"github.com/gen2brain/beeep"
"github.com/whatsauth/watoken"
)
func CheckURLStatus(url string) (status bool, msg string) {
if !ValidUrl(url) {
return
}
response, err := http.Get(url)
if err != nil {
msg = err.Error()
return
}
defer response.Body.Close()
msg = response.Status
if msg == "200 OK" {
if strings.Contains(url, ".github.io") {
if !strings.Contains(url, "github.com") {
status = true
}
} else if strings.Contains(url, ".google.com") {
status = true
} else if strings.Contains(url, "cdn.jsdelivr.net") {
status = true
} else if strings.Contains(url, "pkg.go.dev") {
status = true
} else if strings.Contains(url, "npmjs.org") {
status = true
} else if strings.Contains(url, "pypi.org") {
status = true
} else if strings.Contains(url, "packagist.org") {
status = true
} else if strings.Contains(url, ".my.id") {
status = true
}else if strings.Contains(url, ".me/") {
status = true
}
}
return
}
func ValidUrl(urllink string) bool {
_, er := url.Parse(urllink)
if er != nil {
return false
}
return true
}
func InputWAGroup() (wag string) {
beeep.Alert("Pomokit Info", "Please Input Your WhatsApp Group ID with keyword : Iteung minta id grup : ", "information.png")
fmt.Println("Please Input Your WhatsApp Group ID with keyword : Iteung minta id grup : ")
fmt.Scanln(&wag)
return
}
func InputURLGithub() (hashurl string) {
var urltask string
fmt.Println("input URL Yang Akan Dikerjakan(copas dari browser) : ")
fmt.Scanln(&urltask)
urlvalid, msgerrurl := CheckURLStatus(urltask)
for !urlvalid {
beeep.Alert("Invalid Link", "URL Tidak Valid : "+msgerrurl, "information.png")
fmt.Println("URL Invalid, Masukkan kembali URL yang benar : ")
fmt.Scanln(&urltask)
urlvalid, msgerrurl = CheckURLStatus(urltask)
}
hashurl, err := watoken.EncodeforHours(urltask, PrivateKey, 3)
if err != nil {
fmt.Println(err)
}
return
}
func InputMilestone() (milestone string) {
beeep.Alert("Pomokit Info", "Silahkan input rencana yang akan anda kerjakan pada 1 cycle pomodoro sekarang", "information.png")
fmt.Println("Rencana yang akan anda kerjakan pada 1 cycle pomodoro sekarang : ")
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
milestone = scanner.Text()
if len(milestone) > 17 {
break
} else {
beeep.Alert("Pomokit Info", "Rencana belum diisi atau terlalu pendek", "information.png")
fmt.Println("Rencana belum diisi atau terlalu pendek, Rencana Anda : ")
}
}
if err := scanner.Err(); err != nil {
fmt.Println(err)
}
return
}