Commit Graph
54 Commits
Author SHA1 Message Date
gnuxieandGnuxie 8157bae07a Migrate status command to use interface-manager. 2023-02-11 14:20:46 +00:00
gnuxieandGnuxie 1257b26306 Rename Parmater Parameter
Yeah don't ask.
2023-02-08 13:10:49 +00:00
GnuxieandGitHub 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 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 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 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
gnuxieandgnuxie d7adaef0bf It's time for mjolnir-shell, a presentation style interface.
While this isn't a true presentation style interface,
the idea is that there is an argument stream to commands
that we pattern match commands against, and there are
different mediums that the commands can be invoked from.

There are translators between presentation types
and also between commands and mediums to do things like
render the result of the command for Matrix etc.

This is all inspired by the Common Lisp Interface Manager (CLIM).
But there are significant differences since, hello, this is
essentially being made for Matrix bots and appservices.

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
gnuxieandgnuxie 98ea5a9586 Create a reader to assist parsing commands.
The idea is that the reader allows us to parse commands into
concrete types that will help us destructure/pattern match
against them later on.

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:26:12 +00:00
gnuxie 9330e319ce Add new header to all files. 2023-01-02 16:54:50 +00:00
gnuxie 63e0a24e6e First stage of commands refactor. 2022-12-09 20:08:34 +00:00
GnuxieandGitHub d5e0baaac5 Missing newline and indentation in command handler help. (#445) 2022-12-05 16:56:57 +00:00
Than HarrisonandGitHub 0379cc45fb Fix small typo (#382)
* src/commands/CommandHandler.ts:
 - fix small typo that's bugging me in `!status` response.
   change "projection" -> "protection"

Signed-off-by: Than Harrison <infosecvoid@proton.me>

Signed-off-by: Than Harrison <infosecvoid@proton.me>
2022-10-10 12:35:35 +02:00
David TellerandGitHub 829e1bd0aa Towards opinions in PolicyLists. (#336)
Towards opinions in PolicyLists.

This changeset is part of an ongoing effort to implement "opinions"
within policy lists, as per MSC3847.

For the time being:
- we rename BanList into PolicyList;
- we cleanup a little dead code;
- we replace a few `string`s with `enum`;
- `ListRule` becomes an abstract class with two concrete subclasses `ListRuleBan` and `ListRuleOpinion`.
2022-07-26 21:47:26 +02:00
GnuxieandGitHub 941cc32ddd Add !mjolnir rules matching <entity> to search watched lists. (#307)
* Add `!mjolnir rules matching <entity> to search watched lists.

Lists all the rules that will match the entity.
2022-07-07 13:03:03 +01:00
Jae Lo PrestiandGitHub a876a05520 Glob kick command (#291)
This pull requests adds for glob support in the `!mjolnir kick` command.

## Example
```
!mjolnir kick @*:domain.tld <reason> --force
```
This command will kick every user having a mxid matching `domain.tld`.  
You can also still kick a particular user:
```
!mjolnir kick @user:domain.tld <reason>
```

## Tests:
Tested on the Furry Tech room (`vRGLvqJYlFvzpThbxI:matrix.org`) after a spam wave.  
It kicked over 13k bots in a matter of hours without putting too much strain on the homeserver.  
For instance, this command was matching `@spam*`:
![image](https://user-images.githubusercontent.com/76598503/167320002-f0575f50-4b54-41d1-8220-f67d72ccaf16.png)

  
  
Signed-off-by: Jae Lo Presti <me@jae.fi>
2022-06-15 12:20:27 +01:00
David TellerandGitHub 74d8caa7e7 Since command: adding the ability to mute (#272) 2022-05-10 17:19:16 +02:00
David TellerandGitHub e05616b327 New command !mjolnir since <date or duration> <kick | ban | show> <limit> [reason] [...rooms] (#238)
A new command `since` to affect all users who have joined a protected room since a given date.
2022-03-21 10:39:15 +01:00
Marco CirilloandGitHub 97df4d5f61 Add command to elevate a user (or the bot) as room administrator (#219) 2022-03-07 10:14:06 +01:00
David TellerandGitHub 82a2e63d23 A room Protection designed to measure lag in a room (#217) 2022-02-24 13:43:31 +01:00
Jess PorterandGitHub f70d97e4d9 enable noImplicitAny (#209) 2022-02-02 12:43:05 +00:00
Jess PorterandGitHub 423a34bebe runtime persistent settings system (#158) 2022-01-25 14:47:50 +00:00
David Teller b60f503e2e FIXUP 2021-08-17 12:56:25 +02:00
Travis Ralston ff4cbc018f Update matrix-bot-sdk and use request cleaning function 2021-07-01 15:11:27 -06:00
Travis Ralston 7ee66a03dd Trim command arguments too for accessory spaces 2020-05-11 21:36:53 -06:00
Travis Ralston a8d03ffea7 Add a kick command 2020-04-15 08:12:42 -06:00
Travis Ralston 6f80a17558 Improve redaction handling 2020-04-14 16:49:20 -06:00
Travis Ralston f5763803d9 Add a command to resolve a room alias to a room ID 2020-02-21 09:58:22 -07:00
Travis Ralston 3dd4274b3b Add alias add/remove commands
Fixes https://github.com/matrix-org/mjolnir/issues/42
2020-02-20 13:30:48 -07:00
Travis Ralston e424f03ef2 Support redacting an individual event 2020-02-16 14:00:40 -07:00
Travis Ralston dea6f8cbf1 Add a command to shut down a room
Fixes https://github.com/matrix-org/mjolnir/issues/21
2020-02-13 13:56:03 -07:00
Travis Ralston 5b4c253002 Add a 'set powerlevel' command
Fixes https://github.com/matrix-org/mjolnir/issues/35
2020-02-13 13:43:30 -07:00
Travis Ralston aee562455a Add commands for managing room aliases and the room directory 2020-02-13 12:40:44 -07:00
Travis Ralston 38e22ee155 Add commands to add/remove protected rooms on the fly 2020-01-21 13:46:15 -07:00
Travis Ralston d5f260b982 Add a protection system with a "first message is an image" demo 2019-12-04 18:51:03 -07:00
Travis Ralston 778f9c3459 Add a command to deactivate a user 2019-11-14 15:44:13 -07:00
Travis Ralston 66a5775136 Make the [un]ban command smarter
Fixes https://github.com/matrix-org/mjolnir/issues/11
2019-11-13 21:38:19 -07:00
Travis Ralston dd260091bb Add a command to set a default ban list 2019-11-13 20:34:45 -07:00
Travis Ralston 84135c5ff5 Update log handling for debugging 2019-11-06 18:46:49 -07:00
Travis Ralston 12a3d6255d Add a moderator's guide to Mjolnir
Fixes https://github.com/matrix-org/mjolnir/issues/6
2019-10-28 20:20:47 -06:00
Travis Ralston 5409f4916a Add a way to actually unban people 2019-10-10 12:37:42 +01:00
Travis Ralston 8fbd918431 Add a rule import command 2019-10-10 11:30:52 +01:00
Travis Ralston 78b73153b7 Add a redact command 2019-10-09 15:53:37 +01:00
Travis Ralston 49468c5aab Fix command processing for recent refactorings 2019-10-08 21:06:54 +01:00
Travis Ralston 05ab8f60c6 Add watch and unwatch commands 2019-10-08 20:58:31 +01:00
Travis Ralston aecc6e4882 Support multiple ban lists 2019-10-08 17:57:03 +01:00
Travis Ralston 83e74af525 Add a command to perform permission checks 2019-10-04 21:26:38 -06:00
Travis Ralston 063bac77e5 Add a sync command 2019-09-27 20:02:03 -06:00
Travis Ralston 149d6dfa2e Add a help command 2019-09-27 16:12:53 -06:00