From 7e7087e94e8569e6c14e128b340c51462ed3aaeb Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Sat, 30 May 2015 23:57:30 -0400 Subject: [PATCH] add mod-list prune command --- src/execute.c | 1 + src/group_commands.c | 16 +++++++++++++++- src/group_commands.h | 1 + src/groupchat.c | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/execute.c b/src/execute.c index 9ff54c3..e23a64f 100644 --- a/src/execute.c +++ b/src/execute.c @@ -92,6 +92,7 @@ static struct cmd_func group_commands[] = { { "/passwd", cmd_set_passwd }, { "/peerlimit", cmd_set_peerlimit }, { "/privacy", cmd_set_privacy }, + { "/prune", cmd_prune }, { "/rejoin", cmd_rejoin }, { "/topic", cmd_set_topic }, { "/unignore", cmd_unignore }, diff --git a/src/group_commands.c b/src/group_commands.c index d6a1f38..c48f2d9 100644 --- a/src/group_commands.c +++ b/src/group_commands.c @@ -92,7 +92,7 @@ void cmd_kick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA return; } - int ret = tox_group_op_kick_peer(m, self->num, (uint32_t) peernumber); + int ret = tox_group_kick_peer(m, self->num, (uint32_t) peernumber); switch (ret) { case 0: { @@ -140,9 +140,23 @@ void cmd_mod(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "You do not have permission to promote moderators."); return; } + case -3: { + line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Moderator list is full. Use the \"/prune\" command to remove all offline mods from the mod list."); + return; + } } } +void cmd_prune(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]) +{ + if (tox_group_prune_moderator_list(m, self->num) == -1) { + line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to prune moderator list."); + return; + } + + line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Moderator list has been successfully pruned."); +} + void cmd_unmod(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]) { if (argc < 1) { diff --git a/src/group_commands.h b/src/group_commands.h index 477bf0e..9276e90 100644 --- a/src/group_commands.h +++ b/src/group_commands.h @@ -30,6 +30,7 @@ void cmd_chatid(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[ void cmd_ignore(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_kick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_mod(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]); +void cmd_prune(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_set_passwd(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_set_peerlimit(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_set_privacy(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]); diff --git a/src/groupchat.c b/src/groupchat.c index 8d338cf..7edb62c 100644 --- a/src/groupchat.c +++ b/src/groupchat.c @@ -603,7 +603,7 @@ static void groupchat_onGroupModeration(ToxWindow *self, Tox *m, int groupnum, u line_info_add(self, timefrmt, NULL, NULL, SYS_MSG, 1, BLUE, "-!- %s has been silenced by %s", tgt_name, src_name); break; case TOX_GROUP_MOD_EVENT_USER: - line_info_add(self, timefrmt, NULL, NULL, SYS_MSG, 1, BLUE, "-!- %s has been user'd by %s", tgt_name, src_name); + line_info_add(self, timefrmt, NULL, NULL, SYS_MSG, 1, BLUE, "-!- %s has been made a normal user by %s", tgt_name, src_name); break; case TOX_GROUP_MOD_EVENT_MODERATOR: line_info_add(self, timefrmt, NULL, NULL, SYS_MSG, 1, BLUE, "-!- %s has been promoted to moderator by %s", tgt_name, src_name);