mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-24 21:06:20 +00:00
Add /blocked command
This commit is contained in:
@@ -2984,6 +2984,63 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_blocked(ProfWin *window, const char *const command, gchar **args)
|
||||
{
|
||||
if (jabber_get_connection_status() != JABBER_CONNECTED) {
|
||||
cons_show("You are not currently connected.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!jabber_service_supports(XMPP_FEATURE_BLOCKING)) {
|
||||
cons_show("Blocking not supported by server.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "add") == 0) {
|
||||
if (args[1] == NULL) {
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean res = blocked_add(args[1]);
|
||||
if (!res) {
|
||||
cons_show("User %s already blocked.", args[1]);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "remove") == 0) {
|
||||
if (args[1] == NULL) {
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean res = blocked_remove(args[1]);
|
||||
if (!res) {
|
||||
cons_show("User %s is not currently blocked.", args[1]);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GList *blocked = blocked_list();
|
||||
GList *curr = blocked;
|
||||
if (curr) {
|
||||
cons_show("Blocked users:");
|
||||
while (curr) {
|
||||
cons_show(" %s", curr->data);
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
} else {
|
||||
cons_show("No blocked users.");
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
cmd_resource(ProfWin *window, const char *const command, gchar **args)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user