View difference between Paste ID: tgmHzUr8 and B1Dr7GkQ
SHOW: | | - or go back to the newest paste.
1
/*
2
 Connected via WEBIRC users only Channel Mode +W)
3
 */
4
 
5
#include "unrealircd.h"
6
 
7
ModuleHeader MOD_HEADER(m_webirconly)
8
  = {
9
    "chanmodes/webirconly",
10
    "$Id: v0.01 2018/12/21 Mauropek$",
11
    "Channel Mode +W",
12
    "3.2-b8-1",
13
    NULL
14
    };
15
 
16
Cmode_t EXTCMODE_WEBIRCONLY;
17
 
18
#define Iswebirconly(chptr)    (chptr->mode.extmode & EXTCMODE_WEBIRCONLY)
19
 
20
DLLFUNC int webirconly_can_send (aClient* cptr, aChannel *chptr, char* message, Membership* lp, int notice);
21
DLLFUNC char *webirconly_part_message (aClient* sptr, aChannel *chptr, char* comment);
22
23
static int is_webirc (aClient *cptr);
24
 
25
MOD_TEST(m_webirconly)
26
{
27
    return MOD_SUCCESS;
28
}
29
 
30
MOD_INIT(m_webirconly)
31
{
32
CmodeInfo req;
33
    memset(&req, 0, sizeof(req));
34
    req.paracount = 0;
35
    req.flag = 'W';
36
    req.is_ok = extcmode_default_requirehalfop;
37
    CmodeAdd(modinfo->handle, req, &EXTCMODE_WEBIRCONLY);
38
   
39
	HookAdd(modinfo->handle, HOOKTYPE_CAN_SEND, 0, webirconly_can_send);
40
	HookAddPChar(modinfo->handle, HOOKTYPE_PRE_LOCAL_PART, 0, webirconly_part_message);
41
 
42
   return MOD_SUCCESS;
43
}
44
 
45
MOD_LOAD(m_webirconly)
46
{
47
    return MOD_SUCCESS;
48
}
49
 
50
MOD_UNLOAD(m_webirconly)
51
{
52
    return MOD_SUCCESS;
53
}
54
55
DLLFUNC char *webirconly_part_message (aClient *sptr, aChannel *chptr, char *comment)
56
{
57
	if (!comment)
58
		return NULL;
59
60
	if (Iswebirconly(chptr) && !is_webirc(sptr))
61
		return NULL;
62
63
	return comment;
64
}
65
66
DLLFUNC int webirconly_can_send (aClient *cptr, aChannel *chptr, char *message, Membership *lp, int notice)
67
{
68
	Hook *h;
69
	int i;
70
71-
	if (Iswebirconly(chptr) && !is_webirc(sptr) &&
71+
	if (Iswebirconly(chptr) && !is_webirc(cptr) &&
72
		    (!lp
73
		    || !(lp->flags & (CHFL_CHANOP | CHFL_VOICE | CHFL_CHANOWNER |
74
		    CHFL_HALFOP | CHFL_CHANPROT))))
75
	{
76
		for (h = Hooks[HOOKTYPE_CAN_BYPASS_CHANNEL_MESSAGE_RESTRICTION]; h; h = h->next)
77
		{
78
			i = (*(h->func.intfunc))(cptr, chptr, BYPASS_CHANMSG_MODERATED);
79
			if (i != HOOK_CONTINUE)
80
				break;
81
		}
82
		if (i == HOOK_ALLOW)
83
			return HOOK_CONTINUE; /* bypass +W restriction */
84
85
		return CANNOT_SEND_MODREG; /* BLOCK message */
86
	}
87
88
	return HOOK_CONTINUE;
89
}
90
91
static int is_webirc (aClient *cptr){
92
    ModDataInfo *moddata;
93
    moddata = findmoddata_byname("webirc", MODDATATYPE_CLIENT);
94
    if(moddata == NULL) return 0;
95-
    if(Iswebirconly(chptr) && !moddata_client(cptr, moddata).l){
95+
    if(moddata_client(cptr, moddata).l){
96
        return 1;
97
    }
98
    return 0;
99
}