public async Task SendNewQuestion()
        {
            var randomNumber = new Random().Next(0, 5);
            var chatIdList   = await _requestHistoryRepository.GetChatIdListAsync();

            var words = await _wordRepository.GetAnyWordsAsync(count : 5);

            var questionWord = words.ToList()[randomNumber];

            var question = $"Which translation is correct? 🤔 *{questionWord.En}*";

            var options = words.Select(word => word.Tr);

            foreach (var chatId in chatIdList)
            {
                try
                {
                    await _telegramBotClient.SendPollAsync(chatId, question, options, type : PollType.Quiz, isAnonymous : false, correctOptionId : randomNumber);
                }
                catch
                {
                    System.Console.WriteLine($"{chatId} blocked me! :((");
                }
            }
        }
예제 #2
0
        public async Task ExecuteAsync(Message message)
        {
            await _telegramBotClient.SendChatActionAsync(message.Chat.Id, ChatAction.Typing);

            var randomNumber = new Random().Next(0, 5);

            var words = await _wordRepository.GetAnyWordsAsync(count : 5);

            var questionWord = words.ToList()[randomNumber];

            var question = $"Which translation is correct? 🤔 *{questionWord.En}*";

            var options = words.Select(word => word.Tr);

            try
            {
                await _telegramBotClient.SendPollAsync(message.Chat.Id, question, options, type : PollType.Quiz, isAnonymous : false, correctOptionId : randomNumber);
            }
            catch
            {
                System.Console.WriteLine($"{message.Chat.Id} blocked me! :((");
            }
        }