mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-14 02:05:17 +00:00
[MOD/ADD] Use glob-like system for admins.
This commit is contained in:
parent
0fc0fdd6f4
commit
95aaa0dbc9
10 changed files with 154 additions and 13 deletions
49
src/Commands/Admin.c
Normal file
49
src/Commands/Admin.c
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#include <Routes.h>
|
||||
|
||||
#include <Cytoplasm/Cytoplasm.h>
|
||||
#include <Cytoplasm/Memory.h>
|
||||
#include <Cytoplasm/Str.h>
|
||||
|
||||
#include <Matrix.h>
|
||||
#include <Bot.h>
|
||||
#include <AS.h>
|
||||
|
||||
CommandHead(CmdAdmin, cmd, argp)
|
||||
{
|
||||
ParseeCmdArg *args = argp;
|
||||
ParseeData *data = args->data;
|
||||
HashMap *event = args->event;
|
||||
char *glob;
|
||||
BotInitialise();
|
||||
BotRequired(glob);
|
||||
{
|
||||
DbRef *admins = DbLock(data->db, 1, "admins");
|
||||
HashMap *json;
|
||||
Array *list;
|
||||
bool init = false;
|
||||
|
||||
if (!admins)
|
||||
{
|
||||
admins = DbCreate(data->db, 1, "admins");
|
||||
}
|
||||
json = DbJson(admins);
|
||||
|
||||
if (!(list = GrabArray(json, 1, "admins")))
|
||||
{
|
||||
list = ArrayCreate();
|
||||
init = true;
|
||||
}
|
||||
|
||||
ArrayAdd(list, JsonValueString(glob));
|
||||
|
||||
if (init)
|
||||
{
|
||||
HashMapSet(json, "admins", JsonValueArray(list));
|
||||
}
|
||||
|
||||
DbUnlock(data->db, admins);
|
||||
}
|
||||
ReplySprintf("Added glob '%s'", glob);
|
||||
end:
|
||||
BotDestroy();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue