From 39364f057fb7d2e0bf62e2aad103ff4fa64657f4 Mon Sep 17 00:00:00 2001 From: psychon Date: Wed, 8 Jul 2009 20:17:47 +0000 Subject: [PATCH] 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 --- modules/perform.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/perform.cpp b/modules/perform.cpp index 6d64ee7a..351c72f2 100644 --- a/modules/perform.cpp +++ b/modules/perform.cpp @@ -7,6 +7,7 @@ */ #include "User.h" +#include 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 , del , list, execute"); + PutModule("Commands: add , del , list, execute, swap "); } }