-
Notifications
You must be signed in to change notification settings - Fork 3
/
tribute.go
66 lines (55 loc) · 1.42 KB
/
tribute.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
package tribute
import (
"fmt"
"github.com/dixonwille/wmenu"
"github.com/pkg/errors"
"github.com/xackery/eqcleanup/client"
)
var focus = "tribute"
// Menu represents menu options
func Menu(opt wmenu.Opt) (err error) {
c, ok := opt.Value.(*client.Client)
if !ok {
err = fmt.Errorf("invalid client value passed")
return
}
ok = true
fmt.Println("This will remove fabled NPCs")
menu := wmenu.NewMenu("Continue operation?")
menu.Option("Return to main menu", nil, false, func(opt wmenu.Opt) error {
ok = false
return nil
})
menu.Option("I understand the risks - continue", nil, false, func(opt wmenu.Opt) error {
return Clean(c)
})
for ok {
err = menu.Run()
}
return
}
// Clean removes tribute npcs
func Clean(c *client.Client) (err error) {
//tribute master
ids, err := c.Database.SpawnGroupIDsByClassSearch(63)
if err != nil {
err = fmt.Errorf("Error getting %s Ids: %s", focus, err.Error())
return
}
//tribute grand master
mids, err := c.Database.SpawnGroupIDsByClassSearch(64)
for _, id := range mids {
ids = append(ids, id)
}
if len(ids) < 1 {
fmt.Println("No ", focus, "were found to delete")
return
}
totalChanged, err := c.Database.SpawnGroupAndEntryByIDDelete(ids)
if err != nil {
err = errors.Wrapf(err, "failed to remove spawn groups for %s", focus)
return
}
fmt.Println("Removed", totalChanged, " DB entries related to", focus, "in spawnentry and spawngroup successfully.")
return
}