/
range.go
64 lines (55 loc) · 1.72 KB
/
range.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
package fifth
import (
"context"
"fmt"
"github.com/bwmarrin/discordgo"
"github.com/eddbc/fifth-bot/mux"
"log"
)
//Range Bot command to give dotlan links with the jump ranges fro ma given system
func (f *Fifth) Range(ds *discordgo.Session, dm *discordgo.Message, ctx *mux.Context) {
if len(ctx.Fields) <= 1 {
SendMsgToChan(dm.ChannelID, "You need to specify a system you fucking noob")
return
}
strings := []string{"solar_system"}
res, _, err := Eve.SearchApi.GetSearch(context.Background(), strings, ctx.Fields[1], nil)
if err != nil {
log.Printf("Error searching for system: %v", err)
SendMsgToChan(dm.ChannelID, "Error searching for system")
return
}
if len(res.SolarSystem) == 0 {
SendMsgToChan(dm.ChannelID, "Couldn't find that system")
return
}
if len(res.SolarSystem) > 1 {
systems := ""
for _, s := range res.SolarSystem {
system, _, err := Eve.UniverseApi.GetUniverseSystemsSystemId(context.Background(), s, nil)
if err == nil {
systems = fmt.Sprintf("%v \n%v", systems, system.Name)
}
}
SendMsgToChan(dm.ChannelID, fmt.Sprintf("Found %v possible matches : %v", len(res.SolarSystem), systems))
return
}
system, _, err := Eve.UniverseApi.GetUniverseSystemsSystemId(context.Background(), res.SolarSystem[0], nil)
if err == nil {
ranges := ""
classes := []rangeClass{
{"Capital", "Thanatos"},
{"Super Capital", "Nyx"},
{"Rorqual", "Rorqual"},
{"Black-Ops", "Panther"},
}
for _, class := range classes {
ranges = fmt.Sprintf("%v\n%v : <http://evemaps.dotlan.net/range/%v,5/%v/>", ranges, class.size, class.class, system.Name)
}
SendMsgToChan(dm.ChannelID, fmt.Sprintf("Ranges from %v: %v", system.Name, ranges))
}
}
type rangeClass struct {
size string
class string
}