1 |
/** |
2 |
* main.C: This file contains the main() routine. |
3 |
* |
4 |
* Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team |
5 |
* Rights to this code are as documented in COPYING. |
6 |
* |
7 |
* |
8 |
* Portions of this file were derived from sources bearing the following license: |
9 |
* Copyright © 2005 Atheme Development Group |
10 |
* Rights to this code are documented in doc/pod/license.pod. |
11 |
* |
12 |
* $Id: main.C,v 1.6 2007-09-16 18:54:43 pippijn Exp $ |
13 |
*/ |
14 |
|
15 |
#include "atheme.h" |
16 |
#include "confparse.h" |
17 |
#include <ermyth/module.h> |
18 |
|
19 |
static char const rcsid[] = "$Id: main.C,v 1.6 2007-09-16 18:54:43 pippijn Exp $"; |
20 |
|
21 |
REGISTER_MODULE ("nickserv/main", false, "The Ermyth Team <http://ermyth.xinutec.org>"); |
22 |
|
23 |
static void on_config_ready (void); |
24 |
|
25 |
cmdvec ns_cmdtree; |
26 |
helpvec ns_helptree; |
27 |
|
28 |
/* main services client routine */ |
29 |
static void |
30 |
nickserv (sourceinfo_t *si, int parc, char *parv[]) |
31 |
{ |
32 |
char *cmd; |
33 |
char *text; |
34 |
char orig[BUFSIZE]; |
35 |
|
36 |
/* this should never happen */ |
37 |
if (parv[0][0] == '&') |
38 |
{ |
39 |
slog (LG_ERROR, "services(): got parv with local channel: %s", parv[0]); |
40 |
return; |
41 |
} |
42 |
|
43 |
/* make a copy of the original for debugging */ |
44 |
strlcpy (orig, parv[parc - 1], BUFSIZE); |
45 |
|
46 |
/* lets go through this to get the command */ |
47 |
cmd = strtok (parv[parc - 1], " "); |
48 |
text = strtok (NULL, ""); |
49 |
|
50 |
if (!cmd) |
51 |
return; |
52 |
if (*cmd == '\001') |
53 |
{ |
54 |
handle_ctcp_common (si, cmd, text); |
55 |
return; |
56 |
} |
57 |
|
58 |
/* take the command through the hash table */ |
59 |
command_exec_split (si->service, si, cmd, text, ns_cmdtree); |
60 |
} |
61 |
|
62 |
struct |
63 |
{ |
64 |
char const * const nickstring; |
65 |
char const * const accountstring; |
66 |
} nick_account_trans[] = |
67 |
{ |
68 |
/* command descriptions */ |
69 |
{ |
70 |
"Reclaims use of a nickname.", "Disconnects an old session."}, |
71 |
{ |
72 |
"Prevents a nickname from expiring.", "Prevents an account from expiring."}, |
73 |
{ |
74 |
"Registers a nickname.", "Registers an account."}, |
75 |
{ |
76 |
"Lists nicknames registered matching a given pattern.", "Lists accounts matching a given pattern."}, |
77 |
{ |
78 |
"Lists nicknames registered to an e-mail address.", "Lists accounts registered to an e-mail address."}, |
79 |
{ |
80 |
"Resets a nickname password.", "Resets an account password."}, |
81 |
{ |
82 |
"Returns a nickname to its owner.", "Returns a account to its owner."}, |
83 |
{ |
84 |
"Verifies a nickname registration.", "Verifies an account registration."}, |
85 |
/* messages */ |
86 |
{ |
87 |
"Usage: FREEZE <nickname> <ON|OFF> [reason]", "Usage: FREEZE <account> <ON|OFF> [reason]"}, |
88 |
{ |
89 |
"\2%s\2 is not a registered nickname.", "\2%s\2 is not a registered account."}, |
90 |
{ |
91 |
"Syntax: INFO <nickname>", "Syntax: INFO <account>"}, |
92 |
{ |
93 |
"No nicknames matched pattern \2%s\2", "No accounts matched pattern \2%s\2"}, |
94 |
{ |
95 |
"Nicknames matching e-mail address \2%s\2:", "Accounts matching e-mail address \2%s\2:"}, |
96 |
{ |
97 |
"No nicknames matched e-mail address \2%s\2", "No accounts matched e-mail address \2%s\2"}, |
98 |
{ |
99 |
"%s marked the nickname \2%s\2.", "%s marked the account \2%s\2."}, |
100 |
{ |
101 |
"%s unmarked the nickname \2%s\2.", "%s unmarked the account \2%s\2."}, |
102 |
{ |
103 |
"\2%s\2 has too many nicknames registered.", "\2%s\2 has too many accounts registered."}, |
104 |
{ |
105 |
"An email containing nickname activation instructions has been sent to \2%s\2.", "An email containing account activation instructions has been sent to \2%s\2."}, |
106 |
{ |
107 |
"If you do not complete registration within one day your nickname will expire.", "If you do not complete registration within one day your account will expire."}, |
108 |
{ |
109 |
"%s registered the nick \2%s\2 and gained services operator privileges.", "%s registered the account \2%s\2 and gained services operator privileges."}, |
110 |
{ |
111 |
"Syntax: RESETPASS <nickname>", "Syntax: RESETPASS <account>"}, |
112 |
{ |
113 |
"Overriding MARK placed by %s on the nickname %s.", "Overriding MARK placed by %s on the account %s."}, |
114 |
{ |
115 |
"The password for the nickname %s has been changed to %s.", "The password for the account %s has been changed to %s."}, |
116 |
{ |
117 |
"This operation cannot be performed on %s, because the nickname has been marked by %s.", "This operation cannot be performed on %s, because the account has been marked by %s."}, |
118 |
{ |
119 |
"The password for the nickname %s has been changed to %s.", "The password for the account %s has been changed to %s."}, |
120 |
{ |
121 |
"%s reset the password for the nickname %s", "%s reset the password for the account %s"}, |
122 |
{ |
123 |
"Usage: RETURN <nickname> <e-mail address>", "Usage: RETURN <account> <e-mail address>"}, |
124 |
{ |
125 |
"%s returned the nickname \2%s\2 to \2%s\2", "%s returned the account \2%s\2 to \2%s\2"}, |
126 |
{ |
127 |
"Syntax: SENDPASS <nickname>", "Syntax: SENDPASS <account>"}, |
128 |
{ |
129 |
"Manipulates metadata entries associated with a nickname.", "Manipulates metadata entries associated with an account."}, |
130 |
{ |
131 |
"You cannot use your nickname as a password.", "You cannot use your account name as a password."}, |
132 |
{ |
133 |
"Changes the password associated with your nickname.", "Changes the password associated with your account."}, |
134 |
{ |
135 |
"Syntax: TAXONOMY <nick>", "Syntax: TAXONOMY <account>"}, |
136 |
{ |
137 |
"Syntax: VERIFY <operation> <nickname> <key>", "Syntax: VERIFY <operation> <account> <key>"}, |
138 |
{ |
139 |
"Syntax: VHOST <nick> [vhost]", "Syntax: VHOST <account> [vhost]"}, |
140 |
{ |
141 |
NULL, NULL} |
142 |
}; |
143 |
|
144 |
static void |
145 |
on_config_ready (void) |
146 |
{ |
147 |
// int i; |
148 |
|
149 |
if (nicksvs.me) |
150 |
del_service (nicksvs.me); |
151 |
|
152 |
nicksvs.me = add_service (nicksvs.nick, nicksvs.user, nicksvs.host, nicksvs.real, nickserv, ns_cmdtree); |
153 |
nicksvs.disp = nicksvs.me->disp; |
154 |
|
155 |
#if 0 |
156 |
if (nicksvs.no_nick_ownership) |
157 |
for (i = 0; nick_account_trans[i].nickstring != NULL; i++) |
158 |
itranslation_create (nick_account_trans[i].nickstring, nick_account_trans[i].accountstring); |
159 |
else |
160 |
for (i = 0; nick_account_trans[i].nickstring != NULL; i++) |
161 |
itranslation_destroy (nick_account_trans[i].nickstring); |
162 |
#endif |
163 |
} |
164 |
|
165 |
bool |
166 |
_modinit (module *m) |
167 |
{ |
168 |
ConfTable::callback.ready.attach (on_config_ready); |
169 |
|
170 |
if (!cold_start) |
171 |
{ |
172 |
nicksvs.me = add_service (nicksvs.nick, nicksvs.user, nicksvs.host, nicksvs.real, nickserv, ns_cmdtree); |
173 |
nicksvs.disp = nicksvs.me->disp; |
174 |
} |
175 |
authservice_loaded++; |
176 |
|
177 |
return true; |
178 |
} |
179 |
|
180 |
void |
181 |
_moddeinit () |
182 |
{ |
183 |
authservice_loaded--; |
184 |
if (nicksvs.me) |
185 |
{ |
186 |
del_service (nicksvs.me); |
187 |
nicksvs.me = NULL; |
188 |
} |
189 |
|
190 |
ConfTable::callback.ready.detach (on_config_ready); |
191 |
} |