public void Handle(string input)
        {
            Request.SetContext(input);
            MattermostMessage ret = new MattermostMessage();

            Random rnd = new Random((int)DateTime.Now.Ticks);
            string list;

            list = Request.Form["text"] ?? "nothing";
            List <string> vals = new List <string>(list.Split(','));

            int val0 = rnd.Next(0, vals.Count);

            ret.text  = String.Format("From the options: {0}", list);
            ret.text += String.Format("\nI pick for you: **{0}**", vals[val0].Trim());

            Console.WriteLine(JsonConvert.SerializeObject(ret));
        }
Beispiel #2
0
        public void Handle(string input)
        {
            int totalThrows          = 5;
            MattermostMessage ret    = new MattermostMessage();
            Random            rnd    = new Random((int)DateTime.Now.Ticks);
            List <string>     throws = new List <string>();

            for (int cni = 0; cni < totalThrows; cni++)
            {
                throws.Add(rnd.Next(100) < 50?"Tails":"Heads");
            }
            for (int pni = 0; pni < throws.Count; pni++)
            {
                ret.text += String.Format("Flip {0} is: {1}\n", pni + 1, throws[pni]);
            }
            ret.text += String.Format("\n**{0} wins!**", throws.Count(it => it == "Tails") > totalThrows / 2?"Tails":"Heads");
            Console.WriteLine(JsonConvert.SerializeObject(ret));
        }
Beispiel #3
0
        public void Handle(string input)
        {
            Request.SetContext(input);

            Dictionary <string, List <string> > responses = new Dictionary <string, List <string> >();

            responses.Add("greets", new List <string> {
                "Hello {0}! Welcome to {1}", "Hey {0}! What brings you to {1}?", "This is {1}. We've been expecting you {0}", "Sup {0}?", "Mi casa ({1}) es su casa {0}", "The people of {1} greet you {0}", "Welcome to Walmart... \\*ahem\\* I mean {1}.", "Top of the morning!", "Good day to you sir!..or madam? I really don't know what you are {0}", "Hola {0}", "Salutations!", "Aloha!"
            });
            responses.Add("laughs", new List <string> {
                "hahaha!", "LOL that's funny", "jajajajaja siii", "ROFL", "haha good one", "That's really funny {0}"
            });
            responses.Add("questions", new List <string>      {
                "What?", "How? I don't know...", "Why?", "When?", "That is the question {0}!", "IDK", "Hmmm", "Wait! What?"
            });
            responses.Add("thanks", new List <string> {
                "You're welcome", "No problem", "De nada", "Don't mention it", "No, thank you!", "You thank me, I thank you. It's a thank you loop", "You got it!"
            });
            responses.Add("rude", new List <string>   {
                "You shut up!", "Me?", "What? what? what?", "Whatever", "Sureeeee", "I don't remember anyone asking your opinion", "I have better things to do than listening to you", "Talk to the hand!", "Bless your heart!", "If I had eyes, I will be rolling them right now", "No wonder everyone talks behind your back", "Woah! Do you hear that? That's the sound of me not caring", "Surprise me. Say something intelligent.", "I'm busy. Go away.", "Sorry, I don't speak whatever language that is.", "Not too many people like you, do they?", "K.", "Awww! Are you having a bad day?"
            });
            responses.Add("bye", new List <string>    {
                "Byeee!", "Bye bye!", "Toodles!", "See you later alligator!", "Hasta la vista!", "You'll be back", "Goodbye!", "Have a good day {0}", "Adios!", "Ciao!", "Au revoir!", "Ta-ta!", "Take it easy", "Aloha!", "Farewell", "Later!", "Until next time", "Goodnight"
            });
            string type = (Request.QueryString["type"] ?? "greets").ToLower();

            if (!responses.ContainsKey(type))
            {
                type = "greets";
            }
            Random            rnd = new Random((int)DateTime.Now.Ticks);
            int               pos = rnd.Next(0, responses[type].Count);
            MattermostMessage ret = new MattermostMessage {
                text = String.Format(responses[type][pos], Request.Form["user_name"], Request.Form["channel_name"])
            };

            Console.WriteLine(JsonConvert.SerializeObject(ret));
        }