Browse Source

Fixed issue where long results would cause Combot to flood.

master 3.0.5
Teknikode 7 years ago
parent
commit
fcdcc5ba1c
  1. 7
      Modules/Wolfram Alpha/Module.Default.json
  2. 8
      Modules/Wolfram Alpha/Wolfram_Alpha.cs

7
Modules/Wolfram Alpha/Module.Default.json

@ -49,7 +49,12 @@ @@ -49,7 +49,12 @@
{
"Name": "API",
"Description": "The API key for Wolfram Alpha.",
"Value": "892JG5-XVQVU5JUEW"
"Value": ""
},
{
"Name": "Max Response Length",
"Description": "The maximum length for the response to be.",
"Value": 400
}
]
}

8
Modules/Wolfram Alpha/Wolfram_Alpha.cs

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
using System.Net;
using System;
using System.Net;
using System.Text;
using System.Web;
using System.Xml;
@ -45,6 +46,11 @@ namespace Combot.Modules.Plugins @@ -45,6 +46,11 @@ namespace Combot.Modules.Plugins
{
string queryMessage = string.Format("Result for: {0}", xnList[0]["subpod"]["plaintext"].InnerText);
string resultMessage = xnList[1]["subpod"]["plaintext"].InnerText;
int maxResults = Convert.ToInt32(GetOptionValue("Max Response Length"));
if (resultMessage.Length > (int)maxResults)
{
resultMessage = string.Format("{0}...", resultMessage.Substring(0, (int)maxResults));
}
SendResponse(command.MessageType, command.Location, command.Nick.Nickname, queryMessage);
SendResponse(command.MessageType, command.Location, command.Nick.Nickname, resultMessage);
}

Loading…
Cancel
Save