Add games chat
Games chat used to divide talks in Bastion from @gamee games and so on.
This commit is contained in:
parent
af525b207f
commit
f67e652ae4
@ -13,5 +13,6 @@ special_chats:
|
||||
bastion_id: "group_id"
|
||||
default_id: "group_id"
|
||||
headquarters_id: "group_id"
|
||||
games_id: "group_id"
|
||||
logs:
|
||||
log_path: "./i2_bot.log"
|
||||
|
@ -1,11 +1,12 @@
|
||||
// i2_bot – Instinct PokememBro Bot
|
||||
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
|
||||
// Copyright (c) 2017-2018 Vladimir "fat0troll" Hodakov
|
||||
|
||||
package chatter
|
||||
|
||||
import (
|
||||
"github.com/go-telegram-bot-api/telegram-bot-api"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-telegram-bot-api/telegram-bot-api"
|
||||
)
|
||||
|
||||
// GroupsList lists all chats where bot exist
|
||||
@ -16,6 +17,7 @@ func (ct *Chatter) GroupsList(update *tgbotapi.Update) string {
|
||||
bastionChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.BastionID, 10, 64)
|
||||
defaultChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.DefaultID, 10, 64)
|
||||
hqChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.HeadquartersID, 10, 64)
|
||||
gamesChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.GamesID, 10, 64)
|
||||
|
||||
message := "*Бот состоит в следующих групповых чатах:*\n"
|
||||
|
||||
@ -42,6 +44,10 @@ func (ct *Chatter) GroupsList(update *tgbotapi.Update) string {
|
||||
if groupChats[i].TelegramID == hqChatID {
|
||||
message += "Является чатом совета лиги\n"
|
||||
}
|
||||
|
||||
if groupChats[i].TelegramID == gamesChatID {
|
||||
message += "Является игровым чатом\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// i2_bot – Instinct PokememBro Bot
|
||||
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
|
||||
// Copyright (c) 2017-2018 Vladimir "fat0troll" Hodakov
|
||||
|
||||
package chatter
|
||||
|
||||
@ -17,6 +17,7 @@ func (ct *Chatter) userPrivilegesCheck(update *tgbotapi.Update, user *tgbotapi.U
|
||||
bastionChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.BastionID, 10, 64)
|
||||
academyChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.AcademyID, 10, 64)
|
||||
hqChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.HeadquartersID, 10, 64)
|
||||
gamesChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.GamesID, 10, 64)
|
||||
|
||||
if update.Message.Chat.ID == defaultChatID || update.Message.Chat.ID == hqChatID {
|
||||
return true
|
||||
@ -32,6 +33,10 @@ func (ct *Chatter) userPrivilegesCheck(update *tgbotapi.Update, user *tgbotapi.U
|
||||
}
|
||||
}
|
||||
|
||||
if update.Message.Chat.ID == gamesChatID && strings.Contains(user.UserName, "bot") {
|
||||
return true
|
||||
}
|
||||
|
||||
playerRaw, err := c.DataCache.GetPlayerByTelegramID(user.ID)
|
||||
if err != nil {
|
||||
c.Log.Error(err.Error())
|
||||
@ -44,11 +49,7 @@ func (ct *Chatter) userPrivilegesCheck(update *tgbotapi.Update, user *tgbotapi.U
|
||||
|
||||
// So, user is not a PokememBro admin. For Bastion and Academy she needs to be league player
|
||||
switch update.Message.Chat.ID {
|
||||
case academyChatID:
|
||||
if playerRaw.LeagueID == 1 && playerRaw.Status != "spy" && playerRaw.Status != "league_changed" && playerRaw.Status != "banned" {
|
||||
return true
|
||||
}
|
||||
case bastionChatID:
|
||||
case academyChatID, bastionChatID, gamesChatID:
|
||||
if playerRaw.LeagueID == 1 && playerRaw.Status != "spy" && playerRaw.Status != "league_changed" && playerRaw.Status != "banned" {
|
||||
return true
|
||||
}
|
||||
|
@ -1,17 +1,18 @@
|
||||
// i2_bot – Instinct PokememBro Bot
|
||||
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
|
||||
// Copyright (c) 2017-2018 Vladimir "fat0troll" Hodakov
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"bitbucket.org/pztrn/mogrus"
|
||||
"gopkg.in/yaml.v2"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
|
||||
"bitbucket.org/pztrn/mogrus"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// VERSION is the current bot's version
|
||||
const VERSION = "0.7.2"
|
||||
const VERSION = "0.7.4"
|
||||
|
||||
// DatabaseConnection handles database connection settings in config.yaml
|
||||
type DatabaseConnection struct {
|
||||
@ -35,6 +36,7 @@ type SpecialChats struct {
|
||||
BastionID string `yaml:"bastion_id"`
|
||||
DefaultID string `yaml:"default_id"`
|
||||
HeadquartersID string `yaml:"headquarters_id"`
|
||||
GamesID string `yaml:"games_id"`
|
||||
}
|
||||
|
||||
// LoggingConfig handles log file configuration
|
||||
|
Reference in New Issue
Block a user