Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
bot.chat(result);
//bot.chat("For more info: http://www.merriam-webster.com/dictionary/" + linkQualifier);
}
else{
bot.chat("No definition found.");
}
});
}
else{
bot.chat("Try .define followed by something to look up.");
}
break;
case ".wiki": //Returns Wikipedia article summary of a given query with .define [givenWord]
if (qualifier!=""){
Wiki.page(qualifier, false, function(err, page){
page.summary(function(err, summary){
if (summary!=undefined){
Wiki.page(qualifier, false, function(err, page){
page.html(function(err, html){
if (html.indexOf('<ul>')!=-1){
html=html.substring(0, html.indexOf('<ul>'));
}
html=html.replace(/<[^>]+>/g, '');
Wiki.page(qualifier, false, function(err, page){
page.summary(function(err, summary){
if (summary!=undefined){
if (summary=="" || summary.indexOf("This is a redirect")!=-1){
summary="redirect "+html;
}
if (summary.indexOf('may refer to:')!=-1 || summary.indexOf('can refer to:')!=-1 || summary.indexOf('may also refer to:')!=-1 || summary.indexOf('may refer to the following:')!=-1 || summary.indexOf('may stand for:')!=-1){
bot.chat("This may refer to several things - please be more specific.");</ul></ul>
}
else if (summary.substring(0,8).toLowerCase()=="redirect"){
subQuery='';
if (summary.indexOf('#')==-1){
if (summary.substring(8,9)==' '){
var query=summary.substring(9);
}
else{
var query=summary.substring(8);
}
}
else{
var query=summary.substring(9, summary.indexOf('#'));
subQuery=summary.substring(summary.indexOf('#')+1);
}
Wiki.page(query, false, function(err, page2){
page2.content(function(err, content){
if (content!=undefined){
if (content.indexOf('may refer to:')!=-1 || content.indexOf('can refer to:')!=-1 || content.indexOf('may also refer to:')!=-1 || content.indexOf('may refer to the following:')!=-1 || content.indexOf('may stand for:')!=-1){
bot.chat("This may refer to several things - please be more specific.");
}
else if (subQuery!=''){
content=content.substring(content.indexOf("=== "+subQuery+" ===")+8+subQuery.length);
if (content.length>250){
content=content.substring(0, 247)+"...";
}
bot.chat(content);
}
else{
if (content.length>250){
content=content.substring(0, 247)+"...";
}