Skip to content

Commit

Permalink
add new logs for error in admincache
Browse files Browse the repository at this point in the history
  • Loading branch information
Divkix committed Aug 4, 2024
1 parent 70c7013 commit e26fbdb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Alita_Robot
Alita_Robot.exe
.env
.db.env
local.docker-compose.yml

# Mac OS DS_Store file
.DS_Store
16 changes: 14 additions & 2 deletions alita/utils/cache/adminCache.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,22 @@ import (

// LoadAdminCache loads the admin cache for the chat.
func LoadAdminCache(b *gotgbot.Bot, chat *gotgbot.Chat) AdminCache {
if b == nil {
log.Error("LoadAdminCache: bot is nil")
return AdminCache{}
}
if chat == nil {
log.Error("LoadAdminCache: chat is nil")
return AdminCache{}
}

adminList, err := chat.GetAdministrators(b, nil)
if err != nil {
log.Error(err)
return AdminCache{}
}

var userList []gotgbot.MergedChatMember

for _, admin := range adminList {
userList = append(userList, admin.MergeChatMember())
}
Expand Down Expand Up @@ -45,13 +53,17 @@ func LoadAdminCache(b *gotgbot.Bot, chat *gotgbot.Chat) AdminCache {

// GetAdminCacheList gets the admin cache for the chat.
func GetAdminCacheList(chatId int64) (bool, AdminCache) {
gotAdminlist, _ := Marshal.Get(
gotAdminlist, err := Marshal.Get(
Context,
AdminCache{
ChatId: chatId,
},
new(AdminCache),
)
if err != nil {
log.Error(err)
return false, AdminCache{}
}
if gotAdminlist == nil {
return false, AdminCache{}
}
Expand Down

0 comments on commit e26fbdb

Please sign in to comment.