-
Notifications
You must be signed in to change notification settings - Fork 0
/
task.go
executable file
·45 lines (38 loc) · 1.07 KB
/
task.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
package main
import (
"encoding/json"
"fmt"
"github.com/alexsetta/httputils"
"log"
)
func taskTest() {
log.Printf("Debug: %t, Último: %s", debug, ultimo)
}
func task() (string, error) {
data, err := httputils.GetBody(url, false)
if err != nil {
log.Println(err)
return "", err
}
var res map[string]interface{}
json.Unmarshal([]byte(data), &res)
concurso := fmt.Sprintf("%v", res["numero"])
listaDezenas := fmt.Sprintf("%v", res["listaDezenas"])
if debug {
log.Printf("Concurso: %s, Último: %s, Dezenas sorteadas: %s", concurso, ultimo, listaDezenas)
}
if ultimo != concurso {
ultimo = concurso
msg := fmt.Sprintf("Mega-Sena concurso %s\n\r", concurso)
msg += fmt.Sprintf("Resultado: %s\n\r", listaDezenas)
msg += "\n\r"
msg += fmt.Sprintf("Aposta: %s\n\r", aposta)
acertos := verifica(aposta, listaDezenas)
if len(acertos) >= 12 {
msg += "*** PARABENS ***\n\r"
}
msg += fmt.Sprintf("Acertos (%d): %s", len(acertos)/3, acertos)
notifica(msg)
}
return fmt.Sprintf("%v", res["listaDezenas"]), nil
}