forked from unrealircd/unrealircd-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
My implementation of ircv3/ircv3-ideas#108
## `+draft/rated` This lets users who post media mark their posts as "Not safe for work" to some degree, allowing other users to choose whether or not they want to see this post.
- Loading branch information
1 parent
c124bf1
commit 75f49a6
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
Licence: GPLv3 or later | ||
Copyright Ⓒ 2023 Valerie Pond | ||
draft/rated | ||
*/ | ||
/*** <<<MODULE MANAGER START>>> | ||
module | ||
{ | ||
documentation "https://github.com/ValwareIRC/valware-unrealircd-mods/blob/main/rated/README.md"; | ||
troubleshooting "In case of problems, documentation or e-mail me at [email protected]"; | ||
min-unrealircd-version "6.*"; | ||
max-unrealircd-version "6.*"; | ||
post-install-text { | ||
"The module is installed. Now all you need to do is add a loadmodule line:"; | ||
"loadmodule \"third/rated\";"; | ||
"The module does not need any other configuration."; | ||
} | ||
} | ||
*** <<<MODULE MANAGER END>>> | ||
*/ | ||
|
||
|
||
#include "unrealircd.h" | ||
#define MTAG_RATED "+draft/rated" // can be changed at a later date | ||
|
||
ModuleHeader MOD_HEADER = { | ||
"third/rated", | ||
"1.0", | ||
"+draft/rated", | ||
"Valware", | ||
"unrealircd-6", | ||
}; | ||
|
||
int rated_mtag_is_ok(Client *client, const char *name, const char *value); | ||
void mtag_add_rated(Client *client, MessageTag *recv_mtags, MessageTag **mtag_list, const char *signature); | ||
|
||
MOD_INIT() | ||
{ | ||
MessageTagHandlerInfo mtag; | ||
|
||
MARK_AS_GLOBAL_MODULE(modinfo); | ||
|
||
memset(&mtag, 0, sizeof(mtag)); | ||
mtag.is_ok = rated_mtag_is_ok; | ||
mtag.flags = MTAG_HANDLER_FLAGS_NO_CAP_NEEDED; | ||
mtag.name = MTAG_RATED; | ||
MessageTagHandlerAdd(modinfo->handle, &mtag); | ||
|
||
HookAddVoid(modinfo->handle, HOOKTYPE_NEW_MESSAGE, 0, mtag_add_rated); | ||
|
||
return MOD_SUCCESS; | ||
} | ||
|
||
MOD_LOAD() | ||
{ | ||
return MOD_SUCCESS; | ||
} | ||
|
||
MOD_UNLOAD() | ||
{ | ||
return MOD_SUCCESS; | ||
} | ||
|
||
int rated_mtag_is_ok(Client *client, const char *name, const char *value) | ||
{ | ||
if (strlen(value) && strlen(value) >= 100) // allow null values but cap long values to 100 chars. | ||
return 0; | ||
return 1; | ||
} | ||
|
||
void mtag_add_rated(Client *client, MessageTag *recv_mtags, MessageTag **mtag_list, const char *signature) | ||
{ | ||
MessageTag *m; | ||
|
||
if (IsUser(client)) | ||
{ | ||
m = find_mtag(recv_mtags, MTAG_RATED); | ||
if (m) | ||
{ | ||
m = duplicate_mtag(m); | ||
AddListItem(m, *mtag_list); | ||
} | ||
} | ||
} |