From 910075a3b12fda93148f75e4035ae90fe98f18a3 Mon Sep 17 00:00:00 2001 From: imaginos Date: Sun, 15 May 2005 04:40:58 +0000 Subject: [PATCH] onjoin, when its me and the buffer is empty, reload any older buffer for fun git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@302 726aef4b-f618-498e-8847-2d620e286838 --- modules/savebuff.cpp | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/modules/savebuff.cpp b/modules/savebuff.cpp index 0d7d5d05..6f134290 100644 --- a/modules/savebuff.cpp +++ b/modules/savebuff.cpp @@ -26,6 +26,9 @@ * better solution then plain text. * * $Log$ + * Revision 1.22 2005/05/15 04:40:58 imaginos + * onjoin, when its me and the buffer is empty, reload any older buffer for fun + * * Revision 1.21 2005/05/08 06:42:02 prozacx * Moved CUtils::ToString() into CString class * @@ -271,20 +274,8 @@ public: PutModule( "//!-- EOF " + sArgs ); } else if ( strcasecmp( sCom.c_str(), "replay" ) == 0 ) { - CString sFile; - PutUser( ":***!znc@znc.com PRIVMSG " + sArgs + " :Buffer Playback..." ); - if ( DecryptChannel( sArgs, sFile ) ) - { - CString sLine; - u_int iPos = 0; - while( ReadLine( sFile, sLine, iPos ) ) - { - sLine.Trim(); - PutUser( sLine ); - } - } + Replay( sArgs ); PutModule( "Replayed " + sArgs ); - PutUser( ":***!znc@znc.com PRIVMSG " + sArgs + " :Playback Complete." ); } else if ( strcasecmp( sCom.c_str(), "save" ) == 0 ) { @@ -294,6 +285,23 @@ public: PutModule( "Unknown command [" + sCommand + "]" ); } + void Replay( const CString & sChan ) + { + CString sFile; + PutUser( ":***!znc@znc.com PRIVMSG " + sChan + " :Buffer Playback..." ); + if ( DecryptChannel( sChan, sFile ) ) + { + CString sLine; + u_int iPos = 0; + while( ReadLine( sFile, sLine, iPos ) ) + { + sLine.Trim(); + PutUser( sLine ); + } + } + PutUser( ":***!znc@znc.com PRIVMSG " + sChan + " :Playback Complete." ); + } + CString GetPath( const CString & sChannel ) { CString sBuffer = m_pUser->GetUserName() + Lower( sChannel ); @@ -343,6 +351,12 @@ public: } virtual void OnJoin(const CNick& cNick, const CChan& cChannel) { + if ( ( cNick.GetNick().CaseCmp( m_pUser->GetNick() ) == 0 ) && ( cChannel.GetBuffer().empty() ) ) + { + BootStrap( (CChan *)&cChannel ); + if ( !cChannel.GetBuffer().empty() ) + Replay( cChannel.GetName() ); + } if ( !cChannel.KeepBuffer() ) return; ((CChan &)cChannel).AddBuffer( SpoofChanMsg( cChannel.GetName(), cNick.GetNickMask() + " JOIN" ) );