Pass game admins to our chats. Easter egg chance generation.
This commit is contained in:
parent
200a7d14ea
commit
9d21ebd44b
@ -6,6 +6,7 @@ package router
|
|||||||
import (
|
import (
|
||||||
"github.com/go-telegram-bot-api/telegram-bot-api"
|
"github.com/go-telegram-bot-api/telegram-bot-api"
|
||||||
"lab.pztrn.name/fat0troll/i2_bot/lib/dbmapping"
|
"lab.pztrn.name/fat0troll/i2_bot/lib/dbmapping"
|
||||||
|
"math/rand"
|
||||||
"regexp"
|
"regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ func (r *Router) routeGroupRequest(update *tgbotapi.Update, playerRaw *dbmapping
|
|||||||
// Regular expressions
|
// Regular expressions
|
||||||
var durakMsg = regexp.MustCompile("(Д|д)(У|у)(Р|р)(А|а|Е|е|О|о)")
|
var durakMsg = regexp.MustCompile("(Д|д)(У|у)(Р|р)(А|а|Е|е|О|о)")
|
||||||
var huMsg = regexp.MustCompile("(Х|х)(У|у)(Й|й|Я|я|Ю|ю|Е|е)")
|
var huMsg = regexp.MustCompile("(Х|х)(У|у)(Й|й|Я|я|Ю|ю|Е|е)")
|
||||||
var blMsg = regexp.MustCompile("(\\s|^)(Б|б)(Л|л)(Я|я)(Т|т|Д|д)")
|
var blMsg = regexp.MustCompile("(\\s|^)(Б|б)(Л|л)((Я|я)(Т|т|Д|д)|)")
|
||||||
var ebMsg = regexp.MustCompile("(\\s|^|ЗА|За|зА|за)(Е|е|Ё|ё)(Б|б)(\\s|Л|л|А|а|Т|т|У|у|Е|е|Ё|ё|И|и)")
|
var ebMsg = regexp.MustCompile("(\\s|^|ЗА|За|зА|за)(Е|е|Ё|ё)(Б|б)(\\s|Л|л|А|а|Т|т|У|у|Е|е|Ё|ё|И|и)")
|
||||||
var piMsg = regexp.MustCompile("(П|п)(И|и)(З|з)(Д|д)")
|
var piMsg = regexp.MustCompile("(П|п)(И|и)(З|з)(Д|д)")
|
||||||
|
|
||||||
@ -50,6 +51,9 @@ func (r *Router) routeGroupRequest(update *tgbotapi.Update, playerRaw *dbmapping
|
|||||||
return "fail"
|
return "fail"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// easter eggs
|
||||||
|
trigger := rand.Intn(5)
|
||||||
|
if trigger == 4 {
|
||||||
switch {
|
switch {
|
||||||
case huMsg.MatchString(text):
|
case huMsg.MatchString(text):
|
||||||
c.Talkers.MatMessage(update)
|
c.Talkers.MatMessage(update)
|
||||||
@ -62,6 +66,7 @@ func (r *Router) routeGroupRequest(update *tgbotapi.Update, playerRaw *dbmapping
|
|||||||
case durakMsg.MatchString(text):
|
case durakMsg.MatchString(text):
|
||||||
c.Talkers.DurakMessage(update)
|
c.Talkers.DurakMessage(update)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return "ok"
|
return "ok"
|
||||||
}
|
}
|
||||||
|
@ -465,6 +465,14 @@ func (s *Squader) ProcessMessage(update *tgbotapi.Update, chatRaw *dbmapping.Cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !isChatValid {
|
if !isChatValid {
|
||||||
|
switch newUsers[i].UserName {
|
||||||
|
case "gantz_yaka":
|
||||||
|
messageProcessed = true
|
||||||
|
case "@agentpb":
|
||||||
|
messageProcessed = true
|
||||||
|
case "@pbhelp":
|
||||||
|
messageProcessed = true
|
||||||
|
default:
|
||||||
s.kickUserFromSquadChat(&newUsers[i], chatRaw)
|
s.kickUserFromSquadChat(&newUsers[i], chatRaw)
|
||||||
messageProcessed = true
|
messageProcessed = true
|
||||||
}
|
}
|
||||||
@ -472,6 +480,7 @@ func (s *Squader) ProcessMessage(update *tgbotapi.Update, chatRaw *dbmapping.Cha
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if processMain {
|
if processMain {
|
||||||
c.Log.Debug("Message found in one of squad's main chats.")
|
c.Log.Debug("Message found in one of squad's main chats.")
|
||||||
@ -514,11 +523,46 @@ func (s *Squader) ProtectBastion(update *tgbotapi.Update, newUser *tgbotapi.User
|
|||||||
|
|
||||||
playerRaw, ok := c.Users.GetOrCreatePlayer(newUser.ID)
|
playerRaw, ok := c.Users.GetOrCreatePlayer(newUser.ID)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
switch newUser.UserName {
|
||||||
|
case "gantz_yaka":
|
||||||
|
// do nothing
|
||||||
|
case "@agentpb":
|
||||||
|
// do nothing
|
||||||
|
case "@pbhelp":
|
||||||
|
// do nothing
|
||||||
|
default:
|
||||||
s.kickUserFromSquadChat(newUser, &chatRaw)
|
s.kickUserFromSquadChat(newUser, &chatRaw)
|
||||||
return "fail"
|
return "fail"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if playerRaw.LeagueID != 1 {
|
if playerRaw.LeagueID != 1 {
|
||||||
|
switch newUser.UserName {
|
||||||
|
case "gantz_yaka":
|
||||||
|
message := "Здравствуй, " + newUser.UserName + "!\n"
|
||||||
|
message += "Инстинкт рад приветствовать Бога мира ПокемемБро! Проходите, располагайтесь, чувствуйте себя, как дома.\n"
|
||||||
|
|
||||||
|
msg := tgbotapi.NewMessage(chatRaw.TelegramID, message)
|
||||||
|
msg.ParseMode = "Markdown"
|
||||||
|
|
||||||
|
c.Bot.Send(msg)
|
||||||
|
case "@agentpb":
|
||||||
|
message := "Здравствуй, " + newUser.UserName + "!\n"
|
||||||
|
message += "Инстинкт рад приветствовать одного из богов мира ПокемемБро! Проходите, располагайтесь, чувствуйте себя, как дома.\n"
|
||||||
|
|
||||||
|
msg := tgbotapi.NewMessage(chatRaw.TelegramID, message)
|
||||||
|
msg.ParseMode = "Markdown"
|
||||||
|
|
||||||
|
c.Bot.Send(msg)
|
||||||
|
case "@pbhelp":
|
||||||
|
message := "Здравствуй, " + newUser.UserName + "!\n"
|
||||||
|
message += "Инстинкт рад приветствовать одного из богов мира ПокемемБро! Проходите, располагайтесь, чувствуйте себя, как дома.\n"
|
||||||
|
|
||||||
|
msg := tgbotapi.NewMessage(chatRaw.TelegramID, message)
|
||||||
|
msg.ParseMode = "Markdown"
|
||||||
|
|
||||||
|
c.Bot.Send(msg)
|
||||||
|
default:
|
||||||
// Check for profile
|
// Check for profile
|
||||||
_, profileOK := c.Users.GetProfile(playerRaw.ID)
|
_, profileOK := c.Users.GetProfile(playerRaw.ID)
|
||||||
if !profileOK {
|
if !profileOK {
|
||||||
@ -539,6 +583,7 @@ func (s *Squader) ProtectBastion(update *tgbotapi.Update, newUser *tgbotapi.User
|
|||||||
s.kickUserFromSquadChat(newUser, &chatRaw)
|
s.kickUserFromSquadChat(newUser, &chatRaw)
|
||||||
return "fail"
|
return "fail"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return "ok"
|
return "ok"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user