| 1 |
/* |
| 2 |
* Copyright (c) 2005-2006 Atheme Development Group |
| 3 |
* Rights to this code are documented in doc/LICENSE. |
| 4 |
* |
| 5 |
* This file contains functionality which implements the HelpServ HELPME command. |
| 6 |
* |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "atheme.h" |
| 10 |
#include "uplink.h" |
| 11 |
|
| 12 |
DECLARE_MODULE_V1 |
| 13 |
( |
| 14 |
"helpserv/helpme", false, _modinit, _moddeinit, |
| 15 |
PACKAGE_STRING, |
| 16 |
VENDOR_STRING |
| 17 |
); |
| 18 |
|
| 19 |
unsigned int ratelimit_count = 0; |
| 20 |
time_t ratelimit_firsttime = 0; |
| 21 |
|
| 22 |
static void helpserv_cmd_helpme(sourceinfo_t *si, int parc, char *parv[]); |
| 23 |
|
| 24 |
command_t helpserv_helpme = { "HELPME", N_("Request help from network staff."), AC_NONE, 1, helpserv_cmd_helpme, { .path = "helpserv/helpme" } }; |
| 25 |
|
| 26 |
void _modinit(module_t *m) |
| 27 |
{ |
| 28 |
service_named_bind_command("helpserv", &helpserv_helpme); |
| 29 |
} |
| 30 |
|
| 31 |
void _moddeinit(module_unload_intent_t intent) |
| 32 |
{ |
| 33 |
service_named_unbind_command("helpserv", &helpserv_helpme); |
| 34 |
} |
| 35 |
|
| 36 |
static void helpserv_cmd_helpme(sourceinfo_t *si, int parc, char *parv[]) |
| 37 |
{ |
| 38 |
char *topic = parv[0]; |
| 39 |
|
| 40 |
if ((unsigned int)(CURRTIME - ratelimit_firsttime) > config_options.ratelimit_period) |
| 41 |
ratelimit_count = 0, ratelimit_firsttime = CURRTIME; |
| 42 |
|
| 43 |
if (ratelimit_count > config_options.ratelimit_uses && !has_priv(si, PRIV_FLOOD)) |
| 44 |
{ |
| 45 |
command_fail(si, fault_toomany, _("The system is currently too busy to process your help request, please try again later.")); |
| 46 |
slog(LG_INFO, "HELPME:THROTTLED: %s", si->su->nick); |
| 47 |
return; |
| 48 |
} |
| 49 |
|
| 50 |
if (si->smu != NULL && metadata_find(si->smu, "private:restrict:setter")) |
| 51 |
{ |
| 52 |
command_fail(si, fault_noprivs, _("You have been restricted from requesting help by network staff.")); |
| 53 |
return; |
| 54 |
} |
| 55 |
|
| 56 |
command_add_flood(si, FLOOD_HEAVY); |
| 57 |
|
| 58 |
if (topic) |
| 59 |
{ |
| 60 |
logcommand(si, CMDLOG_ADMIN, "HELPME: \2%s\2", topic); |
| 61 |
wallops("\2%s\2 has requested help about \2%s\2", get_source_name(si), topic); |
| 62 |
} |
| 63 |
else |
| 64 |
{ |
| 65 |
logcommand(si, CMDLOG_ADMIN, "HELPME"); |
| 66 |
wallops("\2%s\2 has requested help.", get_source_name(si)); |
| 67 |
} |
| 68 |
|
| 69 |
command_success_nodata(si, "The network staff has been notified that you need help and will be with you shortly."); |
| 70 |
|
| 71 |
if (config_options.ratelimit_uses && config_options.ratelimit_period) |
| 72 |
ratelimit_count++; |
| 73 |
|
| 74 |
return; |
| 75 |
} |
| 76 |
/* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs |
| 77 |
* vim:ts=8 |
| 78 |
* vim:sw=8 |
| 79 |
* vim:noexpandtab |
| 80 |
*/ |