forked from matrix-org/mjolnir
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Base structure for an antispam module
- Loading branch information
Showing
4 changed files
with
73 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .antispam import AntiSpam |
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,24 @@ | ||
class AntiSpam(object): | ||
def __init__(self, config): | ||
self._block_invites = config.get("block_invites", True) | ||
self._block_messages = config.get("block_messages", False) | ||
self._list_room_ids = config.get("ban_lists", []) | ||
|
||
def check_event_for_spam(self, event): | ||
return False # not spam | ||
|
||
def user_may_invite(self, inviter_user_id, invitee_user_id, room_id): | ||
return True # allowed | ||
|
||
def user_may_create_room(self, user_id): | ||
return True # allowed | ||
|
||
def user_may_create_room_alias(self, user_id, room_alias): | ||
return True # allowed | ||
|
||
def user_may_publish_room(self, user_id, room_id): | ||
return True # allowed | ||
|
||
@staticmethod | ||
def parse_config(config): | ||
return config # no parsing needed |
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,11 @@ | ||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name="mjolnir", | ||
version="0.0.1", | ||
packages=find_packages(), | ||
description="Mjolnir Antispam", | ||
include_package_data=True, | ||
zip_safe=True, | ||
install_requires=[], | ||
) |