/* modcmd.c - Generalized module command support
- * Copyright 2002-2006 srvx Development Team
+ * Copyright 2002-2007 srvx Development Team
*
* This file is part of srvx.
*
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "arch-version.h"
#include "chanserv.h"
#include "conf.h"
#include "modcmd.h"
{ "MCMSG_HELPFILE_UNBOUND", "Since that was the last command from module %s on the service, the helpfile for %s was removed." },
{ "MCMSG_NO_HELPFILE", "Module %s does not have a help file." },
{ "MCMSG_HELPFILE_ERROR", "Syntax error reading %s; help contents not changed." },
- { "MCMSG_HELPFILE_READ", "Read %s help database in "FMT_TIME_T".%03lu seconds." },
- { "MCMSG_COMMAND_TIME", "Command $b%s$b finished in "FMT_TIME_T".%06lu seconds." },
+ { "MCMSG_HELPFILE_READ", "Read %s help database in %lu.%03lu seconds." },
+ { "MCMSG_COMMAND_TIME", "Command $b%s$b finished in %lu.%06lu seconds." },
{ "MCMSG_NEED_OPSERV_LEVEL", "You must have $O access of at least $b%u$b." },
{ "MCMSG_NEED_CHANSERV_LEVEL", "You must have $C access of at least $b%u$b in the channel." },
{ "MCMSG_NEED_ACCOUNT_FLAGS", "You must have account flags $b%s$b." },
svccmd_invoke_argv(struct userNode *user, struct service *service, struct chanNode *channel, unsigned int argc, char *argv[], unsigned int server_qualified) {
extern struct userNode *chanserv;
struct svccmd *cmd;
- unsigned int cmd_arg, perms, flags, options;
+ unsigned int cmd_arg, perms, flags, options, result;
char channel_name[CHANNELLEN+1];
/* First check pubcmd for the channel. */
safestrncpy(channel_name, channel->name, sizeof(channel_name));
else
channel_name[0] = 0;
- if (!cmd->command->func(user, channel, argc, argv, cmd))
+ if (!(result = cmd->command->func(user, channel, argc, argv, cmd)))
return 0;
if (!(flags & MODCMD_NO_LOG)) {
enum log_severity slvl;
- if (perms & ACTION_STAFF)
+ if (result & CMD_LOG_OVERRIDE)
+ slvl = LOG_OVERRIDE;
+ else if ((perms & ACTION_STAFF) || (result & CMD_LOG_STAFF))
slvl = LOG_STAFF;
else if (perms & ACTION_OVERRIDE)
slvl = LOG_OVERRIDE;
irc_notice_user(bot,user, "\x01PING\x01");
}
} else if (!irccasecmp(text, "TIME")) {
- struct tm tm;
- localtime_r(&now, &tm);
- strftime(response, sizeof(response), "\x01TIME %a %b %d %H:%M:%S %Y\x01", &tm);
+ time_t feh;
+ feh = now;
+ strftime(response, sizeof(response), "\x01TIME %a %b %d %H:%M:%S %Y\x01", localtime(&feh));
irc_notice_user(bot, user, response);
} else if (!irccasecmp(text, "USERINFO")) {
snprintf(response, sizeof(response), "\x01USERINFO %s\x01", bot->info);
* users, except to add copyright information pertaining
* to changes you make to srvx.
*/
- snprintf(response, sizeof(response), "\x01VERSION %s (%s) %s\x01", PACKAGE_STRING, CODENAME, ARCH_VERSION);
+ snprintf(response, sizeof(response), "\x01VERSION %s (%s) %s\x01", PACKAGE_STRING, CODENAME, git_version);
irc_notice_user(bot, user, response);
}
return;
}
void
-modcmd_chanmsg(struct userNode *user, struct chanNode *chan, const char *text, struct userNode *bot) {
+modcmd_chanmsg(struct userNode *user, struct chanNode *chan, const char *text, struct userNode *bot, unsigned int is_notice) {
struct service *service;
- if (!(service = dict_find(services, bot->nick, NULL))) return;
+ if (!(service = dict_find(services, bot->nick, NULL)))
+ return;
svccmd_invoke(user, service, chan, text, 0);
+ (void)is_notice;
}
struct service *
stop.tv_sec -= start.tv_sec;
stop.tv_usec -= start.tv_usec;
if (stop.tv_usec < 0) {
- stop.tv_sec -= 1;
- stop.tv_usec += 1000000;
+ stop.tv_sec -= 1;
+ stop.tv_usec += 1000000;
}
- reply("MCMSG_HELPFILE_READ", module->name, stop.tv_sec, stop.tv_usec/1000);
+ reply("MCMSG_HELPFILE_READ", module->name, (unsigned long)stop.tv_sec, (unsigned long)stop.tv_usec/1000);
return 1;
}
stop.tv_sec -= start.tv_sec;
stop.tv_usec -= start.tv_usec;
if (stop.tv_usec < 0) {
- stop.tv_sec -= 1;
- stop.tv_usec += 1000000;
+ stop.tv_sec -= 1;
+ stop.tv_usec += 1000000;
}
- reply("MCMSG_COMMAND_TIME", cmd_text, stop.tv_sec, stop.tv_usec);
+ reply("MCMSG_COMMAND_TIME", cmd_text, (unsigned long)stop.tv_sec, (unsigned long)stop.tv_usec);
return 1;
}
* command or its accessibility to normal IRC users, except to add
* copyright information pertaining to changes you make to srvx.
*/
- send_message_type(4, user, cmd->parent->bot, "$b"PACKAGE_STRING"$b ("CODENAME"), Built: "__DATE__", "__TIME__".\nCopyright 2000-2004 srvx Development Team.\nThe srvx Development Team includes Paul Chang, Adrian Dewhurst, Miles Peterson, Michael Poole and others.\nThe srvx Development Team can be reached at http://sf.net/projects/srvx/ or in #srvx on irc.gamesurge.net.");
- if ((argc > 1) && !irccasecmp(argv[1], "arch"))
- send_message_type(4, user, cmd->parent->bot, "%s", ARCH_VERSION);
+ send_message_type(4, user, cmd->parent->bot, "$b"PACKAGE_STRING"$b ("CODENAME"), Built: "__DATE__", "__TIME__". Copyright 2000-2007 srvx Development Team.");
+ if (argc > 1)
+ send_message_type(4, user, cmd->parent->bot, "%s", git_version);
+ else
+ send_message_type(12, user, cmd->parent->bot, "The srvx Development Team includes Paul Chang, Adrian Dewhurst, Miles Peterson, Michael Poole and others.\nThe srvx Development Team can be reached at http://sf.net/projects/srvx/ or in #srvx on irc.gamesurge.net.");
return 1;
}
+static MODCMD_FUNC(cmd_tell) {
+ struct userNode *target;
+ char *msg;
+
+ target = GetUserH(argv[1]);
+ msg = unsplit_string(argv + 2, argc - 2, NULL);
+ if (!target) {
+ reply("MSG_NOT_TARGET_NAME");
+ return 0;
+ }
+ send_message_type(MSG_TYPE_NOXLATE, target, cmd->parent->bot, "%s", msg);
+ return 1;
+}
void
modcmd_nick_change(struct userNode *user, const char *old_nick) {
modcmd_register(modcmd_module, "service privileged", cmd_service_privileged, 2, 0, "flags", "+oper", NULL);
modcmd_register(modcmd_module, "service remove", cmd_service_remove, 2, 0, "flags", "+oper", NULL);
modcmd_register(modcmd_module, "dumpmessages", cmd_dump_messages, 1, 0, "oper_level", "1000", NULL);
+ modcmd_register(modcmd_module, "tell", cmd_tell, 3, 0, "flags", "+oper", NULL);
version_command = modcmd_register(modcmd_module, "version", cmd_version, 1, 0, NULL);
message_register_table(msgtab);
}