Explorar el Código

Added max title length to url parsing.

tags/3.0.5
Teknikode hace 6 años
padre
commit
fa496aaa36
Se han modificado 2 ficheros con 12 adiciones y 1 borrados
  1. 7
    1
      Modules/Url Parsing/Module.config
  2. 5
    0
      Modules/Url Parsing/Url_Parsing.cs

+ 7
- 1
Modules/Url Parsing/Module.config Ver fichero

@@ -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 Ver fichero

@@ -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;

Cargando…
Cancelar
Guardar