Beispiel #1
0
        private void BotOnMessage(object sender, Telegram.Bot.Args.MessageEventArgs e)
        {
            if (string.IsNullOrEmpty(e.Message.Text))
            {
                return;
            }

            var text = e.Message.Text.ToLower();

            if (text == "/мошна")
            {
                var reply = e.Message.ReplyToMessage;
                if (reply != null && reply.Text != "/мошна")
                {
                    this.sentimentService.AddToData(reply.Text, true);
                }
            }
            else if (text == "/немошна")
            {
                var reply = e.Message.ReplyToMessage;
                if (reply != null && reply.Text != "/немошна")
                {
                    this.sentimentService.AddToData(reply.Text, false);
                }
            }
            else if (text.StartsWith("/science"))
            {
                var values = text.Split(' ');
                try
                {
                    var science = int.Parse(values[1]);
                    var turn    = int.Parse(values[2]);
                    var result  = CivCalculator.CalculateCityResultsForScienceAndTurn(science, turn);
                    this.botClient.SendTextMessageAsync(e.Message.Chat, result.ToString()).Wait();
                }
                catch
                {
                    // ignored
                }
            }
            else
            {
                var isMoshna = this.sentimentService.IsMoshna(text);
                if (isMoshna)
                {
                    this.botClient.SendTextMessageAsync(e.Message.Chat, $"{e.Message.From.Username}, МОШНА!!!").Wait();
                }
            }
        }
 public void CalculateForSingleTown()
 {
     var results = CivCalculator.CalculateCityResultsForScienceAndTurn(100, 60);
 }
Beispiel #3
0
        private async void BotOnMessage(object sender, MessageEventArgs e)
        {
            var message = e.Message;

            if (string.IsNullOrEmpty(message.Text))
            {
                return;
            }

            var text = message.Text.ToLower();

            if (text == "/мошна")
            {
                var reply = message.ReplyToMessage;
                if (reply != null && reply.Text != "/мошна")
                {
                    sentimentService.AddToData(reply.Text, true);
                }
            }
            else if (text == "/немошна")
            {
                var reply = message.ReplyToMessage;
                if (reply != null && reply.Text != "/немошна")
                {
                    sentimentService.AddToData(reply.Text, false);
                }
            }
            else if (text.StartsWith("/science"))
            {
                var values = text.Split(' ');
                try
                {
                    var science = int.Parse(values[1]);
                    var turn    = int.Parse(values[2]);
                    var result  = CivCalculator.CalculateCityResultsForScienceAndTurn(science, turn);
                    await botClient.SendTextMessageAsync(message.Chat, result.ToString());
                }
                catch
                {
                    // ignored
                }
            }
            else if (text.StartsWith("/флуд_полная_статистика"))
            {
                var userStatistics = await statisticWrapper.GetTotalOrderedStatisticsAsync(message.Chat.Id);
                await SendStatistics(userStatistics, message);
            }
            else if (text.StartsWith("/флуд"))
            {
                var userStatistics = await statisticWrapper.GetTodayOrderedStatisticsAsync(message.Chat.Id);
                await SendStatistics(userStatistics, message);
            }
            else if (text.StartsWith("/опрос"))
            {
                // var poll = await this.botClient.SendPollAsync(message.Chat.Id, "Srabotaet?", new[] { "Да", "Нет" }, isAnonymous: false);
            }
            else
            {
                await statisticWrapper.ProcessMessageAsync(message);

                // turn off moshna checking
                return;

                var isMoshna = sentimentService.IsMoshna(text);
                if (isMoshna)
                {
                    await botClient.SendTextMessageAsync(message.Chat, $"{message.From.Username}, МОШНА!!!");
                }
            }
        }