Archived
1

All code formatted with gofmt

This commit is contained in:
Vladimir Hodakov 2017-10-18 07:03:34 +04:00
parent df58e25adc
commit 6f374e560e
58 changed files with 1957 additions and 1962 deletions

View File

@ -5,8 +5,8 @@ package appcontext
import (
// 3rd-party
"github.com/jmoiron/sqlx"
"github.com/go-telegram-bot-api/telegram-bot-api"
"github.com/jmoiron/sqlx"
// local
"../config"
"../connections"

View File

@ -7,9 +7,9 @@ import (
// stdlib
"log"
// 3rd-party
_ "github.com/go-sql-driver/mysql"
"github.com/go-telegram-bot-api/telegram-bot-api"
"github.com/jmoiron/sqlx"
_ "github.com/go-sql-driver/mysql"
// local
"../config"
)
@ -29,7 +29,7 @@ func BotInit(cfg *config.Config) *tgbotapi.BotAPI {
}
func DBInit(cfg *config.Config) *sqlx.DB {
database, err := sqlx.Connect("mysql", cfg.Database.User + ":" + cfg.Database.Password + "@tcp(" + cfg.Database.Host + ":" + cfg.Database.Port + ")/" + cfg.Database.Database + "?parseTime=true&charset=utf8mb4,utf8")
database, err := sqlx.Connect("mysql", cfg.Database.User+":"+cfg.Database.Password+"@tcp("+cfg.Database.Host+":"+cfg.Database.Port+")/"+cfg.Database.Database+"?parseTime=true&charset=utf8mb4,utf8")
if err != nil {
log.Fatal(err)
}

View File

@ -15,7 +15,7 @@ var (
c *appcontext.Context
)
type Getters struct {}
type Getters struct{}
func New(ac *appcontext.Context) {
c = ac

View File

@ -16,38 +16,38 @@ import (
func (g *Getters) formFullPokememes(pokememes []dbmapping.Pokememe) ([]dbmapping.PokememeFull, bool) {
pokememes_full := []dbmapping.PokememeFull{}
elements := []dbmapping.Element{}
err := c.Db.Select(&elements, "SELECT * FROM elements");
err := c.Db.Select(&elements, "SELECT * FROM elements")
if err != nil {
log.Println(err)
return pokememes_full, false
}
locations := []dbmapping.Location{}
err = c.Db.Select(&locations, "SELECT * FROM locations");
err = c.Db.Select(&locations, "SELECT * FROM locations")
if err != nil {
log.Println(err)
return pokememes_full, false
}
pokememes_elements := []dbmapping.PokememeElement{}
err = c.Db.Select(&pokememes_elements, "SELECT * FROM pokememes_elements");
err = c.Db.Select(&pokememes_elements, "SELECT * FROM pokememes_elements")
if err != nil {
log.Println(err)
return pokememes_full, false
}
pokememes_locations := []dbmapping.PokememeLocation{}
err = c.Db.Select(&pokememes_locations, "SELECT * FROM pokememes_locations");
err = c.Db.Select(&pokememes_locations, "SELECT * FROM pokememes_locations")
if err != nil {
log.Println(err)
return pokememes_full, false
}
for i := range(pokememes) {
for i := range pokememes {
full_pokememe := dbmapping.PokememeFull{}
elements_listed := []dbmapping.Element{}
locations_listed := []dbmapping.Location{}
for j := range(pokememes_locations) {
for j := range pokememes_locations {
if pokememes_locations[j].Pokememe_id == pokememes[i].Id {
for l := range(locations) {
for l := range locations {
if pokememes_locations[j].Location_id == locations[l].Id {
locations_listed = append(locations_listed, locations[l])
}
@ -55,9 +55,9 @@ func (g *Getters) formFullPokememes(pokememes []dbmapping.Pokememe) ([]dbmapping
}
}
for k := range(pokememes_elements) {
for k := range pokememes_elements {
if pokememes_elements[k].Pokememe_id == pokememes[i].Id {
for e := range(elements) {
for e := range elements {
if pokememes_elements[k].Element_id == elements[e].Id {
elements_listed = append(elements_listed, elements[e])
}
@ -80,7 +80,7 @@ func (g *Getters) formFullPokememes(pokememes []dbmapping.Pokememe) ([]dbmapping
func (g *Getters) GetPokememes() ([]dbmapping.PokememeFull, bool) {
pokememes_full := []dbmapping.PokememeFull{}
pokememes := []dbmapping.Pokememe{}
err := c.Db.Select(&pokememes, "SELECT * FROM pokememes ORDER BY grade asc, name asc");
err := c.Db.Select(&pokememes, "SELECT * FROM pokememes ORDER BY grade asc, name asc")
if err != nil {
log.Println(err)
return pokememes_full, false
@ -107,7 +107,7 @@ func (g *Getters) GetBestPokememes(player_id int) ([]dbmapping.PokememeFull, boo
// TODO: make it more complicated
pokememes := []dbmapping.Pokememe{}
err := c.Db.Select(&pokememes, c.Db.Rebind("SELECT p.* FROM pokememes p, pokememes_elements pe, elements e WHERE e.league_id = ? AND p.grade = ? AND pe.element_id = e.id AND pe.pokememe_id = p.id ORDER BY p.attack DESC"), player_raw.League_id, profile_raw.Level_id + 1)
err := c.Db.Select(&pokememes, c.Db.Rebind("SELECT p.* FROM pokememes p, pokememes_elements pe, elements e WHERE e.league_id = ? AND p.grade = ? AND pe.element_id = e.id AND pe.pokememe_id = p.id ORDER BY p.attack DESC"), player_raw.League_id, profile_raw.Level_id+1)
if err != nil {
log.Println(err)
return pokememes_full, false
@ -126,25 +126,25 @@ func (g *Getters) GetPokememeByID(pokememe_id string) (dbmapping.PokememeFull, b
return pokememe_full, false
}
elements := []dbmapping.Element{}
err = c.Db.Select(&elements, "SELECT * FROM elements");
err = c.Db.Select(&elements, "SELECT * FROM elements")
if err != nil {
log.Println(err)
return pokememe_full, false
}
locations := []dbmapping.Location{}
err = c.Db.Select(&locations, "SELECT * FROM locations");
err = c.Db.Select(&locations, "SELECT * FROM locations")
if err != nil {
log.Println(err)
return pokememe_full, false
}
pokememes_elements := []dbmapping.PokememeElement{}
err = c.Db.Select(&pokememes_elements, "SELECT * FROM pokememes_elements WHERE pokememe_id='" + strconv.Itoa(pokememe.Id) + "'");
err = c.Db.Select(&pokememes_elements, "SELECT * FROM pokememes_elements WHERE pokememe_id='"+strconv.Itoa(pokememe.Id)+"'")
if err != nil {
log.Println(err)
return pokememe_full, false
}
pokememes_locations := []dbmapping.PokememeLocation{}
err = c.Db.Select(&pokememes_locations, "SELECT * FROM pokememes_locations WHERE pokememe_id='" + strconv.Itoa(pokememe.Id) + "'");
err = c.Db.Select(&pokememes_locations, "SELECT * FROM pokememes_locations WHERE pokememe_id='"+strconv.Itoa(pokememe.Id)+"'")
if err != nil {
log.Println(err)
return pokememe_full, false
@ -153,9 +153,9 @@ func (g *Getters) GetPokememeByID(pokememe_id string) (dbmapping.PokememeFull, b
elements_listed := []dbmapping.Element{}
locations_listed := []dbmapping.Location{}
for j := range(pokememes_locations) {
for j := range pokememes_locations {
if pokememes_locations[j].Pokememe_id == pokememe.Id {
for l := range(locations) {
for l := range locations {
if pokememes_locations[j].Location_id == locations[l].Id {
locations_listed = append(locations_listed, locations[l])
}
@ -163,9 +163,9 @@ func (g *Getters) GetPokememeByID(pokememe_id string) (dbmapping.PokememeFull, b
}
}
for k := range(pokememes_elements) {
for k := range pokememes_elements {
if pokememes_elements[k].Pokememe_id == pokememe.Id {
for e := range(elements) {
for e := range elements {
if pokememes_elements[k].Element_id == elements[e].Id {
elements_listed = append(elements_listed, elements[e])
}

View File

@ -10,7 +10,7 @@ import (
"github.com/pressly/goose"
)
type Migrations struct {}
type Migrations struct{}
func (m *Migrations) Init() {
log.Printf("Initializing migrations...")

View File

@ -13,7 +13,7 @@ var (
c *appcontext.Context
)
type Parsers struct {}
type Parsers struct{}
func New(ac *appcontext.Context) {
c = ac

View File

@ -10,7 +10,6 @@ import (
"../../dbmapping"
)
type ParsersInterface interface {
ParsePokememe(text string, player_raw dbmapping.Player) string
ParseProfile(update tgbotapi.Update, player_raw dbmapping.Player) string

View File

@ -7,8 +7,8 @@ import (
// stdlib
"log"
"regexp"
"strings"
"strconv"
"strings"
"time"
// local
"../dbmapping"
@ -38,7 +38,7 @@ func (p *Parsers) ParsePokememe(text string, player_raw dbmapping.Player) string
var defendable_pokememe bool = false
pokememe_info_strings := strings.Split(text, "\n")
pokememe_info_runed_strings := make([][]rune, 0)
for i := range(pokememe_info_strings) {
for i := range pokememe_info_strings {
pokememe_info_runed_strings = append(pokememe_info_runed_strings, []rune(pokememe_info_strings[i]))
}
@ -57,7 +57,7 @@ func (p *Parsers) ParsePokememe(text string, player_raw dbmapping.Player) string
element_emojis = append(element_emojis, string(pokememe_info_runed_strings[4][15]))
}
err := c.Db.Select(&elements, "SELECT * FROM elements WHERE symbol IN ('" + strings.Join(element_emojis, "', '") + "')")
err := c.Db.Select(&elements, "SELECT * FROM elements WHERE symbol IN ('"+strings.Join(element_emojis, "', '")+"')")
if err != nil {
log.Printf(err.Error())
return "fail"
@ -109,7 +109,7 @@ func (p *Parsers) ParsePokememe(text string, player_raw dbmapping.Player) string
return "fail"
}
err2 := c.Db.Select(&locations, "SELECT * FROM locations WHERE name IN ('" + strings.Join(locationsNames, "', '") + "')")
err2 := c.Db.Select(&locations, "SELECT * FROM locations WHERE name IN ('"+strings.Join(locationsNames, "', '")+"')")
if err2 != nil {
log.Printf(err2.Error())
return "fail"
@ -141,7 +141,7 @@ func (p *Parsers) ParsePokememe(text string, player_raw dbmapping.Player) string
return "fail"
}
err2 := c.Db.Select(&locations, "SELECT * FROM locations WHERE name IN ('" + strings.Join(locationsNames, "', '") + "')")
err2 := c.Db.Select(&locations, "SELECT * FROM locations WHERE name IN ('"+strings.Join(locationsNames, "', '")+"')")
if err2 != nil {
log.Printf(err2.Error())
return "fail"
@ -152,7 +152,6 @@ func (p *Parsers) ParsePokememe(text string, player_raw dbmapping.Player) string
image = strings.Replace(string(pokememe_info_runed_strings[11]), " ", "", -1)
}
grade := string(pokememe_info_runed_strings[0][0])
name := string(pokememe_info_runed_strings[0][3:])
description := string(pokememe_info_runed_strings[1])
@ -160,7 +159,7 @@ func (p *Parsers) ParsePokememe(text string, player_raw dbmapping.Player) string
log.Printf("Pokememe name: " + name)
log.Printf("Pokememe description: " + description)
log.Printf("Elements:")
for i := range(elements) {
for i := range elements {
log.Printf(elements[i].Symbol + " " + elements[i].Name)
}
log.Printf("Attack: " + hitPoints[0])
@ -169,7 +168,7 @@ func (p *Parsers) ParsePokememe(text string, player_raw dbmapping.Player) string
log.Printf("Defence: " + defence)
log.Printf("Price: " + price)
log.Printf("Locations:")
for i := range(locations) {
for i := range locations {
log.Printf(locations[i].Symbol + " " + locations[i].Name)
}
if purchaseable {
@ -182,7 +181,7 @@ func (p *Parsers) ParsePokememe(text string, player_raw dbmapping.Player) string
// Building pokememe
pokememe := dbmapping.Pokememe{}
// Checking if pokememe exists in database
err3 := c.Db.Get(&pokememe, c.Db.Rebind("SELECT * FROM pokememes WHERE grade='" + grade + "' AND name='" + name + "';"))
err3 := c.Db.Get(&pokememe, c.Db.Rebind("SELECT * FROM pokememes WHERE grade='"+grade+"' AND name='"+name+"';"))
if err3 != nil {
log.Printf("Adding new pokememe...")
} else {
@ -221,12 +220,12 @@ func (p *Parsers) ParsePokememe(text string, player_raw dbmapping.Player) string
}
// Getting new pokememe
err5 := c.Db.Get(&pokememe, c.Db.Rebind("SELECT * FROM pokememes WHERE grade='" + grade + "' AND name='" + name + "';"))
err5 := c.Db.Get(&pokememe, c.Db.Rebind("SELECT * FROM pokememes WHERE grade='"+grade+"' AND name='"+name+"';"))
if err5 != nil {
log.Printf("Pokememe isn't added!")
return "fail"
}
for i := range(elements) {
for i := range elements {
link := dbmapping.PokememeElement{}
link.Pokememe_id = pokememe.Id
link.Element_id = elements[i].Id
@ -238,7 +237,7 @@ func (p *Parsers) ParsePokememe(text string, player_raw dbmapping.Player) string
return "fail"
}
}
for i := range(locations) {
for i := range locations {
link := dbmapping.PokememeLocation{}
link.Pokememe_id = pokememe.Id
link.Location_id = locations[i].Id
@ -251,7 +250,6 @@ func (p *Parsers) ParsePokememe(text string, player_raw dbmapping.Player) string
}
}
return "ok"
}

View File

@ -7,8 +7,8 @@ import (
// stdlib
"log"
"regexp"
"strings"
"strconv"
"strings"
"time"
// 3rd party
"github.com/go-telegram-bot-api/telegram-bot-api"
@ -20,7 +20,7 @@ import (
func (p *Parsers) fillProfilePokememe(profile_id int, meme string, attack string, rarity string) {
spk_raw := dbmapping.Pokememe{}
err := c.Db.Get(&spk_raw, c.Db.Rebind("SELECT * FROM pokememes WHERE name='" + meme + "';"))
err := c.Db.Get(&spk_raw, c.Db.Rebind("SELECT * FROM pokememes WHERE name='"+meme+"';"))
if err != nil {
log.Println(err)
} else {
@ -53,7 +53,7 @@ func (p *Parsers) ParseProfile(update tgbotapi.Update, player_raw dbmapping.Play
profile_info_strings := strings.Split(text, "\n")
profile_info_runed_strings := make([][]rune, 0)
for i := range(profile_info_strings) {
for i := range profile_info_strings {
profile_info_runed_strings = append(profile_info_runed_strings, []rune(profile_info_strings[i]))
}
@ -79,16 +79,16 @@ func (p *Parsers) ParseProfile(update tgbotapi.Update, player_raw dbmapping.Play
// Filling information
// We don't know how many strings we got, so we iterating each other
for i := range(profile_info_runed_strings) {
for i := range profile_info_runed_strings {
current_string := string(profile_info_runed_strings[i])
current_runes := profile_info_runed_strings[i]
if strings.HasPrefix(current_string, "🈸") || strings.HasPrefix(current_string, "🈳 ") || strings.HasPrefix(current_string, "🈵") {
err1 := c.Db.Get(&league, c.Db.Rebind("SELECT * FROM leagues WHERE symbol='" + string(current_runes[0]) + "'"))
err1 := c.Db.Get(&league, c.Db.Rebind("SELECT * FROM leagues WHERE symbol='"+string(current_runes[0])+"'"))
if err1 != nil {
log.Println(err1)
return "fail"
}
for j := range(current_runes) {
for j := range current_runes {
if j > 1 {
nickname += string(current_runes[j])
}
@ -138,7 +138,7 @@ func (p *Parsers) ParseProfile(update tgbotapi.Update, player_raw dbmapping.Play
}
wealth = wealth_array[0]
wealth_int = p.getPoints(wealth)
crystalls =wealth_array[1]
crystalls = wealth_array[1]
crystalls_int = p.getPoints(crystalls)
}
@ -159,7 +159,7 @@ func (p *Parsers) ParseProfile(update tgbotapi.Update, player_raw dbmapping.Play
pokememes_count, _ := strconv.Atoi(pk_num_array[0])
if pokememes_count > 0 {
for pi := 0; pi < pokememes_count; pi++ {
pokememe_string := string(profile_info_runed_strings[i + 1 + pi])
pokememe_string := string(profile_info_runed_strings[i+1+pi])
attackRx := regexp.MustCompile("(\\d|\\.|K|M)+")
pk_points_array := attackRx.FindAllString(pokememe_string, -1)
pk_attack := pk_points_array[1]
@ -191,7 +191,7 @@ func (p *Parsers) ParseProfile(update tgbotapi.Update, player_raw dbmapping.Play
log.Println(crystalls_int)
log.Printf("Weapon: " + weapon)
if len(pokememes) > 0 {
for meme, attack := range(pokememes) {
for meme, attack := range pokememes {
log.Printf(meme + ": " + attack)
}
} else {
@ -200,7 +200,7 @@ func (p *Parsers) ParseProfile(update tgbotapi.Update, player_raw dbmapping.Play
// Information is gathered, let's create profile in database!
weapon_raw := dbmapping.Weapon{}
err2 := c.Db.Get(&weapon_raw, c.Db.Rebind("SELECT * FROM weapons WHERE name='" + weapon + "'"))
err2 := c.Db.Get(&weapon_raw, c.Db.Rebind("SELECT * FROM weapons WHERE name='"+weapon+"'"))
if err2 != nil {
log.Println(err2)
}
@ -227,7 +227,7 @@ func (p *Parsers) ParseProfile(update tgbotapi.Update, player_raw dbmapping.Play
log.Println(err5)
return "fail"
}
err6 := c.Db.Get(&player_raw, c.Db.Rebind("SELECT * FROM players WHERE telegram_id='" + strconv.Itoa(player_raw.Telegram_id) + "' AND league_id='" + strconv.Itoa(league.Id) + "';"))
err6 := c.Db.Get(&player_raw, c.Db.Rebind("SELECT * FROM players WHERE telegram_id='"+strconv.Itoa(player_raw.Telegram_id)+"' AND league_id='"+strconv.Itoa(league.Id)+"';"))
if err6 != nil {
log.Println(err6)
return "fail"
@ -268,8 +268,7 @@ func (p *Parsers) ParseProfile(update tgbotapi.Update, player_raw dbmapping.Play
return "fail"
}
for meme, attack := range(pokememes) {
for meme, attack := range pokememes {
rarity := "common"
if strings.HasPrefix(meme, "🔸") {
rarity = "rare"

View File

@ -8,7 +8,7 @@ import (
"github.com/go-telegram-bot-api/telegram-bot-api"
)
type RouterHandler struct {}
type RouterHandler struct{}
func (rh RouterHandler) Init() {
r.Init()

View File

@ -12,7 +12,7 @@ import (
"github.com/go-telegram-bot-api/telegram-bot-api"
)
type Router struct {}
type Router struct{}
// This function will route requests to appropriative modules
// It will return "ok" or "fail"

View File

@ -15,7 +15,7 @@ var (
c *appcontext.Context
)
type Talkers struct {}
type Talkers struct{}
func New(ac *appcontext.Context) {
c = ac

View File

@ -5,8 +5,8 @@ package talkers
import (
// stdlib
"strings"
"strconv"
"strings"
// 3rd party
"github.com/go-telegram-bot-api/telegram-bot-api"
// local
@ -19,24 +19,24 @@ func (t *Talkers) pokememesListing(update tgbotapi.Update, page int, pokememes_f
message := "*Известные боту покемемы*\n"
message += "Список отсортирован по грейду и алфавиту.\n"
message += "Покедекс: " + strconv.Itoa(len(pokememes_full)) + " / 206\n"
message += "Отображаем покемемов с " + strconv.Itoa(((page - 1)*50)+1) + " по " + strconv.Itoa(page*50) + "\n"
message += "Отображаем покемемов с " + strconv.Itoa(((page-1)*50)+1) + " по " + strconv.Itoa(page*50) + "\n"
if len(pokememes_full) > page*50 {
message += "Переход на следующую страницу: /pokedeks" + strconv.Itoa(page + 1)
message += "Переход на следующую страницу: /pokedeks" + strconv.Itoa(page+1)
}
if page > 1 {
message += "\nПереход на предыдущую страницу: /pokedeks" + strconv.Itoa(page - 1)
message += "\nПереход на предыдущую страницу: /pokedeks" + strconv.Itoa(page-1)
}
message += "\n\n"
for i := range(pokememes_full) {
if (i + 1 > 50*(page - 1)) && (i + 1 < (50*page) + 1) {
for i := range pokememes_full {
if (i+1 > 50*(page-1)) && (i+1 < (50*page)+1) {
pk := pokememes_full[i].Pokememe
pk_e := pokememes_full[i].Elements
message += strconv.Itoa(i + 1) + ". " + strconv.Itoa(pk.Grade)
message += strconv.Itoa(i+1) + ". " + strconv.Itoa(pk.Grade)
message += "⃣ *" + pk.Name
message += "* (" + c.Parsers.ReturnPoints(pk.HP) + "-" + c.Parsers.ReturnPoints(pk.MP) + ") ⚔️ *"
message += c.Parsers.ReturnPoints(pk.Attack) + "* \\["
for j := range(pk_e) {
for j := range pk_e {
message += pk_e[j].Symbol
}
message += "] " + c.Parsers.ReturnPoints(pk.Price) + "$ /pk" + strconv.Itoa(pk.Id)
@ -80,13 +80,13 @@ func (t *Talkers) PokememeInfo(update tgbotapi.Update, player_raw dbmapping.Play
message := strconv.Itoa(pk.Grade) + "⃣ *" + pk.Name + "*\n"
message += pk.Description + "\n\n"
message += "Элементы:"
for i := range(pokememe.Elements) {
for i := range pokememe.Elements {
message += " " + pokememe.Elements[i].Symbol
}
message += "\n⚔ Атака: *" + c.Parsers.ReturnPoints(pk.Attack)
message += "*\n❤ HP: *" + c.Parsers.ReturnPoints(pk.HP)
message += "*\n💙 MP: *" + c.Parsers.ReturnPoints(pk.MP)
if (pk.Defence != pk.Attack) {
if pk.Defence != pk.Attack {
message += "*\n🛡Защита: *" + c.Parsers.ReturnPoints(pk.Defence) + "* _(сопротивляемость покемема к поимке)_"
} else {
message += "*"
@ -99,7 +99,7 @@ func (t *Talkers) PokememeInfo(update tgbotapi.Update, player_raw dbmapping.Play
message += "Нельзя"
}
message += "*\nОбитает:"
for i := range(pokememe.Locations) {
for i := range pokememe.Locations {
message += " *" + pokememe.Locations[i].Name + "*"
if (i + 1) < len(pokememe.Locations) {
message += ","
@ -107,9 +107,9 @@ func (t *Talkers) PokememeInfo(update tgbotapi.Update, player_raw dbmapping.Play
}
if calculate_possibilites {
if (pk.Grade < profile_raw.Level_id + 2) && (pk.Grade > profile_raw.Level_id - 3) {
if (pk.Grade < profile_raw.Level_id+2) && (pk.Grade > profile_raw.Level_id-3) {
message += "\nВероятность поимки:"
for i := range(pokememe.Locations) {
for i := range pokememe.Locations {
percentile, pokeballs := c.Getters.PossibilityRequiredPokeballs(pokememe.Locations[i].Id, pk.Grade, profile_raw.Level_id)
message += "\n" + pokememe.Locations[i].Name + " "
message += strconv.FormatFloat(percentile, 'f', 2, 64) + "% или "
@ -122,9 +122,9 @@ func (t *Talkers) PokememeInfo(update tgbotapi.Update, player_raw dbmapping.Play
msg := tgbotapi.NewMessage(update.Message.Chat.ID, message)
keyboard := tgbotapi.InlineKeyboardMarkup{}
for i := range(pokememe.Locations) {
for i := range pokememe.Locations {
var row []tgbotapi.InlineKeyboardButton
btn := tgbotapi.NewInlineKeyboardButtonSwitch(pokememe.Locations[i].Symbol + pokememe.Locations[i].Name, pokememe.Locations[i].Symbol + pokememe.Locations[i].Name)
btn := tgbotapi.NewInlineKeyboardButtonSwitch(pokememe.Locations[i].Symbol+pokememe.Locations[i].Name, pokememe.Locations[i].Symbol+pokememe.Locations[i].Name)
row = append(row, btn)
keyboard.InlineKeyboard = append(keyboard.InlineKeyboard, row)
}

View File

@ -48,8 +48,8 @@ func (t *Talkers) ProfileMessage(update tgbotapi.Update, player_raw dbmapping.Pl
}
attack_pm := 0
for i := range(p_pk) {
for j := range(pokememes) {
for i := range p_pk {
for j := range pokememes {
if p_pk[i].Pokememe_id == pokememes[j].Id {
single_attack := float64(pokememes[j].Attack)
single_attack = single_attack * float64(p_pk[i].Pokememe_lvl)
@ -61,7 +61,6 @@ func (t *Talkers) ProfileMessage(update tgbotapi.Update, player_raw dbmapping.Pl
}
}
message := "*Профиль игрока "
message += profile_raw.Nickname + "* (@" + profile_raw.TelegramNickname + ")\n"
message += "\nЛига: " + league.Symbol + league.Name
@ -78,8 +77,8 @@ func (t *Talkers) ProfileMessage(update tgbotapi.Update, player_raw dbmapping.Pl
}
message += "\n🐱Покемемы:"
for i := range(p_pk) {
for j := range(pokememes) {
for i := range p_pk {
for j := range pokememes {
if p_pk[i].Pokememe_id == pokememes[j].Id {
single_attack := float64(pokememes[j].Attack)
single_attack = single_attack * float64(p_pk[i].Pokememe_lvl)

View File

@ -21,7 +21,7 @@ func (t *Talkers) BestPokememesList(update tgbotapi.Update, player_raw dbmapping
}
message := "*Лучшие покемемы для ловли*\n\n"
for i := range(pokememes) {
for i := range pokememes {
pk := pokememes[i].Pokememe
pk_l := pokememes[i].Locations
pk_e := pokememes[i].Elements
@ -29,20 +29,20 @@ func (t *Talkers) BestPokememesList(update tgbotapi.Update, player_raw dbmapping
message += pk.Name + " (⚔"
message += c.Parsers.ReturnPoints(pk.Attack)
message += ", 🛡" + c.Parsers.ReturnPoints(pk.Defence) + ")"
for i := range(pk_e) {
for i := range pk_e {
message += pk_e[i].Symbol
}
message += " /pk" + strconv.Itoa(pk.Id) + "\n"
message += "Локации: "
for i := range(pk_l) {
for i := range pk_l {
message += pk_l[i].Symbol + pk_l[i].Name
if i + 1 < len(pk_l) {
if i+1 < len(pk_l) {
message += ", "
}
}
message += "\nКупить: "
if pk.Purchaseable {
message += "💲" + c.Parsers.ReturnPoints(pk.Price * 3)
message += "💲" + c.Parsers.ReturnPoints(pk.Price*3)
} else {
message += "Нельзя"
}