first version
This commit is contained in:
commit
27e64828d0
5 changed files with 68 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
*.mbp
|
29
LICENSE
Normal file
29
LICENSE
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
Lain Iwakura <lain@serialexperiments.club> 2019 ~ 2025
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the “Software”),
|
||||||
|
to deal in the Software without restriction, including without limitation
|
||||||
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
1. The above Name and Email shall be included in all copies or
|
||||||
|
substantial portions of the Software. Additionally, this license
|
||||||
|
file shall be included with the software files on top directory
|
||||||
|
with no changes on the file name or its contents.
|
||||||
|
|
||||||
|
2. In the case of selling copies of this software, you must direct a
|
||||||
|
portion of the income obtained to my address in the form of sweets,
|
||||||
|
cookies and milk. These may be replaced by technological gadgets, such as
|
||||||
|
full-sized robots, AI-controlled devices, tiny portable synthesizers,
|
||||||
|
and/or at your discretion sex devices remotely controlled via the internet.
|
||||||
|
|
||||||
|
3. In case you are making a lot of money with my software, you should send
|
||||||
|
a monthly email to the address at the top of this file with the subject
|
||||||
|
"I will feel only love" and in the content "I love you Lain". You are
|
||||||
|
also allowed to write whatever you want after this sentence.
|
||||||
|
|
||||||
|
3. You acknowledge that this software is not designed, licensed or
|
||||||
|
intended for use in the design, construction, operation or
|
||||||
|
maintenance of any nuclear facility.
|
||||||
|
|
5
README.md
Normal file
5
README.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Thread Only
|
||||||
|
A [maubot](https://github.com/maubot/maubot) that redacts text messages that isn't in a thread.
|
||||||
|
|
||||||
|
Invite it to your room, give it moderator permission (or whatever is necessary to redact
|
||||||
|
messages), and it will delete text messages that isn't in a thread as they're sent.
|
6
maubot.yaml
Normal file
6
maubot.yaml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
id: club.serialexperiments.threadonly
|
||||||
|
version: 0.0.1
|
||||||
|
license: Custom
|
||||||
|
modules:
|
||||||
|
- threadonly
|
||||||
|
main_class: ThreadOnly
|
27
threadonly.py
Normal file
27
threadonly.py
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
# Lain Iwakura <lain@serialexperiments.club> 2025
|
||||||
|
|
||||||
|
from typing import Tuple
|
||||||
|
|
||||||
|
from mautrix.types import RelationType, MessageType
|
||||||
|
from mautrix.errors import MForbidden
|
||||||
|
from maubot import Plugin, MessageEvent
|
||||||
|
from maubot.handlers import command
|
||||||
|
|
||||||
|
class ThreadOnly(Plugin):
|
||||||
|
BLOCKLIST = [
|
||||||
|
MessageType.TEXT,
|
||||||
|
MessageType.EMOTE,
|
||||||
|
MessageType.STICKER,
|
||||||
|
MessageType.LOCATION,
|
||||||
|
]
|
||||||
|
|
||||||
|
@command.passive("", msgtypes=BLOCKLIST)
|
||||||
|
async def handler(self, evt: MessageEvent, match: Tuple[str]) -> None:
|
||||||
|
if evt.content.relates_to.rel_type != RelationType.THREAD:
|
||||||
|
self.log.info(f"redacting {evt.content.msgtype}")
|
||||||
|
|
||||||
|
try:
|
||||||
|
await evt.redact(reason="Only threads allowed!")
|
||||||
|
except MForbidden:
|
||||||
|
self.log.error("No permission to redact!")
|
||||||
|
|
Loading…
Add table
Reference in a new issue