Beispiel #1
0
        public bool CanEnterGroup(Guid userId, bool isPlatformAdmin = false)
        {
            // Platform admins can always enter all groups
            if (isPlatformAdmin)
            {
                return(true);
            }

            // Open groups can be entered by everyone
            if (GroupType == GroupType.Open)
            {
                return(true);
            }

            // Hidden and private groups by admins and users of that group and platform admins
            if (GroupType == GroupType.Hidden || GroupType == GroupType.Private)
            {
                if (AdminIds != null && AdminIds.Contains(userId))
                {
                    return(true);
                }
                if (UserIds != null && UserIds.Contains(userId))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #2
0
        public bool IsAdmin(Guid userId, bool isPlatformAdmin = false)
        {
            // Platform admins can always enter all groups
            if (isPlatformAdmin)
            {
                return(true);
            }

            if (AdminIds != null && AdminIds.Contains(userId))
            {
                return(true);
            }



            return(false);
        }
Beispiel #3
0
        /// <summary>
        /// Ответ бота на сообщение пользователя
        /// </summary>
        /// <param name="message">Сообщение пользователя</param>
        private void MessageResponse(Message message)
        {
            var command = message.Text.ToLower();
            var userId  = message.FromId.Value;

            if (!AllUserSessions.ContainsKey(userId))
            {
                AllUserSessions.Add(userId, new UserSession(userId, this));
            }
            if ((command == "таблица" || command == "принять" || command == "отклонить") &&
                !AdminIds.Contains(userId))
            {
                command = "unknown";
            }
            if (!CommandsPhrases.Commands.ContainsKey(command))
            {
                command = "unknown";
            }
            CommandsPhrases.CommandsActions[CommandsPhrases.Commands[command]].Invoke(this, message);
        }