mirror of
https://github.com/znc/znc.git
synced 2026-08-06 17:03:14 +02:00
perform: Clean up the style a little and make this look like the rest of znc
Patch by SilverLeo, thanks. :) git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1242 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
+16
-35
@@ -8,29 +8,21 @@
|
||||
|
||||
#include "User.h"
|
||||
|
||||
class CPerform : public CModule
|
||||
{
|
||||
class CPerform : public CModule {
|
||||
public:
|
||||
MODCONSTRUCTOR(CPerform)
|
||||
{
|
||||
}
|
||||
MODCONSTRUCTOR(CPerform) {}
|
||||
|
||||
virtual ~CPerform()
|
||||
{
|
||||
}
|
||||
virtual ~CPerform() {}
|
||||
|
||||
virtual bool OnLoad(const CString& sArgs, CString& sMessage)
|
||||
{
|
||||
virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
|
||||
GetNV("Perform").Split("\n", m_vPerform, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void OnModCommand(const CString& sCommand)
|
||||
{
|
||||
virtual void OnModCommand(const CString& sCommand) {
|
||||
CString sCmdName = sCommand.Token(0).AsLower();
|
||||
if (sCmdName == "add")
|
||||
{
|
||||
if (sCmdName == "add") {
|
||||
CString sPerf = sCommand.Token(1, true);
|
||||
|
||||
if (sPerf.empty()) {
|
||||
@@ -54,26 +46,20 @@ public:
|
||||
m_vPerform.push_back(sPerf);
|
||||
PutModule("Added!");
|
||||
Save();
|
||||
} else if (sCmdName == "del")
|
||||
{
|
||||
} else if (sCmdName == "del") {
|
||||
u_int iNum = atoi(sCommand.Token(1, true).c_str());
|
||||
if (iNum > m_vPerform.size() || iNum <= 0)
|
||||
{
|
||||
if (iNum > m_vPerform.size() || iNum <= 0) {
|
||||
PutModule("Illegal # Requested");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
m_vPerform.erase(m_vPerform.begin() + iNum - 1);
|
||||
PutModule("Command Erased.");
|
||||
}
|
||||
Save();
|
||||
} else if (sCmdName == "list")
|
||||
{
|
||||
} else if (sCmdName == "list") {
|
||||
int i = 1;
|
||||
CString sExpanded;
|
||||
for (VCString::iterator it = m_vPerform.begin(); it != m_vPerform.end(); it++, i++)
|
||||
{
|
||||
for (VCString::iterator it = m_vPerform.begin(); it != m_vPerform.end(); it++, i++) {
|
||||
sExpanded = GetUser()->ExpandString(*it);
|
||||
if (sExpanded != *it)
|
||||
PutModule(CString(i) + ": " + *it + " (" + sExpanded + ")");
|
||||
@@ -81,28 +67,23 @@ public:
|
||||
PutModule(CString(i) + ": " + *it);
|
||||
}
|
||||
PutModule(" -- End of List");
|
||||
}else
|
||||
{
|
||||
} else {
|
||||
PutModule("Commands: add <command>, del <nr>, list");
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnIRCConnected()
|
||||
{
|
||||
virtual void OnIRCConnected() {
|
||||
for (VCString::iterator it = m_vPerform.begin();
|
||||
it != m_vPerform.end(); it++)
|
||||
{
|
||||
it != m_vPerform.end(); it++) {
|
||||
PutIRC(GetUser()->ExpandString(*it));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
bool Save()
|
||||
{
|
||||
bool Save() {
|
||||
CString sBuffer = "";
|
||||
|
||||
for (VCString::iterator it = m_vPerform.begin(); it != m_vPerform.end(); it++)
|
||||
{
|
||||
for (VCString::iterator it = m_vPerform.begin(); it != m_vPerform.end(); it++) {
|
||||
sBuffer += *it + "\n";
|
||||
}
|
||||
SetNV("Perform", sBuffer);
|
||||
|
||||
Reference in New Issue
Block a user