Преглед изворни кода

Url parsing - Added check to see if Youtube title was in youtube result and remove it.

master
Teknikode пре 7 година
родитељ
комит
e71bf30a9b
  1. 9
      Modules/Url Parsing/Url_Parsing.cs

9
Modules/Url Parsing/Url_Parsing.cs

@ -14,6 +14,7 @@ namespace Combot.Modules.Plugins @@ -14,6 +14,7 @@ namespace Combot.Modules.Plugins
{
public class Url_Parsing : Module
{
private const string YOUTUBE_URL = "(((youtube.*(v=|/v/))|(youtu\\.be/))(?<ID>[-_a-zA-Z0-9]+))";
public override void Initialize()
{
Bot.IRC.Message.ChannelMessageReceivedEvent += HandleChannelMessage;
@ -70,11 +71,17 @@ namespace Combot.Modules.Plugins @@ -70,11 +71,17 @@ namespace Combot.Modules.Plugins
Bot.IRC.Command.SendPrivateMessage(message.Channel, string.Format("[Audio] Type: {0} | Size: {1}", webResponse.ContentType.Split('/')[1], ToFileSize(contentLength)));
break;
default:
Regex ytRegex = new Regex("(((youtube.*(v=|/v/))|(youtu\\.be/))(?<ID>[-_a-zA-Z0-9]+))");
Regex ytRegex = new Regex(YOUTUBE_URL);
if (ytRegex.IsMatch(urlMatch.ToString()))
{
Match ytMatch = ytRegex.Match(urlMatch.ToString());
string youtubeMessage = GetYoutubeDescription(ytMatch.Groups["ID"].Value);
Regex ytTitle = new Regex(YOUTUBE_URL);
if (ytTitle.IsMatch(youtubeMessage))
{
youtubeMessage = ytTitle.Replace(youtubeMessage, string.Empty);
}
Bot.IRC.Command.SendPrivateMessage(message.Channel, youtubeMessage);
}
else

Loading…
Откажи
Сачувај