ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/chanserv/mark.C
Revision: 1.5
Committed: Tue Aug 28 17:08:08 2007 UTC (19 years, 3 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.4: +12 -20 lines
Log Message:
- changed name
- updated the example config to the new system
- added more documentation
- enhanced documentation generators
- added a link to the pdf to the website
- added an RSS feed generator
- transitioned hooks to c++ callbacks
- did various merges with upstream along the way
- added const where appropriate
- removed the old block allocator
- fixed most memory leaks
- transitioned some dictionaries to std::map
- transitioned some lists to std::vector
- made some free functions members where appropriate
- renamed string to dynstr and added a static string ststr
- use NOW instead of time (NULL) if possible
- completely reworked database backends, crypto handlers and protocol handlers
  to use an object factory
- removed the old module system. ermyth does not do any dynamic loading anymore
- fixed most of the build system
- reworked how protocol commands work

File Contents

# User Rev Content
1 pippijn 1.1 /*
2 pippijn 1.5 * Copyright © 2005 William Pitcock
3 pippijn 1.2 * Rights to this code are as documented in doc/pod/license.pod.
4 pippijn 1.1 *
5     * Marking for channels.
6     *
7 pippijn 1.5 * $Id: mark.C,v 1.4 2007-07-22 18:38:43 pippijn Exp $
8 pippijn 1.1 */
9    
10     #include "atheme.h"
11 pippijn 1.5 #include <ermyth/module.h>
12 pippijn 1.1 #include <account/mychan.h>
13    
14 pippijn 1.5 static char const rcsid[] = "$Id: mark.C,v 1.4 2007-07-22 18:38:43 pippijn Exp $";
15 pippijn 1.1
16 pippijn 1.5 REGISTER_MODULE ("chanserv/mark", false, "The Ermyth Team <http://ermyth.schmorp.de>");
17 pippijn 1.1
18     static void cs_cmd_mark (sourceinfo_t *si, int parc, char *parv[]);
19    
20 pippijn 1.5 command_t const cs_mark = { "MARK", N_("Adds a note to a channel."), PRIV_MARK, 3, cs_cmd_mark };
21 pippijn 1.1
22 pippijn 1.5 E cmdvec cs_cmdtree;
23     E helpvec cs_helptree;
24 pippijn 1.1
25 pippijn 1.5 bool
26     _modinit (module *m)
27 pippijn 1.1 {
28     cs_cmdtree << cs_mark;
29 pippijn 1.4 help_addentry (cs_helptree, "MARK", "help/chanserv/mark", NULL);
30 pippijn 1.5
31     return true;
32 pippijn 1.1 }
33    
34     void
35     _moddeinit ()
36     {
37     cs_cmdtree >> cs_mark;
38     help_delentry (cs_helptree, "MARK");
39     }
40    
41     static void
42     cs_cmd_mark (sourceinfo_t *si, int parc, char *parv[])
43     {
44     char *target = parv[0];
45     char *action = parv[1];
46     char *info = parv[2];
47     mychan_t *mc;
48    
49     if (!target || !action)
50     {
51     command_fail (si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "MARK");
52     command_fail (si, fault_needmoreparams, _("Usage: MARK <#channel> <ON|OFF> [note]"));
53     return;
54     }
55    
56     if (target[0] != '#')
57     {
58     command_fail (si, fault_badparams, STR_INVALID_PARAMS, "MARK");
59     return;
60     }
61    
62     if (!(mc = mychan_find (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 <#channel> ON <note>"));
74     return;
75     }
76    
77     if (mc->find_metadata ("private:mark:setter"))
78     {
79     command_fail (si, fault_nochange, _("\2%s\2 is already marked."), target);
80     return;
81     }
82    
83     mc->add_metadata ("private:mark:setter", get_oper_name (si));
84     mc->add_metadata ("private:mark:reason", info);
85     mc->add_metadata ("private:mark:timestamp", itoa (NOW));
86    
87     wallops ("%s marked the channel \2%s\2.", get_oper_name (si), target);
88     logcommand (si, CMDLOG_ADMIN, "%s MARK ON", mc->name);
89     command_success_nodata (si, _("\2%s\2 is now marked."), target);
90     }
91     else if (!strcasecmp (action, "OFF"))
92     {
93     if (!mc->find_metadata ("private:mark:setter"))
94     {
95     command_fail (si, fault_nochange, _("\2%s\2 is not marked."), target);
96     return;
97     }
98    
99     mc->del_metadata ("private:mark:setter");
100     mc->del_metadata ("private:mark:reason");
101     mc->del_metadata ("private:mark:timestamp");
102    
103     wallops ("%s unmarked the channel \2%s\2.", get_oper_name (si), target);
104     logcommand (si, CMDLOG_ADMIN, "%s MARK OFF", mc->name);
105     command_success_nodata (si, _("\2%s\2 is now unmarked."), target);
106     }
107     else
108     {
109     command_fail (si, fault_badparams, STR_INVALID_PARAMS, "MARK");
110     command_fail (si, fault_badparams, _("Usage: MARK <#channel> <ON|OFF> [note]"));
111     }
112     }
113    
114     /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
115     * vim:ts=8
116     * vim:sw=8
117     * vim:noexpandtab
118     */