Last active
October 22, 2017 16:25
-
-
Save alyx/9205147 to your computer and use it in GitHub Desktop.
Put this in modules/contrib/ns_backdate.c.
This file contains hidden or 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
/* | |
* Copyright 2014 Alyx Wolcott | |
* Rights to this code are as documented in doc/LICENSE. | |
* | |
* Gives services the ability to backdate nicknames | |
* | |
*/ | |
#include "atheme.h" | |
DECLARE_MODULE_V1 | |
( | |
"contrib/ns_backdate", false, _modinit, _moddeinit, | |
PACKAGE_STRING, | |
"Atheme Development Group <http://www.atheme.org>" | |
); | |
static void ns_cmd_backdate(sourceinfo_t *si, int parc, char *parv[]); | |
command_t ns_backdate = { "BACKDATE", N_("Change registration date of an account."), PRIV_USER_ADMIN, 3, ns_cmd_backdate }; | |
list_t *ns_cmdtree, *ns_helptree; | |
void _modinit(module_t *m) | |
{ | |
MODULE_USE_SYMBOL(ns_cmdtree, "nickserv/main", "ns_cmdtree"); | |
MODULE_USE_SYMBOL(ns_helptree, "nickserv/main", "ns_helptree"); | |
command_add(&ns_backdate, ns_cmdtree); | |
} | |
void _moddeinit() | |
{ | |
command_delete(&ns_backdate, ns_cmdtree); | |
} | |
static void ns_cmd_backdate(sourceinfo_t *si, int parc, char *parv[]) | |
{ | |
myuser_t *mu; | |
mynick_t *mn; | |
char *target = parv[0]; | |
char *stime = parv[1]; | |
if (!stime) | |
goto failure; | |
time_t mytime = (time_t)strtol(stime, NULL, 10); | |
/*char *target = parv[0];*/ | |
/*char *action = parv[1];*/ | |
/*char *reason = parv[2];*/ | |
user_t *u; | |
mowgli_node_t *n, *tn; | |
if (!target || !time) | |
{ | |
goto failure; | |
} | |
mu = myuser_find_ext(target); | |
if (!mu) | |
{ | |
command_fail(si, fault_nosuch_target, _("\2%s\2 is not registered."), target); | |
return; | |
} | |
mu->registered = mytime; | |
MOWGLI_ITER_FOREACH(n, mu->nicks.head) | |
{ | |
mn = (mynick_t *)n->data; | |
mn->registered = mytime; | |
} | |
command_success_nodata(si, "Successfully changed time for %s", target); | |
return; | |
failure: | |
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "BACKDATE"); | |
command_fail(si, fault_needmoreparams, _("Usage: backdate <account> <unix timestamp>")); | |
return; | |
} | |
/* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs | |
* vim:ts=8 | |
* vim:sw=8 | |
* vim:noexpandtab | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment