Commit Graph
513 Commits
Author SHA1 Message Date
gnuxie b59247df61 Allow fragments to be used in DeadDocument.
They work like React.Fragment except we don't have components yet
so it has to be a special node.
2023-02-11 14:20:46 +00:00
gnuxie cbddf71ebe Include version information in !draupnir status. 2023-02-11 14:20:46 +00:00
gnuxie 58ebc39c03 v1.80.0-beta.0 v1.80.0-beta.0 2023-02-08 15:25:13 +00:00
gnuxie ce44e6259a update CONTRIBUTING. 2023-02-08 15:11:24 +00:00
gnuxie 4f1781e31b Rename the bot from Mjolnir to Draupnir in the documentation
Following through with this everywhere will take a lot of time.
2023-02-08 15:04:42 +00:00
jesopo 71e0958505 fix 2 issues in !config get 2023-02-08 13:11:07 +00:00
gnuxie 1257b26306 Rename Parmater Parameter
Yeah don't ask.
2023-02-08 13:10:49 +00:00
Gnuxie c936332442 Ban/Unban rework + Prompts for missing arguments (#12)
* basic ban conversion, but i have better ideas

* Still very WIP on CLIM prompt-for-accept semantics.

* Introduce promotable streams.

This allows parameters to specify details to prompt for missing
arguments
and allow for interactive commands.

* Changes that were made before PolicyListManager that no longer make sense

We don't want the default list anymore since we're just going to prompt
with the lists that they can choose from.

* Fix semantics of TagDynamicEnvironment.

Bind and write were wrong and bind was binding to the node name
instead of the variable name.

* The JSX factory can render presentation types to DocumentNodes, unsure if this is the right
move yet but it works

* Attributes for anchor nodes now render properly

* Ban command prompts are working!!!!

* Stub AppserviceBotEmitter.

There isn't much we can do right now until there is time to work on
https://github.com/Gnuxie/Draupnir/issues/13.

* Combine ban/unban syntax.

* Remove old UnbanBanCommands.

WARNING: There is a major difference in that the ban command no longer supports
globs, I don't think?

* Activate new unban command.

* The presentation type boolean will have to be just a string for now.

I don't think it makes sense to read them into actual booleans.

* configurable defaults for ban reason.
2023-02-08 12:50:23 +00:00
Gnuxie 0d4864ed26 Merge pull request #5 from Gnuxie/gnuxie/policy-list-manager
Incorperate Mjolnir's new Policy List Manager

- https://github.com/matrix-org/mjolnir/pull/462
- https://github.com/matrix-org/mjolnir/pull/463
2023-01-31 20:23:08 +00:00
gnuxie 9797e32b5e Make MatrixRoomReference.joinClient return a new MatrixRoomReference. 2023-01-31 20:16:28 +00:00
gnuxie e293cecd7b Extract PolicyListManager from PolicyList to its own file. 2023-01-31 20:16:28 +00:00
gnuxie 7de7a1f506 Fail early when PolicyManager cannot resolve alias.
as per https://github.com/matrix-org/mjolnir/issues/404.
2023-01-31 20:13:52 +00:00
David Teller 9b08b51dac PolicyListManager: Let's not forget to remove the room also from the set of rooms we failed to resolve (#463) 2023-01-31 20:12:06 +00:00
David Teller 9e9b48700d This should hopefully fix some startup woes (#462)
Splitting PolicyListManager from Mjolnir, making it more resilient to startup errors
2023-01-31 20:12:04 +00:00
Gnuxie ad1e7cfac8 Merge pull request #9 from Gnuxie/gnuxie/errors
Improve errors caused by HTTP requests and stop alarm fatigue.
2023-01-31 20:07:17 +00:00
gnuxie 5164e48149 Rename MakeRoomAdminCommand to HijackRoomCommand 2023-01-31 20:00:14 +00:00
gnuxie 72f554ef2e Improve HTTP Error handling.
So as a history lesson.
The Matrix Bot SDK uses the npm library "requests".
When there was a http error, matrix-bot-sdk
would literally throw the response object.
This would be a horrible 1000+line long thing to accidentally
be logged to the console via node's inspect.
Though it was inevitable since you can't be sure every catch
was handling the error correctly. Irregardless, the solution
developed at Element was to create an error object
that had concise details.
This was great, however, within the matrix-bot-sdk there is
[this](https://github.com/Half-Shot/matrix-bot-sdk/blob/f58d7ea6e24d1db8b9b8009dea4cd97cbff54d0c/src/http.ts#L66)
awful line of code which logs every http error as error using the
matrix-bot-sdk logger.
This wastes so much log space and causes alarm fatigue,
rather than muting the module, the action instead taken
was to redact stack traces from http errors.
This was not a good idea.
Eventually matrix-bot-sdk was updated to have a MatrixError type
when a request was performed via the client-server api that had an
error.
matrix-appservice-bridge depends upon this and so Mjolnir now needs
to be updated to throw MatrixError's.
We have gone a step further in this commit and also muted
the matrix-bot-sdk http module, to stop the alarm fatigue problem
https://github.com/turt2live/matrix-bot-sdk/pull/158
2023-01-31 19:57:56 +00:00
gnuxie 277140240a Catch exceptions from commands better by giving them a uuid.
They can then be used as a reference to look for in the logs.
The MakeAdminCommand has been refactored as an example.
2023-01-31 19:57:56 +00:00
gnuxie 7a076033a3 Protect Draupnir from matrix-bot-sdk 2023-01-31 18:25:42 +00:00
gnuxie fda74c1aad Keyword argument (aka options/flags) support. 2023-01-19 17:56:48 +00:00
gnuxie b28a795d04 Stop MatrixRoomReference relying on bot-sdk's MatrixClient 2023-01-19 17:56:48 +00:00
gnuxie 9efdb241ad Allow command tables to be named with symbols to ease testing. 2023-01-19 17:56:48 +00:00
gnuxie 719d7a93d0 htmlEscape when serializing TextNodes to html 2023-01-19 17:56:48 +00:00
gnuxie d17d94a80a Update TypeScript so it can infer from narrowing unknown. 2023-01-19 17:56:48 +00:00
dependabot[bot] 41d9acc32f Bump json5 from 1.0.1 to 1.0.2 (#3)
Bumps [json5](https://github.com/json5/json5) from 1.0.1 to 1.0.2.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](https://github.com/json5/json5/compare/v1.0.1...v1.0.2)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-14 23:22:28 +00:00
Gnuxie bb125b3828 Dockerhub gnuxie/draupnir (#2)
Change old matrix.org/mjolnir references in github actions.
2023-01-14 22:43:39 +00:00
Gnuxie cccace8ef8 Merge pull request #1 from Gnuxie/gnuxie/command-reader
Add framework for parsing commands & hard fork Mjolnir
2023-01-14 20:15:35 +00:00
gnuxie 270910a317 note about status incase there are stragglers 2023-01-14 19:56:26 +00:00
gnuxie df671e1778 Place unban/ban back into the legacy command handler for now.
We haven't changed this yet and I'd like to merge the current changes
to the new command framework before we go to town changing all the legacy commands.
2023-01-14 19:51:37 +00:00
gnuxie b3f9fbe0af Remove stale test
Yes a test should probably be written for this, even if just as a debug
utility. This test just wasn't testing much regardless and
time needs to be put aside to do it properly.

The feature is still under development though.
2023-01-14 19:05:51 +00:00
gnuxie ccc17c4750 Add Utility for testing appservice commands in integration tests. 2023-01-14 19:00:33 +00:00
gnuxie 052ded0f30 Tidy up the interface-manager lint & doc. 2023-01-14 18:33:06 +00:00
gnuxie 0be83ae8ce We can now render to Matrix using JSX. 2023-01-14 18:33:06 +00:00
gnuxie 4b7e6637fa OK, it's plugged in, now how to test it 2023-01-14 18:33:06 +00:00
gnuxie de39bf5274 Ok, so this is how Matrix event rendering should work...
It does need a cleanup though, and i really hate how
loop initialization code is duplicated 💀
2023-01-14 18:33:06 +00:00
gnuxie da94b8d4bc Ahhhh you're doing it all wrong!!!
yeah
2023-01-14 18:33:06 +00:00
gnuxie d3e54440b2 Need PagedOutputStream instead of TransactionalOutputStream 2023-01-14 18:33:06 +00:00
gnuxie 3b49f18de2 Incremental Message rendering with JSX templates.
targetting both markdown and html.
2023-01-14 18:33:06 +00:00
gnuxie dede585d64 Pandoc AST please.
I've just realised my node model is wrong while halfway through
writing an incremental FringeWalker to help with renderering
events.
2023-01-14 18:33:06 +00:00
gnuxie eb710edc95 Remove unused, obsolete MatrixInterfaceCommand.
I'm not sure how it survived? probably f'd something up in
a rebase.
2023-01-14 18:33:06 +00:00
gnuxie de9a0a078b Two appservice bot commands to test with.
One lists unstarted mjolnirs, and one allows you to try restart them.
2023-01-14 18:33:06 +00:00
gnuxie 203f42dc0e Better argument validation error rendering. 2023-01-14 18:33:06 +00:00
gnuxie b9767532a8 help for commands.
This commit is NOT contributed under the Apache-2.0 License.
Copyright (C) 2022 Gnuxie <Gnuxie@protonmail.com>
All rights reserved.
2023-01-14 18:33:06 +00:00
gnuxie 76c48cccfc The error codes in CommandError are not going to work.
They're required which is bs because people are just going to make
up bullshit to satisfy the requirement. And it's rare
that they need to be intercepted.

What's rarer is intercepting them and not being able to change
the implementation.

So what am i going to do instead?

just not have it and you can subtype CommandError.
until i can think of something else.

This commit is NOT contributed under the Apache-2.0 License.
Copyright (C) 2022 Gnuxie <Gnuxie@protonmail.com>
All rights reserved.
2023-01-14 18:33:06 +00:00
gnuxie e6d0aaf9ea Richer paramater parsing.
This commit is NOT contributed under the Apache-2.0 License.
Copyright (C) 2022 Gnuxie <Gnuxie@protonmail.com>
All rights reserved.
2023-01-14 18:33:06 +00:00
gnuxie 66907a571e lint
This commit is NOT contributed under the Apache-2.0 License.
Copyright (C) 2022 Gnuxie <Gnuxie@protonmail.com>
All rights reserved.
2023-01-14 18:33:06 +00:00
gnuxie beb9152b10 New command system working in appservice
This commit is NOT contributed under the Apache-2.0 License.
Copyright (C) 2022 Gnuxie <Gnuxie@protonmail.com>
All rights reserved.
2023-01-14 18:33:06 +00:00
gnuxie dd21b48714 ValidationResult -> CommandResult
we need it for more than validation
probably considering getting rid of the error code thing
or making it optional idk.

This commit is NOT contributed under the Apache-2.0 License.
Copyright (C) 2022 Gnuxie <Gnuxie@protonmail.com>
All rights reserved.
2023-01-14 18:33:06 +00:00
gnuxie 6e6a3fdada MatrixInterfaceAdaptor
This commit is NOT contributed under the Apache-2.0 License.
Copyright (C) 2022 Gnuxie <Gnuxie@protonmail.com>
All rights reserved.
2023-01-14 18:33:06 +00:00
gnuxie b36376753d introduce InterfaceCommand.
We've basically made an embedded mini language for commands.

The idea is that there are a sequence of strings at the start
of a command that are pattern matched against a table.
Then eventually we will also pattern match against the presentation
types that they each accept.

This commit is NOT contributed under the Apache-2.0 License.
Copyright (C) 2022 Gnuxie <Gnuxie@protonmail.com>
All rights reserved.
2023-01-14 18:33:06 +00:00