hdkv
/
i2_bot
Archived
1
Fork 0

Explicit error message for profile posting with enabled artifacts

master
Vladimir Hodakov 2018-01-23 20:50:21 +04:00
parent c5d8590b87
commit b7379013a8
5 changed files with 22 additions and 4 deletions

View File

@ -11,7 +11,7 @@ import (
) )
// VERSION is the current bot's version // VERSION is the current bot's version
const VERSION = "0.6.5" const VERSION = "0.6.6"
// DatabaseConnection handles database connection settings in config.yaml // DatabaseConnection handles database connection settings in config.yaml
type DatabaseConnection struct { type DatabaseConnection struct {

View File

@ -4,8 +4,8 @@
package forwarder package forwarder
import ( import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"git.wtfteam.pro/fat0troll/i2_bot/lib/dbmapping" "git.wtfteam.pro/fat0troll/i2_bot/lib/dbmapping"
"github.com/go-telegram-bot-api/telegram-bot-api"
"regexp" "regexp"
) )
@ -15,6 +15,7 @@ func (f *Forwarder) ProcessForward(update *tgbotapi.Update, playerRaw *dbmapping
// Forwards // Forwards
var pokememeMsg = regexp.MustCompile("(Уровень)(.+)(Опыт)(.+)\n(Элементы:)(.+)\n(.+)(💙MP)") var pokememeMsg = regexp.MustCompile("(Уровень)(.+)(Опыт)(.+)\n(Элементы:)(.+)\n(.+)(💙MP)")
var profileMsg = regexp.MustCompile(`(Онлайн: )(\d+)\n(Турнир через)(.+)\n\n((.*)\n|(.*)\n(.*)\n)(Элементы)(.+)\n(.*)\n\n(.+)(Уровень)(.+)\n`) var profileMsg = regexp.MustCompile(`(Онлайн: )(\d+)\n(Турнир через)(.+)\n\n((.*)\n|(.*)\n(.*)\n)(Элементы)(.+)\n(.*)\n\n(.+)(Уровень)(.+)\n`)
var profileWithEffectsMsg = regexp.MustCompile(`(Онлайн: )(\d+)\n(Турнир через)(.+)\n\n((.*)\n|(.*)\n(.*)\n)(Элементы)(.+)\n(.*)\n(Эффекты)(.*)\n\n(.+)(Уровень)(.+)\n`)
switch { switch {
case pokememeMsg.MatchString(text): case pokememeMsg.MatchString(text):
@ -27,6 +28,8 @@ func (f *Forwarder) ProcessForward(update *tgbotapi.Update, playerRaw *dbmapping
case profileMsg.MatchString(text): case profileMsg.MatchString(text):
c.Log.Debug("Profile posted!") c.Log.Debug("Profile posted!")
return c.Users.ParseProfile(update, playerRaw) return c.Users.ParseProfile(update, playerRaw)
case profileWithEffectsMsg.MatchString(text):
return c.Users.ProfileAddEffectsMessage(update)
default: default:
c.Log.Debug(text) c.Log.Debug(text)
} }

View File

@ -4,9 +4,9 @@
package talkers package talkers
import ( import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"git.wtfteam.pro/fat0troll/i2_bot/lib/config" "git.wtfteam.pro/fat0troll/i2_bot/lib/config"
"git.wtfteam.pro/fat0troll/i2_bot/lib/dbmapping" "git.wtfteam.pro/fat0troll/i2_bot/lib/dbmapping"
"github.com/go-telegram-bot-api/telegram-bot-api"
) )
// AcademyMessage gives user link to Bastion // AcademyMessage gives user link to Bastion
@ -49,7 +49,7 @@ func (t *Talkers) BastionMessage(update *tgbotapi.Update, playerRaw *dbmapping.P
// HelpMessage gives user all available commands // HelpMessage gives user all available commands
func (t *Talkers) HelpMessage(update *tgbotapi.Update, playerRaw *dbmapping.Player) { func (t *Talkers) HelpMessage(update *tgbotapi.Update, playerRaw *dbmapping.Player) {
message := "*Бот Инстинкта Enchanched.*\n\n" message := "*Бот Инстинкта Enhanced.*\n\n"
message += "Текущая версия: *" + config.VERSION + "*\n\n" message += "Текущая версия: *" + config.VERSION + "*\n\n"
message += "Список команд\n\n" message += "Список команд\n\n"
message += "\\* /me посмотреть свой сохраненный профиль в боте\n" message += "\\* /me посмотреть свой сохраненный профиль в боте\n"
@ -69,6 +69,7 @@ func (t *Talkers) HelpMessage(update *tgbotapi.Update, playerRaw *dbmapping.Play
} }
if c.Users.PlayerBetterThan(playerRaw, "academic") { if c.Users.PlayerBetterThan(playerRaw, "academic") {
message += "\\* /users — просмотреть зарегистрированных пользователей бота\n" message += "\\* /users — просмотреть зарегистрированных пользователей бота\n"
message += "\\* /find\\_level _цифра_ — показать всех игроков соответствующего уровня. Учитываются профили за 72 часа\n"
message += "\\* /find\\_user _строка_ — найти игрока в боте по его нику или имени. Ник ищется без собачки в начале\n" message += "\\* /find\\_user _строка_ — найти игрока в боте по его нику или имени. Ник ищется без собачки в начале\n"
} }
message += "\\* /help выводит данное сообщение\n" message += "\\* /help выводит данное сообщение\n"

View File

@ -79,6 +79,19 @@ func (u *Users) ForeignProfileMessage(update *tgbotapi.Update) string {
return u.ProfileMessage(update, &playerRaw) return u.ProfileMessage(update, &playerRaw)
} }
// ProfileAddEffectsMesage 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 // ProfileMessage shows current player's profile
func (u *Users) ProfileMessage(update *tgbotapi.Update, playerRaw *dbmapping.Player) string { func (u *Users) ProfileMessage(update *tgbotapi.Update, playerRaw *dbmapping.Player) string {
profileRaw, ok := u.GetProfile(playerRaw.ID) profileRaw, ok := u.GetProfile(playerRaw.ID)

View File

@ -24,6 +24,7 @@ type UsersInterface interface {
FindByName(update *tgbotapi.Update) string FindByName(update *tgbotapi.Update) string
ForeignProfileMessage(update *tgbotapi.Update) string ForeignProfileMessage(update *tgbotapi.Update) string
FormatUsername(userName string) string FormatUsername(userName string) string
ProfileAddEffectsMessage(update *tgbotapi.Update) string
ProfileMessage(update *tgbotapi.Update, playerRaw *dbmapping.Player) string ProfileMessage(update *tgbotapi.Update, playerRaw *dbmapping.Player) string
UsersList(update *tgbotapi.Update) string UsersList(update *tgbotapi.Update) string
} }