Skip to content

Instantly share code, notes, and snippets.

@jonypoins
Created April 25, 2012 05:10
Show Gist options
  • Save jonypoins/2486642 to your computer and use it in GitHub Desktop.
Save jonypoins/2486642 to your computer and use it in GitHub Desktop.
ZNC: Self-written Query Message Relay, Query Buffering, Webadmin Patch
diff -urN znc-0.206-orig//Client.cpp znc-0.206/Client.cpp
--- znc-0.206-orig//Client.cpp 2012-04-06 04:25:50.000000000 +0900
+++ znc-0.206/Client.cpp 2012-04-23 12:24:40.000000000 +0900
@@ -389,17 +389,28 @@
}
// Relay to the rest of the clients that may be connected to this user
- if (m_pUser->IsChan(sTarget)) {
- vector<CClient*>& vClients = m_pUser->GetClients();
+ //if (m_pUser->IsChan(sTarget)) {
+ vector<CClient*>& vClients = m_pUser->GetClients();
- for (unsigned int a = 0; a < vClients.size(); a++) {
- CClient* pClient = vClients[a];
+ for (unsigned int a = 0; a < vClients.size(); a++) {
+ CClient* pClient = vClients[a];
+ //if (pClient != this) {
+ // pClient->PutClient(":" + GetNickMask() + " PRIVMSG " + sTarget + " :\001" + sCTCP + "\001");
+ //}
+ if (m_pUser->IsChan(sTarget)) {
if (pClient != this) {
pClient->PutClient(":" + GetNickMask() + " PRIVMSG " + sTarget + " :\001" + sCTCP + "\001");
}
+ } else {
+ if (pClient == this) {
+ m_pUser->AddQueryBuffer(":" + sTarget + " PRIVMSG ", GetNick() + " :\001ACTION <***> * " + GetNick() + " " + m_pUser->AddTimestamp(sMessage) + "\001");
+ } else {
+ pClient->PutClient(":" + sTarget + " PRIVMSG " + GetNick() + " :\001ACTION <***> * " + GetNick() + " " + sMessage + "\001");
+ }
}
}
+ //}
} else {
MODULECALL(OnUserCTCP(sTarget, sCTCP), m_pUser, this, return);
}
@@ -437,17 +448,28 @@
// Relay to the rest of the clients that may be connected to this user
- if (m_pUser->IsChan(sTarget)) {
- vector<CClient*>& vClients = m_pUser->GetClients();
+ //if (m_pUser->IsChan(sTarget)) {
+ vector<CClient*>& vClients = m_pUser->GetClients();
- for (unsigned int a = 0; a < vClients.size(); a++) {
- CClient* pClient = vClients[a];
+ for (unsigned int a = 0; a < vClients.size(); a++) {
+ CClient* pClient = vClients[a];
+ //if (pClient != this) {
+ // pClient->PutClient(":" + GetNickMask() + " PRIVMSG " + sTarget + " :" + sMsg);
+ //}
+ if (m_pUser->IsChan(sTarget)) {
if (pClient != this) {
pClient->PutClient(":" + GetNickMask() + " PRIVMSG " + sTarget + " :" + sMsg);
}
+ } else {
+ if (pClient == this) {
+ m_pUser->AddQueryBuffer(":" + sTarget + " PRIVMSG ", GetNick() + " :<***> <" + GetNick() + "> " + m_pUser->AddTimestamp(sMsg));
+ } else {
+ pClient->PutClient(":" + sTarget + " PRIVMSG " + GetNick() + " :<***> <" + GetNick() + "> " + sMsg);
+ }
}
}
+ //}
return;
}
diff -urN znc-0.206-orig//IRCSock.cpp znc-0.206/IRCSock.cpp
--- znc-0.206-orig//IRCSock.cpp 2012-04-06 04:25:50.000000000 +0900
+++ znc-0.206/IRCSock.cpp 2012-04-23 12:25:13.000000000 +0900
@@ -785,10 +785,10 @@
if (sMessage.TrimPrefix("ACTION ")) {
MODULECALL(OnPrivAction(Nick, sMessage), m_pUser, NULL, return true);
- if (!m_pUser->IsUserAttached()) {
+ //if (!m_pUser->IsUserAttached()) {
// If the user is detached, add to the buffer
- m_pUser->AddQueryBuffer(":" + Nick.GetNickMask() + " PRIVMSG ", " :\001ACTION " + m_pUser->AddTimestamp(sMessage) + "\001");
- }
+ m_pUser->AddQueryBuffer(":" + Nick.GetNickMask() + " PRIVMSG ", " :\001ACTION " + m_pUser->AddTimestamp(sMessage) + "\001");
+ //}
sMessage = "ACTION " + sMessage;
}
@@ -844,10 +844,10 @@
bool CIRCSock::OnPrivNotice(CNick& Nick, CString& sMessage) {
MODULECALL(OnPrivNotice(Nick, sMessage), m_pUser, NULL, return true);
- if (!m_pUser->IsUserAttached()) {
+ //if (!m_pUser->IsUserAttached()) {
// If the user is detached, add to the buffer
- m_pUser->AddQueryBuffer(":" + Nick.GetNickMask() + " NOTICE ", " :" + m_pUser->AddTimestamp(sMessage));
- }
+ m_pUser->AddQueryBuffer(":" + Nick.GetNickMask() + " NOTICE ", " :" + m_pUser->AddTimestamp(sMessage));
+ //}
return false;
}
@@ -855,10 +855,10 @@
bool CIRCSock::OnPrivMsg(CNick& Nick, CString& sMessage) {
MODULECALL(OnPrivMsg(Nick, sMessage), m_pUser, NULL, return true);
- if (!m_pUser->IsUserAttached()) {
+ //if (!m_pUser->IsUserAttached()) {
// If the user is detached, add to the buffer
- m_pUser->AddQueryBuffer(":" + Nick.GetNickMask() + " PRIVMSG ", " :" + m_pUser->AddTimestamp(sMessage));
- }
+ m_pUser->AddQueryBuffer(":" + Nick.GetNickMask() + " PRIVMSG ", " :" + m_pUser->AddTimestamp(sMessage));
+ //}
return false;
}
diff -urN znc-0.206-orig//WebModules.cpp znc-0.206/WebModules.cpp
--- znc-0.206-orig//WebModules.cpp 2012-04-06 04:25:50.000000000 +0900
+++ znc-0.206/WebModules.cpp 2012-04-23 00:58:19.000000000 +0900
@@ -618,7 +618,7 @@
ParsePath();
// Make sure modules are treated as directories
if (sURI.Right(1) != "/" && sURI.find(".") == CString::npos && sURI.TrimLeft_n("/mods/").TrimLeft_n("/").find("/") == CString::npos) {
- Redirect(sURI + "/");
+ Redirect("/" + sURI + "/");
return PAGE_DONE;
}
@amyreese
Copy link

amyreese commented Feb 4, 2013

Updated to compile against 1.0: https://gist.github.com/4710462

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment