#ifndef PARSEE_BOT_H #define PARSEE_BOT_H #include #include #include #include #include #define BotInitialise() char *profile = ParseeMXID(data); \ char *id = GrabString(event, 1, "room_id") #define BotRequired(prop) prop = HashMapGet(cmd->arguments, #prop); \ if (!prop) \ { \ ReplyBasic("Field `" #prop "` REQUIRED."); \ goto end; \ } #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