mirror of
https://git.kappach.at/lda/Parsee.git
synced 2025-04-16 17:47:49 +02:00
I honestly don't know what to call it.
It's not a 0.2 release, btw.
This commit is contained in:
parent
e7ba1fa48d
commit
3ceae7b053
13 changed files with 179 additions and 85 deletions
|
@ -23,12 +23,14 @@ of Parsee. May occasionally deadlock.
|
|||
#### Deprecated features
|
||||
*NONE*
|
||||
|
||||
### v0.1.1[star-of-hope] <X/X/XXXX>
|
||||
### v0.2.0[star-of-hope] <X/X/XXXX>
|
||||
Fixes some media metadata things, replaces the build system,
|
||||
and speeds up Parsee a tad bit.
|
||||
#### New things
|
||||
- Start dealing with some basic PEP-based avatars.
|
||||
- Allows MbedTLS through a specific Cytoplasm patch.
|
||||
- Kicking/Banning Parsee from XMPP effectively unlinks it.
|
||||
- Start adding documentation to Parsee;
|
||||
#### Bugfixes
|
||||
- Adds more information to media events so that clients can
|
||||
behave.
|
||||
|
|
|
@ -71,9 +71,7 @@ Currently, the main sources of documentation are the Ayadocs(for headers) and th
|
|||
(see `etc/man`).
|
||||
|
||||
## TODOS before 1.0 rolls around
|
||||
- Make Parsee go *vroooooooooommmmmmm*, by NOT asking the server constantly
|
||||
about what is available and what is not, as that is a source of latency, and
|
||||
thus slowdowns.
|
||||
- Make Parsee actually go *vroooooooooommmmmmm*.
|
||||
- PROPER FUCKING VCARD AVATARS
|
||||
XMPP->Matrix is decent, Matrix->XMPP is effectively a WIP
|
||||
- Add [libomemo](https://github.com/gkdr/libomemo) or something as an optional dependency.
|
||||
|
@ -93,6 +91,8 @@ restricted to Parsee admins, with permission from MUC owners, too
|
|||
- Limiting to admins may be a way to "control" consent for both, but this is
|
||||
only if Parsee admins are good-willed, which we must assume such statment to
|
||||
be false by default.
|
||||
- Currently, MUC owners may kick Parsee out, with the effect of unlinking the
|
||||
MUC.
|
||||
- Look at XEPS-TBD.TXT for XEPs to be done
|
||||
- Add a MUC server to Parsee, such that it may be able to hook onto it and therefore
|
||||
support XMPP->Matrix bridging.
|
||||
|
|
15
XEPS-TBD.TXT
15
XEPS-TBD.TXT
|
@ -21,10 +21,14 @@ Somewhat implemented XEPs:
|
|||
This allows reactions, which Matrix also has support to. The two
|
||||
systems don't seem *too* restrictive on one-another (unlike some
|
||||
IM platforms I won't mention), so this doesn't sound too bad to do
|
||||
HALF-IMPLEMENTED: Removing reacts won't work.
|
||||
TODO: Add support from Matrix.
|
||||
~ https://xmpp.org/extensions/xep-0184.html
|
||||
Only Matrix->XMPP as of now. Requesting data from Matrix ASes without
|
||||
/sync seems like a non-option as of now, which _sucks_.
|
||||
~ https://xmpp.org/extensions/xep-0084.html
|
||||
Avatar support would be extremely useful, if just a QoL improvment.
|
||||
Matrix and XMPP both have support for these.
|
||||
XEP-0084 is a pain in the ass to implement and seems generally just
|
||||
|
||||
For future XEPs:
|
||||
- https://xmpp.org/extensions/xep-0449.html
|
||||
|
@ -34,12 +38,7 @@ For future XEPs:
|
|||
which is used along PEP, it seems, and meanwhile Matrix has ''support''
|
||||
for packs too, tracking them is between "annoyance" and "yeah, no.".
|
||||
|
||||
ON STANDBY BECAUSE THESE HAVE BEEN TERRIBLE TO DEAL WITH AND WHO KEEPS WRITING
|
||||
THESE I WANT TO SEND THEM A NICE, BRIGHT GIFT:
|
||||
x https://xmpp.org/extensions/xep-0084.html
|
||||
Avatar support would be extremely useful, if just a QoL improvment.
|
||||
Matrix and XMPP both have support for these.
|
||||
XEP-0084 is a pain in the ass to implement and seems generally just
|
||||
On Standby:
|
||||
unreliable, however.
|
||||
x https://xmpp.org/extensions/xep-0080.html
|
||||
Can't think of a good analogy to these...
|
||||
|
@ -48,7 +47,7 @@ THESE I WANT TO SEND THEM A NICE, BRIGHT GIFT:
|
|||
Not XEPs, but ideas that _needs_ to be added:
|
||||
~ "GIVE THE PUPPETS APPROPRIATE PLS/ROLES" - Hydro/t4d
|
||||
Happens on Matrix. I'll need to handle that on XMPP as well.
|
||||
- Standalone/Static Parsee, ideally as small as it can be(if not as APE).
|
||||
~ Standalone/Static Parsee, ideally as small as it can be(if not as APE).
|
||||
- Kappa-like extension system(maybe bridging more than just Matrix-XMPP.)
|
||||
- https://www.youtube.com/watch?v=InL414iDZmY
|
||||
|
||||
|
|
|
@ -7,3 +7,4 @@ INCLUDES=src/include
|
|||
OBJECT=build
|
||||
CC=cc
|
||||
CFLAGS=-O3
|
||||
PREFIX=/usr
|
||||
|
|
50
etc/man/man7/parsee-cmd-syntax.7
Normal file
50
etc/man/man7/parsee-cmd-syntax.7
Normal file
|
@ -0,0 +1,50 @@
|
|||
." The last field is the codename, by the way.
|
||||
." ALL MANPAGES FOR PARSEE ARE UNDER PUBLIC DOMAIN
|
||||
.TH parsee-cmd-syntax 7 "Parsee Utility" "star-of-hope"
|
||||
|
||||
.SH NAME
|
||||
parsee-cmd-syntax - Basic syntax information with Parsee Matrix commands
|
||||
|
||||
.SH DESCRIPTION
|
||||
Parsee uses a specific syntax for commands, which is generally different
|
||||
from regular bots, but closer to
|
||||
.B dd(1) 's
|
||||
syntax.
|
||||
.PP
|
||||
A command is formatted as so.
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
.B ![NAME] arg1=val1 arg2='val2' arg3="val\(rs\(dq3"
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
.sp
|
||||
|
||||
.PP
|
||||
The
|
||||
.B arg1=val1
|
||||
syntax is to be used for simple values, with values containing no spaces.
|
||||
|
||||
.PP
|
||||
The
|
||||
.B NAME
|
||||
attribute defines the command to be called, and the
|
||||
.B arg1='val1' ,
|
||||
and
|
||||
.B arg2="val2"
|
||||
syntax is to be used for simple values, with values containing spaces. If
|
||||
the value needs to contain quotes, they may be escaped with
|
||||
.B \(rs'
|
||||
and
|
||||
.B \(rs"
|
||||
respectively.
|
||||
|
||||
.SH LICENSE
|
||||
This document is under public domain, or CC0 if not allowed by local law.
|
||||
|
||||
.SH SEE ALSO
|
||||
.B parsee(1)
|
|
@ -25,7 +25,7 @@ CommandParse(char *cmd)
|
|||
}
|
||||
|
||||
end_data = strchr(cmd, ' ');
|
||||
if (!end_data)
|
||||
if (!end_data || (cmd > end_data))
|
||||
{
|
||||
ret = Malloc(sizeof(*ret));
|
||||
ret->command = StrDuplicate(cmd);
|
||||
|
|
|
@ -22,11 +22,9 @@ CommandHead(CmdBanUser, cmd, argp)
|
|||
BotDestroy();
|
||||
return;
|
||||
}
|
||||
ASBan(data->config, room, user);
|
||||
|
||||
ReplySprintf("Banning %s from '%s'...",
|
||||
user, room
|
||||
);
|
||||
ASBan(data->config, room, user);
|
||||
ReplySprintf("Banning %s from '%s'...", user, room);
|
||||
|
||||
BotDestroy();
|
||||
}
|
||||
|
|
|
@ -9,43 +9,60 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
static bool
|
||||
Grab(ParseeData *data, Command *cmd, char **muc, char **chat_id, char **room)
|
||||
{
|
||||
if (HashMapGet(cmd->arguments, "muc"))
|
||||
{
|
||||
*muc = HashMapGet(cmd->arguments, "muc");
|
||||
|
||||
*chat_id = ParseeGetFromMUCID(data, *muc);
|
||||
*room = ParseeGetRoomID(data, *chat_id);
|
||||
if (!chat_id || !room)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (HashMapGet(cmd->arguments, "room"))
|
||||
{
|
||||
*room = HashMapGet(cmd->arguments, "room");
|
||||
|
||||
*chat_id = ParseeGetFromRoomID(data, *room);
|
||||
*muc = ParseeGetMUCID(data, *chat_id);
|
||||
if (!chat_id || !muc)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
CommandHead(CmdUnlinkMUC, cmd, argp)
|
||||
{
|
||||
ParseeCmdArg *args = argp;
|
||||
ParseeData *data = args->data;
|
||||
HashMap *json, *event = args->event, *mucs;
|
||||
DbRef *ref;
|
||||
char *muc = NULL, *chat_id = NULL, *room = NULL;
|
||||
|
||||
BotInitialise();
|
||||
|
||||
muc = HashMapGet(cmd->arguments, "muc");
|
||||
if (!muc)
|
||||
if (!Grab(data, cmd, &muc, &chat_id, &room))
|
||||
{
|
||||
ReplyBasic("`muc` field REQUIRED.");
|
||||
ReplyBasic("`muc`|`room` REQUIRED");
|
||||
goto end;
|
||||
}
|
||||
|
||||
ref = DbLock(data->db, 1, "chats");
|
||||
json = DbJson(ref);
|
||||
chat_id = StrDuplicate(GrabString(json, 2, "mucs", muc));
|
||||
chat_id = ParseeGetFromMUCID(data, muc);
|
||||
room = ParseeGetRoomID(data, chat_id);
|
||||
if (!chat_id)
|
||||
{
|
||||
ReplySprintf("No internal mapping to '%s'.", muc);
|
||||
goto end;
|
||||
}
|
||||
mucs = GrabObject(json, 1, "mucs");
|
||||
JsonValueFree(HashMapDelete(mucs, muc));
|
||||
DbUnlock(data->db, ref);
|
||||
|
||||
room = ParseeGetRoomID(data, chat_id);
|
||||
ref = DbLock(data->db, 1, "chats");
|
||||
json = DbJson(ref);
|
||||
mucs = GrabObject(json, 1, "rooms");
|
||||
JsonValueFree(HashMapDelete(mucs, room));
|
||||
DbUnlock(data->db, ref);
|
||||
|
||||
DbDelete(data->db, 2, "chats", chat_id);
|
||||
ParseeUnlinkRoom(data, chat_id);
|
||||
|
||||
/* TODO: Do it automatically, if *not plumbed* */
|
||||
ReplySprintf("The MUC %s is now *unlinked*.", muc);
|
||||
|
|
|
@ -47,7 +47,7 @@ static const Argument arguments[] =
|
|||
"Generates a parsee.yaml AS file before exiting")
|
||||
Arg('v', false, NULL,
|
||||
"Forces Parsee to print in a more verbose fashion "
|
||||
"(-vv prints stanzas to stderr)")
|
||||
"(-vvv prints stanzas to stderr)")
|
||||
Arg('h', false, NULL,
|
||||
"Generates an help screen(this one!)")
|
||||
|
||||
|
@ -116,6 +116,9 @@ Main(Array *args, HashMap *env)
|
|||
case PARSEE_VERBOSE_LOG:
|
||||
LogConfigLevelSet(LogConfigGlobal(), LOG_DEBUG);
|
||||
break;
|
||||
case PARSEE_VERBOSE_TIMINGS:
|
||||
Log(LOG_DEBUG, "Logging bench information.");
|
||||
break;
|
||||
case PARSEE_VERBOSE_STANZA:
|
||||
Log(LOG_DEBUG, "Enabling stanza printing.");
|
||||
break;
|
||||
|
@ -226,6 +229,8 @@ Main(Array *args, HashMap *env)
|
|||
if (ASRegisterUser(parsee_conf, parsee_conf->sender_localpart))
|
||||
{
|
||||
char *parsee = ParseeMXID(conf.handlerArgs);
|
||||
|
||||
/* TODO: An hardcoded avatar like this sucks. */
|
||||
ASSetAvatar(parsee_conf,
|
||||
parsee,
|
||||
"mxc://tedomum.net/"
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
#include <Parsee.h>
|
||||
|
||||
#include <Cytoplasm/Memory.h>
|
||||
#include <Cytoplasm/Json.h>
|
||||
|
||||
void
|
||||
ParseeUnlinkRoom(ParseeData *data, char *chat_id)
|
||||
{
|
||||
char *muc, *room;
|
||||
DbRef *ref;
|
||||
if (!data || !chat_id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
muc = ParseeGetMUCID(data, chat_id);
|
||||
room = ParseeGetRoomID(data, chat_id);
|
||||
if (!muc || !room)
|
||||
{
|
||||
Free(muc);
|
||||
Free(room);
|
||||
return;
|
||||
}
|
||||
|
||||
ref = DbLock(data->db, 1, "chats");
|
||||
JsonValueFree(HashMapDelete(
|
||||
GrabObject(DbJson(ref), 1, "rooms"),
|
||||
room
|
||||
));
|
||||
JsonValueFree(HashMapDelete(
|
||||
GrabObject(DbJson(ref), 1, "mucs"),
|
||||
muc
|
||||
));
|
||||
DbUnlock(data->db, ref);
|
||||
DbDelete(data->db, 2, "chats", chat_id);
|
||||
|
||||
Free(muc);
|
||||
Free(room);
|
||||
}
|
|
@ -538,3 +538,38 @@ end:
|
|||
return ret;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
ParseeUnlinkRoom(ParseeData *data, char *chat_id)
|
||||
{
|
||||
char *muc, *room;
|
||||
DbRef *ref;
|
||||
if (!data || !chat_id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
muc = ParseeGetMUCID(data, chat_id);
|
||||
room = ParseeGetRoomID(data, chat_id);
|
||||
if (!muc || !room)
|
||||
{
|
||||
Free(muc);
|
||||
Free(room);
|
||||
return;
|
||||
}
|
||||
|
||||
ref = DbLock(data->db, 1, "chats");
|
||||
JsonValueFree(HashMapDelete(
|
||||
GrabObject(DbJson(ref), 1, "rooms"),
|
||||
room
|
||||
));
|
||||
JsonValueFree(HashMapDelete(
|
||||
GrabObject(DbJson(ref), 1, "mucs"),
|
||||
muc
|
||||
));
|
||||
DbUnlock(data->db, ref);
|
||||
DbDelete(data->db, 2, "chats", chat_id);
|
||||
|
||||
Free(muc);
|
||||
Free(room);
|
||||
}
|
||||
|
|
|
@ -223,7 +223,10 @@ MessageStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
|||
ParseePushOIDTable(from, occ_id);
|
||||
}
|
||||
}
|
||||
Log(LOG_DEBUG, "XEP-421: %fs", Elapsed(rectime));
|
||||
if (args->verbosity >= PARSEE_VERBOSE_TIMINGS)
|
||||
{
|
||||
Log(LOG_DEBUG, "XEP-421: %fs", Elapsed(rectime));
|
||||
}
|
||||
|
||||
if (StrEquals(type, "error"))
|
||||
{
|
||||
|
@ -268,7 +271,10 @@ end_error:
|
|||
);
|
||||
return false;
|
||||
}
|
||||
Log(LOG_DEBUG, "Error management: %fs", Elapsed(rectime));
|
||||
if (args->verbosity >= PARSEE_VERBOSE_TIMINGS)
|
||||
{
|
||||
Log(LOG_DEBUG, "Error management: %fs", Elapsed(rectime));
|
||||
}
|
||||
|
||||
if (moderated)
|
||||
{
|
||||
|
@ -296,19 +302,28 @@ end_error:
|
|||
body = XMLookForUnique(stanza, "body");
|
||||
|
||||
PEPManagerHandle(thr->info->pep_manager, stanza);
|
||||
Log(LOG_DEBUG, "PEP management: %fs", Elapsed(rectime));
|
||||
if (args->verbosity >= PARSEE_VERBOSE_TIMINGS)
|
||||
{
|
||||
Log(LOG_DEBUG, "PEP management: %fs", Elapsed(rectime));
|
||||
}
|
||||
|
||||
to = ParseeDecodeMXID(HashMapGet(stanza->attrs, "to"));
|
||||
decode_from = ParseeLookupJID(from);
|
||||
from_matrix = ParseeEncodeJID(args->config, decode_from, true);
|
||||
room = ParseeFindDMRoom(args, to, from);
|
||||
data = body ? ArrayGet(body->children, 0) : NULL;
|
||||
Log(LOG_DEBUG, "Fetching user info: %fs", Elapsed(rectime));
|
||||
if (args->verbosity >= PARSEE_VERBOSE_TIMINGS)
|
||||
{
|
||||
Log(LOG_DEBUG, "Fetching user info: %fs", Elapsed(rectime));
|
||||
}
|
||||
|
||||
/* TODO: CLEAN THAT UP INTO A CREATEDM FUNCTION */
|
||||
mroom_id = ParseeGetBridgedRoom(args, stanza);
|
||||
Log(LOG_DEBUG, "Bridging event to '%s'...", mroom_id);
|
||||
Log(LOG_DEBUG, "Fetching bridge: %fs", Elapsed(rectime));
|
||||
if (args->verbosity >= PARSEE_VERBOSE_TIMINGS)
|
||||
{
|
||||
Log(LOG_DEBUG, "Fetching bridge: %fs", Elapsed(rectime));
|
||||
}
|
||||
if (!mroom_id && !room && !XMPPIsParseeStanza(stanza) &&
|
||||
to && *to == '@')
|
||||
{
|
||||
|
@ -367,7 +382,10 @@ end_error:
|
|||
StreamFlush(jabber->stream);
|
||||
pthread_mutex_unlock(&jabber->write_lock);
|
||||
XMLFreeElement(ps);
|
||||
Log(LOG_DEBUG, "Subscription to XEP-0084: %fs", Elapsed(rectime));
|
||||
if (args->verbosity >= PARSEE_VERBOSE_TIMINGS)
|
||||
{
|
||||
Log(LOG_DEBUG, "Subscription to XEP-0084: %fs", Elapsed(rectime));
|
||||
}
|
||||
|
||||
Free(parsee);
|
||||
Free(trim);
|
||||
|
@ -380,7 +398,10 @@ end_error:
|
|||
pthread_mutex_unlock(&thr->info->chk_lock);
|
||||
|
||||
LazyRegister(args, encoded, !chat ? res : NULL);
|
||||
Log(LOG_DEBUG, "Matrix registration: %fs", Elapsed(rectime));
|
||||
if (args->verbosity >= PARSEE_VERBOSE_TIMINGS)
|
||||
{
|
||||
Log(LOG_DEBUG, "Matrix registration: %fs", Elapsed(rectime));
|
||||
}
|
||||
|
||||
reactions = XMLookForTKV(stanza,
|
||||
"reactions", "xmlns", "urn:xmpp:reactions:0"
|
||||
|
@ -539,7 +560,10 @@ end_error:
|
|||
}
|
||||
|
||||
ProcessChatstates(args, stanza);
|
||||
Log(LOG_DEBUG, "Chatstate management: %fs", Elapsed(rectime));
|
||||
if (args->verbosity >= PARSEE_VERBOSE_TIMINGS)
|
||||
{
|
||||
Log(LOG_DEBUG, "Chatstate management: %fs", Elapsed(rectime));
|
||||
}
|
||||
|
||||
end:
|
||||
Free(mroom_id);
|
||||
|
|
|
@ -20,7 +20,8 @@ typedef struct ParseeData ParseeData;
|
|||
|
||||
#define PARSEE_VERBOSE_NONE 0
|
||||
#define PARSEE_VERBOSE_LOG 1
|
||||
#define PARSEE_VERBOSE_STANZA 2
|
||||
#define PARSEE_VERBOSE_TIMINGS 2
|
||||
#define PARSEE_VERBOSE_STANZA 3
|
||||
#define PARSEE_VERBOSE_COMICAL 53 /* MINUTES */
|
||||
|
||||
typedef struct ParseeConfig {
|
||||
|
@ -100,7 +101,8 @@ typedef struct Argument {
|
|||
/* A base64-encoded Parsee logo */
|
||||
extern const char media_parsee_logo[];
|
||||
|
||||
/* An ASCII-art rendition of "小橋" */
|
||||
/* An ASCII-art rendition of "小橋".
|
||||
* I'm sorry for its quality. If anyone wants to redraw it, feel free. */
|
||||
#define PARSEE_ASCII_LINES 8
|
||||
extern const char *parsee_ascii[PARSEE_ASCII_LINES];
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue