mirror of
https://github.com/znc/znc.git
synced 2026-05-06 05:22:26 +02:00
Add an optional argument to /znc jump
If you have 10 servers in your server list and you want to directly jump to e.g. irc.foo.bar, you can now do "/znc jump irc.foo.bar". Thanks to PsWii60 for constantly bugging me for this. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2109 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -234,11 +234,38 @@ void CClient::UserCommand(CString& sLine) {
|
||||
return;
|
||||
}
|
||||
|
||||
CString sArgs = sLine.Token(1, true);
|
||||
CServer *pServer = NULL;
|
||||
|
||||
if (!sArgs.empty()) {
|
||||
pServer = m_pUser->FindServer(sArgs);
|
||||
if (!pServer) {
|
||||
PutStatus("Server [" + sArgs + "] not found");
|
||||
return;
|
||||
}
|
||||
m_pUser->SetNextServer(pServer);
|
||||
|
||||
if (!GetIRCSock()) {
|
||||
// If we are already connecting to some server,
|
||||
// we have to abort that attempt
|
||||
Csock *pIRCSock = CZNC::Get().GetManager()
|
||||
.FindSockByName("IRC::" + m_pUser->GetUserName());
|
||||
if (pIRCSock)
|
||||
pIRCSock->Close();
|
||||
}
|
||||
}
|
||||
|
||||
if (GetIRCSock()) {
|
||||
GetIRCSock()->Quit();
|
||||
PutStatus("Jumping to the next server in the list...");
|
||||
if (pServer)
|
||||
PutStatus("Connecting to [" + pServer->GetName() + "]...");
|
||||
else
|
||||
PutStatus("Jumping to the next server in the list...");
|
||||
} else {
|
||||
PutStatus("Connecting...");
|
||||
if (pServer)
|
||||
PutStatus("Connecting to [" + pServer->GetName() + "]...");
|
||||
else
|
||||
PutStatus("Connecting...");
|
||||
}
|
||||
|
||||
m_pUser->SetIRCConnectEnabled(true);
|
||||
@@ -1193,8 +1220,8 @@ void CClient::HelpUser() {
|
||||
}
|
||||
|
||||
Table.AddRow();
|
||||
Table.SetCell("Command", "Jump");
|
||||
Table.SetCell("Description", "Jump to the next server in the list");
|
||||
Table.SetCell("Command", "Jump [server]");
|
||||
Table.SetCell("Description", "Jump to the next or the specified server");
|
||||
|
||||
Table.AddRow();
|
||||
Table.SetCell("Command", "Disconnect");
|
||||
|
||||
11
User.cpp
11
User.cpp
@@ -925,6 +925,17 @@ CServer* CUser::GetCurrentServer() const {
|
||||
return m_vServers[uIdx];
|
||||
}
|
||||
|
||||
bool CUser::SetNextServer(const CServer* pServer) {
|
||||
for (unsigned int a = 0; a < m_vServers.size(); a++) {
|
||||
if (m_vServers[a] == pServer) {
|
||||
m_uServerIdx = a;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CUser::CheckPass(const CString& sPass) const {
|
||||
switch (m_eHashType)
|
||||
{
|
||||
|
||||
1
User.h
1
User.h
@@ -60,6 +60,7 @@ public:
|
||||
bool AddServer(const CString& sName, unsigned short uPort, const CString& sPass = "", bool bSSL = false);
|
||||
CServer* GetNextServer();
|
||||
CServer* GetCurrentServer() const;
|
||||
bool SetNextServer(const CServer* pServer);
|
||||
bool CheckPass(const CString& sPass) const;
|
||||
bool AddAllowedHost(const CString& sHostMask);
|
||||
bool IsHostAllowed(const CString& sHostMask) const;
|
||||
|
||||
Reference in New Issue
Block a user