2629
by Alexey Sokolov
ZNC-Extra no more. |
1 |
/*
|
2930
by Alexey Sokolov
Change ZNC license to Apache 2.0 |
2 |
* Copyright (C) 2004-2013 ZNC, see the NOTICE file for details.
|
3 |
*
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
6 |
* You may obtain a copy of the License at
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13 |
* See the License for the specific language governing permissions and
|
|
14 |
* limitations under the License.
|
|
2629
by Alexey Sokolov
ZNC-Extra no more. |
15 |
*/
|
16 |
||
17 |
#include <znc/IRCNetwork.h> |
|
18 |
#include <znc/Chan.h> |
|
19 |
||
2736
by Alexey Sokolov
using in headers is evil :( |
20 |
using std::vector; |
21 |
||
2629
by Alexey Sokolov
ZNC-Extra no more. |
22 |
class CClearBufferOnMsgMod : public CModule { |
23 |
public: |
|
24 |
MODCONSTRUCTOR(CClearBufferOnMsgMod) {} |
|
25 |
||
26 |
void ClearAllBuffers() { |
|
27 |
if (m_pNetwork) { |
|
28 |
const vector<CChan*>& vChans = m_pNetwork->GetChans(); |
|
29 |
vector<CChan*>::const_iterator it; |
|
30 |
||
31 |
for (it = vChans.begin(); it != vChans.end(); ++it) { |
|
32 |
// Skip detached channels, they weren't read yet
|
|
33 |
if ((*it)->IsDetached()) |
|
34 |
continue; |
|
35 |
||
36 |
(*it)->ClearBuffer(); |
|
2692
by Alexey Sokolov
Rename (non-) KeepBuffer to AutoClearChanBuffer. |
37 |
// We deny AutoClearChanBuffer on all channels since this module
|
38 |
// doesn't make any sense with it
|
|
39 |
(*it)->SetAutoClearChanBuffer(false); |
|
2629
by Alexey Sokolov
ZNC-Extra no more. |
40 |
}
|
41 |
}
|
|
42 |
}
|
|
43 |
||
44 |
virtual EModRet OnUserMsg(CString& sTarget, CString& sMessage) { |
|
45 |
ClearAllBuffers(); |
|
46 |
return CONTINUE; |
|
47 |
}
|
|
48 |
||
49 |
virtual EModRet OnUserCTCP(CString& sTarget, CString& sMessage) { |
|
50 |
ClearAllBuffers(); |
|
51 |
return CONTINUE; |
|
52 |
}
|
|
53 |
||
54 |
virtual EModRet OnUserAction(CString& sTarget, CString& sMessage) { |
|
55 |
ClearAllBuffers(); |
|
56 |
return CONTINUE; |
|
57 |
}
|
|
58 |
||
59 |
virtual EModRet OnUserNotice(CString& sTarget, CString& sMessage) { |
|
60 |
ClearAllBuffers(); |
|
61 |
return CONTINUE; |
|
62 |
}
|
|
63 |
||
64 |
virtual EModRet OnUserPart(CString& sChannel, CString& sMessage) { |
|
65 |
ClearAllBuffers(); |
|
66 |
return CONTINUE; |
|
67 |
}
|
|
68 |
||
69 |
virtual EModRet OnUserTopic(CString& sChannel, CString& sTopic) { |
|
70 |
ClearAllBuffers(); |
|
71 |
return CONTINUE; |
|
72 |
}
|
|
73 |
};
|
|
74 |
||
2721
by Alexey Sokolov
Fix presense and help of module arguments. |
75 |
template<> void TModInfo<CClearBufferOnMsgMod>(CModInfo& Info) { |
76 |
Info.SetWikiPage("clearbufferonmsg"); |
|
77 |
}
|
|
78 |
||
2629
by Alexey Sokolov
ZNC-Extra no more. |
79 |
USERMODULEDEFS(CClearBufferOnMsgMod, "Clear all channel buffers whenever the user does something") |