| 1 |
/* main.c - rpgserv main() routine. |
| 2 |
* based on elly's rpgserv for atheme-6.x --nenolod |
| 3 |
*/ |
| 4 |
|
| 5 |
#include "atheme.h" |
| 6 |
#include "prettyprint.h" |
| 7 |
|
| 8 |
DECLARE_MODULE_V1 |
| 9 |
( |
| 10 |
"rpgserv/info", false, _modinit, _moddeinit, |
| 11 |
PACKAGE_STRING, |
| 12 |
VENDOR_STRING |
| 13 |
); |
| 14 |
|
| 15 |
static void rs_cmd_info(sourceinfo_t *si, int parc, char *parv[]); |
| 16 |
|
| 17 |
command_t rs_info = { "INFO", N_("Displays info for a particular game."), |
| 18 |
AC_NONE, 1, rs_cmd_info, { .path = "rpgserv/info" } }; |
| 19 |
|
| 20 |
static void rs_cmd_info(sourceinfo_t *si, int parc, char *parv[]) |
| 21 |
{ |
| 22 |
mychan_t *mc; |
| 23 |
metadata_t *md; |
| 24 |
|
| 25 |
if (parc < 1) |
| 26 |
{ |
| 27 |
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "INFO"); |
| 28 |
command_fail(si, fault_needmoreparams, _("Syntax: INFO <channel>")); |
| 29 |
return; |
| 30 |
} |
| 31 |
|
| 32 |
mc = mychan_find(parv[0]); |
| 33 |
if (!mc) |
| 34 |
{ |
| 35 |
command_fail(si, fault_nosuch_target, _("Channel \2%s\2 is not registered."), parv[0]); |
| 36 |
return; |
| 37 |
} |
| 38 |
|
| 39 |
if (!metadata_find(mc, "private:rpgserv:enabled")) |
| 40 |
{ |
| 41 |
command_fail(si, fault_nosuch_target, _("Channel \2%s\2 does not have RPGServ enabled."), parv[0]); |
| 42 |
return; |
| 43 |
} |
| 44 |
|
| 45 |
command_success_nodata(si, _("Information on \2%s\2:"), parv[0]); |
| 46 |
md = metadata_find(mc, "private:rpgserv:genre"); |
| 47 |
command_success_nodata(si, _("Genre : %s"), rs_prettyprint_keywords(md, genre_keys, genre_names, ARRAY_SIZE(genre_keys))); |
| 48 |
md = metadata_find(mc, "private:rpgserv:period"); |
| 49 |
command_success_nodata(si, _("Period : %s"), rs_prettyprint_keywords(md, period_keys, period_names, ARRAY_SIZE(period_keys))); |
| 50 |
md = metadata_find(mc, "private:rpgserv:ruleset"); |
| 51 |
command_success_nodata(si, _("Ruleset : %s"), rs_prettyprint_keywords(md, ruleset_keys, ruleset_names, ARRAY_SIZE(ruleset_keys))); |
| 52 |
md = metadata_find(mc, "private:rpgserv:rating"); |
| 53 |
command_success_nodata(si, _("Rating : %s"), rs_prettyprint_keywords(md, rating_keys, rating_names, ARRAY_SIZE(rating_keys))); |
| 54 |
md = metadata_find(mc, "private:rpgserv:system"); |
| 55 |
command_success_nodata(si, _("System : %s"), rs_prettyprint_keywords(md, system_keys, system_names, ARRAY_SIZE(system_keys))); |
| 56 |
md = metadata_find(mc, "private:rpgserv:setting"); |
| 57 |
command_success_nodata(si, _("Setting : %s"), md ? md->value : "<none>"); |
| 58 |
md = metadata_find(mc, "private:rpgserv:storyline"); |
| 59 |
command_success_nodata(si, _("Storyline: %s"), md ? md->value : "<none>"); |
| 60 |
md = metadata_find(mc, "private:rpgserv:summary"); |
| 61 |
command_success_nodata(si, _("Summary : %s"), md ? md->value : "<none>"); |
| 62 |
command_success_nodata(si, _("\2*** End of Info ***\2")); |
| 63 |
|
| 64 |
logcommand(si, CMDLOG_GET, "RPGSERV:INFO: \2%s\2", mc->name); |
| 65 |
} |
| 66 |
|
| 67 |
void _modinit(module_t *m) |
| 68 |
{ |
| 69 |
service_named_bind_command("rpgserv", &rs_info); |
| 70 |
} |
| 71 |
|
| 72 |
void _moddeinit(module_unload_intent_t intent) |
| 73 |
{ |
| 74 |
service_named_unbind_command("rpgserv", &rs_info); |
| 75 |
} |