Beispiel #1
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));
        }
Beispiel #2
0
 private static string GetPrediction(Random rnd)
 {
     try
     {
         var path = "Local/predictions.txt";
         return(BotHandler.GetRandomLineFromFile(rnd, path));
     }
     catch (Exception e)
     {
         return(e.Message);
     }
 }
Beispiel #3
0
 private static string GetPrediction(Random rnd, int count)
 {
     try
     {
         var path = "Local/emodzy.txt";
         return(string.Join(' ', BotHandler.GetRandomLineFromFile(rnd, path, count)));
     }
     catch (Exception e)
     {
         return(e.Message);
     }
 }
Beispiel #4
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));
        }
Beispiel #5
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);
        }