Merge pull request #70 from AttorneyOnline/joke-mod-commands
Add /gimp, /disemvowel, /shake, and their reverse commands
This commit is contained in:
commit
431baee68a
bin/config_sample/text
include
src
11
bin/config_sample/text/gimp.txt
Normal file
11
bin/config_sample/text/gimp.txt
Normal file
@ -0,0 +1,11 @@
|
||||
I love the mods on this server!
|
||||
At 3:03 PM maya went into my house and ate my corn bread
|
||||
Enlargement
|
||||
Do you think I am imcompetent?
|
||||
WE CAN'T TRUST ANY OF THE WITNESSES THROW THEM ALL OUT
|
||||
I'm not a clown, I'm the entire circus.
|
||||
What if the murder, it was not a murder?
|
||||
omti
|
||||
<3
|
||||
what's an akashi
|
||||
*punches bailiff*
|
@ -221,17 +221,17 @@ class AOClient : public QObject {
|
||||
/**
|
||||
* @brief If true, the client's in-character messages will have their word order randomised.
|
||||
*/
|
||||
bool is_shaken;
|
||||
bool is_shaken = false;
|
||||
|
||||
/**
|
||||
* @brief If true, the client's in-character messages will have their vowels (English alphabet only) removed.
|
||||
*/
|
||||
bool is_disemvoweled;
|
||||
bool is_disemvoweled = false;
|
||||
|
||||
/**
|
||||
* @brief If true, the client's in-character messages will be overwritten by a randomly picked predetermined message.
|
||||
*/
|
||||
bool is_gimped;
|
||||
bool is_gimped = false;
|
||||
|
||||
public slots:
|
||||
/**
|
||||
@ -1399,6 +1399,60 @@ class AOClient : public QObject {
|
||||
*/
|
||||
void cmd8Ball(int argc, QStringList argv);
|
||||
|
||||
/**
|
||||
* @brief Replaces a target client's in-character messages with strings randomly selected from gimp.txt.
|
||||
*
|
||||
* @details The only argument is the **the target's ID** whom the client wants to gimp.
|
||||
*
|
||||
* @iscommand
|
||||
*/
|
||||
void cmdGimp(int argc, QStringList argv);
|
||||
|
||||
/**
|
||||
* @brief Allows a gimped client to speak normally.
|
||||
*
|
||||
* @details The only argument is **the target's ID** whom the client wants to ungimp.
|
||||
*
|
||||
* @iscommand
|
||||
*/
|
||||
void cmdUnGimp(int argc, QStringList argv);
|
||||
|
||||
/**
|
||||
* @brief Removes all vowels from a target client's in-character messages.
|
||||
*
|
||||
* @details The only argument is **the target's ID** whom the client wants to disemvowel.
|
||||
*
|
||||
* @iscommand
|
||||
*/
|
||||
void cmdDisemvowel(int argc, QStringList argv);
|
||||
|
||||
/**
|
||||
* @brief Allows a disemvoweled client to speak normally.
|
||||
*
|
||||
* @details The only argument is **the target's ID** whom the client wants to undisemvowel.
|
||||
*
|
||||
* @iscommand
|
||||
*/
|
||||
void cmdUnDisemvowel(int argc, QStringList argv);
|
||||
|
||||
/**
|
||||
* @brief Scrambles the words of a target client's in-character messages.
|
||||
*
|
||||
* @details The only argument is **the target's ID** whom the client wants to shake.
|
||||
*
|
||||
* @iscommand
|
||||
*/
|
||||
void cmdShake(int argc, QStringList argv);
|
||||
|
||||
/**
|
||||
* @brief Allows a shaken client to speak normally.
|
||||
*
|
||||
* @details The only argument is **the target's ID** whom the client wants to unshake.
|
||||
*
|
||||
* @iscommand
|
||||
*/
|
||||
void cmdUnShake(int argc, QStringList argv);
|
||||
|
||||
/**
|
||||
* @brief Reloads all server configuration files.
|
||||
*
|
||||
@ -1624,8 +1678,14 @@ class AOClient : public QObject {
|
||||
{"lm", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdLM}},
|
||||
{"judgelog", {ACLFlags.value("CM"), 0, &AOClient::cmdJudgeLog}},
|
||||
{"allow_blankposting", {ACLFlags.value("MODCHAT"), 0, &AOClient::cmdAllow_Blankposting}},
|
||||
{"gimp", {ACLFlags.value("MUTE"), 1, &AOClient::cmdGimp}},
|
||||
{"ungimp", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnGimp}},
|
||||
{"baninfo", {ACLFlags.value("BAN"), 1, &AOClient::cmdBanInfo}},
|
||||
{"reload", {ACLFlags.value("SUPER"), 0, &AOClient::cmdReload}},
|
||||
{"disemvowel", {ACLFlags.value("MUTE"), 1, &AOClient::cmdDisemvowel}},
|
||||
{"undisemvowel", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnDisemvowel}},
|
||||
{"shake", {ACLFlags.value("MUTE"), 1, &AOClient::cmdShake}},
|
||||
{"unshake", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnShake}},
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -264,6 +264,11 @@ class Server : public QObject {
|
||||
*/
|
||||
QStringList reprimands_list;
|
||||
|
||||
/**
|
||||
* @brief List holding the contents of gimp.txt, used by AOClient::cmdGimp.
|
||||
*/
|
||||
QStringList gimp_list;
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* @brief Handles a new connection.
|
||||
|
119
src/commands.cpp
119
src/commands.cpp
@ -1289,6 +1289,45 @@ void AOClient::cmdAllow_Blankposting(int argc, QStringList argv)
|
||||
}
|
||||
}
|
||||
|
||||
void AOClient::cmdGimp(int argc, QStringList argv)
|
||||
{
|
||||
bool conv_ok = false;
|
||||
int uid = argv[0].toInt(&conv_ok);
|
||||
if (!conv_ok) {
|
||||
sendServerMessage("Invalid user ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
AOClient* target = server->getClientByID(uid);
|
||||
|
||||
if (target->is_gimped)
|
||||
sendServerMessage("That player is already gimped!");
|
||||
else {
|
||||
sendServerMessage("Gimped player.");
|
||||
target->sendServerMessage("You have been gimped! " + getReprimand());
|
||||
}
|
||||
target->is_gimped = true;
|
||||
}
|
||||
|
||||
void AOClient::cmdUnGimp(int argc, QStringList argv)
|
||||
{
|
||||
bool conv_ok = false;
|
||||
int uid = argv[0].toInt(&conv_ok);
|
||||
if (!conv_ok) {
|
||||
sendServerMessage("Invalid user ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
AOClient* target = server->getClientByID(uid);
|
||||
|
||||
if (!(target->is_gimped))
|
||||
sendServerMessage("That player is not gimped!");
|
||||
else {
|
||||
sendServerMessage("Ungimped player.");
|
||||
target->sendServerMessage("A moderator has ungimped you! " + getReprimand(true));
|
||||
}
|
||||
target->is_gimped = false;
|
||||
}
|
||||
void AOClient::cmdBanInfo(int argc, QStringList argv)
|
||||
{
|
||||
QStringList ban_info;
|
||||
@ -1335,6 +1374,86 @@ void AOClient::cmdReload(int argc, QStringList argv)
|
||||
sendServerMessage("Reloaded configurations");
|
||||
}
|
||||
|
||||
void AOClient::cmdDisemvowel(int argc, QStringList argv)
|
||||
{
|
||||
bool conv_ok = false;
|
||||
int uid = argv[0].toInt(&conv_ok);
|
||||
if (!conv_ok) {
|
||||
sendServerMessage("Invalid user ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
AOClient* target = server->getClientByID(uid);
|
||||
|
||||
if (target->is_disemvoweled)
|
||||
sendServerMessage("That player is already disemvoweled!");
|
||||
else {
|
||||
sendServerMessage("Disemvoweled player.");
|
||||
target->sendServerMessage("You have been disemvoweled! " + getReprimand());
|
||||
}
|
||||
target->is_disemvoweled = true;
|
||||
}
|
||||
|
||||
void AOClient::cmdUnDisemvowel(int argc, QStringList argv)
|
||||
{
|
||||
bool conv_ok = false;
|
||||
int uid = argv[0].toInt(&conv_ok);
|
||||
if (!conv_ok) {
|
||||
sendServerMessage("Invalid user ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
AOClient* target = server->getClientByID(uid);
|
||||
|
||||
if (!(target->is_disemvoweled))
|
||||
sendServerMessage("That player is not disemvoweled!");
|
||||
else {
|
||||
sendServerMessage("Undisemvoweled player.");
|
||||
target->sendServerMessage("A moderator has undisemvoweled you! " + getReprimand(true));
|
||||
}
|
||||
target->is_disemvoweled = false;
|
||||
}
|
||||
|
||||
void AOClient::cmdShake(int argc, QStringList argv)
|
||||
{
|
||||
bool conv_ok = false;
|
||||
int uid = argv[0].toInt(&conv_ok);
|
||||
if (!conv_ok) {
|
||||
sendServerMessage("Invalid user ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
AOClient* target = server->getClientByID(uid);
|
||||
|
||||
if (target->is_shaken)
|
||||
sendServerMessage("That player is already shaken!");
|
||||
else {
|
||||
sendServerMessage("Shook player.");
|
||||
target->sendServerMessage("A moderator has shaken your words! " + getReprimand());
|
||||
}
|
||||
target->is_shaken = true;
|
||||
}
|
||||
|
||||
void AOClient::cmdUnShake(int argc, QStringList argv)
|
||||
{
|
||||
bool conv_ok = false;
|
||||
int uid = argv[0].toInt(&conv_ok);
|
||||
if (!conv_ok) {
|
||||
sendServerMessage("Invalid user ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
AOClient* target = server->getClientByID(uid);
|
||||
|
||||
if (!(target->is_shaken))
|
||||
sendServerMessage("That player is not shaken!");
|
||||
else {
|
||||
sendServerMessage("Unshook player.");
|
||||
target->sendServerMessage("A moderator has unshook you! " + getReprimand(true));
|
||||
}
|
||||
target->is_shaken = false;
|
||||
}
|
||||
|
||||
QStringList AOClient::buildAreaList(int area_idx)
|
||||
{
|
||||
QStringList entries;
|
||||
|
@ -182,7 +182,7 @@ bool ConfigManager::fileExists(QFileInfo* file)
|
||||
|
||||
bool ConfigManager::verifyCommandConfig()
|
||||
{
|
||||
QStringList filelist = {"8ball", "praise", "reprimands"};
|
||||
QStringList filelist = {"8ball", "praise", "reprimands", "gimp"};
|
||||
foreach (QString filename, filelist) {
|
||||
QFileInfo file("config/text/" + filename + ".txt");
|
||||
if (!(fileExists(&file))) {
|
||||
|
@ -443,6 +443,24 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
|
||||
sendServerMessage("Blankposting has been forbidden in this area.");
|
||||
return invalid;
|
||||
}
|
||||
|
||||
if (is_gimped) {
|
||||
QString gimp_message = server->gimp_list[(genRand(1, server->gimp_list.size() - 1))];
|
||||
incoming_msg = gimp_message;
|
||||
}
|
||||
|
||||
if (is_shaken) {
|
||||
QStringList parts = incoming_msg.split(" ");
|
||||
std::random_shuffle(parts.begin(), parts.end());
|
||||
incoming_msg = parts.join(" ");
|
||||
}
|
||||
|
||||
if (is_disemvoweled) {
|
||||
QString disemvoweled_message = incoming_msg.remove(QRegExp("[AEIOUaeiou]"));
|
||||
incoming_msg = disemvoweled_message;
|
||||
}
|
||||
|
||||
last_message = incoming_msg;
|
||||
args.append(incoming_msg);
|
||||
|
||||
// side
|
||||
|
@ -203,6 +203,7 @@ void Server::loadCommandConfig()
|
||||
magic_8ball_answers = (loadConfigFile("8ball"));
|
||||
praise_list = (loadConfigFile("praise"));
|
||||
reprimands_list = (loadConfigFile("reprimands"));
|
||||
gimp_list = (loadConfigFile("gimp"));
|
||||
}
|
||||
|
||||
QStringList Server::loadConfigFile(QString filename)
|
||||
|
Loading…
Reference in New Issue
Block a user