1 /*
2 * Copyright (c) 2012 Jilles Tjoelker <jilles@stack.nl>
3 * Rights to this code are as documented in doc/LICENSE.
4 *
5 * Remembers the last quit message of a user.
6 */
7
8 #include "atheme.h"
9
10 DECLARE_MODULE_V1
11 (
12 "nickserv/info_lastquit", false, _modinit, _moddeinit,
13 PACKAGE_STRING,
14 VENDOR_STRING
15 );
16
user_delete_info_hook(hook_user_delete_t * hdata)17 static void user_delete_info_hook(hook_user_delete_t *hdata)
18 {
19 if (hdata->u->myuser == NULL)
20 return;
21 metadata_add(hdata->u->myuser,
22 "private:lastquit:message", hdata->comment);
23 }
24
info_hook(hook_user_req_t * hdata)25 static void info_hook(hook_user_req_t *hdata)
26 {
27 metadata_t *md;
28
29 if (!(hdata->mu->flags & MU_PRIVATE) || hdata->si->smu == hdata->mu ||
30 has_priv(hdata->si, PRIV_USER_AUSPEX))
31 {
32 md = metadata_find(hdata->mu, "private:lastquit:message");
33 if (md != NULL)
34 command_success_nodata(hdata->si, "Last quit : %s",
35 md->value);
36 }
37 }
38
_modinit(module_t * m)39 void _modinit(module_t *m)
40 {
41 hook_add_event("user_delete_info");
42 hook_add_user_delete_info(user_delete_info_hook);
43
44 hook_add_event("user_info");
45 hook_add_first_user_info(info_hook);
46 }
47
_moddeinit(module_unload_intent_t intent)48 void _moddeinit(module_unload_intent_t intent)
49 {
50 hook_del_user_delete_info(user_delete_info_hook);
51 hook_del_user_info(info_hook);
52 }
53
54 /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
55 * vim:ts=8
56 * vim:sw=8
57 * vim:noexpandtab
58 */
59