From e2e9b74febbaf43c362198dd264bcd5aefbeec3f Mon Sep 17 00:00:00 2001 From: psychon Date: Fri, 7 Aug 2009 19:29:43 +0000 Subject: [PATCH] Import the buffextras module from znc-extra This module adds topic changes, nick changes, parts, joins, quits, kicks and mode changes to the buffer playback. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1592 726aef4b-f618-498e-8847-2d620e286838 --- modules/buffextras.cpp | 70 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 modules/buffextras.cpp diff --git a/modules/buffextras.cpp b/modules/buffextras.cpp new file mode 100644 index 00000000..c9316369 --- /dev/null +++ b/modules/buffextras.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2004-2009 See the AUTHORS file for details. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + */ + +#include "Chan.h" +#include "User.h" +#include "Modules.h" + +class CBuffExtras : public CModule { +public: + MODCONSTRUCTOR(CBuffExtras) {} + + virtual ~CBuffExtras() {} + + void AddBuffer(CChan& Channel, const CString& sMessage) { + // If they have keep buffer disabled, only add messages if a client is connected + if (!Channel.KeepBuffer() && m_pUser->IsUserAttached()) + return; + + CString s = ":" + GetModNick() + "!" + GetModName() + "@znc.in PRIVMSG " + + Channel.GetName() + " :" + m_pUser->AddTimestamp(sMessage); + Channel.AddBuffer(s); + } + + virtual void OnRawMode(const CNick& OpNick, CChan& Channel, const CString& sModes, const CString& sArgs) { + AddBuffer(Channel, OpNick.GetNickMask() + " set mode: " + sModes + " " + sArgs); + } + + virtual void OnKick(const CNick& OpNick, const CString& sKickedNick, CChan& Channel, const CString& sMessage) { + AddBuffer(Channel, OpNick.GetNickMask() + " kicked " + sKickedNick + + " Reason: [" + sMessage + "]"); + } + + virtual void OnQuit(const CNick& Nick, const CString& sMessage, const vector& vChans) { + vector::const_iterator it; + CString sMsg = Nick.GetNickMask() + " quit with message: [" + sMessage + "]"; + for (it = vChans.begin(); it != vChans.end(); it++) { + AddBuffer(**it, sMsg); + } + } + + virtual void OnJoin(const CNick& Nick, CChan& Channel) { + AddBuffer(Channel, Nick.GetNickMask() + " joined"); + } + + virtual void OnPart(const CNick& Nick, CChan& Channel) { + AddBuffer(Channel, Nick.GetNickMask() + " parted"); + } + + virtual void OnNick(const CNick& OldNick, const CString& sNewNick, const vector& vChans) { + vector::const_iterator it; + CString sMsg = OldNick.GetNickMask() + " is now known as " + sNewNick; + for (it = vChans.begin(); it != vChans.end(); it++) { + AddBuffer(**it, sMsg); + } + } + + virtual EModRet OnTopic(CNick& Nick, CChan& Channel, CString& sTopic) { + AddBuffer(Channel, Nick.GetNickMask() + " changed the topic to: " + sTopic); + + return CONTINUE; + } +}; + +MODULEDEFS(CBuffExtras, "Add joins, parts etc. to the playback buffer") +