[MOD/ADD] Use glob-like system for admins.

This commit is contained in:
LDA 2024-07-06 02:16:52 +02:00
commit 95aaa0dbc9
10 changed files with 154 additions and 13 deletions

View file

@ -19,6 +19,7 @@
if (!prop) \
{ \
ReplyBasic("Field `" #prop "` REQUIRED."); \
goto end; \
}
#define BotDestroy() Free(profile)

10
src/include/Glob.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef PARSEE_GLOB_H
#define PARSEE_GLOB_H
#include <stdbool.h>
/* Verifies if a string matches a rule, as specified in
* https://spec.matrix.org/v1.11/appendices/#glob-style-matching. */
extern bool GlobMatches(char *rule, char *string);
#endif

View file

@ -35,10 +35,6 @@ typedef struct ParseeConfig {
/* ------- DB -------- */
char *db_path;
/* ------- ADMIN ------- */
char *jabber_admin;
char *matrix_admin;
} ParseeConfig;
typedef struct ParseeData {
@ -217,4 +213,8 @@ extern bool ParseeManageBan(ParseeData *, char *user, char *room);
/* Same as ParseeVerifyStanza, but DMs */
extern bool ParseeVerifyDMStanza(ParseeData *data, char *room_id, char *id);
/* Checks if any user is an admin */
extern bool ParseeIsAdmin(ParseeData *data, char *user);
#endif

View file

@ -42,7 +42,7 @@ typedef struct ParseeCmdArg {
) \
X_COMMAND( \
"plumb-muc", CmdPlumb, \
"Plumbs an existing Matrix room to a MUC." \
"Plumbs an existing Matrix room to a MUC. " \
"You'll need to give the Parsee bot enough " \
"privileges, however. " \
) \
@ -50,6 +50,10 @@ typedef struct ParseeCmdArg {
"help", CmdHelp, \
"Shows the command list" \
) \
X_COMMAND( \
"adminify", CmdAdmin, \
"Adminifies a Matrix glob pattern." \
) \
X_COMMAND( \
"stats", CmdStats, \
"Shows some Parsee statistics." \