-
Notifications
You must be signed in to change notification settings - Fork 3
/
autoinvitejoin.cpp
45 lines (36 loc) · 1.02 KB
/
autoinvitejoin.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <znc/main.h>
#include <znc/Modules.h>
#include <znc/Chan.h>
#include <znc/IRCNetwork.h>
/*
* AutoInviteJoin module
* Author: Cizzle
* Description: Joins saved channels upon invite, even when the user is not connected.
* Version: 20160621
*/
using std::set;
class CAutoInviteJoin : public CModule {
public:
MODCONSTRUCTOR(CAutoInviteJoin) {}
virtual ~CAutoInviteJoin() {}
virtual EModRet OnInvite(const CNick& Nick, const CString& sChan) override {
CIRCNetwork *pNetwork = GetNetwork();
if (pNetwork) {
/* Only autojoin channels in our config */
CChan *invChan = pNetwork->FindChan(sChan);
if (invChan) {
set<CChan*> sChans;
sChans.insert(invChan);
pNetwork->JoinChans(sChans);
}
}
return CONTINUE;
}
};
template <>
void TModInfo<CAutoInviteJoin>(CModInfo& Info) {
Info.SetWikiPage("autoinvitejoin");
Info.AddType(CModInfo::UserModule);
Info.AddType(CModInfo::GlobalModule);
}
NETWORKMODULEDEFS(CAutoInviteJoin, "Auto joins saved channels on invite even when the user is not connected.")