Browse Source

Added max title length to url parsing.

tags/3.0.5
Teknikode 4 years ago
parent
commit
fa496aaa36
2 changed files with 12 additions and 1 deletions
  1. 7
    1
      Modules/Url Parsing/Module.config
  2. 5
    0
      Modules/Url Parsing/Url_Parsing.cs

+ 7
- 1
Modules/Url Parsing/Module.config View File

@@ -5,5 +5,11 @@
"ChannelBlacklist": [],
"NickBlacklist": [],
"Commands": [],
"Options": []
"Options": [
{
"Name": "Max Title",
"Description": "The maximum number of characters to display for a title",
"Value": 140
}
]
}

+ 5
- 0
Modules/Url Parsing/Url_Parsing.cs View File

@@ -57,6 +57,11 @@ namespace Combot.Modules.Plugins
x.Encoding = Encoding.UTF8;
string source = x.DownloadString(urlMatch.ToString());
string title = Regex.Match(source, @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>", RegexOptions.IgnoreCase).Groups["Title"].Value;
int maxTitle = Convert.ToInt32(GetOptionValue("Max Title"));
if (title.Length > (int)maxTitle)
{
title = string.Format("{0}...", title.Substring(0, (int)maxTitle));
}
Bot.IRC.Command.SendPrivateMessage(message.Channel, string.Format("[URL] {0} ({1})", HttpUtility.HtmlDecode(HttpUtility.UrlDecode(StripTagsCharArray(title))), url.Host));
}
break;

Loading…
Cancel
Save