mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 21:25:11 +00:00
[FIX/WIP] Plumbing, -Werror, death to hitmen
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".
This commit is contained in:
parent
1f658ece76
commit
bb836789b2
23 changed files with 310 additions and 165 deletions
89
src/Commands/Plumb.c
Normal file
89
src/Commands/Plumb.c
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
#include <Routes.h>
|
||||
|
||||
#include <Cytoplasm/Memory.h>
|
||||
#include <Cytoplasm/Str.h>
|
||||
|
||||
#include <Matrix.h>
|
||||
#include <Bot.h>
|
||||
#include <AS.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
CommandHead(CmdPlumb, cmd, argp)
|
||||
{
|
||||
ParseeCmdArg *args = argp;
|
||||
ParseeData *data = args->data;
|
||||
HashMap *event = args->event;
|
||||
char *muc = NULL, *room = NULL, *chat_id = NULL;
|
||||
char *room_id = NULL;
|
||||
MUCInfo info = { .exists = false };
|
||||
|
||||
BotInitialise();
|
||||
|
||||
BotRequired(muc);
|
||||
BotRequired(room);
|
||||
|
||||
/* Check MUC viability */
|
||||
Log(LOG_INFO, "BAR1");
|
||||
if (ParseeManageBan(args->data, muc, NULL))
|
||||
{
|
||||
ReplySprintf("MUC '%s' is not allowed on this bridge.", muc);
|
||||
Log(LOG_INFO, "BAR1F");
|
||||
goto end;
|
||||
}
|
||||
Log(LOG_INFO, "BAR2");
|
||||
if (!XMPPQueryMUC(args->data->jabber, muc, &info))
|
||||
{
|
||||
ReplySprintf("MUC '%s' does not exist.", muc);
|
||||
Log(LOG_INFO, "BAR2F");
|
||||
goto end;
|
||||
}
|
||||
Log(LOG_INFO, "BAR3");
|
||||
if ((chat_id = ParseeGetFromMUCID(args->data, muc)))
|
||||
{
|
||||
Free(chat_id);
|
||||
chat_id = NULL;
|
||||
ReplySprintf("MUC '%s' is already mapped.", muc);
|
||||
Log(LOG_INFO, "BAR3F");
|
||||
goto end;
|
||||
}
|
||||
|
||||
Log(LOG_INFO, "FOO");
|
||||
|
||||
/* Check room viability */
|
||||
room_id = ASJoin(args->data->config, room, NULL);
|
||||
if (!room_id)
|
||||
{
|
||||
ReplySprintf("Room '%s' does not exist.", room);
|
||||
Log(LOG_INFO, "FOO2");
|
||||
goto end;
|
||||
}
|
||||
Log(LOG_INFO, "FOO3");
|
||||
if ((chat_id = ParseeGetFromRoomID(args->data, room_id)))
|
||||
{
|
||||
Free(chat_id);
|
||||
chat_id = NULL;
|
||||
ReplySprintf("Room '%s' is already mapped.", room);
|
||||
Log(LOG_INFO, "FOO4");
|
||||
goto end;
|
||||
}
|
||||
|
||||
Log(LOG_INFO, "FOO5");
|
||||
chat_id = ParseePushMUC(args->data, room_id, muc);
|
||||
if (chat_id)
|
||||
{
|
||||
char *rev = StrConcat(2, muc, "/parsee");
|
||||
XMPPJoinMUC(args->data->jabber, "parsee", rev);
|
||||
|
||||
Free(rev);
|
||||
}
|
||||
Log(LOG_INFO, "FOO6");
|
||||
|
||||
ReplySprintf("Plumbed '%s'", muc);
|
||||
end:
|
||||
Log(LOG_INFO, "End.");
|
||||
BotDestroy();
|
||||
Free(chat_id);
|
||||
Free(room_id);
|
||||
XMPPFreeMUCInfo(info);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue