Example #1
0
        private static bool CheckSession(long chatId)
        {
            bool isExist = IsUserExists(chatId);

            if (isExist)
            {
                bool isBlock = IsUserBlock(chatId);
                if (!isBlock)
                {
                    bool IsSessionExists = LoginInBot.CheckSession(chatId);
                    if (!IsSessionExists)
                    {
                        client.SendTextMessageAsync(chatId, "Your session is over!", replyMarkup: new ReplyKeyboardRemove()).Wait();
                    }
                    return(IsSessionExists);
                }
            }
            return(false);
        }
Example #2
0
        private async static void BotOnMessageReceived(object sender, MessageEventArgs e)
        {
            try
            {
                CommandEvents[e.Message.Text](sender, e);
            }
            catch (KeyNotFoundException)
            {
                if (RegistrationInBot.IsRegistrationCommand)
                {
                    await RegistrationInBot.RegistrationConfirmed(sender, e);

                    await LoginInBot.LoginConfirmed(sender, e);

                    return;
                }

                if (LoginInBot.IsLoginCommand)
                {
                    await LoginInBot.LoginConfirmed(sender, e);

                    return;
                }
                var chatId = e.Message.Chat.Id;
                var user   = GetUser(u => u.Id == e.Message.From.Id);


                InformUserAboutBlock(chatId);

                bool IsSessionExists = CheckSession(chatId);
                if (IsSessionExists)
                {
                    await client.SendTextMessageAsync(e.Message.Chat.Id, "Not found this command");
                }
            }
            catch (ArgumentNullException)
            {
                SendInfo(e.Message.Chat.Id, e);
            }
        }