Example #1
0
        protected override void OnProcessMessage(VkApi vkApi, Message message, string[] sentence)
        {
            try
            {
                if (message.FromId != null &&
                    vkApi.Users.Get(new[] { message.FromId.Value }, ProfileFields.Sex)[0].Sex ==
                    Sex.Male)
                {
                    BotHandler.SendMessage(vkApi, message.PeerId,
                                           new Random().NextDouble() > 0.5
                            ? "У вас нет бибасиков у только вас биба"
                            : "Бибасики только для девушек, у вас только биба");
                    return;
                }
            }
            catch (Exception)
            {
                // ignored
            }

            var rnd = new Random(BotHandler.GetDayUserSeed(message.FromId));

            var    length       = (float)rnd.NextDouble();
            double resultLenght = 80 + Math.Tan(0.5 * Math.PI * (2 * length - 1));

            BotHandler.SendMessage(vkApi, message.PeerId, $"Сегодня ваши бибасики {resultLenght:F1} см в обхвате");
        }
Example #2
0
        protected override void OnProcessMessage(VkApi vkApi, Message message, string[] sentence)
        {
            var rnd    = new Random();
            int result = rnd.Next();

            BotHandler.SendMessage(vkApi, message.PeerId, result % 2 == 0 ? "Успех" : "Провал");
        }
Example #3
0
        protected override void OnProcessMessage(VkApi vkApi, Message message, string[] sentence)
        {
            string[] dices = sentence[1].Split('d');
            if (!int.TryParse(dices[0], out int diceCount))
            {
                return;
            }
            if (!int.TryParse(dices[1], out int diceValue))
            {
                return;
            }
            if (diceValue < 0 || diceCount < 0)
            {
                return;
            }

            var modificator = 0;

            if (sentence.Length >= 3)
            {
                int.TryParse(sentence[2], out modificator);
            }

            var rnd = new Random();

            var result = 0;

            for (var i = 0; i < diceCount; i++)
            {
                result += rnd.Next(0, diceValue) + 1;
            }

            BotHandler.SendMessage(vkApi, message.PeerId, $"Выпало {result} + {modificator} = {result + modificator}");
        }
Example #4
0
        protected override void OnProcessMessage(VkApi vkApi, Message message, string[] sentence)
        {
            var path   = "Local/wisdom.txt";
            var random = new Random();

            BotHandler.SendMessage(vkApi, message.PeerId, BotHandler.GetRandomLineFromFile(random, path));
        }
Example #5
0
        protected override void OnProcessMessage(VkApi vkApi, Message message, string[] sentence)
        {
            List <string> names;

            try
            {
                names = vkApi.Messages.GetConversationMembers(message.PeerId.Value, new[] { "" })
                        .Profiles
                        .Select(user => $"{user.FirstName} {user.LastName}")
                        .ToList();
            }
            catch (ConversationAccessDeniedException)
            {
                BotHandler.SendMessage(vkApi, message.PeerId,
                                       "Для вывода случайного статуса участника, боту необходимы права администратора");
                return;
            }

            string question        = message.Text.Substring(sentence[0].Length).TrimStart().TrimEnd("?!".ToCharArray());
            var    rnd             = new Random(question.ToLower().GetHashCode());
            int    result          = rnd.Next(0, names.Count());
            double chanceOfNothing = rnd.NextDouble();
            var    answer          = $"{(chanceOfNothing > 0.9 ? "Никто не" : names[result])} {question}";

            BotHandler.SendMessage(vkApi, message.PeerId, answer);
        }
Example #6
0
        protected override void OnProcessMessage(VkApi vkApi, Message message, string[] sentence)
        {
            string answer = string.Join('\n',
                                        _processors.Where(processor => processor.VisiblyDescription)
                                        .Select(processor => $"{processor.Name}\n{processor.Description}\n")
                                        );

            BotHandler.SendMessage(vkApi, message.PeerId, answer);
        }
Example #7
0
        protected override void OnProcessMessage(VkApi vkApi, Message message, string[] sentence)
        {
            var rnd = new Random(BotHandler.GetDayUserSeed(message.FromId));


            var stringBuilder = new StringBuilder($"Сегодня вас ждет {GetPrediction(rnd, rnd.Next(3, 6))}");

            BotHandler.SendMessage(vkApi, message.PeerId, stringBuilder.ToString());
        }
Example #8
0
        protected override void OnProcessMessage(VkApi vkApi, Message message, string[] sentence)
        {
            var rnd = new Random(BotHandler.GetDayUserSeed(message.FromId));


            int predictionLength = (int)Math.Abs(15 + Math.Tan(0.5 * Math.PI * Math.Pow(2 * rnd.NextDouble() - 1, 5)));
            var stringBuilder    = new StringBuilder($"Мудрец видит что в будущем будет {GetPrediction(rnd, predictionLength)}");

            BotHandler.SendMessage(vkApi, message.PeerId, stringBuilder.ToString());
        }
Example #9
0
        protected override void OnProcessMessage(VkApi vkApi, Message message, string[] sentence)
        {
            var path = "Local/8.txt";

            int seed = new Random().Next(int.MinValue, int.MaxValue);

            if (sentence.Length > 1)
            {
                seed = BotHandler.GetDayUserSeed(message.PeerId) + message.Text.GetHashCode();
            }

            BotHandler.SendMessage(vkApi, message.PeerId, BotHandler.GetRandomLineFromFile(new Random(seed), path));
        }
Example #10
0
        protected override void OnProcessMessage(VkApi vkApi, Message message, string[] sentence)
        {
            var           path   = "Local/wisdom.txt";
            var           random = sentence.Length > 1 ? new Random(message.Text.GetHashCode()) : new Random();
            List <string> lines  = BotHandler.GetRandomLineFromFile(random, path, random.Next(2, 5));
            string        line   = string.Join(" ", lines);
            var           words  = line.Split(' ').OrderBy(s => random.Next()).ToList();

            int    randomWordCount = random.Next(3, words.Count);
            int    clampedCount    = Math.Clamp(randomWordCount, 0, words.Count);
            string answer          = string.Join(' ', words.Take(clampedCount).ToArray());

            BotHandler.SendMessage(vkApi, message.PeerId, answer);
        }
Example #11
0
        protected override void OnProcessMessage(VkApi vkApi, Message message, string[] sentence)
        {
            var    rnd               = new Random(BotHandler.GetDayUserSeed(message.FromId));
            int    pages             = rnd.Next(-3, 130);
            double originality       = rnd.Next(0, 100) + Math.Round(rnd.NextDouble(), 2);
            double chanceOfSurrender = rnd.Next(0, 100) + Math.Round(rnd.NextDouble(), 2);
            string prediction        = GetPrediction(rnd);

            string result = $"[id{message.FromId}|Ваш] диплом состоит из {pages} страниц(ы) , \n" +
                            $"текущая оригинальность {originality}%, \n" +
                            $"шанс сдать = {chanceOfSurrender}%\n" +
                            $"Предсказание к диплому: {prediction}";

            BotHandler.SendMessage(vkApi, message.PeerId, result);
        }
Example #12
0
        protected override void OnProcessMessage(VkApi vkApi, Message message, string[] sentence)
        {
            var  rnd      = new Random(BotHandler.GetDayUserSeed(message.FromId));
            bool maleBiba = rnd.NextDouble() < 0.46f;

            var    length       = (float)rnd.NextDouble();
            double resultLenght = maleBiba
                ? 15 + Math.Tan(0.5 * Math.PI * (2 * length - 1))
                : -4 + Math.Tan(0.5 * Math.PI * (2 * length - 1));

            var    diameter       = (float)rnd.NextDouble();
            double resultDiameter = 30 + Math.Tan(0.5 * Math.PI * Math.Pow(2 * diameter - 1, 1));

            BotHandler.SendMessage(vkApi, message.PeerId,
                                   $"Сегодня ваша биба ({(maleBiba ? "male" : "female")}) длиной {resultLenght:F2} см и диаметром {resultDiameter:F2} мм");
        }
Example #13
0
        protected override void OnProcessMessage(VkApi vkApi, Message message, string[] sentence)
        {
            List <string> statuses;

            try
            {
                statuses = vkApi.Messages.GetConversationMembers(message.PeerId.Value, new[] { "status" })
                           .Profiles
                           .Where(p => !string.IsNullOrEmpty(p.Status))
                           .Select(p => p.Status)
                           .ToList();
            }
            catch (ConversationAccessDeniedException)
            {
                BotHandler.SendMessage(vkApi, message.PeerId,
                                       "Для вывода случайного статуса участника, боту необходимы права администратора");
                return;
            }

            var rnd    = new Random();
            int result = rnd.Next(0, statuses.Count());

            BotHandler.SendMessage(vkApi, message.PeerId, statuses[result]);
        }
Example #14
0
 protected override void OnProcessMessage(VkApi vkApi, Message message, string[] sentence)
 {
     BotHandler.SendMessage(vkApi, message.PeerId, "Пизда");
 }
Example #15
0
 protected override void OnProcessMessage(VkApi vkApi, Message message, string[] sentence)
 {
     BotHandler.SendMessage(vkApi, message.PeerId, "Император сказал спать");
     Program.Shutdown();
 }