[MOD/WIP] Threading, and bot "API".

Sloppy code!
This commit is contained in:
LDA 2024-07-03 22:28:31 +02:00
commit b81e267141
8 changed files with 259 additions and 124 deletions

View file

@ -2,7 +2,49 @@
#define PARSEE_BOT_H
#include <Cytoplasm/HashMap.h>
#include <Cytoplasm/Memory.h>
#include <Cytoplasm/Log.h>
#define BotInitialise() profile =
#include <stdio.h>
#include <Parsee.h>
#define BotInitialise() char *profile = StrConcat(4, \
"@", data->config->sender_localpart, \
":", data->config->homeserver_host \
); \
char *id = GrabString(event, 1, "room_id")
#define BotDestroy() Free(profile)
#define ReplyBasic(rep) do \
{ \
Free(ASSend( \
data->config, id, profile, \
"m.room.message", \
MatrixCreateNotice(rep) \
)); \
} \
while(0)
#define ReplySprintf(fp,...) do \
{ \
char *formatted = NULL; \
size_t fmt_len = 0; \
fmt_len = snprintf( \
NULL, 0, fp, __VA_ARGS__ \
); \
formatted = Malloc(fmt_len + 2); \
snprintf( \
formatted, fmt_len + 1, fp, __VA_ARGS__ \
); \
Free(ASSend( \
data->config, id, profile, \
"m.room.message", \
MatrixCreateNotice(formatted) \
)); \
Free(formatted); \
} \
while(0)
#endif