ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/nickserv/mark.C
Revision: 1.1
Committed: Thu Jul 19 08:24:54 2007 UTC (19 years, 2 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Log Message:
initial import. the most important changes since Atheme are:
- fixed many memory leaks
- fixed many bugs
- converted to C++ and use more STL containers
- added a (not very enhanced yet) perl module
- greatly improved XML-RPC speed
- added a JSON-RPC module with code from json-cpp
- added a valgrind memcheck module to operserv
- added a more object oriented base64 implementation
- added a specialised unit test framework
- improved stability
- use gettimeofday() if available
- reworked adding/removing commands
- MemoServ IGNORE DEL can now remove indices

File Contents

# User Rev Content
1 pippijn 1.1 /*
2     * Copyright © 2005 William Pitcock
3     * Rights to this code are as documented in doc/LICENSE.
4     *
5     * Marking for nicknames.
6     *
7     * $Id: mark.c 7895 2007-03-06 02:40:03Z pippijn $
8     */
9    
10     #include "atheme.h"
11     #include <account/myuser.h>
12    
13     static char const rcsid[] = "$Id";
14    
15     struct ns_mark_listeners : callback::has_listeners
16     {
17     };
18    
19     ns_mark_listeners listeners;
20    
21     DECLARE_MODULE_V1 ("nickserv/mark", false, _modinit, _moddeinit, rcsid, "The Ermyth Team <http://ermyth.schmorp.de>");
22    
23     static void ns_cmd_mark (sourceinfo_t *si, int parc, char *parv[]);
24    
25     command_t ns_mark = { "MARK", N_("Adds a note to a user."), PRIV_MARK, 3, ns_cmd_mark };
26    
27     cmdvec *ns_cmdtree;
28     helpvec *ns_helptree;
29    
30     void
31     _modinit (module_t *m)
32     {
33     MODULE_USE_SYMBOL_T (ns_cmdtree, cmdvec, "nickserv/main", "ns_cmdtree");
34     MODULE_USE_SYMBOL_T (ns_helptree, helpvec, "nickserv/main", "ns_helptree");
35    
36     ns_cmdtree << ns_mark;
37     help_addentry (ns_helptree, "MARK", "help/nickserv/mark", NULL);
38     }
39    
40     void
41     _moddeinit ()
42     {
43     ns_cmdtree >> ns_mark;
44     help_delentry (ns_helptree, "MARK");
45     }
46    
47     static void
48     ns_cmd_mark (sourceinfo_t *si, int parc, char *parv[])
49     {
50     char *target = parv[0];
51     char *action = parv[1];
52     char *info = parv[2];
53     myuser_t *mu;
54    
55     if (!target || !action)
56     {
57     command_fail (si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "MARK");
58     command_fail (si, fault_needmoreparams, _("Usage: MARK <target> <ON|OFF> [note]"));
59     return;
60     }
61    
62     if (!(mu = myuser_find_ext (target)))
63     {
64     command_fail (si, fault_nosuch_target, _("\2%s\2 is not registered."), target);
65     return;
66     }
67    
68     if (!strcasecmp (action, "ON"))
69     {
70     if (!info)
71     {
72     command_fail (si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "MARK");
73     command_fail (si, fault_needmoreparams, _("Usage: MARK <target> ON <note>"));
74     return;
75     }
76    
77     if (mu->find_metadata ("private:mark:setter"))
78     {
79     command_fail (si, fault_badparams, _("\2%s\2 is already marked."), target);
80     return;
81     }
82    
83     mu->add_metadata ("private:mark:setter", get_oper_name (si));
84     mu->add_metadata ("private:mark:reason", info);
85     mu->add_metadata ("private:mark:timestamp", itoa (time (NULL)));
86    
87     wallops ("%s marked the nickname \2%s\2.", get_oper_name (si), target);
88     logcommand (si, CMDLOG_ADMIN, "MARK %s ON (reason: %s)", target, info);
89     command_success_nodata (si, _("\2%s\2 is now marked."), target);
90     }
91     else if (!strcasecmp (action, "OFF"))
92     {
93     if (!mu->find_metadata ("private:mark:setter"))
94     {
95     command_fail (si, fault_badparams, _("\2%s\2 is not marked."), target);
96     return;
97     }
98    
99     mu->del_metadata ("private:mark:setter");
100     mu->del_metadata ("private:mark:reason");
101     mu->del_metadata ("private:mark:timestamp");
102    
103     wallops ("%s unmarked the nickname \2%s\2.", get_oper_name (si), target);
104     logcommand (si, CMDLOG_ADMIN, "MARK %s OFF", target);
105     command_success_nodata (si, _("\2%s\2 is now unmarked."), target);
106     }
107     else
108     {
109     command_fail (si, fault_needmoreparams, STR_INVALID_PARAMS, "MARK");
110     command_fail (si, fault_needmoreparams, _("Usage: MARK <target> <ON|OFF> [note]"));
111     }
112     }