예제 #1
0
        public static async Task<Message> SendInlineGameKeyboard(ITelegramBotClient botClient, Message message)
        {
            if (!SqLiteHandlers.Users.ContainsKey(message.From.Id))
                SqLiteHandlers.AddUserToDatabaseAsync(message.From.Id, message.From.Username);

            User currentUser = SqLiteHandlers.Users[message.From.Id];
            
            currentUser.NumberOfAttempts = NumberOfAttempts;
            currentUser.ConceivedNumber = (byte)new Random().Next(10);
            SqLiteHandlers.UpdateUserDataAsync(message.From.Id, currentUser);
            
            return await botClient.SendTextMessageAsync(chatId: message.Chat.Id,
                text: "<b><i>Угадай загаданную цыфру от 0 до 9.</i></b>",
                replyMarkup: _inlineGameKeyboard, 
                parseMode: ParseMode.Html);
        }
예제 #2
0
        public static async Task<Message> ShowUserRatings(ITelegramBotClient botClient, Message message)
        {
            SqLiteHandlers.UpdateUserList();
            string rating = "<b>Рейтинг:\n" +
                            $"{"ID", 13} | Баллы</b>\n";

            foreach (var user in SqLiteHandlers.Users.Values)
            {
                if (user.NumberOfWins == 0) break;

                rating += $"<i>{((user.UserName != "") ? user.UserName : "******"), -1}</i> | <i>{user.NumberOfWins}</i>\n";
            }

            return await botClient.SendTextMessageAsync(
                chatId: message.Chat.Id,
                text: rating,
                ParseMode.Html);
        }