Beispiel #1
0
        public StatusData GetRandom()
        {
            StatusData d = null;

            if (false /*random.Next(2) == 0*/) // Random Status!
            {
                ConnectorData connector = randomData.connectors[random.Next(randomData.connectors.Count)];

                d         = new StatusData();
                d.emoji   = "robot";
                d.message = Helper.GetRandomSentence(connector, randomData);
                Console.WriteLine(d.message);
            }
            else // Normal status
            {
                while (d == null || d == current)
                {
                    d = data[random.Next(data.Count)];
                }
            }

            return(d);
        }
Beispiel #2
0
        public void Start()
        {
            // Load the authorization token
            if (!File.Exists("token.txt"))
            {
                Console.WriteLine("token file does not exist!");
                return;
            }

            string[] tokenLines = File.ReadAllLines("token.txt");
            authorization = tokenLines[0];

            ParseSetMessage();
            ParseRandomMessage();
            ParseSetDayMessage();

            var start    = TimeSpan.Zero;
            var interval = TimeSpan.FromSeconds(1800); //1800

            Console.WriteLine("Starting worker.");
            worker = new Timer((e) =>
            {
                StatusData checkDay = CheckDayStatus();
                bool result;
                if (checkDay != null)
                {
                    result = Call(checkDay.message, checkDay.emoji).Result;
                }
                else
                {
                    StatusData sd = GetRandom();
                    //Console.WriteLine($"{sd.message} and {sd.emoji}");
                    result = Call(sd.message, sd.emoji).Result;
                }
            }, null, start, interval);
        }