Archived
1

Format imports with goimport

This commit is contained in:
Vladimir Hodakov 2018-05-02 07:25:39 +04:00
parent ef9cf07abc
commit 86afa52a56
43 changed files with 108 additions and 128 deletions

View File

@ -4,8 +4,9 @@
package broadcaster
import (
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"time"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
func (b *Broadcaster) createBroadcastMessage(playerRaw *dbmapping.Player, messageBody string, broadcastType string) (dbmapping.Broadcast, bool) {

View File

@ -5,10 +5,10 @@ package connections
import (
"bitbucket.org/pztrn/mogrus"
"source.wtfteam.pro/i2_bot/i2_bot/lib/config"
_ "github.com/go-sql-driver/mysql"
"github.com/go-telegram-bot-api/telegram-bot-api"
"github.com/jmoiron/sqlx"
"source.wtfteam.pro/i2_bot/i2_bot/lib/config"
)
// BotInit initializes connection to Telegram

View File

@ -5,10 +5,11 @@ package datacache
import (
"errors"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"strconv"
"time"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
func (dc *DataCache) initChats() {

View File

@ -5,10 +5,11 @@ package datacache
import (
"errors"
"strconv"
"gopkg.in/yaml.v2"
"source.wtfteam.pro/i2_bot/i2_bot/lib/datamapping"
"source.wtfteam.pro/i2_bot/i2_bot/static"
"strconv"
)
func (dc *DataCache) initElements() {

View File

@ -4,11 +4,12 @@
package datacache
import (
"sync"
"source.wtfteam.pro/i2_bot/i2_bot/lib/appcontext"
"source.wtfteam.pro/i2_bot/i2_bot/lib/datacache/datacacheinterface"
"source.wtfteam.pro/i2_bot/i2_bot/lib/datamapping"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"sync"
)
var (

View File

@ -5,10 +5,11 @@ package datacache
import (
"errors"
"strconv"
"gopkg.in/yaml.v2"
"source.wtfteam.pro/i2_bot/i2_bot/lib/datamapping"
"source.wtfteam.pro/i2_bot/i2_bot/static"
"strconv"
)
func (dc *DataCache) initLeagues() {

View File

@ -5,10 +5,11 @@ package datacache
import (
"errors"
"strconv"
"gopkg.in/yaml.v2"
"source.wtfteam.pro/i2_bot/i2_bot/lib/datamapping"
"source.wtfteam.pro/i2_bot/i2_bot/static"
"strconv"
)
func (dc *DataCache) initLevels() {

View File

@ -5,10 +5,11 @@ package datacache
import (
"errors"
"strconv"
"gopkg.in/yaml.v2"
"source.wtfteam.pro/i2_bot/i2_bot/lib/datamapping"
"source.wtfteam.pro/i2_bot/i2_bot/static"
"strconv"
)
func (dc *DataCache) initLocations() {

View File

@ -5,9 +5,10 @@ package datacache
import (
"errors"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"strconv"
"time"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
func (dc *DataCache) initPlayers() {

View File

@ -5,11 +5,12 @@ package datacache
import (
"errors"
"strconv"
"strings"
"gopkg.in/yaml.v2"
"source.wtfteam.pro/i2_bot/i2_bot/lib/datamapping"
"source.wtfteam.pro/i2_bot/i2_bot/static"
"strconv"
"strings"
)
func (dc *DataCache) initPokememes() {

View File

@ -5,8 +5,9 @@ package datacache
import (
"errors"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"strconv"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
func (dc *DataCache) initProfiles() {

View File

@ -5,8 +5,9 @@ package datacache
import (
"errors"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"strconv"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
func (dc *DataCache) initSquads() {

View File

@ -5,11 +5,12 @@ package datacache
import (
"errors"
"strconv"
"strings"
"gopkg.in/yaml.v2"
"source.wtfteam.pro/i2_bot/i2_bot/lib/datamapping"
"source.wtfteam.pro/i2_bot/i2_bot/static"
"strconv"
"strings"
)
func (dc *DataCache) initWeapons() {

View File

@ -4,8 +4,9 @@
package dbmapping
import (
"github.com/go-sql-driver/mysql"
"time"
"github.com/go-sql-driver/mysql"
)
// Order is a struct, which represents `orders` table item in databse.

View File

@ -4,8 +4,9 @@
package dbmapping
import (
"source.wtfteam.pro/i2_bot/i2_bot/lib/datamapping"
"time"
"source.wtfteam.pro/i2_bot/i2_bot/lib/datamapping"
)
// Player is a struct, which represents `players` table item in databse.

View File

@ -1,16 +0,0 @@
// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
package dbmapping
import (
"time"
)
// PokememeElement is a struct, which represents `pokememes_elements` table item in databse.
type PokememeElement struct {
ID int `db:"id"`
PokememeID int `db:"pokememe_id"`
ElementID int `db:"element_id"`
CreatedAt time.Time `db:"created_at"`
}

View File

@ -1,16 +0,0 @@
// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
package dbmapping
import (
"time"
)
// PokememeLocation is a struct, which represents `pokememes_locations` table item in databse.
type PokememeLocation struct {
ID int `db:"id"`
PokememeID int `db:"pokememe_id"`
LocationID int `db:"location_id"`
CreatedAt time.Time `db:"created_at"`
}

View File

@ -4,7 +4,6 @@
package dbmapping
import (
"math"
"time"
)
@ -22,18 +21,12 @@ type Profile struct {
EggExp int `db:"egg_exp"`
Power int `db:"power"`
WeaponID int `db:"weapon_id"`
Crystalls int `db:"crystalls"`
Crystals int `db:"crystalls"`
CreatedAt time.Time `db:"created_at"`
}
// FullExp returns exp points in summary, gained after registration
func (p *Profile) FullExp() int {
fullExp := 0.00
for i := 1; i < p.LevelID+1; i++ {
fullExp = fullExp + (100 * math.Pow(2.0, float64(i)))
}
fullExp += float64(p.Exp)
return int(fullExp)
// ProfileWithPokememes is a struct, which represents full profile with current hand
type ProfileWithPokememes struct {
Profile Profile
Pokememes ProfilePokememe
}

View File

@ -4,18 +4,19 @@
package forwarder
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"regexp"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
// ProcessForward process forwards for single-user chats
func (f *Forwarder) ProcessForward(update *tgbotapi.Update, playerRaw *dbmapping.Player) string {
text := update.Message.Text
// Forwards
var pokememeMsg = regexp.MustCompile(`Dex(.+)\nGrade(.+)\nName(.+)`)
var profileMsg = regexp.MustCompile(`(Онлайн: )(\d+)(| Турнир: )(.+)\n(.+)\n(.+)\n(👤Уровень)(.+)\n`)
var profileWithEffectsMsg = regexp.MustCompile(`(Онлайн: )(\d+)(| Турнир: )(.+)\n(.+)\n(.+)\n(.+)\n(👤Уровень)(.+)\n`)
var profileMsg = regexp.MustCompile(`id(\s)(\d+)\n(Team)(\s)([А-Я]+)\nName(\s)(.*)\nLvl(\s)(\d+)`)
switch {
case pokememeMsg.MatchString(text):
@ -28,8 +29,6 @@ func (f *Forwarder) ProcessForward(update *tgbotapi.Update, playerRaw *dbmapping
case profileMsg.MatchString(text):
c.Log.Debug("Profile posted!")
return c.Users.ParseProfile(update, playerRaw)
case profileWithEffectsMsg.MatchString(text):
return c.Users.ProfileAddEffectsMessage(update)
default:
c.Log.Debug(text)
}

View File

@ -4,10 +4,11 @@
package orders
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"strconv"
"strings"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
// Internal functions

View File

@ -4,8 +4,9 @@
package orders
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"strconv"
"github.com/go-telegram-bot-api/telegram-bot-api"
)
// ListAllOrders returns to user all orders in database

View File

@ -4,10 +4,11 @@
package pinner
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"strconv"
"strings"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
func (p *Pinner) execMassMessagePin(update *tgbotapi.Update, groupChats []dbmapping.Chat) string {

View File

@ -5,9 +5,10 @@ package pokedexer
import (
"sort"
"source.wtfteam.pro/i2_bot/i2_bot/lib/datamapping"
"strconv"
"strings"
"source.wtfteam.pro/i2_bot/i2_bot/lib/datamapping"
)
func (p *Pokedexer) getAdvicePokememes(playerID int, adviceType string) ([]*datamapping.PokememeFull, bool) {

View File

@ -4,10 +4,11 @@
package pokedexer
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"strconv"
"strings"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
// ParsePokememe parses pokememe, forwarded from PokememeBroBot, to database

View File

@ -4,10 +4,11 @@
package pokedexer
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"sort"
"source.wtfteam.pro/i2_bot/i2_bot/lib/datamapping"
"strconv"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/datamapping"
)
func (p *Pokedexer) pokememesListingMessage(update *tgbotapi.Update, page int, pokememesArray map[int]*datamapping.PokememeFull) string {

View File

@ -4,10 +4,11 @@
package pokedexer
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"strconv"
"strings"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
// AdvicePokememesList shows list for catching

View File

@ -4,9 +4,10 @@
package reminder
import (
"strconv"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"strconv"
)
func (r *Reminder) getRemindersForUser(playerRaw *dbmapping.Player) ([]dbmapping.Alarm, bool) {

View File

@ -4,9 +4,10 @@
package reminder
import (
"time"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"time"
)
// SendReminders sends reminders for users about coming league tournament

View File

@ -4,11 +4,12 @@
package reminder
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"strconv"
"strings"
"time"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
// CreateAlarmSetting creates alarm setting for user

View File

@ -4,10 +4,11 @@
package router
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"regexp"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"strconv"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
func (r *Router) routePrivateRequest(update tgbotapi.Update, playerRaw *dbmapping.Player, chatRaw *dbmapping.Chat) string {

View File

@ -4,10 +4,11 @@
package squader
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"strconv"
"strings"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
// SquadsList lists all squads

View File

@ -4,12 +4,13 @@
package squader
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"regexp"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"strconv"
"strings"
"time"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
func (s *Squader) isUserAnyCommander(playerID int) bool {

View File

@ -4,8 +4,9 @@
package statistics
import (
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"strconv"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
// SquadStatictics generates statistics message snippet. Public due to usage in chats list

View File

@ -4,8 +4,8 @@
package statisticsinterface
import (
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
// StatisticsInterface implements Statistics for importing via appcontext.

View File

@ -4,10 +4,11 @@
package statistics
import (
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"github.com/go-telegram-bot-api/telegram-bot-api"
"sort"
"strconv"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
func (s *Statistics) renderPosition(profilesRaw *[]*dbmapping.PlayerProfile, playerRaw *dbmapping.Player) string {
@ -110,11 +111,11 @@ func (s *Statistics) TopList(update *tgbotapi.Update, playerRaw *dbmapping.Playe
message += "\n*Топ-5 по опыту*\n"
sort.Slice(profiles, func(i, j int) bool {
return profiles[i].Profile.FullExp() > profiles[j].Profile.FullExp()
return profiles[i].Profile.Exp > profiles[j].Profile.Exp
})
for i := 0; i < topLimit; i++ {
message += "*" + strconv.Itoa(i+1) + "*: " + c.Users.FormatUsername(profiles[i].Profile.Nickname) + " (" + strconv.Itoa(profiles[i].Profile.FullExp()) + " очков)\n"
message += "*" + strconv.Itoa(i+1) + "*: " + c.Users.FormatUsername(profiles[i].Profile.Nickname) + " (" + strconv.Itoa(profiles[i].Profile.Exp) + " очков)\n"
}
message += s.renderPosition(&profiles, playerRaw)

View File

@ -4,8 +4,8 @@
package users
import (
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
// GetPrettyName returns "pretty" name of user (first_name + last name or username)

View File

@ -1,5 +1,5 @@
// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
// Copyright (c) 2017-2018 Vladimir "fat0troll" Hodakov
package users
@ -64,8 +64,8 @@ func (u *Users) ParseProfile(update *tgbotapi.Update, playerRaw *dbmapping.Playe
wealthInt := 0
pokememesWealth := ""
pokememesWealthInt := 0
crystalls := ""
crystallsInt := 0
crystals := ""
crystalsInt := 0
weapon := ""
pokememes := make(map[string]string)
powerInt := 0
@ -145,8 +145,8 @@ func (u *Users) ParseProfile(update *tgbotapi.Update, playerRaw *dbmapping.Playe
}
wealth = wealthArray[0]
wealthInt = c.Statistics.GetPoints(wealth)
crystalls = wealthArray[1]
crystallsInt = c.Statistics.GetPoints(crystalls)
crystals = wealthArray[1]
crystalsInt = c.Statistics.GetPoints(crystals)
}
if strings.HasPrefix(currentString, "🔫") {
@ -208,8 +208,8 @@ func (u *Users) ParseProfile(update *tgbotapi.Update, playerRaw *dbmapping.Playe
c.Log.Debugln(pokeballsInt)
c.Log.Debug("Wealth: " + wealth)
c.Log.Debugln(wealthInt)
c.Log.Debug("Crystalls: " + crystalls)
c.Log.Debugln(crystallsInt)
c.Log.Debug("crystals: " + crystals)
c.Log.Debugln(crystalsInt)
c.Log.Debug("Weapon: " + weapon)
if len(pokememes) > 0 {
c.Log.Debug("Hand cost: " + pokememesWealth)
@ -265,7 +265,7 @@ func (u *Users) ParseProfile(update *tgbotapi.Update, playerRaw *dbmapping.Playe
} else {
profileRaw.WeaponID = 0
}
profileRaw.Crystalls = crystallsInt
profileRaw.Crystals = crystalsInt
profileRaw.CreatedAt = time.Now().UTC()
newProfileID, err := c.DataCache.AddProfile(&profileRaw)

View File

@ -4,10 +4,11 @@
package users
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"strconv"
"strings"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
// FormatUsername formats Telegram username for posting
@ -97,19 +98,6 @@ func (u *Users) ForeignProfileMessage(update *tgbotapi.Update) string {
return u.ProfileMessage(update, playerRaw)
}
// ProfileAddEffectsMessage shows when user tries to post profile with effects enabled
func (u *Users) ProfileAddEffectsMessage(update *tgbotapi.Update) string {
message := "*Наркоман, штоле?*\n\n"
message += "Бот не принимает профили во время активированных эффектов. Закончи свои дела и принеси чистый профиль через полчаса."
msg := tgbotapi.NewMessage(update.Message.Chat.ID, message)
msg.ParseMode = "Markdown"
c.Bot.Send(msg)
return "fail"
}
// ProfileMessage shows current player's profile
func (u *Users) ProfileMessage(update *tgbotapi.Update, playerRaw *dbmapping.Player) string {
profileRaw, err := c.DataCache.GetProfileByPlayerID(playerRaw.ID)
@ -158,7 +146,7 @@ func (u *Users) ProfileMessage(update *tgbotapi.Update, playerRaw *dbmapping.Pla
message += " | 🎓 " + strconv.Itoa(profileRaw.Exp) + "/" + strconv.Itoa(level.MaxExp)
message += " | 🥚 " + strconv.Itoa(profileRaw.EggExp) + "/" + strconv.Itoa(level.MaxEgg)
message += "\n💲" + c.Statistics.GetPrintablePoints(profileRaw.Wealth)
message += " |💎" + strconv.Itoa(profileRaw.Crystalls)
message += " |💎" + strconv.Itoa(profileRaw.Crystals)
message += " |⭕" + strconv.Itoa(profileRaw.Pokeballs)
if weapon != nil {
message += "\n⚔Атака: " + c.Statistics.GetPrintablePoints(weapon.Power) + " + " + c.Statistics.GetPrintablePoints(attackPokememes) + "\n"

View File

@ -4,12 +4,13 @@
package users
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"sort"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"strconv"
"strings"
"time"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
// Internal functions for Users package

View File

@ -4,8 +4,8 @@
package usersinterface
import (
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
// UsersInterface implements Users for importing via appcontex
@ -22,7 +22,6 @@ type UsersInterface interface {
FindByTopAttack(update *tgbotapi.Update) string
ForeignProfileMessage(update *tgbotapi.Update) string
FormatUsername(userName string) string
ProfileAddEffectsMessage(update *tgbotapi.Update) string
ProfileMessage(update *tgbotapi.Update, playerRaw *dbmapping.Player) string
UsersList(update *tgbotapi.Update) string
}

View File

@ -4,8 +4,9 @@
package welcomer
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"strconv"
"github.com/go-telegram-bot-api/telegram-bot-api"
)
func (w *Welcomer) alertUserWithoutProfile(update *tgbotapi.Update, newUser *tgbotapi.User) string {

View File

@ -4,9 +4,10 @@
package welcomer
import (
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"github.com/go-telegram-bot-api/telegram-bot-api"
"strconv"
"github.com/go-telegram-bot-api/telegram-bot-api"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
)
// PrivateWelcomeMessageUnauthorized tell new user what to do.

View File

@ -4,8 +4,9 @@
package welcomer
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"time"
"github.com/go-telegram-bot-api/telegram-bot-api"
)
func (w *Welcomer) groupWelcomeUser(update *tgbotapi.Update, newUser *tgbotapi.User) string {