diff --git a/lib/datacache/weapons.go b/lib/datacache/weapons.go index 7c7214d..4b03b66 100644 --- a/lib/datacache/weapons.go +++ b/lib/datacache/weapons.go @@ -7,6 +7,7 @@ import ( "errors" "git.wtfteam.pro/fat0troll/i2_bot/lib/dbmapping" "strconv" + "strings" ) func (dc *DataCache) initWeapons() { @@ -37,7 +38,7 @@ func (dc *DataCache) loadWeapons() { func (dc *DataCache) GetWeaponTypeByName(name string) (*dbmapping.Weapon, error) { dc.weaponsMutex.Lock() for i := range dc.weapons { - if dc.weapons[i].Name == name { + if strings.HasPrefix(dc.weapons[i].Name, name) { dc.weaponsMutex.Unlock() return dc.weapons[i], nil } diff --git a/lib/users/parsers.go b/lib/users/parsers.go index 1205b73..3535c0f 100644 --- a/lib/users/parsers.go +++ b/lib/users/parsers.go @@ -247,7 +247,11 @@ func (u *Users) ParseProfile(update *tgbotapi.Update, playerRaw *dbmapping.Playe profileRaw.Exp = expInt profileRaw.EggExp = eggexpInt profileRaw.Power = powerInt - profileRaw.WeaponID = weaponRaw.ID + if weaponRaw != nil { + profileRaw.WeaponID = weaponRaw.ID + } else { + profileRaw.WeaponID = 0 + } profileRaw.Crystalls = crystallsInt profileRaw.CreatedAt = time.Now().UTC()