From a719ea36aac09c3775ed34dea29a2d15b32044a3 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Sat, 26 Aug 2017 21:46:55 +0100 Subject: [PATCH] Make disconkick a module again. While not kicking upon disconnect can cause desync with client and other issues, there were multiple complains about the new behavior, and the user should have the choice. Revert 2f65dbbc6478c6e4e25718f5c1f4f6fc74c90e82 Ref #968 --- modules/disconkick.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++ src/IRCSock.cpp | 10 --------- src/User.cpp | 8 -------- 3 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 modules/disconkick.cpp diff --git a/modules/disconkick.cpp b/modules/disconkick.cpp new file mode 100644 index 00000000..243af6f3 --- /dev/null +++ b/modules/disconkick.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2004-2017 ZNC, see the NOTICE file for details. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +class CKickClientOnIRCDisconnect : public CModule { + public: + MODCONSTRUCTOR(CKickClientOnIRCDisconnect) {} + + void OnIRCDisconnected() override { + CString sPrefix = GetUser()->GetStatusPrefix(); + for (CChan* pChan : GetNetwork()->GetChans()) { + if (pChan->IsOn()) { + PutUser(":" + sPrefix + "disconkick!znc@znc.in KICK " + + pChan->GetName() + " " + + GetNetwork()->GetIRCNick().GetNick() + " :" + + t_s("You have been disconnected from the IRC server")); + } + } + } +}; + +template <> +void TModInfo(CModInfo& Info) { + Info.SetWikiPage("disconkick"); +} + +USERMODULEDEFS( + CKickClientOnIRCDisconnect, + t_s("Kicks the client from all channels when the connection to the " + "IRC server is lost")) diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index 8d2de76c..a0c5a07f 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -1217,16 +1217,6 @@ void CIRCSock::Disconnected() { m_pNetwork->ClearRawBuffer(); m_pNetwork->ClearMotdBuffer(); - CString sPrefix = m_pNetwork->GetUser()->GetStatusPrefix(); - for (CChan* pChan : m_pNetwork->GetChans()) { - if (pChan->IsOn()) { - m_pNetwork->PutUser( - ":" + sPrefix + "status!znc@znc.in KICK " + pChan->GetName() + - " " + GetNick() + - " :You have been disconnected from the IRC server"); - } - } - ResetChans(); // send a "reset user modes" cmd to the client. diff --git a/src/User.cpp b/src/User.cpp index 2347a7c6..c853968b 100644 --- a/src/User.cpp +++ b/src/User.cpp @@ -463,14 +463,6 @@ bool CUser::ParseConfig(CConfig* pConfig, CString& sError) { continue; } - // XXX Legacy crap, added in 1.7 - if (sModName == "disconkick") { - sNotice = - "NOTICE: [disconkick] is integrated to core now, ignoring it"; - CUtils::PrintMessage(sNotice); - continue; - } - CString sModRet; CString sArgs = sMod.Token(1, true);