Skip to content

Instantly share code, notes, and snippets.

@alyx
Created February 25, 2014 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alyx/9205594 to your computer and use it in GitHub Desktop.
Save alyx/9205594 to your computer and use it in GitHub Desktop.
/*
* 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/cs_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, "chanserv/main", "ns_cmdtree");
MODULE_USE_SYMBOL(ns_helptree, "chanserv/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[])
{
mychan_t *mu;
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 = mychan_find_ext(target);
if (!mu)
{
command_fail(si, fault_nosuch_target, _("\2%s\2 is not registered."), target);
return;
}
mu->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