mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-23 03:36:21 +00:00
Autogenerate room name with UUID for /join with no args
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <uuid/uuid.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "chat_session.h"
|
||||
@@ -2070,8 +2071,24 @@ cmd_join(gchar **args, struct cmd_help_t help)
|
||||
}
|
||||
|
||||
if (args[0] == NULL) {
|
||||
cons_show("Usage: %s", help.usage);
|
||||
cons_show("");
|
||||
uuid_t uuid;
|
||||
uuid_generate(uuid);
|
||||
char *uuid_str = malloc(sizeof(char) * 37);
|
||||
uuid_unparse_lower(uuid, uuid_str);
|
||||
|
||||
char *account_name = jabber_get_account_name();
|
||||
ProfAccount *account = accounts_get_account(account_name);
|
||||
|
||||
GString *room_str = g_string_new("");
|
||||
g_string_append_printf(room_str, "private-chat-%s@%s", uuid_str, account->muc_service);
|
||||
|
||||
presence_join_room(room_str->str, account->muc_nick, NULL);
|
||||
muc_join(room_str->str, account->muc_nick, NULL, FALSE);
|
||||
|
||||
g_string_free(room_str, TRUE);
|
||||
free(uuid_str);
|
||||
account_free(account);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user