public async Task HandleUpdate(Update update)
        {
            var chatId     = update.Message.Chat.Id;
            var userId     = update.Message.From.Id;
            var text       = update.Message.Text ?? update.Message.Caption;
            var wordsCount = WordCounterUtil.CountWords(text);
            var currDate   = update.Message.Date.Date;

            await _counterDao.UpdateElseCreateCounter(
                chatId,
                userId,
                wordsCount);

            await _counterDatedDao.UpdateElseCreateCounter(
                chatId,
                userId,
                currDate,
                wordsCount);
        }
Ejemplo n.º 2
0
        public async Task HandleUpdate(Update update)
        {
            var chatId     = update.Message.Chat.Id;
            var msgId      = update.Message.From.Id;
            var wordsCount = WordCounterUtil.CountWords(update.Message.Text);

            if (await _counterDao.CheckCounter(chatId, msgId))
            {
                await _counterDao.IncrementCounter(
                    chatId,
                    msgId,
                    wordsCount);
            }
            else
            {
                await _counterDao.AddCounter(
                    chatId,
                    msgId,
                    wordsCount);
            }
        }
        public void Test()
        {
            var text = "Красная собака поймала синюю (лису) ( ).\n The red dog catched a blue fox.";

            Assert.Equal(12, WordCounterUtil.CountWords(text));
        }