-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't ban users in moderator room #544
Open
H-Shay
wants to merge
11
commits into
main
Choose a base branch
from
shay/no_self_harm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6eadd00
add a list of users/servers who should not be banned, acl'd
H-Shay fab0640
check list of entities who shouldn't be banned before banning
H-Shay 8fc5d05
add command to add users to ignored list
H-Shay 2265011
use correct file when logging
H-Shay 63f8a5b
Merge branch 'main' into shay/no_self_harm
H-Shay 5c70803
lint
H-Shay 989ba8b
add a cache to track ignore list/moderation room members
H-Shay a7977cc
refactor to use modcache
H-Shay 0884596
test
H-Shay 1fb77c4
lint
H-Shay fac9f2d
clear interval in cache when shutting down
H-Shay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
Copyright 2024 The Matrix.org Foundation C.I.C. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import { Mjolnir } from "../Mjolnir"; | ||
import { LogLevel, RichReply } from "@vector-im/matrix-bot-sdk"; | ||
|
||
// !mjolnir ignore <user|server> | ||
export async function execIgnoreCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) { | ||
const target = parts[2]; | ||
|
||
await mjolnir.managementRoomOutput.logMessage( | ||
LogLevel.INFO, | ||
"IgnoreCommand", | ||
`Adding ${target} to internal moderator list.`, | ||
); | ||
mjolnir.moderators.push(target); | ||
await mjolnir.client.unstableApis.addReactionToEvent(roomId, event["event_id"], "✅"); | ||
} | ||
|
||
// !mjolnir ignored | ||
export async function execListIgnoredCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) { | ||
let html = "Ignored users:<ul>"; | ||
let text = "Ignored users:\n"; | ||
|
||
for (const name of mjolnir.moderators) { | ||
html += `<li>${name}</li>`; | ||
text += `* ${name}\n`; | ||
} | ||
|
||
html += "</ul>"; | ||
|
||
const reply = RichReply.createFor(roomId, event, text, html); | ||
reply["msgtype"] = "m.notice"; | ||
await mjolnir.client.sendMessage(roomId, reply); | ||
await mjolnir.client.unstableApis.addReactionToEvent(roomId, event["event_id"], "✅"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users who are invited/joined after the bot starts up would get banned. Adding a cache would help ensure we don't miss anyone. We'd invalidate the cache on two conditions I think:
m.room.member
event in the management room. (we don't have to inspect the event: seeing it fly by should be enough to invalidate&repopulate)For deployments like matrix.org this may mean we pick up on displayname changes quite often, but I'd consider that a feature for keeping the cache active.