Added Pirate vs. Ninja commands
This commit is contained in:
parent
384dcc6416
commit
c71789e949
@ -1,6 +1,7 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## Release Version 1.2
|
## Release Version 1.2
|
||||||
|
- Added [Pirate vs. Ninja](https://majcher.com/project/pvn/pvn.cgi) commands: `?pirate`, `?ninja`, `?pvn`, `?nvp`
|
||||||
- Added `?trace` debug tool
|
- Added `?trace` debug tool
|
||||||
- New aliases: `?fineart`, `?artishard`, `?indeed`, `?florida`, `?stop`
|
- New aliases: `?fineart`, `?artishard`, `?indeed`, `?florida`, `?stop`
|
||||||
- Added YouTube search command
|
- Added YouTube search command
|
||||||
|
@ -243,6 +243,14 @@ class Onequestionmark {
|
|||||||
Sys.println('[${timestamp()}] trace: ${Json.stringify(getMessage(m.referenced_message.channel_id, m.referenced_message.id))}');
|
Sys.println('[${timestamp()}] trace: ${Json.stringify(getMessage(m.referenced_message.channel_id, m.referenced_message.id))}');
|
||||||
}
|
}
|
||||||
m.react('✅');
|
m.react('✅');
|
||||||
|
case "pirate":
|
||||||
|
if (msg.length > 0) {pvn("p",msg,m);}
|
||||||
|
case "ninja":
|
||||||
|
if (msg.length > 0) {pvn("n",msg,m);}
|
||||||
|
case "pvn":
|
||||||
|
if (msg.length > 0) {pvn("pvn",msg,m);}
|
||||||
|
case "nvp":
|
||||||
|
if (msg.length > 0) {pvn("nvp",msg,m);}
|
||||||
// Gaming functions
|
// Gaming functions
|
||||||
case "coin":
|
case "coin":
|
||||||
if ((msg.length == 0) || (Std.parseInt(msg) == null) || (Std.parseInt(msg) == 1)) {
|
if ((msg.length == 0) || (Std.parseInt(msg) == null) || (Std.parseInt(msg) == 1)) {
|
||||||
@ -487,6 +495,54 @@ class Onequestionmark {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function scrapes PVN and replies with the appropriate results.
|
||||||
|
* @param choice `p`, `n`, `pvn`, or `nvp`.
|
||||||
|
* @param query The string to search.
|
||||||
|
*/
|
||||||
|
public static function pvn(choice:String,query:String,m:Message) {
|
||||||
|
if (choice.length > 1) {
|
||||||
|
if (query.contains(" | ")) {
|
||||||
|
var splitQuery = query.split(" | ");
|
||||||
|
query = '${splitQuery[0].urlEncode()}&n2=${splitQuery[1].urlEncode()}';
|
||||||
|
} else {
|
||||||
|
m.reply({content:'$choice: Must choose two combatants.'}, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
query = query.urlEncode();
|
||||||
|
}
|
||||||
|
var req = new haxe.Http('https://majcher.com/project/pvn/pvn.cgi?a=${choice.urlEncode()}&n1=${query}');
|
||||||
|
|
||||||
|
req.onData = function (request) {
|
||||||
|
var data = new HtmlDocument(request);
|
||||||
|
var search = data.find("table>tr>td");
|
||||||
|
|
||||||
|
try {
|
||||||
|
m.reply({content:'## ${search[0].innerText}\n${search[2].innerText} ${search[3].innerText}\n${search[4].innerText} ${search[5].innerText}\n${search[6].innerText} ${search[7].innerText}\n${search[8].innerText} ${search[9].innerText}\n**${search[10].innerText} ${search[11].innerText}**'}, false);
|
||||||
|
|
||||||
|
if (choice.length > 1) {
|
||||||
|
var result = data.find('div#result');
|
||||||
|
|
||||||
|
m.reply({content:'## ${search[12].innerText}\n${search[14].innerText} ${search[15].innerText}\n${search[16].innerText} ${search[17].innerText}\n${search[18].innerText} ${search[19].innerText}\n${search[20].innerText} ${search[21].innerText}\n**${search[22].innerText} ${search[23].innerText}**'}, false);
|
||||||
|
|
||||||
|
m.reply({content:'## ${result[0].innerText}'}, false);
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
m.reply({content:'$choice: Error - $e'}, false);
|
||||||
|
Sys.println('[${timestamp()}] $choice: Error - $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
req.onError = function (error) {
|
||||||
|
m.reply({content:'Error in PVN: $error'}, false);
|
||||||
|
Sys.println('[${timestamp()}] $choice: Error - $error, request was $query');
|
||||||
|
}
|
||||||
|
|
||||||
|
req.request();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function performs a YouTube search and replies with the first result.
|
* This function performs a YouTube search and replies with the first result.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user