X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/827ecd60750447e47f4ca84bad4018f94e2c4029..59b38cc02dd57c5a072cf206794548fbb37e0571:/src/modcmd.c diff --git a/src/modcmd.c b/src/modcmd.c index 8390388..3a9c2cb 100644 --- a/src/modcmd.c +++ b/src/modcmd.c @@ -5,7 +5,7 @@ * * x3 is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -37,7 +37,7 @@ static struct dict *modules; static struct dict *services; static struct pending_template *pending_templates; static struct module *modcmd_module; -static struct modcmd *bind_command, *help_command, *version_command; +static struct modcmd *bind_command, *help_command, *version_command, *credits_command; static const struct message_entry msgtab[] = { { "MCMSG_BARE_FLAG", "Flag %.*s must be preceded by a + or -." }, { "MCMSG_UNKNOWN_FLAG", "Unknown module flag %.*s." }, @@ -587,7 +587,7 @@ svccmd_can_invoke(struct userNode *user, struct userNode *bot, struct svccmd *cm } static int -svccmd_expand_alias(struct svccmd *cmd, unsigned int old_argc, char *old_argv[], char *new_argv[]) { +svccmd_expand_alias(struct svccmd *cmd, struct userNode *user, unsigned int old_argc, char *old_argv[], char *new_argv[]) { unsigned int ii, new_argc; char *arg; @@ -625,8 +625,24 @@ svccmd_expand_alias(struct svccmd *cmd, unsigned int old_argc, char *old_argv[], for (jj = lbound; jj <= ubound; ) new_argv[new_argc++] = old_argv[jj++]; } else { - log_module(MAIN_LOG, LOG_ERROR, "Alias expansion: I do not know how to handle %s (%s.%s arg %d).", arg, cmd->parent->bot->nick, cmd->name, ii); - return 0; + switch(arg[1]) { + case 'a': + new_argv[new_argc++] = (user && user->handle_info) ? user->handle_info->handle : "(account)"; + break; + case 'n': + new_argv[new_argc++] = user ? user->nick : "(nick)"; + break; + case 'm': +#ifdef WITH_PROTOCOL_P10 + new_argv[new_argc++] = user ? user->numeric : "(numnick)"; +#else + new_argv[new_argc++] = "(This ircd protocol has no numnicks!)"; +#endif + break; + default: + log_module(MAIN_LOG, LOG_ERROR, "Alias expansion: I do not know how to handle %s (%s.%s arg %d).", arg, cmd->parent->bot->nick, cmd->name, ii); + return 0; + } } } return new_argc; @@ -702,9 +718,9 @@ svccmd_invoke_argv(struct userNode *user, struct service *service, struct chanNo /* Expand the alias arguments, if there are any. */ if (cmd->alias.used) { char *new_argv[MAXNUMPARAMS]; - argc = svccmd_expand_alias(cmd, argc, argv, new_argv); + argc = svccmd_expand_alias(cmd, user, argc, argv, new_argv); if (!argc) { - send_message(service->bot, user, "MCMSG_ALIAS_ERROR", cmd->name); + send_message(user, service->bot, "MCMSG_ALIAS_ERROR", cmd->name); return 0; } argv = new_argv; @@ -913,6 +929,28 @@ svccmd_invoke(struct userNode *user, struct service *service, struct chanNode *c return argc ? svccmd_invoke_argv(user, service, channel, argc, argv, server_qualified) : 0; } +char *cvs_verstring() { + static char verstring[MAXLEN] = { 0 }; + + if(!*verstring) { + char *svn = NULL, *svnver = NULL, *svndate = NULL, *v = 0, ver[MAXLEN]; + int vc = 0; + + strcpy(ver, CVS_VERSION); + for (svn = x3_strtok(&v, ver, " "); svn; + svn = x3_strtok(&v, 0, " ")) { + if (vc == 2) + svnver = svn; + else if (vc == 3) + svndate = svn; + vc++; + } + sprintf(verstring, "%s %s", svnver, svndate); + } + return verstring; +} + + void modcmd_privmsg(struct userNode *user, struct userNode *bot, char *text, int server_qualified) { struct service *service; @@ -961,13 +999,7 @@ modcmd_privmsg(struct userNode *user, struct userNode *bot, char *text, int serv snprintf(response, sizeof(response), "\x01USERINFO %s\x01", bot->info); irc_notice_user(bot, user, response); } else if (!irccasecmp(text, "VERSION")) { - /* This function provides copyright management information - * to end users of X3. You should not alter, disable or - * remove this command or its accessibility to normal IRC - * users, except to add copyright information pertaining - * to changes you make to X3. - */ - snprintf(response, sizeof(response), "\x01VERSION %s\x01", PACKAGE_STRING); + snprintf(response, sizeof(response), "\x01VERSION %s+[%s]\x01", PACKAGE_STRING, cvs_verstring()); irc_notice_user(bot, user, response); } else if (!irccasecmp(text, "GENDER")) { snprintf(response, sizeof(response), "\x01GENDER ummm im still deciding\x01"); @@ -1083,8 +1115,16 @@ check_alias_args(char *argv[], unsigned int argc) { default: return arg; } - } else - return arg; + } else { + switch(argv[arg][1]) { + case 'a': + case 'n': + case 'm': + continue; + default: + return arg; + } + } } return arg; } @@ -1957,36 +1997,29 @@ static MODCMD_FUNC(cmd_dump_messages) { } static MODCMD_FUNC(cmd_version) { - /* This function provides copyright management information to end - * users of X3. You should not alter, disable or remove this - * command or its accessibility to normal IRC users, except to add - * copyright information pertaining to changes you make to X3. - */ - - char *svn = NULL, *svnver = NULL, *svndate = NULL, *v = 0, ver[MAXLEN]; - int vc = 0; - - strcpy(ver, CVS_VERSION); - for (svn = x3_strtok(&v, ver, " "); svn; - svn = x3_strtok(&v, 0, " ")) { - if (vc == 2) - svnver = svn; - else if (vc == 3) - svndate = svn; - vc++; - } + send_message_type(4, user, cmd->parent->bot, "$b"PACKAGE_STRING"+[%s]$b (Based on srvx 1.3.x), Built: "__DATE__", "__TIME__".", cvs_verstring()); + send_message_type(4, user, cmd->parent->bot, "See $bCREDITS$b for more information."); + return 1; +} - send_message_type(4, user, cmd->parent->bot, "$b"PACKAGE_STRING"+[%s %s]$b (Based on srvx 1.3.x), Built: "__DATE__", "__TIME__".", svnver, svndate); - send_message_type(4, user, cmd->parent->bot, "$b$b"); - send_message_type(4, user, cmd->parent->bot, "Copyright 2000-2006 srvx Development Team."); - send_message_type(4, user, cmd->parent->bot, "Copyright 2004-2006 X3 Development Team."); +/* This function provides copyright management information to end + * users of X3. You should not alter, disable or remove this + * command or its accessibility to normal IRC users, except to add + * copyright information pertaining to changes you make to X3. + */ +static MODCMD_FUNC(cmd_credits) { + send_message_type(4, user, cmd->parent->bot, "$b"PACKAGE"$b is based on srvx"); + send_message_type(4, user, cmd->parent->bot, "Copyright 2000-2007 srvx Development Team."); + send_message_type(4, user, cmd->parent->bot, "Copyright 2004-2007 X3 Development Team."); + send_message_type(4, user, cmd->parent->bot, "This software is OSI Certified Open Source Software."); + send_message_type(4, user, cmd->parent->bot, "OSI Certified is a certification mark of the Open Source Initiative."); send_message_type(4, user, cmd->parent->bot, "$b$b"); send_message_type(4, user, cmd->parent->bot, "The srvx 1.3.x Development Team includes Paul Chang, Adrian Dewhurst, Miles Peterson, Michael Poole and others."); send_message_type(4, user, cmd->parent->bot, "The X3 Development Team includes Alex Schumann, Reed Loden, Neil Spierling."); - send_message_type(4, user, cmd->parent->bot, "The X3 Development Team can be reached at http://sourceforge.net/projects/evilnet or in #evilnet on irc.afternet.org."); + send_message_type(4, user, cmd->parent->bot, "The X3 Development Team can be reached at http://evilnet.sourceforge.net or in #evilnet on irc.afternet.org."); send_message_type(4, user, cmd->parent->bot, "$b$b"); - send_message_type(4, user, cmd->parent->bot, "Thanks goes to Adrian M (thiefmaster), Joe Hansche (joeatrr), Martijn Smit (wasted), and to any other people who have contributed to X3."); - send_message_type(4, user, cmd->parent->bot, "This program is free software; see COPYING in the distribution."); + send_message_type(4, user, cmd->parent->bot, "Thanks goes to ThiefMaster, Joe Hansche (joeatrr), Martijn Smit (wasted), and to any other people who have contributed to X3."); + send_message_type(4, user, cmd->parent->bot, "This program is free software; see COPYING in the distribution files."); return 1; } @@ -2243,6 +2276,7 @@ modcmd_init(void) { modcmd_register(modcmd_module, "dumpmessages", cmd_dump_messages, 1, 0, "oper_level", "1000", NULL); modcmd_register(modcmd_module, "rebindall", cmd_rebindall, 0, MODCMD_KEEP_BOUND, "oper_level", "800", NULL); version_command = modcmd_register(modcmd_module, "version", cmd_version, 1, 0, NULL); + credits_command = modcmd_register(modcmd_module, "credits", cmd_credits, 1, 0, NULL); message_register_table(msgtab); } @@ -2448,21 +2482,24 @@ create_default_binds(int rebind) { /* Bind the help and version commands to this service */ service_bind_modcmd(service, help_command, help_command->name); service_bind_modcmd(service, version_command, version_command->name); + service_bind_modcmd(service, credits_command, credits_command->name); /* Now some silly hax.. (aliases that most people want) */ if (!irccasecmp(def_binds[ii].svcname, "ChanServ")) { - service_make_alias(service, "addowner", "*chanserv.adduser", "$1", "owner", NULL); - service_make_alias(service, "addcoowner", "*chanserv.adduser", "$1", "coowner", NULL); - service_make_alias(service, "addco", "*chanserv.adduser", "$1", "coowner", NULL); - service_make_alias(service, "addmanager", "*chanserv.adduser", "$1", "manager", NULL); - service_make_alias(service, "addop", "*chanserv.adduser", "$1", "op", NULL); - service_make_alias(service, "addhop", "*chanserv.adduser", "$1", "halfop", NULL); - service_make_alias(service, "addpeon", "*chanserv.adduser", "$1", "peon", NULL); + service_make_alias(service, "addowner", "*chanserv.adduser", "$1", "owner", "$2", NULL); + service_make_alias(service, "addcoowner", "*chanserv.adduser", "$1", "coowner", "$2", NULL); + service_make_alias(service, "addco", "*chanserv.adduser", "$1", "coowner", "$2", NULL); + service_make_alias(service, "addmanager", "*chanserv.adduser", "$1", "manager", "$2", NULL); + service_make_alias(service, "addop", "*chanserv.adduser", "$1", "op", "$2", NULL); + service_make_alias(service, "addhop", "*chanserv.adduser", "$1", "halfop", "$2", NULL); + service_make_alias(service, "addpeon", "*chanserv.adduser", "$1", "peon", "$2", NULL); + service_make_alias(service, "addpal", "*chanserv.adduser", "$1", "pal", "$2", NULL); service_make_alias(service, "delowner", "*chanserv.deluser", "owner", "$1", NULL); service_make_alias(service, "delcoowner", "*chanserv.deluser", "coowner", "$1", NULL); service_make_alias(service, "delmanager", "*chanserv.deluser", "manager", "$1", NULL); service_make_alias(service, "delop", "*chanserv.deluser", "op", "$1", NULL); service_make_alias(service, "delpeon", "*chanserv.deluser", "peon", "$1", NULL); + service_make_alias(service, "delpal", "*chanserv.deluser", "pal", "$1", NULL); service_make_alias(service, "llist", "*chanserv.lamers", "$1", NULL); service_make_alias(service, "command", "*modcmd.command", NULL); service_make_alias(service, "god", "*modcmd.god", NULL); @@ -2472,6 +2509,8 @@ create_default_binds(int rebind) { svccmd->min_opserv_level = 101; svccmd = service_make_alias(service, "service", "*modcmd.joiner", NULL); svccmd->min_opserv_level = 900; + svccmd = service_make_alias(service, "routing", "*modcmd.joiner", NULL); + svccmd->min_opserv_level = 100; } } }