示例#1
0
        public override List <IRCResponse> GetResponse(BotMessage message)
        {
            if (message.Type != "PRIVMSG" ||
                message.TargetType != IRCMessage.TargetTypes.CHANNEL ||
                ChannelList.ChannelHasMode(message.ReplyTo, 'U'))
            {
                return(null);
            }

            Match match = Regex.Match(message.MessageString, @"https?://[^\s]+", RegexOptions.IgnoreCase);

            if (!match.Success)
            {
                return(null);
            }

            if (Regex.IsMatch(match.Value, @"\.(jpe?g|gif|png|bmp)$"))
            {
                return(null);
            }

            string response = null;

            Match youtubeMatch = Regex.Match(match.Value, @"www\.youtube\.com/watch\?v=([^&]+)");

            if (youtubeMatch.Success)
            {
                response = FollowYouTube(youtubeMatch.Groups[1].Value);
            }
            else
            {
                response = FollowStandard(match.Value);
            }

            if (response == null)
            {
                return(null);
            }

            return(new List <IRCResponse>()
            {
                new IRCResponse(ResponseType.Say, response, message.ReplyTo)
            });
        }