mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 21:15:11 +00:00
Suspend killers are now no more. Except the actual killers to be gone eventually. Plumbing is also very basic as of now, but it "works".
59 lines
1.4 KiB
C
59 lines
1.4 KiB
C
#include <Routes.h>
|
|
|
|
#include <Cytoplasm/Memory.h>
|
|
#include <Cytoplasm/Str.h>
|
|
|
|
#include <Matrix.h>
|
|
#include <Bot.h>
|
|
#include <AS.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
CommandHead(CmdUnlinkMUC, cmd, argp)
|
|
{
|
|
ParseeCmdArg *args = argp;
|
|
ParseeData *data = args->data;
|
|
HashMap *json, *event = args->event, *mucs;
|
|
DbRef *ref;
|
|
char *muc = NULL, *chat_id = NULL, *room = NULL;
|
|
|
|
BotInitialise();
|
|
|
|
muc = HashMapGet(cmd->arguments, "muc");
|
|
if (!muc)
|
|
{
|
|
ReplyBasic("`muc` field REQUIRED.");
|
|
goto end;
|
|
}
|
|
|
|
ref = DbLock(data->db, 1, "chats");
|
|
json = DbJson(ref);
|
|
chat_id = StrDuplicate(GrabString(json, 2, "mucs", muc));
|
|
if (!chat_id)
|
|
{
|
|
ReplySprintf("No internal mapping to '%s'.", muc);
|
|
goto end;
|
|
}
|
|
mucs = GrabObject(json, 1, "mucs");
|
|
JsonValueFree(HashMapDelete(mucs, muc));
|
|
DbUnlock(data->db, ref);
|
|
|
|
room = ParseeGetRoomID(data, chat_id);
|
|
ref = DbLock(data->db, 1, "chats");
|
|
json = DbJson(ref);
|
|
mucs = GrabObject(json, 1, "rooms");
|
|
JsonValueFree(HashMapDelete(mucs, room));
|
|
DbUnlock(data->db, ref);
|
|
|
|
DbDelete(data->db, 2, "chats", chat_id);
|
|
|
|
/* TODO: Do it automatically, if *not plumbed* */
|
|
ReplySprintf("The MUC %s is now *unlinked*.", muc);
|
|
ReplySprintf("Please now remove the room %s and its aliases.",
|
|
room
|
|
);
|
|
end:
|
|
Free(chat_id);
|
|
Free(room);
|
|
BotDestroy();
|
|
}
|