Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: znc/znc
base: 4ae6cb306120
...
head fork: znc/znc
compare: 114fabfebe39
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 125 additions and 1 deletion.
  1. +125 −1 modules/admin.cpp
View
126 modules/admin.cpp
@@ -42,7 +42,7 @@ class CAdminMod : public CModule {
static const char* str = "String";
static const char* boolean = "Boolean (true/false)";
static const char* integer = "Integer";
- //static const char* doublenum = "Double";
+ static const char* doublenum = "Double";
static const char* vars[][2] = {
{"Nick", str},
{"Altnick", str},
@@ -73,6 +73,27 @@ class CAdminMod : public CModule {
}
PutModule(VarTable);
+ PutModule("The following variables are available when using the SetNetwork/GetNetwork commands:");
+
+ CTable NVarTable;
+ NVarTable.AddColumn("Variable");
+ NVarTable.AddColumn("Type");
+ static const char* nvars[][2] = {
+ {"Nick", str},
+ {"Altnick", str},
+ {"Ident", str},
+ {"RealName", str},
+ {"FloodRate", doublenum},
+ {"FloodBurst", integer},
+ };
+ for (unsigned int i = 0; i != ARRAY_SIZE(nvars); ++i) {
+ NVarTable.AddRow();
+ NVarTable.SetCell("Variable", nvars[i][0]);
+ NVarTable.SetCell("Type", nvars[i][1]);
+ }
+ PutModule(NVarTable);
+
+
PutModule("The following variables are available when using the SetChan/GetChan commands:");
CTable CVarTable;
CVarTable.AddColumn("Variable");
@@ -322,6 +343,105 @@ class CAdminMod : public CModule {
PutModule("Error: Unknown variable");
}
+ void GetNetwork(const CString& sLine) {
+ const CString sVar = sLine.Token(1).AsLower();
+ const CString sUsername = sLine.Token(2);
+ const CString sNetwork = sLine.Token(3);
+
+ CUser *pUser = NULL;
+ CIRCNetwork *pNetwork = NULL;
+
+ if (sUsername.empty()) {
+ pUser = m_pUser;
+ pNetwork = m_pNetwork;
+ } else {
+ pUser = GetUser(sUsername);
+ if (!pUser) {
+ return;
+ }
+
+ pNetwork = pUser->FindNetwork(sNetwork);
+ if (!pNetwork && !sNetwork.empty()) {
+ PutModule("Network not found.");
+ return;
+ }
+ }
+
+ if (!pNetwork) {
+ PutModule("Usage: GetNetwork <variable> <username> <network>");
+ return;
+ }
+
+ if (sVar.Equals("nick")) {
+ PutModule("Nick = " + pNetwork->GetNick());
+ } else if (sVar.Equals("altnick")) {
+ PutModule("AltNick = " + pNetwork->GetAltNick());
+ } else if (sVar.Equals("ident")) {
+ PutModule("Ident = " + pNetwork->GetIdent());
+ } else if (sVar.Equals("realname")) {
+ PutModule("RealName = " + pNetwork->GetRealName());
+ } else if (sVar.Equals("floodrate")) {
+ PutModule("FloodRate = " + CString(pNetwork->GetFloodRate()));
+ } else if (sVar.Equals("floodburst")) {
+ PutModule("FloodBurst = " + CString(pNetwork->GetFloodBurst()));
+ } else {
+ PutModule("Error: Unknown variable");
+ }
+ }
+
+ void SetNetwork(const CString& sLine) {
+ const CString sVar = sLine.Token(1).AsLower();
+ const CString sUsername = sLine.Token(2);
+ const CString sNetwork = sLine.Token(3);
+ const CString sValue = sLine.Token(4, true);
+
+ CUser *pUser = NULL;
+ CIRCNetwork *pNetwork = NULL;
+
+ if (sUsername.empty()) {
+ pUser = m_pUser;
+ pNetwork = m_pNetwork;
+ } else {
+ pUser = GetUser(sUsername);
+ if (!pUser) {
+ return;
+ }
+
+ pNetwork = pUser->FindNetwork(sNetwork);
+ if (!pNetwork && !sNetwork.empty()) {
+ PutModule("Network not found.");
+ return;
+ }
+ }
+
+ if (!pNetwork) {
+ PutModule("Usage: SetNetwork <variable> <username> <network> <value>");
+ return;
+ }
+
+ if (sVar.Equals("nick")) {
+ pNetwork->SetNick(sValue);
+ PutModule("Nick = " + pNetwork->GetNick());
+ } else if (sVar.Equals("altnick")) {
+ pNetwork->SetAltNick(sValue);
+ PutModule("AltNick = " + pNetwork->GetAltNick());
+ } else if (sVar.Equals("ident")) {
+ pNetwork->SetIdent(sValue);
+ PutModule("Ident = " + pNetwork->GetIdent());
+ } else if (sVar.Equals("realname")) {
+ pNetwork->SetRealName(sValue);
+ PutModule("RealName = " + pNetwork->GetRealName());
+ } else if (sVar.Equals("floodrate")) {
+ pNetwork->SetFloodRate(sValue.ToDouble());
+ PutModule("FloodRate = " + CString(pNetwork->GetFloodRate()));
+ } else if (sVar.Equals("floodburst")) {
+ pNetwork->SetFloodBurst(sValue.ToUInt());
+ PutModule("FloodBurst = " + CString(pNetwork->GetFloodBurst()));
+ } else {
+ PutModule("Error: Unknown variable");
+ }
+ }
+
void GetChan(const CString& sLine) {
const CString sVar = sLine.Token(1).AsLower();
CString sUsername = sLine.Token(2);
@@ -951,6 +1071,10 @@ class CAdminMod : public CModule {
"variable [username]", "Prints the variable's value for the given or current user");
AddCommand("Set", static_cast<CModCommand::ModCmdFunc>(&CAdminMod::Set),
"variable username value", "Sets the variable's value for the given user (use $me for the current user)");
+ AddCommand("GetNetwork", static_cast<CModCommand::ModCmdFunc>(&CAdminMod::GetNetwork),
+ "variable [username network]", "Prints the variable's value for the given network");
+ AddCommand("SetNetwork", static_cast<CModCommand::ModCmdFunc>(&CAdminMod::SetNetwork),
+ "variable username network value", "Sets the variable's value for the given network");
AddCommand("GetChan", static_cast<CModCommand::ModCmdFunc>(&CAdminMod::GetChan),
"variable [username] network chan", "Prints the variable's value for the given channel");
AddCommand("SetChan", static_cast<CModCommand::ModCmdFunc>(&CAdminMod::SetChan),

No commit comments for this range

Something went wrong with that request. Please try again.