mirror of
https://github.com/znc/znc.git
synced 2026-07-05 17:31:06 +02:00
clang-format: switch tabs to spaces
I like tabs, but I have to admit that spaces make source code more consistent, because every editor/viewer tends to render tabs differently :(
This commit is contained in:
+107
-107
@@ -21,139 +21,139 @@ using std::vector;
|
||||
using std::map;
|
||||
|
||||
class CSendRaw_Mod : public CModule {
|
||||
void SendClient(const CString& sLine) {
|
||||
CUser* pUser = CZNC::Get().FindUser(sLine.Token(1));
|
||||
void SendClient(const CString& sLine) {
|
||||
CUser* pUser = CZNC::Get().FindUser(sLine.Token(1));
|
||||
|
||||
if (pUser) {
|
||||
CIRCNetwork* pNetwork = pUser->FindNetwork(sLine.Token(2));
|
||||
if (pUser) {
|
||||
CIRCNetwork* pNetwork = pUser->FindNetwork(sLine.Token(2));
|
||||
|
||||
if (pNetwork) {
|
||||
pNetwork->PutUser(sLine.Token(3, true));
|
||||
PutModule("Sent [" + sLine.Token(3, true) + "] to " +
|
||||
pUser->GetUserName() + "/" + pNetwork->GetName());
|
||||
} else {
|
||||
PutModule("Network [" + sLine.Token(2) +
|
||||
"] not found for user [" + sLine.Token(1) + "]");
|
||||
}
|
||||
} else {
|
||||
PutModule("User [" + sLine.Token(1) + "] not found");
|
||||
}
|
||||
}
|
||||
if (pNetwork) {
|
||||
pNetwork->PutUser(sLine.Token(3, true));
|
||||
PutModule("Sent [" + sLine.Token(3, true) + "] to " +
|
||||
pUser->GetUserName() + "/" + pNetwork->GetName());
|
||||
} else {
|
||||
PutModule("Network [" + sLine.Token(2) +
|
||||
"] not found for user [" + sLine.Token(1) + "]");
|
||||
}
|
||||
} else {
|
||||
PutModule("User [" + sLine.Token(1) + "] not found");
|
||||
}
|
||||
}
|
||||
|
||||
void SendServer(const CString& sLine) {
|
||||
CUser* pUser = CZNC::Get().FindUser(sLine.Token(1));
|
||||
void SendServer(const CString& sLine) {
|
||||
CUser* pUser = CZNC::Get().FindUser(sLine.Token(1));
|
||||
|
||||
if (pUser) {
|
||||
CIRCNetwork* pNetwork = pUser->FindNetwork(sLine.Token(2));
|
||||
if (pUser) {
|
||||
CIRCNetwork* pNetwork = pUser->FindNetwork(sLine.Token(2));
|
||||
|
||||
if (pNetwork) {
|
||||
pNetwork->PutIRC(sLine.Token(3, true));
|
||||
PutModule("Sent [" + sLine.Token(3, true) +
|
||||
"] to IRC Server of " + pUser->GetUserName() + "/" +
|
||||
pNetwork->GetName());
|
||||
} else {
|
||||
PutModule("Network [" + sLine.Token(2) +
|
||||
"] not found for user [" + sLine.Token(1) + "]");
|
||||
}
|
||||
} else {
|
||||
PutModule("User [" + sLine.Token(1) + "] not found");
|
||||
}
|
||||
}
|
||||
if (pNetwork) {
|
||||
pNetwork->PutIRC(sLine.Token(3, true));
|
||||
PutModule("Sent [" + sLine.Token(3, true) +
|
||||
"] to IRC Server of " + pUser->GetUserName() + "/" +
|
||||
pNetwork->GetName());
|
||||
} else {
|
||||
PutModule("Network [" + sLine.Token(2) +
|
||||
"] not found for user [" + sLine.Token(1) + "]");
|
||||
}
|
||||
} else {
|
||||
PutModule("User [" + sLine.Token(1) + "] not found");
|
||||
}
|
||||
}
|
||||
|
||||
void CurrentClient(const CString& sLine) {
|
||||
CString sData = sLine.Token(1, true);
|
||||
GetClient()->PutClient(sData);
|
||||
}
|
||||
void CurrentClient(const CString& sLine) {
|
||||
CString sData = sLine.Token(1, true);
|
||||
GetClient()->PutClient(sData);
|
||||
}
|
||||
|
||||
public:
|
||||
virtual ~CSendRaw_Mod() {}
|
||||
virtual ~CSendRaw_Mod() {}
|
||||
|
||||
bool OnLoad(const CString& sArgs, CString& sErrorMsg) override {
|
||||
if (!GetUser()->IsAdmin()) {
|
||||
sErrorMsg = "You must have admin privileges to load this module";
|
||||
return false;
|
||||
}
|
||||
bool OnLoad(const CString& sArgs, CString& sErrorMsg) override {
|
||||
if (!GetUser()->IsAdmin()) {
|
||||
sErrorMsg = "You must have admin privileges to load this module";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
CString GetWebMenuTitle() override { return "Send Raw"; }
|
||||
bool WebRequiresAdmin() override { return true; }
|
||||
CString GetWebMenuTitle() override { return "Send Raw"; }
|
||||
bool WebRequiresAdmin() override { return true; }
|
||||
|
||||
bool OnWebRequest(CWebSock& WebSock, const CString& sPageName,
|
||||
CTemplate& Tmpl) override {
|
||||
if (sPageName == "index") {
|
||||
if (WebSock.IsPost()) {
|
||||
CUser* pUser = CZNC::Get().FindUser(
|
||||
WebSock.GetParam("network").Token(0, false, "/"));
|
||||
if (!pUser) {
|
||||
WebSock.GetSession()->AddError("User not found");
|
||||
return true;
|
||||
}
|
||||
bool OnWebRequest(CWebSock& WebSock, const CString& sPageName,
|
||||
CTemplate& Tmpl) override {
|
||||
if (sPageName == "index") {
|
||||
if (WebSock.IsPost()) {
|
||||
CUser* pUser = CZNC::Get().FindUser(
|
||||
WebSock.GetParam("network").Token(0, false, "/"));
|
||||
if (!pUser) {
|
||||
WebSock.GetSession()->AddError("User not found");
|
||||
return true;
|
||||
}
|
||||
|
||||
CIRCNetwork* pNetwork = pUser->FindNetwork(
|
||||
WebSock.GetParam("network").Token(1, false, "/"));
|
||||
if (!pNetwork) {
|
||||
WebSock.GetSession()->AddError("Network not found");
|
||||
return true;
|
||||
}
|
||||
CIRCNetwork* pNetwork = pUser->FindNetwork(
|
||||
WebSock.GetParam("network").Token(1, false, "/"));
|
||||
if (!pNetwork) {
|
||||
WebSock.GetSession()->AddError("Network not found");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool bToServer = WebSock.GetParam("send_to") == "server";
|
||||
const CString sLine = WebSock.GetParam("line");
|
||||
bool bToServer = WebSock.GetParam("send_to") == "server";
|
||||
const CString sLine = WebSock.GetParam("line");
|
||||
|
||||
Tmpl["user"] = pUser->GetUserName();
|
||||
Tmpl[bToServer ? "to_server" : "to_client"] = "true";
|
||||
Tmpl["line"] = sLine;
|
||||
Tmpl["user"] = pUser->GetUserName();
|
||||
Tmpl[bToServer ? "to_server" : "to_client"] = "true";
|
||||
Tmpl["line"] = sLine;
|
||||
|
||||
if (bToServer) {
|
||||
pNetwork->PutIRC(sLine);
|
||||
} else {
|
||||
pNetwork->PutUser(sLine);
|
||||
}
|
||||
if (bToServer) {
|
||||
pNetwork->PutIRC(sLine);
|
||||
} else {
|
||||
pNetwork->PutUser(sLine);
|
||||
}
|
||||
|
||||
WebSock.GetSession()->AddSuccess("Line sent");
|
||||
}
|
||||
WebSock.GetSession()->AddSuccess("Line sent");
|
||||
}
|
||||
|
||||
const map<CString, CUser*>& msUsers = CZNC::Get().GetUserMap();
|
||||
for (const auto& it : msUsers) {
|
||||
CTemplate& l = Tmpl.AddRow("UserLoop");
|
||||
l["Username"] = it.second->GetUserName();
|
||||
const map<CString, CUser*>& msUsers = CZNC::Get().GetUserMap();
|
||||
for (const auto& it : msUsers) {
|
||||
CTemplate& l = Tmpl.AddRow("UserLoop");
|
||||
l["Username"] = it.second->GetUserName();
|
||||
|
||||
vector<CIRCNetwork*> vNetworks = it.second->GetNetworks();
|
||||
for (const CIRCNetwork* pNetwork : vNetworks) {
|
||||
CTemplate& NetworkLoop = l.AddRow("NetworkLoop");
|
||||
NetworkLoop["Username"] = it.second->GetUserName();
|
||||
NetworkLoop["Network"] = pNetwork->GetName();
|
||||
}
|
||||
}
|
||||
vector<CIRCNetwork*> vNetworks = it.second->GetNetworks();
|
||||
for (const CIRCNetwork* pNetwork : vNetworks) {
|
||||
CTemplate& NetworkLoop = l.AddRow("NetworkLoop");
|
||||
NetworkLoop["Username"] = it.second->GetUserName();
|
||||
NetworkLoop["Network"] = pNetwork->GetName();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
MODCONSTRUCTOR(CSendRaw_Mod) {
|
||||
AddHelpCommand();
|
||||
AddCommand("Client", static_cast<CModCommand::ModCmdFunc>(
|
||||
&CSendRaw_Mod::SendClient),
|
||||
"[user] [network] [data to send]",
|
||||
"The data will be sent to the user's IRC client(s)");
|
||||
AddCommand(
|
||||
"Server",
|
||||
static_cast<CModCommand::ModCmdFunc>(&CSendRaw_Mod::SendServer),
|
||||
"[user] [network] [data to send]",
|
||||
"The data will be sent to the IRC server the user is connected to");
|
||||
AddCommand(
|
||||
"Current",
|
||||
static_cast<CModCommand::ModCmdFunc>(&CSendRaw_Mod::CurrentClient),
|
||||
"[data to send]", "The data will be sent to your current client");
|
||||
}
|
||||
MODCONSTRUCTOR(CSendRaw_Mod) {
|
||||
AddHelpCommand();
|
||||
AddCommand("Client", static_cast<CModCommand::ModCmdFunc>(
|
||||
&CSendRaw_Mod::SendClient),
|
||||
"[user] [network] [data to send]",
|
||||
"The data will be sent to the user's IRC client(s)");
|
||||
AddCommand(
|
||||
"Server",
|
||||
static_cast<CModCommand::ModCmdFunc>(&CSendRaw_Mod::SendServer),
|
||||
"[user] [network] [data to send]",
|
||||
"The data will be sent to the IRC server the user is connected to");
|
||||
AddCommand(
|
||||
"Current",
|
||||
static_cast<CModCommand::ModCmdFunc>(&CSendRaw_Mod::CurrentClient),
|
||||
"[data to send]", "The data will be sent to your current client");
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
void TModInfo<CSendRaw_Mod>(CModInfo& Info) {
|
||||
Info.SetWikiPage("send_raw");
|
||||
Info.SetWikiPage("send_raw");
|
||||
}
|
||||
|
||||
USERMODULEDEFS(CSendRaw_Mod,
|
||||
|
||||
Reference in New Issue
Block a user