Add a "swap" command to perform to change the order of commands

Patch by KiNgMaR, thanks.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1560 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2009-07-08 20:17:47 +00:00
parent be6bd29b20
commit 39364f057f

View File

@@ -7,6 +7,7 @@
*/
#include "User.h"
#include <algorithm>
class CPerform : public CModule {
public:
@@ -70,8 +71,19 @@ public:
} else if (sCmdName == "execute") {
OnIRCConnected();
PutModule("perform commands sent");
} else if (sCmdName == "swap") {
u_int iNumA = sCommand.Token(1).ToUInt();
u_int iNumB = sCommand.Token(2).ToUInt();
if (iNumA > m_vPerform.size() || iNumA <= 0 || iNumB > m_vPerform.size() || iNumB <= 0) {
PutModule("Illegal # Requested");
} else {
std::iter_swap(m_vPerform.begin() + (iNumA - 1), m_vPerform.begin() + (iNumB - 1));
PutModule("Commands Swapped.");
Save();
}
} else {
PutModule("Commands: add <command>, del <nr>, list, execute");
PutModule("Commands: add <command>, del <nr>, list, execute, swap <nr> <nr>");
}
}