mirror of
https://github.com/znc/znc.git
synced 2026-08-06 17:03:14 +02:00
Merge remote branch 'github-kylef/nick'
This commit is contained in:
+6
-12
@@ -539,31 +539,25 @@ bool CModule::PutUser(const CString& sLine) {
|
||||
bool CModule::PutStatus(const CString& sLine) {
|
||||
return (m_pUser) ? m_pUser->PutStatus(sLine, m_pClient) : false;
|
||||
}
|
||||
unsigned int CModule::PutModule(const CTable& table, const CString& sIdent, const CString& sHost) {
|
||||
unsigned int CModule::PutModule(const CTable& table) {
|
||||
if (!m_pUser)
|
||||
return 0;
|
||||
|
||||
unsigned int idx = 0;
|
||||
CString sLine;
|
||||
while (table.GetLine(idx++, sLine))
|
||||
PutModule(sLine, sIdent, sHost);
|
||||
PutModule(sLine);
|
||||
return idx - 1;
|
||||
}
|
||||
bool CModule::PutModule(const CString& sLine, const CString& sIdent, const CString& sHost) {
|
||||
bool CModule::PutModule(const CString& sLine) {
|
||||
if (!m_pUser)
|
||||
return false;
|
||||
return m_pUser->PutUser(":" + GetModNick() + "!" +
|
||||
(sIdent.empty() ? GetModName() : sIdent) + "@" + sHost +
|
||||
" PRIVMSG " + m_pUser->GetCurNick() + " :" + sLine,
|
||||
m_pClient);
|
||||
return m_pUser->PutModule(GetModName(), sLine, m_pClient);
|
||||
}
|
||||
bool CModule::PutModNotice(const CString& sLine, const CString& sIdent, const CString& sHost) {
|
||||
bool CModule::PutModNotice(const CString& sLine) {
|
||||
if (!m_pUser)
|
||||
return false;
|
||||
return m_pUser->PutUser(":" + GetModNick() + "!" +
|
||||
(sIdent.empty() ? GetModName() : sIdent) + "@" + sHost +
|
||||
" NOTICE " + m_pUser->GetCurNick() + " :" + sLine,
|
||||
m_pClient);
|
||||
return m_pUser->PutModNotice(GetModName(), sLine, m_pClient);
|
||||
}
|
||||
|
||||
///////////////////
|
||||
|
||||
@@ -757,28 +757,22 @@ public:
|
||||
* module hook for a specific client, only that client gets this
|
||||
* message, else all connected clients will receive it.
|
||||
* @param sLine The message which should be sent.
|
||||
* @param sIdent The ident for the module nick. Defaults to the module name.
|
||||
* @param sHost The hostname for the module nick. Defaults to znc.in
|
||||
* @return true if the line was sent to at least one client.
|
||||
*/
|
||||
virtual bool PutModule(const CString& sLine, const CString& sIdent = "", const CString& sHost = "znc.in");
|
||||
virtual bool PutModule(const CString& sLine);
|
||||
/** This function calls CModule::PutModule(const CString&, const
|
||||
* CString&, const CString&) for each line in the table.
|
||||
* @param table The table which should be send.
|
||||
* @param sIdent The ident which should be used.
|
||||
* @param sHost The hostname used for the query.
|
||||
* @return The number of lines sent.
|
||||
*/
|
||||
virtual unsigned int PutModule(const CTable& table, const CString& sIdent = "", const CString& sHost = "znc.in");
|
||||
virtual unsigned int PutModule(const CTable& table);
|
||||
/** Send a notice from your module nick. If we are in a module hook for
|
||||
* a specific client, only that client gets this notice, else all
|
||||
* clients will receive it.
|
||||
* @param sLine The line which should be sent.
|
||||
* @param sIdent The ident used for the notice.
|
||||
* @param sHost The host name used for the notice.
|
||||
* @return true if the line was sent to at least one client.
|
||||
*/
|
||||
virtual bool PutModNotice(const CString& sLine, const CString& sIdent = "", const CString& sHost = "znc.in");
|
||||
virtual bool PutModNotice(const CString& sLine);
|
||||
|
||||
/** @returns The name of the module. */
|
||||
const CString& GetModName() const { return m_sModName; }
|
||||
|
||||
@@ -1104,6 +1104,20 @@ bool CUser::PutModule(const CString& sModule, const CString& sLine, CClient* pCl
|
||||
return (pClient == NULL);
|
||||
}
|
||||
|
||||
bool CUser::PutModNotice(const CString& sModule, const CString& sLine, CClient* pClient, CClient* pSkipClient) {
|
||||
for (unsigned int a = 0; a < m_vClients.size(); a++) {
|
||||
if ((!pClient || pClient == m_vClients[a]) && pSkipClient != m_vClients[a]) {
|
||||
m_vClients[a]->PutModNotice(sModule, sLine);
|
||||
|
||||
if (pClient) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (pClient == NULL);
|
||||
}
|
||||
|
||||
bool CUser::ResumeFile(unsigned short uPort, unsigned long uFileSize) {
|
||||
CSockManager& Manager = CZNC::Get().GetManager();
|
||||
|
||||
|
||||
@@ -101,6 +101,7 @@ public:
|
||||
bool PutStatus(const CString& sLine, CClient* pClient = NULL, CClient* pSkipClient = NULL);
|
||||
bool PutStatusNotice(const CString& sLine, CClient* pClient = NULL, CClient* pSkipClient = NULL);
|
||||
bool PutModule(const CString& sModule, const CString& sLine, CClient* pClient = NULL, CClient* pSkipClient = NULL);
|
||||
bool PutModNotice(const CString& sModule, const CString& sLine, CClient* pClient = NULL, CClient* pSkipClient = NULL);
|
||||
|
||||
bool IsUserAttached() const { return !m_vClients.empty(); }
|
||||
void UserConnected(CClient* pClient);
|
||||
|
||||
+17
-17
@@ -162,7 +162,7 @@ public:
|
||||
if (sCommand.Token(1) != "-quiet")
|
||||
{
|
||||
sReason = sCommand.Token(1, true);
|
||||
PutModNotice("You have been marked as away", "away");
|
||||
PutModNotice("You have been marked as away");
|
||||
}
|
||||
else
|
||||
sReason = sCommand.Token(2, true);
|
||||
@@ -171,40 +171,40 @@ public:
|
||||
else if (sCmdName == "back")
|
||||
{
|
||||
if ((m_vMessages.empty()) && (sCommand.Token(1) != "-quiet"))
|
||||
PutModNotice("Welcome Back!", "away");
|
||||
PutModNotice("Welcome Back!");
|
||||
Back();
|
||||
}
|
||||
else if (sCmdName == "messages")
|
||||
{
|
||||
for (u_int a = 0; a < m_vMessages.size(); a++)
|
||||
PutModule(m_vMessages[a], "away");
|
||||
PutModule(m_vMessages[a]);
|
||||
}
|
||||
else if (sCmdName == "delete")
|
||||
{
|
||||
CString sWhich = sCommand.Token(1);
|
||||
if (sWhich == "all")
|
||||
{
|
||||
PutModNotice("Deleted " + CString(m_vMessages.size()) + " Messages.", "away");
|
||||
PutModNotice("Deleted " + CString(m_vMessages.size()) + " Messages.");
|
||||
for (u_int a = 0; a < m_vMessages.size(); a++)
|
||||
m_vMessages.erase(m_vMessages.begin() + a--);
|
||||
|
||||
}
|
||||
else if (sWhich.empty())
|
||||
{
|
||||
PutModNotice("USAGE: delete <num|all>", "away");
|
||||
PutModNotice("USAGE: delete <num|all>");
|
||||
return;
|
||||
} else
|
||||
{
|
||||
u_int iNum = sWhich.ToUInt();
|
||||
if (iNum >= m_vMessages.size())
|
||||
{
|
||||
PutModNotice("Illegal Message # Requested", "away");
|
||||
PutModNotice("Illegal Message # Requested");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_vMessages.erase(m_vMessages.begin() + iNum);
|
||||
PutModNotice("Message Erased.", "away");
|
||||
PutModNotice("Message Erased.");
|
||||
}
|
||||
SaveBufferToDisk();
|
||||
}
|
||||
@@ -212,7 +212,7 @@ public:
|
||||
else if (sCmdName == "save" && m_saveMessages)
|
||||
{
|
||||
SaveBufferToDisk();
|
||||
PutModNotice("Messages saved to disk.", "away");
|
||||
PutModNotice("Messages saved to disk.");
|
||||
}
|
||||
else if (sCmdName == "ping")
|
||||
{
|
||||
@@ -237,7 +237,7 @@ public:
|
||||
if ((sTime.empty()) || (sWhom.empty()) || (sMessage.empty()))
|
||||
{
|
||||
// illegal format
|
||||
PutModule("Corrupt message! [" + m_vMessages[a] + "]", "away");
|
||||
PutModule("Corrupt message! [" + m_vMessages[a] + "]");
|
||||
m_vMessages.erase(m_vMessages.begin() + a--);
|
||||
continue;
|
||||
}
|
||||
@@ -248,7 +248,7 @@ public:
|
||||
size_t iCount = strftime(szFormat, 64, "%F %T", &t);
|
||||
if (iCount <= 0)
|
||||
{
|
||||
PutModule("Corrupt time stamp! [" + m_vMessages[a] + "]", "away");
|
||||
PutModule("Corrupt time stamp! [" + m_vMessages[a] + "]");
|
||||
m_vMessages.erase(m_vMessages.begin() + a--);
|
||||
continue;
|
||||
}
|
||||
@@ -260,11 +260,11 @@ public:
|
||||
}
|
||||
for (map< CString, vector< CString> >::iterator it = msvOutput.begin(); it != msvOutput.end(); ++it)
|
||||
{
|
||||
PutModule(it->first, "away");
|
||||
PutModule(it->first);
|
||||
for (u_int a = 0; a < it->second.size(); a++)
|
||||
PutModule(it->second[a]);
|
||||
}
|
||||
PutModule("#--- End Messages", "away");
|
||||
PutModule("#--- End Messages");
|
||||
} else if (sCmdName == "enabletimer")
|
||||
{
|
||||
SetAwayTime(300);
|
||||
@@ -289,7 +289,7 @@ public:
|
||||
PutModule("Current timer setting: " + CString(GetAwayTime()) + " seconds");
|
||||
} else
|
||||
{
|
||||
PutModule("Commands: away [-quiet], back [-quiet], delete <num|all>, ping, show, save, enabletimer, disabletimer, settimer <secs>, timer", "away");
|
||||
PutModule("Commands: away [-quiet], back [-quiet], delete <num|all>, ping, show, save, enabletimer, disabletimer, settimer <secs>, timer");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,13 +333,13 @@ public:
|
||||
{
|
||||
if (bUsePrivMessage)
|
||||
{
|
||||
PutModule("Welcome Back!", "away");
|
||||
PutModule("You have " + CString(m_vMessages.size()) + " messages!", "away");
|
||||
PutModule("Welcome Back!");
|
||||
PutModule("You have " + CString(m_vMessages.size()) + " messages!");
|
||||
}
|
||||
else
|
||||
{
|
||||
PutModNotice("Welcome Back!", "away");
|
||||
PutModNotice("You have " + CString(m_vMessages.size()) + " messages!", "away");
|
||||
PutModNotice("Welcome Back!");
|
||||
PutModNotice("You have " + CString(m_vMessages.size()) + " messages!");
|
||||
}
|
||||
}
|
||||
m_sReason = "";
|
||||
|
||||
Reference in New Issue
Block a user