Add profile updates via statistics
After nerf update there is machine-readable command /me in PokememBroBot. It can be used for gathering useful information about users.
This commit is contained in:
@@ -49,6 +49,7 @@ type DataCacheInterface interface {
|
||||
FindElementIDBySymbol(symbol string) (int, error)
|
||||
|
||||
GetLeagueByID(leagueID int) (*datamapping.League, error)
|
||||
GetLeagueByName(name string) (*datamapping.League, error)
|
||||
GetLeagueBySymbol(symbol string) (*datamapping.League, error)
|
||||
|
||||
GetLevelByID(levelID int) (*datamapping.Level, error)
|
||||
@@ -60,6 +61,7 @@ type DataCacheInterface interface {
|
||||
GetPokememeByName(name string) (*datamapping.PokememeFull, error)
|
||||
GetPokememesCountByGradeAndLocation(grade int, locationID int) int
|
||||
|
||||
GetWeaponTypeByAttack(attack int) (*datamapping.Weapon, error)
|
||||
GetWeaponTypeByID(weaponID int) (*datamapping.Weapon, error)
|
||||
GetWeaponTypeByName(name string) (*datamapping.Weapon, error)
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ package datacache
|
||||
import (
|
||||
"errors"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
"source.wtfteam.pro/i2_bot/i2_bot/lib/datamapping"
|
||||
@@ -56,6 +57,17 @@ func (dc *DataCache) GetLeagueByID(leagueID int) (*datamapping.League, error) {
|
||||
return nil, errors.New("There is no league with ID = " + strconv.Itoa(leagueID))
|
||||
}
|
||||
|
||||
// GetLeagueByName returns league from datacache by name
|
||||
func (dc *DataCache) GetLeagueByName(name string) (*datamapping.League, error) {
|
||||
for i := range dc.leagues {
|
||||
if strings.Contains(dc.leagues[i].Name, name) {
|
||||
return dc.leagues[i], nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, errors.New("There is no league with name = " + name)
|
||||
}
|
||||
|
||||
// GetLeagueBySymbol returns league from datacache by emoji
|
||||
func (dc *DataCache) GetLeagueBySymbol(symbol string) (*datamapping.League, error) {
|
||||
for i := range dc.leagues {
|
||||
|
@@ -48,6 +48,17 @@ func (dc *DataCache) getWeapons() []datamapping.Weapon {
|
||||
|
||||
// External functions
|
||||
|
||||
// GetWeaponTypeByAttack returns weapon type from datacache by given attack
|
||||
func (dc *DataCache) GetWeaponTypeByAttack(attack int) (*datamapping.Weapon, error) {
|
||||
for i := range dc.weapons {
|
||||
if dc.weapons[i].Power == attack {
|
||||
return dc.weapons[i], nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, errors.New("There is no weapon type with attack = " + strconv.Itoa(attack))
|
||||
}
|
||||
|
||||
// GetWeaponTypeByID returns weapon type from datacache by given ID
|
||||
func (dc *DataCache) GetWeaponTypeByID(weaponID int) (*datamapping.Weapon, error) {
|
||||
if dc.weapons[weaponID] != nil {
|
||||
|
Reference in New Issue
Block a user