add some new files and services add hwtools that shows the current and last GWs - not yet included the user stats (if any available)
46 lines
849 B
Go
46 lines
849 B
Go
package datacollector
|
|
|
|
import (
|
|
"hwcollector/server/models"
|
|
|
|
"github.com/tidwall/gjson"
|
|
)
|
|
|
|
func init() {
|
|
processes["arenaAttack"] = new(DoArenaAttack)
|
|
}
|
|
|
|
// DoArenaAttack ...
|
|
type DoArenaAttack struct {
|
|
data []byte
|
|
}
|
|
|
|
// Start ...
|
|
func (x *DoArenaAttack) Start() {
|
|
}
|
|
|
|
// SetJSONByte ...
|
|
func (x *DoArenaAttack) SetJSONByte(b []byte) {
|
|
x.data = b
|
|
}
|
|
|
|
// SetJSON ...
|
|
func (x *DoArenaAttack) SetJSON(s string) {
|
|
x.data = []byte(s)
|
|
}
|
|
|
|
// GetUserDetails ...
|
|
func (x *DoArenaAttack) GetUserDetails() ([]*models.User, error) {
|
|
var users []*models.User
|
|
|
|
result := gjson.GetBytes(x.data, "response.result.response.enemies.#.user")
|
|
for _, jsonValue := range result.Array() {
|
|
user := new(models.User)
|
|
if err := user.UnmarshalUserJSON([]byte(jsonValue.Raw)); err != nil {
|
|
return nil, err
|
|
}
|
|
users = append(users, user)
|
|
}
|
|
return users, nil
|
|
}
|