Add support for English league name in /me
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
package datacacheinterface
|
||||
|
||||
import (
|
||||
"github.com/go-telegram-bot-api/telegram-bot-api"
|
||||
"github.com/fat0troll/i2_bot/lib/datamapping"
|
||||
"github.com/fat0troll/i2_bot/lib/dbmapping"
|
||||
"github.com/go-telegram-bot-api/telegram-bot-api"
|
||||
)
|
||||
|
||||
// DataCacheInterface implements DataCache for importing via appcontext.
|
||||
@@ -52,6 +52,7 @@ type DataCacheInterface interface {
|
||||
FindElementIDBySymbol(symbol string) (int, error)
|
||||
|
||||
GetLeagueByID(leagueID int) (*datamapping.League, error)
|
||||
GetLeagueByEnglishName(name string) (*datamapping.League, error)
|
||||
GetLeagueByName(name string) (*datamapping.League, error)
|
||||
GetLeagueBySymbol(symbol string) (*datamapping.League, error)
|
||||
|
||||
|
@@ -8,9 +8,9 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
"github.com/fat0troll/i2_bot/lib/datamapping"
|
||||
"github.com/fat0troll/i2_bot/static"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
func (dc *DataCache) initLeagues() {
|
||||
@@ -68,6 +68,17 @@ func (dc *DataCache) GetLeagueByName(name string) (*datamapping.League, error) {
|
||||
return nil, errors.New("There is no league with name = " + name)
|
||||
}
|
||||
|
||||
// GetLeagueByEnglishName returns league from datacache by english name
|
||||
func (dc *DataCache) GetLeagueByEnglishName(name string) (*datamapping.League, error) {
|
||||
for i := range dc.leagues {
|
||||
if strings.Contains(dc.leagues[i].NameEnglish, 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 {
|
||||
|
Reference in New Issue
Block a user