Added +myip command.

This commit is contained in:
Jan Vidar Krey 2009-03-08 17:11:10 +01:00
parent 6511761991
commit 990fc31296
2 changed files with 22 additions and 1 deletions

View File

@ -148,6 +148,26 @@ static int command_version(struct user* user, const char* message)
return 0;
}
static int command_myip(struct user* user, const char* message)
{
struct adc_message* command;
char tmp[128];
char* buffer;
tmp[0] = 0;
strcat(tmp, "*** Your IP: ");
strcat(tmp, ip_convert_to_string(&user->ipaddr));
buffer = adc_msg_escape(tmp);
command = adc_msg_construct(ADC_CMD_IMSG, strlen(buffer) + 6);
adc_msg_add_argument(command, buffer);
route_to_user(user, command);
adc_msg_free(command);
hub_free(buffer);
return 0;
}
int command_dipatcher(struct user* user, const char* message)
{
if (!strncmp(message, "!stats", 6)) command_stats(user, message);
@ -155,6 +175,7 @@ int command_dipatcher(struct user* user, const char* message)
else if (!strncmp(message, "!kick", 5)) command_kick(user, message);
else if (!strncmp(message, "!version", 8)) command_version(user, message);
else if (!strncmp(message, "!uptime", 7)) command_uptime(user, message);
else if (!strncmp(message, "+myip", 5)) command_myip(user, message);
else
return 1;
return 0;

View File

@ -189,7 +189,7 @@ int hub_handle_chat_message(struct user* u, struct adc_message* cmd)
int relay = 1;
/* TODO: Check for hub-commands here. Set relay to 0 and the message will not be sent to other users. */
if (message[0] == '!')
if (message[0] == '!' || message[0] == '+')
{
relay = command_dipatcher(u, message);
}