unrealircd- supernets unrealircd source & configuration |
git clone git://git.acid.vegas/unrealircd.git |
Log | Files | Refs | Archive | README | LICENSE |
channel-context.c (2343B)
1 /* 2 * IRC - Internet Relay Chat, src/modules/channel-context.c 3 * (C) 2022 Valware & The UnrealIRCd Team 4 * 5 * See file AUTHORS in IRC package for additional names of 6 * the programmers. 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 1, or (at your option) 11 * any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 */ 22 23 #include "unrealircd.h" 24 25 ModuleHeader MOD_HEADER 26 = { 27 "channel-context", 28 "1.0", 29 "Channel Context (IRCv3)", 30 "UnrealIRCd team", 31 "unrealircd-6", 32 }; 33 34 int chancontext_mtag_is_ok(Client *client, const char *name, const char *value); 35 void mtag_add_chancontext(Client *client, MessageTag *recv_mtags, MessageTag **mtag_list, const char *signature); 36 37 MOD_INIT() 38 { 39 MessageTagHandlerInfo mtag; 40 41 MARK_AS_OFFICIAL_MODULE(modinfo); 42 43 memset(&mtag, 0, sizeof(mtag)); 44 mtag.is_ok = chancontext_mtag_is_ok; 45 mtag.flags = MTAG_HANDLER_FLAGS_NO_CAP_NEEDED; 46 mtag.name = "+draft/channel-context"; 47 MessageTagHandlerAdd(modinfo->handle, &mtag); 48 49 HookAddVoid(modinfo->handle, HOOKTYPE_NEW_MESSAGE, 0, mtag_add_chancontext); 50 51 return MOD_SUCCESS; 52 } 53 54 MOD_LOAD() 55 { 56 return MOD_SUCCESS; 57 } 58 59 MOD_UNLOAD() 60 { 61 return MOD_SUCCESS; 62 } 63 64 int chancontext_mtag_is_ok(Client *client, const char *name, const char *value) 65 { 66 if (BadPtr(value)) 67 return 0; 68 69 /* Validate a bit further, but only for local users.. */ 70 if (MyUser(client)) 71 { 72 Channel *channel = find_channel(value); 73 if (!channel) 74 return 0; 75 if (!IsMember(client, channel)) 76 return 0; 77 } 78 79 return 1; 80 } 81 82 void mtag_add_chancontext(Client *client, MessageTag *recv_mtags, MessageTag **mtag_list, const char *signature) 83 { 84 MessageTag *m; 85 86 if (IsUser(client)) 87 { 88 m = find_mtag(recv_mtags, "+draft/channel-context"); 89 if (m) 90 { 91 m = duplicate_mtag(m); 92 AddListItem(m, *mtag_list); 93 } 94 } 95 }