Added "banned" status for players
This commit is contained in:
parent
7368c58e2d
commit
4660d02a32
@ -16,6 +16,10 @@ func (r *Router) RouteCallback(update *tgbotapi.Update) string {
|
||||
return "fail"
|
||||
}
|
||||
|
||||
if playerRaw.Status == "banned" {
|
||||
return c.Talkers.BanError(update)
|
||||
}
|
||||
|
||||
var enableAlarmCallback = regexp.MustCompile("enable_reminder_(\\d+)\\z")
|
||||
var disableAlarmCallback = regexp.MustCompile("disable_reminder_(\\d+)\\z")
|
||||
|
||||
|
@ -19,7 +19,7 @@ func (r *Router) RouteInline(update *tgbotapi.Update) string {
|
||||
|
||||
results := make([]interface{}, 0)
|
||||
|
||||
if playerRaw.LeagueID != 1 {
|
||||
if (playerRaw.LeagueID != 1) || (playerRaw.Status == "banned") {
|
||||
article := tgbotapi.NewInlineQueryResultArticle("0", "Команда боту @PokememBroBot:", "👤Герой")
|
||||
article.Description = "👤Герой"
|
||||
|
||||
|
@ -20,6 +20,10 @@ func (r *Router) routePrivateRequest(update *tgbotapi.Update, playerRaw *dbmappi
|
||||
var squadInfoMsg = regexp.MustCompile("/show_squad(\\d+)\\z")
|
||||
var orderSendMsg = regexp.MustCompile("/send_order(\\d+)\\z")
|
||||
|
||||
if playerRaw.Status == "banned" {
|
||||
return c.Talkers.BanError(update)
|
||||
}
|
||||
|
||||
if update.Message.ForwardFrom != nil {
|
||||
if update.Message.ForwardFrom.ID != 360402625 {
|
||||
c.Log.Info("Forward from another user or bot. Ignoring")
|
||||
|
@ -20,6 +20,18 @@ func (t *Talkers) AnyMessageUnauthorized(update *tgbotapi.Update) string {
|
||||
return "fail"
|
||||
}
|
||||
|
||||
// BanError throws error for persona non grata
|
||||
func (t *Talkers) BanError(update *tgbotapi.Update) string {
|
||||
message := "Вам здесь не рады. Использование бота для вас запрещено."
|
||||
|
||||
msg := tgbotapi.NewMessage(update.Message.Chat.ID, message)
|
||||
msg.ParseMode = "Markdown"
|
||||
|
||||
c.Bot.Send(msg)
|
||||
|
||||
return "fail"
|
||||
}
|
||||
|
||||
// BotError throws when bot can't do something
|
||||
func (t *Talkers) BotError(update *tgbotapi.Update) string {
|
||||
message := "Ой, внутренняя ошибка в боте :(\n\n"
|
||||
|
@ -4,8 +4,8 @@
|
||||
package talkersinterface
|
||||
|
||||
import (
|
||||
"github.com/go-telegram-bot-api/telegram-bot-api"
|
||||
"git.wtfteam.pro/fat0troll/i2_bot/lib/dbmapping"
|
||||
"github.com/go-telegram-bot-api/telegram-bot-api"
|
||||
)
|
||||
|
||||
// TalkersInterface implements Talkers for importing via appcontex
|
||||
@ -18,6 +18,7 @@ type TalkersInterface interface {
|
||||
FiveOffer(update *tgbotapi.Update) string
|
||||
|
||||
AnyMessageUnauthorized(update *tgbotapi.Update) string
|
||||
BanError(update *tgbotapi.Update) string
|
||||
BotError(update *tgbotapi.Update) string
|
||||
|
||||
LongMessage(update *tgbotapi.Update) string
|
||||
|
Reference in New Issue
Block a user