Fix bug #158 - Added plugin for setting topic (hub description).

Load plugin mod_topic, and it will provide 3 new user commands:

!topic - set new topic
!cleartopic - reset the topic (use default hub description)
!showtopic - show the current topic
This commit is contained in:
Jan Vidar Krey
2012-04-19 00:21:49 +02:00
parent df7bbc094f
commit 1dba731cc3
8 changed files with 303 additions and 4 deletions

View File

@@ -148,8 +148,11 @@ static enum command_parse_status command_extract_arguments(struct command_base*
{
int arg = 0;
int opt = 0;
int greedy = 0;
char arg_code;
char* token = NULL;
char* tmp = NULL;
size_t size = 0;
struct hub_command_arg_data* data = NULL;
enum command_parse_status status = cmd_status_ok;
@@ -160,7 +163,27 @@ static enum command_parse_status command_extract_arguments(struct command_base*
while (status == cmd_status_ok && (arg_code = command->args[arg++]))
{
token = list_get_first(tokens);
if (greedy)
{
size = 1;
for (tmp = (char*) list_get_first(tokens); tmp; tmp = (char*) list_get_next(tokens))
size += (strlen(tmp) + 1);
token = hub_malloc_zero(size);
while ((tmp = list_get_first(tokens)))
{
if (*token)
strcat(token, " ");
strcat(token, tmp);
list_remove(tokens, tmp);
hub_free(tmp);
}
}
else
{
token = list_get_first(tokens);
}
if (!token || !*token)
{
status = (arg_code == '?' ? cmd_status_ok : cmd_status_missing_args);
@@ -173,6 +196,10 @@ static enum command_parse_status command_extract_arguments(struct command_base*
opt = 1;
continue;
case '+':
greedy = 1;
continue;
case 'u':
data = hub_malloc(sizeof(*data));
data->type = type_user;