hdkv
/
i2_bot
Archived
1
Fork 0

Fixing chats DataCache

master
Vladimir Hodakov 2018-02-17 16:25:50 +04:00
parent 2466a723be
commit 5e4ce71ff8
3 changed files with 5 additions and 2 deletions

View File

@ -22,7 +22,7 @@ func (ct *Chatter) userPrivilegesCheck(update *tgbotapi.Update, user *tgbotapi.U
}
// There are special users, which will bypass these checks
specialUsers := []string{"gantz_yaka", "agentpb", "pbhelp"}
specialUsers := []string{"gantz_yaka", "agentpb", "pbhelp", "i2_bot", "i2_dev_bot"}
for j := range specialUsers {
if strings.ToLower(user.UserName) == specialUsers[j] {

View File

@ -116,13 +116,14 @@ func (dc *DataCache) GetLeaguePrivateChats() []dbmapping.Chat {
// GetOrCreateChat returns current or new Chat object by Telegram update
func (dc *DataCache) GetOrCreateChat(update *tgbotapi.Update) (*dbmapping.Chat, error) {
telegramID := update.Message.From.ID
telegramID := update.Message.Chat.ID
chatRaw := dbmapping.Chat{}
c.Log.Info("DataCache: Getting chat with Telegram ID=", telegramID)
dc.chatsMutex.Lock()
for i := range dc.chats {
if dc.chats[i].TelegramID == int64(telegramID) {
c.Log.Debug("Chat stream found in DataCache")
dc.chatsMutex.Unlock()
return dc.chats[i], nil
}

View File

@ -9,6 +9,7 @@ import (
// RouteRequest decides, what to do with user input
func (r *Router) RouteRequest(update *tgbotapi.Update) string {
c.Log.Debugln(update)
playerRaw, err := c.DataCache.GetOrCreatePlayerByTelegramID(update.Message.From.ID)
if err != nil {
c.Log.Error(err.Error())
@ -16,6 +17,7 @@ func (r *Router) RouteRequest(update *tgbotapi.Update) string {
return "fail"
}
c.Log.Debug("Getting chat...")
chatRaw, err := c.DataCache.GetOrCreateChat(update)
if err != nil {
c.Log.Error(err.Error())