degesch: further cleanups
This commit is contained in:
parent
5be1cad4da
commit
b55494c68f
67
degesch.c
67
degesch.c
|
@ -6314,16 +6314,14 @@ handle_command_channel_mode (struct app_context *ctx, char *arguments,
|
|||
{
|
||||
CHANNEL_COMMAND (command_name, true)
|
||||
|
||||
if (*arguments)
|
||||
{
|
||||
if (!*arguments)
|
||||
return false;
|
||||
|
||||
struct str_vector v;
|
||||
str_vector_init (&v);
|
||||
split_str_ignore_empty (arguments, ' ', &v);
|
||||
mass_channel_mode (s, channel_name, adding, mode_char, &v);
|
||||
str_vector_free (&v);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -6391,16 +6389,14 @@ handle_command_kick (struct app_context *ctx, char *arguments)
|
|||
{
|
||||
CHANNEL_COMMAND ("kick", true)
|
||||
|
||||
if (*arguments)
|
||||
{
|
||||
if (!*arguments)
|
||||
return false;
|
||||
|
||||
char *target = cut_word (&arguments);
|
||||
if (*arguments)
|
||||
irc_send (s, "KICK %s %s :%s", channel_name, target, arguments);
|
||||
else
|
||||
irc_send (s, "KICK %s %s", channel_name, target);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -6409,8 +6405,9 @@ handle_command_kickban (struct app_context *ctx, char *arguments)
|
|||
{
|
||||
CHANNEL_COMMAND ("kickban", true)
|
||||
|
||||
if (*arguments)
|
||||
{
|
||||
if (!*arguments)
|
||||
return false;
|
||||
|
||||
char *target = cut_word (&arguments);
|
||||
if (strpbrk (target, "!@*?"))
|
||||
return false;
|
||||
|
@ -6421,26 +6418,31 @@ handle_command_kickban (struct app_context *ctx, char *arguments)
|
|||
irc_send (s, "KICK %s %s :%s", channel_name, target, arguments);
|
||||
else
|
||||
irc_send (s, "KICK %s %s", channel_name, target);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
complete_user_masks (struct str_vector *v)
|
||||
mass_channel_mode_mask_list (struct server *s, const char *channel_name,
|
||||
bool adding, char mode_char, const char *arguments)
|
||||
{
|
||||
struct str_vector v;
|
||||
str_vector_init (&v);
|
||||
split_str_ignore_empty (arguments, ' ', &v);
|
||||
|
||||
// XXX: this may be a bit too trivial; we could map also nicknames
|
||||
// to information from WHO polling or userhost-in-names
|
||||
for (size_t i = 0; i < v->len; i++)
|
||||
for (size_t i = 0; i < v.len; i++)
|
||||
{
|
||||
char *target = v->vector[i];
|
||||
char *target = v.vector[i];
|
||||
if (strpbrk (target, "!@*?"))
|
||||
continue;
|
||||
|
||||
v->vector[i] = xstrdup_printf ("%s!*@*", target);
|
||||
v.vector[i] = xstrdup_printf ("%s!*@*", target);
|
||||
free (target);
|
||||
}
|
||||
|
||||
mass_channel_mode (s, channel_name, adding, mode_char, &v);
|
||||
str_vector_free (&v);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -6448,18 +6450,14 @@ handle_command_ban (struct app_context *ctx, char *arguments)
|
|||
{
|
||||
CHANNEL_COMMAND ("ban", true)
|
||||
|
||||
if (*arguments)
|
||||
if (!*arguments)
|
||||
{
|
||||
struct str_vector v;
|
||||
str_vector_init (&v);
|
||||
split_str_ignore_empty (arguments, ' ', &v);
|
||||
complete_user_masks (&v);
|
||||
mass_channel_mode (s, channel_name, true, 'b', &v);
|
||||
str_vector_free (&v);
|
||||
}
|
||||
else
|
||||
irc_send (s, "MODE %s +b", channel_name);
|
||||
return true;
|
||||
}
|
||||
|
||||
mass_channel_mode_mask_list (s, channel_name, true, 'b', arguments);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -6467,17 +6465,10 @@ handle_command_unban (struct app_context *ctx, char *arguments)
|
|||
{
|
||||
CHANNEL_COMMAND ("unban", true)
|
||||
|
||||
if (*arguments)
|
||||
{
|
||||
struct str_vector v;
|
||||
str_vector_init (&v);
|
||||
split_str_ignore_empty (arguments, ' ', &v);
|
||||
complete_user_masks (&v);
|
||||
mass_channel_mode (s, channel_name, false, 'b', &v);
|
||||
str_vector_free (&v);
|
||||
}
|
||||
else
|
||||
if (!*arguments)
|
||||
return false;
|
||||
|
||||
mass_channel_mode_mask_list (s, channel_name, false, 'b', arguments);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue