Example #1
0
        /**
         *  This event is called whenever someone, either in a private query
         *  or in a channel, calls up the bot, with any command that matches
         *  this modules synonyms. Any remaining part of the message is then
         *  delivered here along with the room to reply to, and the user who
         *  called it. In order to send out a message back out, then use the
         *  syntax of 'Anxious.Send(<target>, <message>)'. If the message is
         *  supposed to be send in private then insert the user parameter in
         *  the target, else insert the rooms parameter. In the message part
         *  please keep the replies short to avoid sending too much flooding
         */
        public static void OnMessage(string user, string room, string text)
        {
            Match match;

            // -------------------------------------------------------------
            // Permission                                                 {}
            // -------------------------------------------------------------

            if (Permission.IsBlacklisted(user))
            {
                return;
            }

            // -------------------------------------------------------------
            // Die                           {die, dice, roll, rolls, throw}
            // -------------------------------------------------------------

            if ((match = Regex.Match(text, @"^(die|dice|roll|rolls|throw)[\s]*(.*)$", RegexOptions.IgnoreCase)).Success)
            {
                Die.OnMessage
                (
                    user,
                    room,
                    match.Groups[2].Value
                );

                return;
            }

            // -------------------------------------------------------------
            // Remind                           {remind, inform, notify, ps}
            // -------------------------------------------------------------

            if ((match = Regex.Match(text, @"^(remind|inform|notify|ps)[\s]+(\S+.*)", RegexOptions.IgnoreCase)).Success)
            {
                Remind.OnMessage
                (
                    user,
                    room,
                    match.Groups[2].Value
                );

                return;
            }

            // -------------------------------------------------------------
            // Coin                            {coin, coinflip, coins, flip}
            // -------------------------------------------------------------

            if ((match = Regex.Match(text, @"^(coin|coinflip|coins|flip)\s*(\d{0,5})$", RegexOptions.IgnoreCase)).Success)
            {
                Coin.OnMessage
                (
                    user,
                    room,
                    match.Groups[2].Value
                );

                return;
            }

            // -------------------------------------------------------------
            // Card                                      {card, cards, draw}
            // -------------------------------------------------------------

            if ((match = Regex.Match(text, @"^(card|cards|draw)(.*)$", RegexOptions.IgnoreCase)).Success)
            {
                Card.OnMessage
                (
                    user,
                    room,
                    match.Groups[2].Value
                );

                return;
            }

            // -------------------------------------------------------------
            // Google                         {google, search, lookup, find}
            // -------------------------------------------------------------

            if ((match = Regex.Match(text, @"^(google|search|lookup|find)[\s]+(\S+.*)", RegexOptions.IgnoreCase)).Success)
            {
                Google.OnMessage
                (
                    user,
                    room,
                    match.Groups[2].Value
                );

                return;
            }

            // -------------------------------------------------------------
            // Metacritic         {metacritic, score, meta, critic, ranking}
            // -------------------------------------------------------------

            if ((match = Regex.Match(text, @"^(metacritic|score|meta|critic|ranking)[\s]+(\S+.*)", RegexOptions.IgnoreCase)).Success)
            {
                Metacritic.OnMessage
                (
                    user,
                    room,
                    match.Groups[2].Value
                );

                return;
            }

            // -------------------------------------------------------------
            // News                                              {bbc, news}
            // -------------------------------------------------------------

            if ((match = Regex.Match(text, @"^(bbc|news)[\s]+(\S+.*)", RegexOptions.IgnoreCase)).Success)
            {
                News.OnMessage
                (
                    user,
                    room,
                    match.Groups[2].Value
                );

                return;
            }

            // -------------------------------------------------------------
            // Stackoverflow                {question, stack, stackoverflow}
            // -------------------------------------------------------------

            if ((match = Regex.Match(text, @"^(question|stack|stackoverflow)[\s]+(\S+.*)", RegexOptions.IgnoreCase)).Success)
            {
                Stackoverflow.OnMessage
                (
                    user,
                    room,
                    match.Groups[2].Value
                );

                return;
            }

            // -------------------------------------------------------------
            // Reddit                                               {reddit}
            // -------------------------------------------------------------

            if ((match = Regex.Match(text, @"^(reddit)[\s]+(\S+.*)", RegexOptions.IgnoreCase)).Success)
            {
                Reddit.OnMessage
                (
                    user,
                    room,
                    match.Groups[2].Value
                );

                return;
            }

            // -------------------------------------------------------------
            // Tumblr                                      {tumblr, tumbler}
            // -------------------------------------------------------------

            if ((match = Regex.Match(text, @"^(tumblr|tumbler)[\s]+(\S+.*)", RegexOptions.IgnoreCase)).Success)
            {
                Tumblr.OnMessage
                (
                    user,
                    room,
                    match.Groups[2].Value
                );

                return;
            }

            // -------------------------------------------------------------
            // Wikipedia                       {wiki, wikipedia, definition}
            // -------------------------------------------------------------

            if ((match = Regex.Match(text, @"^(wiki|wikipedia|definition)[\s]+(\S+.*)", RegexOptions.IgnoreCase)).Success)
            {
                Wikipedia.OnMessage
                (
                    user,
                    room,
                    match.Groups[2].Value
                );

                return;
            }

            // -------------------------------------------------------------
            // Youtube                                      {youtube, video}
            // -------------------------------------------------------------

            if ((match = Regex.Match(text, @"^(youtube|video)[\s]+(\S+.*)", RegexOptions.IgnoreCase)).Success)
            {
                Youtube.OnMessage
                (
                    user,
                    room,
                    match.Groups[2].Value
                );

                return;
            }

            // -------------------------------------------------------------
            // Joke                              {joke, jokes, humor, funny}
            // -------------------------------------------------------------

            if ((match = Regex.Match(text, @"^(joke|jokes|humor|funny)", RegexOptions.IgnoreCase)).Success)
            {
                Joke.OnMessage
                (
                    user,
                    room,
                    text
                );

                return;
            }

            // -------------------------------------------------------------
            // Genre                             {genre, idea, design, game}
            // -------------------------------------------------------------

            if ((match = Regex.Match(text, @"^(genre|idea|design|game)", RegexOptions.IgnoreCase)).Success)
            {
                Genre.OnMessage
                (
                    user,
                    room,
                    text
                );

                return;
            }

            // -------------------------------------------------------------
            // Wisdom                              {wisdom, chinese, advice}
            // -------------------------------------------------------------

            if ((match = Regex.Match(text, @"^(wisdom|chinese|advice)\s*(.*)", RegexOptions.IgnoreCase)).Success)
            {
                Wisdom.OnMessage
                (
                    user,
                    room,
                    match.Groups[2].Value
                );

                return;
            }

            // -------------------------------------------------------------
            // Fallout4                         {fallout, fallout4, fo4, fo}
            // -------------------------------------------------------------

            if ((match = Regex.Match(text, @"^(fallout|fallout4|fo4|fo)\s*$", RegexOptions.IgnoreCase)).Success)
            {
                Fallout4.OnMessage
                (
                    user,
                    room,
                    text
                );

                return;
            }

            // -------------------------------------------------------------
            // Question {does, is, were, are, will, can, have, am, was, ...}
            // -------------------------------------------------------------

            if ((match = Regex.Match(text, @"^(does|is|were|are|will|can|have|am|was|did|should|do|has)\s(.*)", RegexOptions.IgnoreCase)).Success)
            {
                Question.OnMessage
                (
                    user,
                    room,
                    text
                );

                return;
            }

            // -------------------------------------------------------------
            // Cat                                               {cat, cats}
            // -------------------------------------------------------------

            if ((match = Regex.Match(text, @"^(cat|cats)(.*)", RegexOptions.IgnoreCase)).Success)
            {
                Cat.OnMessage
                (
                    user,
                    room,
                    text
                );

                return;
            }

            // -------------------------------------------------------------
            // Help      {help, command, commands, overview, credit, manual}
            // -------------------------------------------------------------

            if ((match = Regex.Match(text, @"^(help|command|commands|overview|credit|manual)", RegexOptions.IgnoreCase)).Success)
            {
                Help.OnMessage
                (
                    user,
                    room,
                    text
                );

                return;
            }
        }