├── .gitignore ├── reactbot ├── __init__.py ├── rule.py ├── simplepattern.py ├── bot.py ├── template.py └── config.py ├── .gitlab-ci.yml ├── maubot.yaml ├── pyproject.toml ├── samples ├── nitter.yaml ├── random-reaction.yaml ├── jesari.yaml ├── thread.yaml └── stallman.yaml ├── .pre-commit-config.yaml ├── .github └── workflows │ └── python-lint.yml ├── base-config.yaml ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | *.mbp 2 | -------------------------------------------------------------------------------- /reactbot/__init__.py: -------------------------------------------------------------------------------- 1 | from .bot import ReactBot 2 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | include: 2 | - project: 'maubot/maubot' 3 | file: '/.gitlab-ci-plugin.yml' 4 | -------------------------------------------------------------------------------- /maubot.yaml: -------------------------------------------------------------------------------- 1 | maubot: 0.1.0 2 | id: xyz.maubot.reactbot 3 | version: 2.2.0 4 | license: AGPL-3.0-or-later 5 | modules: 6 | - reactbot 7 | main_class: ReactBot 8 | extra_files: 9 | - base-config.yaml 10 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.isort] 2 | profile = "black" 3 | force_to_top = "typing" 4 | from_first = true 5 | combine_as_imports = true 6 | known_first_party = ["mautrix", "maubot"] 7 | line_length = 99 8 | 9 | [tool.black] 10 | line-length = 99 11 | target-version = ["py38"] 12 | -------------------------------------------------------------------------------- /samples/nitter.yaml: -------------------------------------------------------------------------------- 1 | templates: 2 | nitter: 3 | type: m.room.message 4 | content: 5 | msgtype: m.text 6 | body: https://nitter.net/$${1}/status/$${2} 7 | 8 | default_flags: 9 | - ignorecase 10 | 11 | rules: 12 | twitter: 13 | matches: 14 | - https://twitter.com/(.+?)/status/(\d+) 15 | template: nitter 16 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: v4.4.0 4 | hooks: 5 | - id: trailing-whitespace 6 | exclude_types: [markdown] 7 | - id: end-of-file-fixer 8 | - id: check-added-large-files 9 | - repo: https://github.com/psf/black 10 | rev: 23.9.1 11 | hooks: 12 | - id: black 13 | language_version: python3 14 | files: ^reactbot/.*\.pyi?$ 15 | - repo: https://github.com/PyCQA/isort 16 | rev: 5.12.0 17 | hooks: 18 | - id: isort 19 | files: ^reactbot/.*\.pyi?$ 20 | -------------------------------------------------------------------------------- /.github/workflows/python-lint.yml: -------------------------------------------------------------------------------- 1 | name: Python lint 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | lint: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v4 10 | - uses: actions/setup-python@v4 11 | with: 12 | python-version: "3.11" 13 | - uses: isort/isort-action@master 14 | with: 15 | sortPaths: "./reactbot" 16 | - uses: psf/black@stable 17 | with: 18 | src: "./reactbot" 19 | - name: pre-commit 20 | run: | 21 | pip install pre-commit 22 | pre-commit run -av trailing-whitespace 23 | pre-commit run -av end-of-file-fixer 24 | pre-commit run -av check-added-large-files 25 | -------------------------------------------------------------------------------- /samples/random-reaction.yaml: -------------------------------------------------------------------------------- 1 | templates: 2 | random_reaction: 3 | type: m.reaction 4 | variables: 5 | react_to_event: '{{event.event_id}}' 6 | reaction: '{{ variables.reaction_choices | random }}' 7 | content: 8 | m.relates_to: 9 | rel_type: m.annotation 10 | event_id: $${react_to_event} 11 | key: $${reaction} 12 | 13 | default_flags: 14 | - ignorecase 15 | 16 | rules: 17 | random: 18 | matches: 19 | - hmm 20 | template: random_reaction 21 | variables: 22 | reaction_choices: 23 | - 🤔 24 | - 🧐 25 | - 🤨 26 | -------------------------------------------------------------------------------- /samples/jesari.yaml: -------------------------------------------------------------------------------- 1 | templates: 2 | jesari: 3 | type: m.room.message 4 | content: 5 | msgtype: m.image 6 | body: putkiteippi.gif 7 | url: mxc://maunium.net/LNjeTZvDEaUdQAROvWGHLLDi 8 | info: 9 | mimetype: image/gif 10 | w: 1280 11 | h: 535 12 | size: 7500893 13 | thumbnail_url: mxc://maunium.net/xdhlegZQgGwlMRzBfhNxyEfb 14 | thumbnail_info: 15 | mimetype: image/png 16 | w: 800 17 | h: 334 18 | size: 417896 19 | 20 | default_flags: 21 | - ignorecase 22 | 23 | rules: 24 | jesari: 25 | matches: [jesaro?i] 26 | template: jesari 27 | -------------------------------------------------------------------------------- /base-config.yaml: -------------------------------------------------------------------------------- 1 | templates: 2 | reaction: 3 | type: m.reaction 4 | variables: 5 | react_to_event: "{{event.content.get_reply_to() or event.event_id}}" 6 | content: 7 | m.relates_to: 8 | rel_type: m.annotation 9 | event_id: $${react_to_event} 10 | key: $${reaction} 11 | alot: 12 | type: m.room.message 13 | content: 14 | msgtype: m.image 15 | body: image.png 16 | url: "mxc://maunium.net/eFnyRdgJOHlKXCxzoKPQbwLV" 17 | info: 18 | mimetype: image/png 19 | w: 680 20 | h: 510 21 | size: 247492 22 | thumbnail_url: "mxc://maunium.net/PMxffxMfcUZeWeeYMDCdghBG" 23 | thumbnail_info: 24 | w: 680 25 | h: 510 26 | mimetype: image/png 27 | size: 233763 28 | 29 | default_flags: 30 | - ignorecase 31 | 32 | antispam: 33 | room: 34 | max: 1 35 | delay: 60 36 | user: 37 | max: 2 38 | delay: 60 39 | 40 | rules: 41 | twim_cookies: 42 | rooms: ["!FPUfgzXYWTKgIrwKxW:matrix.org"] 43 | matches: [^TWIM] 44 | template: reaction 45 | variables: 46 | reaction: 🍪 47 | alot: 48 | matches: [alot] 49 | template: alot 50 | -------------------------------------------------------------------------------- /samples/thread.yaml: -------------------------------------------------------------------------------- 1 | templates: 2 | always_in_thread: 3 | type: m.room.message 4 | variables: 5 | thread_parent: '{{event.content.get_thread_parent() or event.event_id}}' 6 | event_id: '{{event.event_id}}' 7 | content: 8 | msgtype: m.text 9 | body: $${text} 10 | m.relates_to: 11 | rel_type: m.thread 12 | event_id: $${thread_parent} 13 | is_falling_back: true 14 | m.in_reply_to: 15 | event_id: $${event_id} 16 | # Reply in thread if the message is already in a thread, otherwise use a normal reply. 17 | # This currently requires using a jinja template as the content instead of a normal yaml map. 18 | thread_or_reply: 19 | type: m.room.message 20 | variables: 21 | relates_to: | 22 | {{ 23 | {"rel_type": "m.thread", "event_id": event.content.get_thread_parent(), "is_falling_back": True, "m.in_reply_to": {"event_id": event.event_id}} 24 | if event.content.get_thread_parent() 25 | else {"m.in_reply_to": {"event_id": event.event_id}} 26 | }} 27 | content: 28 | msgtype: m.text 29 | body: $${text} 30 | m.relates_to: $${relates_to} 31 | 32 | antispam: 33 | room: 34 | max: 60 35 | delay: 60 36 | user: 37 | max: 60 38 | delay: 60 39 | 40 | rules: 41 | thread: 42 | matches: [^!thread$] 43 | template: always_in_thread 44 | variables: 45 | text: meow 3:< 46 | maybe_thread: 47 | matches: [^!thread --maybe$] 48 | template: thread_or_reply 49 | variables: 50 | text: meow >:3 51 | -------------------------------------------------------------------------------- /reactbot/rule.py: -------------------------------------------------------------------------------- 1 | # reminder - A maubot plugin that reacts to messages that match predefined rules. 2 | # Copyright (C) 2019 Tulir Asokan 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU Affero General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU Affero General Public License 15 | # along with this program. If not, see . 16 | from typing import Any, Dict, List, Match, Optional, Pattern, Set, Union 17 | 18 | from attr import dataclass 19 | 20 | from maubot import MessageEvent 21 | from mautrix.types import EventType, RoomID 22 | 23 | from .simplepattern import SimplePattern 24 | from .template import OmitValue, Template 25 | 26 | RPattern = Union[Pattern, SimplePattern] 27 | 28 | 29 | @dataclass 30 | class Rule: 31 | rooms: Set[RoomID] 32 | not_rooms: Set[RoomID] 33 | matches: List[RPattern] 34 | not_matches: List[RPattern] 35 | template: Template 36 | type: Optional[EventType] 37 | variables: Dict[str, Any] 38 | 39 | def _check_not_match(self, body: str) -> bool: 40 | for pattern in self.not_matches: 41 | if pattern.search(body): 42 | return True 43 | return False 44 | 45 | def match(self, evt: MessageEvent) -> Optional[Match]: 46 | if len(self.rooms) > 0 and evt.room_id not in self.rooms: 47 | return None 48 | elif evt.room_id in self.not_rooms: 49 | return None 50 | for pattern in self.matches: 51 | match = pattern.search(evt.content.body) 52 | if match: 53 | if self._check_not_match(evt.content.body): 54 | return None 55 | return match 56 | return None 57 | 58 | async def execute(self, evt: MessageEvent, match: Match) -> None: 59 | extra_vars = { 60 | "0": match.group(0), 61 | **{str(i + 1): val for i, val in enumerate(match.groups())}, 62 | **match.groupdict(), 63 | } 64 | content = self.template.execute(evt=evt, rule_vars=self.variables, extra_vars=extra_vars) 65 | await evt.client.send_message_event(evt.room_id, self.type or self.template.type, content) 66 | -------------------------------------------------------------------------------- /reactbot/simplepattern.py: -------------------------------------------------------------------------------- 1 | # reminder - A maubot plugin that reacts to messages that match predefined rules. 2 | # Copyright (C) 2021 Tulir Asokan 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU Affero General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU Affero General Public License 15 | # along with this program. If not, see . 16 | from typing import Callable, Dict, List, NamedTuple, Optional 17 | import re 18 | 19 | 20 | class SimpleMatch(NamedTuple): 21 | value: str 22 | 23 | def groups(self) -> List[str]: 24 | return [self.value] 25 | 26 | def group(self, group: int) -> Optional[str]: 27 | if group == 0: 28 | return self.value 29 | return None 30 | 31 | def groupdict(self) -> Dict[str, str]: 32 | return {} 33 | 34 | 35 | def matcher_equals(val: str, pattern: str) -> bool: 36 | return val == pattern 37 | 38 | 39 | def matcher_startswith(val: str, pattern: str) -> bool: 40 | return val.startswith(pattern) 41 | 42 | 43 | def matcher_endswith(val: str, pattern: str) -> bool: 44 | return val.endswith(pattern) 45 | 46 | 47 | def matcher_contains(val: str, pattern: str) -> bool: 48 | return pattern in val 49 | 50 | 51 | SimpleMatcherFunc = Callable[[str, str], bool] 52 | 53 | 54 | class SimplePattern: 55 | matcher: SimpleMatcherFunc 56 | pattern: str 57 | ignorecase: bool 58 | 59 | def __init__(self, matcher: SimpleMatcherFunc, pattern: str, ignorecase: bool) -> None: 60 | self.matcher = matcher 61 | self.pattern = pattern 62 | self.ignorecase = ignorecase 63 | 64 | def search(self, val: str) -> SimpleMatch: 65 | if self.ignorecase: 66 | val = val.lower() 67 | if self.matcher(val, self.pattern): 68 | return SimpleMatch(self.pattern) 69 | 70 | @staticmethod 71 | def compile( 72 | pattern: str, flags: re.RegexFlag = re.RegexFlag(0), force_raw: bool = False 73 | ) -> Optional["SimplePattern"]: 74 | ignorecase = flags == re.IGNORECASE 75 | s_pattern = pattern.lower() if ignorecase else pattern 76 | esc = "" 77 | if not force_raw: 78 | esc = re.escape(pattern) 79 | first, last = pattern[0], pattern[-1] 80 | if first == "^" and last == "$" and (force_raw or esc == f"\\^{pattern[1:-1]}\\$"): 81 | s_pattern = s_pattern[1:-1] 82 | func = matcher_equals 83 | elif first == "^" and (force_raw or esc == f"\\^{pattern[1:]}"): 84 | s_pattern = s_pattern[1:] 85 | func = matcher_startswith 86 | elif last == "$" and (force_raw or esc == f"{pattern[:-1]}\\$"): 87 | s_pattern = s_pattern[:-1] 88 | func = matcher_endswith 89 | elif force_raw or esc == pattern: 90 | func = matcher_contains 91 | else: 92 | # Not a simple pattern 93 | return None 94 | return SimplePattern(matcher=func, pattern=s_pattern, ignorecase=ignorecase) 95 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # reactbot 2 | A [maubot](https://github.com/maubot/maubot) that responds to messages that match predefined rules. 3 | 4 | ## Samples 5 | * The [base config](base-config.yaml) contains a cookie reaction for TWIM submissions 6 | in [#thisweekinmatrix:matrix.org](https://matrix.to/#/#thisweekinmatrix:matrix.org) 7 | and an image response for "alot". 8 | * [samples/jesari.yaml](samples/jesari.yaml) contains a replacement for [jesaribot](https://github.com/maubot/jesaribot). 9 | * [samples/stallman.yaml](samples/stallman.yaml) contains a Stallman interject bot. 10 | * [samples/random-reaction.yaml](samples/random-reaction.yaml) has an example of 11 | a randomized reaction to matching messages. 12 | * [samples/nitter.yaml](samples/nitter.yaml) has an example of matching tweet links 13 | and responding with a corresponding nitter.net link. 14 | * [samples/thread.yaml](samples/thread.yaml) has an example of replying in a thread. 15 | 16 | ## Config format 17 | ### Templates 18 | Templates contain the actual event type and content to be sent. 19 | * `type` - The Matrix event type to send 20 | * `content` - The event content. Either an object or jinja2 template that produces JSON. 21 | * `variables` - A key-value map of variables. 22 | 23 | Variables that start with `{{` are parsed as jinja2 templates and get the 24 | maubot event object in `event`. As of v3, variables are parsed using jinja2's 25 | [native types mode](https://jinja.palletsprojects.com/en/3.1.x/nativetypes/), 26 | which means the output can be a non-string type. 27 | 28 | If the content is a string, it'll be parsed as a jinja2 template and the output 29 | will be parsed as JSON. The content jinja2 template will get `event` just like 30 | variable templates, but it will also get all of the variables. 31 | 32 | If the content is an object, that object is what will be sent as the content. 33 | The object can contain variables using a custom syntax: All instances of 34 | `$${variablename}` will be replaced with the value matching `variablename`. 35 | This works in object keys and values and list items. If a key/value/item only 36 | consists of a variable insertion, the variable may be of any type. If there's 37 | something else than the variable, the variable will be concatenated using `+`, 38 | which means it should be a string. 39 | 40 | ### Default flags 41 | Default regex flags. Most Python regex flags are available. 42 | See [docs](https://docs.python.org/3/library/re.html#re.A). 43 | 44 | Most relevant flags: 45 | * `i` / `ignorecase` - Case-insensitive matching. 46 | * `s` / `dotall` - Make `.` match any character at all, including newline. 47 | * `x` / `verbose` - Ignore comments and whitespace in regex. 48 | * `m` / `multiline` - When specified, `^` and `$` match the start and end of 49 | line respectively instead of start and end of whole string. 50 | 51 | ### Rules 52 | Rules have five fields. Only `matches` and `template` are required. 53 | * `rooms` - The list of rooms where the rule should apply. 54 | If empty, the rule will apply to all rooms the bot is in. 55 | * `matches` - The regex or list of regexes to match. 56 | * `template` - The name of the template to use. 57 | * `variables` - A key-value map of variables to extend or override template variables. 58 | Like with template variables, the values are parsed as Jinja2 templates. 59 | 60 | The regex(es) in `matches` can either be simple strings containing the pattern, 61 | or objects containing additional info: 62 | * `pattern` - The regex to match. 63 | * `flags` - Regex flags (replaces default flags). 64 | * `raw` - Whether or not the regex should be forced to be raw. 65 | 66 | If `raw` is `true` OR the pattern contains no special regex characters other 67 | than `^` at the start and/or `$` at the end, the pattern will be considered 68 | "raw". Raw patterns don't use regex, but instead use faster string operators 69 | (equality, starts/endwith, contains). Patterns with the `multiline` flag will 70 | never be converted into raw patterns implicitly. 71 | -------------------------------------------------------------------------------- /reactbot/bot.py: -------------------------------------------------------------------------------- 1 | # reminder - A maubot plugin that reacts to messages that match predefined rules. 2 | # Copyright (C) 2019 Tulir Asokan 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU Affero General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU Affero General Public License 15 | # along with this program. If not, see . 16 | from typing import Dict, Tuple, Type 17 | import time 18 | 19 | from attr import dataclass 20 | 21 | from maubot import MessageEvent, Plugin 22 | from maubot.handlers import event 23 | from mautrix.types import EventType, MessageType, RoomID, UserID 24 | from mautrix.util.config import BaseProxyConfig 25 | 26 | from .config import Config, ConfigError 27 | 28 | 29 | @dataclass 30 | class FloodInfo: 31 | max: int 32 | delay: int 33 | count: int 34 | last_message: int 35 | 36 | def bump(self) -> bool: 37 | now = int(time.time()) 38 | if self.last_message + self.delay < now: 39 | self.count = 0 40 | self.count += 1 41 | if self.count > self.max: 42 | return True 43 | self.last_message = now 44 | return False 45 | 46 | 47 | class ReactBot(Plugin): 48 | allowed_msgtypes: Tuple[MessageType, ...] = (MessageType.TEXT, MessageType.EMOTE) 49 | user_flood: Dict[UserID, FloodInfo] 50 | room_flood: Dict[RoomID, FloodInfo] 51 | 52 | @classmethod 53 | def get_config_class(cls) -> Type[BaseProxyConfig]: 54 | return Config 55 | 56 | async def start(self) -> None: 57 | await super().start() 58 | self.user_flood = {} 59 | self.room_flood = {} 60 | self.on_external_config_update() 61 | 62 | def on_external_config_update(self) -> None: 63 | self.config.load_and_update() 64 | try: 65 | self.config.parse_data() 66 | except ConfigError: 67 | self.log.exception("Failed to load config") 68 | for fi in self.user_flood.values(): 69 | fi.max = self.config["antispam.user.max"] 70 | fi.delay = self.config["antispam.user.delay"] 71 | for fi in self.room_flood.values(): 72 | fi.max = self.config["antispam.room.max"] 73 | fi.delay = self.config["antispam.room.delay"] 74 | 75 | def _make_flood_info(self, for_type: str) -> "FloodInfo": 76 | return FloodInfo( 77 | max=self.config[f"antispam.{for_type}.max"], 78 | delay=self.config[f"antispam.{for_type}.delay"], 79 | count=0, 80 | last_message=0, 81 | ) 82 | 83 | def _get_flood_info(self, flood_map: dict, key: str, for_type: str) -> "FloodInfo": 84 | try: 85 | return flood_map[key] 86 | except KeyError: 87 | fi = flood_map[key] = self._make_flood_info(for_type) 88 | return fi 89 | 90 | def is_flood(self, evt: MessageEvent) -> bool: 91 | return ( 92 | self._get_flood_info(self.user_flood, evt.sender, "user").bump() 93 | or self._get_flood_info(self.room_flood, evt.room_id, "room").bump() 94 | ) 95 | 96 | @event.on(EventType.ROOM_MESSAGE) 97 | async def event_handler(self, evt: MessageEvent) -> None: 98 | if evt.sender == self.client.mxid or evt.content.msgtype not in self.allowed_msgtypes: 99 | return 100 | for name, rule in self.config.rules.items(): 101 | match = rule.match(evt) 102 | if match is not None: 103 | if self.is_flood(evt): 104 | return 105 | try: 106 | await rule.execute(evt, match) 107 | except Exception: 108 | self.log.exception(f"Failed to execute {name} in {evt.room_id}") 109 | return 110 | -------------------------------------------------------------------------------- /reactbot/template.py: -------------------------------------------------------------------------------- 1 | # reminder - A maubot plugin that reacts to messages that match predefined rules. 2 | # Copyright (C) 2021 Tulir Asokan 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU Affero General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU Affero General Public License 15 | # along with this program. If not, see . 16 | from typing import Any, Dict, List, Tuple, Union 17 | from itertools import chain 18 | import copy 19 | import json 20 | import re 21 | 22 | from attr import dataclass 23 | from jinja2 import Template as JinjaStringTemplate 24 | from jinja2.nativetypes import Template as JinjaNativeTemplate 25 | 26 | from mautrix.types import Event, EventType 27 | 28 | 29 | class Key(str): 30 | pass 31 | 32 | 33 | variable_regex = re.compile(r"\$\${([0-9A-Za-z-_]+)}") 34 | OmitValue = object() 35 | 36 | global_vars = { 37 | "omit": OmitValue, 38 | } 39 | 40 | Index = Union[str, int, Key] 41 | 42 | 43 | @dataclass 44 | class Template: 45 | type: EventType 46 | variables: Dict[str, Any] 47 | content: Union[Dict[str, Any], JinjaStringTemplate] 48 | 49 | _variable_locations: List[Tuple[Index, ...]] = None 50 | 51 | def init(self) -> "Template": 52 | self._variable_locations = [] 53 | self._map_variable_locations((), self.content) 54 | return self 55 | 56 | def _map_variable_locations(self, path: Tuple[Index, ...], data: Any) -> None: 57 | if isinstance(data, list): 58 | for i, v in enumerate(data): 59 | self._map_variable_locations((*path, i), v) 60 | elif isinstance(data, dict): 61 | for k, v in data.items(): 62 | if variable_regex.search(k): 63 | self._variable_locations.append((*path, Key(k))) 64 | self._map_variable_locations((*path, k), v) 65 | elif isinstance(data, str): 66 | if variable_regex.search(data): 67 | self._variable_locations.append(path) 68 | 69 | @classmethod 70 | def _recurse(cls, content: Any, path: Tuple[Index, ...]) -> Any: 71 | if len(path) == 0: 72 | return content 73 | return cls._recurse(content[path[0]], path[1:]) 74 | 75 | @staticmethod 76 | def _replace_variables(tpl: str, variables: Dict[str, Any]) -> str: 77 | full_var_match = variable_regex.fullmatch(tpl) 78 | if full_var_match: 79 | # Whole field is a single variable, just return the value to allow non-string types. 80 | return variables[full_var_match.group(1)] 81 | return variable_regex.sub(lambda match: str(variables[match.group(1)]), tpl) 82 | 83 | def execute( 84 | self, evt: Event, rule_vars: Dict[str, Any], extra_vars: Dict[str, str] 85 | ) -> Dict[str, Any]: 86 | variables = extra_vars 87 | for name, template in chain(rule_vars.items(), self.variables.items()): 88 | if isinstance(template, JinjaNativeTemplate): 89 | rendered_var = template.render(event=evt, variables=variables, **global_vars) 90 | if ( 91 | not isinstance(rendered_var, (str, int, list, tuple, dict, bool)) 92 | and rendered_var is not None 93 | and rendered_var is not OmitValue 94 | ): 95 | rendered_var = str(rendered_var) 96 | variables[name] = rendered_var 97 | else: 98 | variables[name] = template 99 | if isinstance(self.content, JinjaStringTemplate): 100 | raw_json = self.content.render(event=evt, **variables) 101 | return json.loads(raw_json) 102 | content = copy.deepcopy(self.content) 103 | for path in self._variable_locations: 104 | data: Dict[str, Any] = self._recurse(content, path[:-1]) 105 | key = path[-1] 106 | if isinstance(key, Key): 107 | key = str(key) 108 | data[self._replace_variables(key, variables)] = data.pop(key) 109 | else: 110 | replaced_data = self._replace_variables(data[key], variables) 111 | if replaced_data is OmitValue: 112 | del data[key] 113 | else: 114 | data[key] = replaced_data 115 | return content 116 | -------------------------------------------------------------------------------- /reactbot/config.py: -------------------------------------------------------------------------------- 1 | # reminder - A maubot plugin that reacts to messages that match predefined rules. 2 | # Copyright (C) 2019 Tulir Asokan 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU Affero General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU Affero General Public License 15 | # along with this program. If not, see . 16 | from typing import Any, Dict, List, Union 17 | import re 18 | 19 | from jinja2 import Template as JinjaStringTemplate 20 | from jinja2.nativetypes import NativeTemplate as JinjaNativeTemplate 21 | 22 | from mautrix.types import EventType 23 | from mautrix.util.config import BaseProxyConfig, ConfigUpdateHelper 24 | 25 | from .rule import RPattern, Rule 26 | from .simplepattern import SimplePattern 27 | from .template import Template 28 | 29 | InputPattern = Union[str, Dict[str, str]] 30 | 31 | 32 | class Config(BaseProxyConfig): 33 | rules: Dict[str, Rule] 34 | templates: Dict[str, Template] 35 | default_flags: re.RegexFlag 36 | 37 | def do_update(self, helper: ConfigUpdateHelper) -> None: 38 | helper.copy("rules") 39 | helper.copy("templates") 40 | helper.copy("default_flags") 41 | helper.copy("antispam.user.max") 42 | helper.copy("antispam.user.delay") 43 | helper.copy("antispam.room.max") 44 | helper.copy("antispam.room.delay") 45 | 46 | def parse_data(self) -> None: 47 | self.default_flags = re.RegexFlag(0) 48 | self.templates = {} 49 | self.rules = {} 50 | 51 | self.default_flags = self._get_flags(self["default_flags"]) 52 | self.templates = { 53 | name: self._make_template(name, tpl) for name, tpl in self["templates"].items() 54 | } 55 | self.rules = {name: self._make_rule(name, rule) for name, rule in self["rules"].items()} 56 | 57 | def _make_rule(self, name: str, rule: Dict[str, Any]) -> Rule: 58 | try: 59 | return Rule( 60 | rooms=set(rule.get("rooms", [])), 61 | not_rooms=set(rule.get("not_rooms", [])), 62 | matches=self._compile_all(rule["matches"]), 63 | not_matches=self._compile_all(rule.get("not_matches", [])), 64 | type=EventType.find(rule["type"]) if "type" in rule else None, 65 | template=self.templates[rule["template"]], 66 | variables=self._parse_variables(rule), 67 | ) 68 | except Exception as e: 69 | raise ConfigError(f"Failed to load {name}") from e 70 | 71 | def _make_template(self, name: str, tpl: Dict[str, Any]) -> Template: 72 | try: 73 | return Template( 74 | type=EventType.find(tpl.get("type", "m.room.message")), 75 | variables=self._parse_variables(tpl), 76 | content=self._parse_content(tpl.get("content", None)), 77 | ).init() 78 | except Exception as e: 79 | raise ConfigError(f"Failed to load {name}") from e 80 | 81 | def _compile_all(self, patterns: Union[InputPattern, List[InputPattern]]) -> List[RPattern]: 82 | if isinstance(patterns, list): 83 | return [self._compile(pattern) for pattern in patterns] 84 | else: 85 | return [self._compile(patterns)] 86 | 87 | def _compile(self, pattern: InputPattern) -> RPattern: 88 | flags = self.default_flags 89 | raw = None 90 | if isinstance(pattern, dict): 91 | flags = self._get_flags(pattern["flags"]) if "flags" in pattern else flags 92 | raw = pattern.get("raw", False) 93 | pattern = pattern["pattern"] 94 | if raw is not False and (not flags & re.MULTILINE or raw is True): 95 | return SimplePattern.compile(pattern, flags, raw) or re.compile(pattern, flags=flags) 96 | return re.compile(pattern, flags=flags) 97 | 98 | @staticmethod 99 | def _parse_variables(data: Dict[str, Any]) -> Dict[str, Any]: 100 | return { 101 | name: ( 102 | JinjaNativeTemplate(var_tpl) 103 | if isinstance(var_tpl, str) and var_tpl.startswith("{{") 104 | else var_tpl 105 | ) 106 | for name, var_tpl in data.get("variables", {}).items() 107 | } 108 | 109 | @staticmethod 110 | def _parse_content( 111 | content: Union[Dict[str, Any], str] 112 | ) -> Union[Dict[str, Any], JinjaStringTemplate]: 113 | if not content: 114 | return {} 115 | elif isinstance(content, str): 116 | return JinjaStringTemplate(content) 117 | return content 118 | 119 | @staticmethod 120 | def _get_flags(flags: Union[str, List[str]]) -> re.RegexFlag: 121 | output = re.RegexFlag(0) 122 | for flag in flags: 123 | flag = flag.lower() 124 | if flag == "i" or flag == "ignorecase": 125 | output |= re.IGNORECASE 126 | elif flag == "s" or flag == "dotall": 127 | output |= re.DOTALL 128 | elif flag == "x" or flag == "verbose": 129 | output |= re.VERBOSE 130 | elif flag == "m" or flag == "multiline": 131 | output |= re.MULTILINE 132 | elif flag == "l" or flag == "locale": 133 | output |= re.LOCALE 134 | elif flag == "u" or flag == "unicode": 135 | output |= re.UNICODE 136 | elif flag == "a" or flag == "ascii": 137 | output |= re.ASCII 138 | return output 139 | 140 | 141 | class ConfigError(Exception): 142 | pass 143 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published by 637 | the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /samples/stallman.yaml: -------------------------------------------------------------------------------- 1 | # Messages from https://github.com/interwho/stallman-bot (MIT license) 2 | 3 | templates: 4 | plaintext_notice: 5 | type: m.room.message 6 | content: 7 | msgtype: m.notice 8 | body: $${message} 9 | 10 | default_flags: 11 | - ignorecase 12 | 13 | antispam: 14 | room: 15 | max: 1 16 | delay: 60 17 | user: 18 | max: 2 19 | delay: 60 20 | 21 | rules: 22 | linux: 23 | matches: 24 | - linux 25 | not_matches: 26 | - gnu 27 | - kernel 28 | template: plaintext_notice 29 | variables: 30 | message: | 31 | I'd just like to interject for one moment. What you're referring to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX. 32 | Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called "Linux", and many of its users are not aware that it is basically the GNU system, developed by the GNU Project. 33 | There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called "Linux" distributions are really distributions of GNU/Linux. 34 | bsdstyle: 35 | matches: [bsd( |-)style] 36 | template: plaintext_notice 37 | variables: 38 | message: | 39 | I'd just like to interject for one moment. The expression "BSD-style license" leads to confusion because it lumps together licenses that have important differences. For instance, the original BSD license with the advertising clause is incompatible with the GNU General Public License, but the revised BSD license is compatible with the GPL. 40 | To avoid confusion, it is best to name the specific license in question and avoid the vague term "BSD-style." 41 | cloudcomp: 42 | matches: [cloud computing, the cloud] 43 | template: plaintext_notice 44 | variables: 45 | message: | 46 | I'd just like to interject for one moment. The term "cloud computing" is a marketing buzzword with no clear meaning. It is used for a range of different activities whose only common characteristic is that they use the Internet for something beyond transmitting files. Thus, the term is a nexus of confusion. If you base your thinking on it, your thinking will be vague. 47 | When thinking about or responding to a statement someone else has made using this term, the first step is to clarify the topic. Which kind of activity is the statement really about, and what is a good, clear term for that activity? Once the topic is clear, the discussion can head for a useful conclusion. 48 | Curiously, Larry Ellison, a proprietary software developer, also noted the vacuity of the term "cloud computing." He decided to use the term anyway because, as a proprietary software developer, he isn't motivated by the same ideals as we are. 49 | One of the many meanings of "cloud computing" is storing your data in online services. That exposes you to surveillance. 50 | Another meaning (which overlaps that but is not the same thing) is Software as a Service, which denies you control over your computing. 51 | Another meaning is renting a remote physical server, or virtual server. These can be ok under certain circumstances. 52 | closed: 53 | matches: [closed source] 54 | template: plaintext_notice 55 | variables: 56 | message: | 57 | I'd just like to interject for one moment. Describing nonfree software as "closed" clearly refers to the term "open source". In the free software movement, we do not want to be confused with the open source camp, so we are careful to avoid saying things that would encourage people to lump us in with them. For instance, we avoid describing nonfree software as "closed". We call it "nonfree" or "proprietary". 58 | commercial: 59 | matches: [commercial] 60 | template: plaintext_notice 61 | variables: 62 | message: | 63 | I'd just like to interject for one moment. Please don't use "commercial" as a synonym for "nonfree." That confuses two entirely different issues. 64 | A program is commercial if it is developed as a business activity. A commercial program can be free or nonfree, depending on its manner of distribution. Likewise, a program developed by a school or an individual can be free or nonfree, depending on its manner of distribution. The two questions--what sort of entity developed the program and what freedom its users have--are independent. 65 | In the first decade of the free software movement, free software packages were almost always noncommercial; the components of the GNU/Linux operating system were developed by individuals or by nonprofit organizations such as the FSF and universities. Later, in the 1990s, free commercial software started to appear. 66 | Free commercial software is a contribution to our community, so we should encourage it. But people who think that "commercial" means "nonfree" will tend to think that the "free commercial" combination is self-contradictory, and dismiss the possibility. Let's be careful not to use the word "commercial" in that way. 67 | consumer: 68 | matches: [consumer] 69 | template: plaintext_notice 70 | variables: 71 | message: | 72 | I'd just like to interject for one moment. The term "consumer," when used to refer to computer users, is loaded with assumptions we should reject. Playing a digital recording, or running a program, does not consume it. 73 | The terms "producer" and "consumer" come from economic theory, and bring with them its narrow perspective and misguided assumptions. These tend to warp your thinking. 74 | In addition, describing the users of software as "consumers" presumes a narrow role for them: it regards them as sheep that passively graze on what others make available to them. 75 | This kind of thinking leads to travesties like the CBDTPA "Consumer Broadband and Digital Television Promotion Act" which would require copying restriction facilities in every digital device. If all the users do is "consume," then why should they mind? 76 | The shallow economic conception of users as "consumers" tends to go hand in hand with the idea that published works are mere "content." 77 | To describe people who are not limited to passive use of works, we suggest terms such as "individuals" and "citizens". 78 | content: 79 | matches: [content] 80 | template: plaintext_notice 81 | variables: 82 | message: | 83 | I'd just like to interject for one moment. If you want to describe a feeling of comfort and satisfaction, by all means say you are "content," but using the word as a noun to describe written and other works of authorship adopts an attitude you might rather avoid. It regards these works as a commodity whose purpose is to fill a box and make money. In effect, it disparages the works themselves. 84 | Those who use this term are often the publishers that push for increased copyright power in the name of the authors ("creators," as they say) of the works. The term "content" reveals their real attitude towards these works and their authors. (See Courtney Love's open letter to Steve Case and search for "content provider" in that page. Alas, Ms. Love is unaware that the term "intellectual property" is also biased and confusing.) 85 | However, as long as other people use the term "content provider", political dissidents can well call themselves "malcontent providers". 86 | The term "content management" takes the prize for vacuity. "Content" means "some sort of information," and "management" in this context means "doing something with it." So a "content management system" is a system for doing something to some sort of information. Nearly all programs fit that description. 87 | In most cases, that term really refers to a system for updating pages on a web site. For that, we recommend the term "web site revision system" (WRS). 88 | digital_goods: 89 | matches: [digital goods] 90 | template: plaintext_notice 91 | variables: 92 | message: | 93 | I'd just like to interject for one moment. The term "digital goods," as applied to copies of works of authorship, erroneously identifies them with physical goods--which cannot be copied, and which therefore have to be manufactured and sold. 94 | digital_locks: 95 | matches: [digital locks] 96 | template: plaintext_notice 97 | variables: 98 | message: | 99 | I'd just like to interject for one moment. "Digital locks" is used to refer to Digital Restrictions Management by some who criticize it. The problem with this term is that it fails to show what's wrong with the practice. 100 | Locks are not necessarily an injustice. You probably own several locks, and their keys or codes as well; you may find them useful or troublesome, but either way they don't oppress you, because you can open and close them. 101 | DRM is like a lock placed on you by someone else, who refuses to give you the key -- in other words, like handcuffs. Therefore, we call them "digital handcuffs", not "digital locks". 102 | A number of campaigns have chosen the unwise term "digital locks"; therefore, to correct the mistake, we must work firmly against it. We may support a campaign that criticizes "digital locks", because we might agree with the substance; but when we do, we always state our rejection of that term and conspicuously say "digital handcuffs" so as to set a better example. 103 | drm: 104 | matches: [drm, digital rights management] 105 | template: plaintext_notice 106 | variables: 107 | message: | 108 | I'd just like to interject for one moment. "Digital Rights Management" refers to technical schemes designed to impose restrictions on computer users. The use of the word "rights" in this term is propaganda, designed to lead you unawares into seeing the issue from the viewpoint of the few that impose the restrictions, and ignoring that of the general public on whom these restrictions are imposed. 109 | Good alternatives include "Digital Restrictions Management," and "digital handcuffs." 110 | eco: 111 | matches: [ecosystem] 112 | template: plaintext_notice 113 | variables: 114 | message: | 115 | I'd just like to interject for one moment. It is a mistake to describe the free software community, or any human community, as an "ecosystem," because that word implies the absence of ethical judgment. 116 | The term "ecosystem" implicitly suggests an attitude of nonjudgmental observation: don't ask how what should happen, just study and explain what does happen. In an ecosystem, some organisms consume other organisms. We do not ask whether it is fair for an owl to eat a mouse or for a mouse to eat a plant, we only observe that they do so. Species' populations grow or shrink according to the conditions; this is neither right nor wrong, merely an ecological phenomenon. 117 | By contrast, beings that adopt an ethical stance towards their surroundings can decide to preserve things that, on their own, might vanish--such as civil society, democracy, human rights, peace, public health, clean air and water, endangered species, traditional arts…and computer users' freedom. 118 | freeware: 119 | matches: [freeware] 120 | template: plaintext_notice 121 | variables: 122 | message: | 123 | I'd just like to interject for one moment. Please don't use the term "freeware" as a synonym for "free software." The term "freeware" was used often in the 1980s for programs released only as executables, with source code not available. Today it has no particular agreed-on definition. 124 | When using languages other than English, please avoid borrowing English terms such as "free software" or "freeware." It is better to translate the term "free software" into your language. 125 | By using a word in your own language, you show that you are really referring to freedom and not just parroting some mysterious foreign marketing concept. The reference to freedom may at first seem strange or disturbing to your compatriots, but once they see that it means exactly what it says, they will really understand what the issue is. 126 | give: 127 | matches: [give away software] 128 | template: plaintext_notice 129 | variables: 130 | message: | 131 | I'd just like to interject for one moment. It's misleading to use the term "give away" to mean "distribute a program as free software." This locution has the same problem as "for free": it implies the issue is price, not freedom. One way to avoid the confusion is to say "release as free software." 132 | hacker: 133 | matches: [hacker] 134 | template: plaintext_notice 135 | variables: 136 | message: | 137 | I'd just like to interject for one moment. A hacker is someone who enjoys playful cleverness--not necessarily with computers. The programmers in the old MIT free software community of the 60s and 70s referred to themselves as hackers. Around 1980, journalists who discovered the hacker community mistakenly took the term to mean "security breaker." 138 | Please don't spread this mistake. People who break security are "crackers." 139 | ip: 140 | matches: [intellectual property] 141 | template: plaintext_notice 142 | variables: 143 | message: | 144 | I'd just like to interject for one moment. Publishers and lawyers like to describe copyright as "intellectual property"--a term also applied to patents, trademarks, and other more obscure areas of law. These laws have so little in common, and differ so much, that it is ill-advised to generalize about them. It is best to talk specifically about "copyright," or about "patents," or about "trademarks." 145 | The term "intellectual property" carries a hidden assumption--that the way to think about all these disparate issues is based on an analogy with physical objects, and our conception of them as physical property. 146 | When it comes to copying, this analogy disregards the crucial difference between material objects and information: information can be copied and shared almost effortlessly, while material objects can't be. 147 | To avoid spreading unnecessary bias and confusion, it is best to adopt a firm policy not to speak or even think in terms of "intellectual property". 148 | The hypocrisy of calling these powers "rights" is starting to make the World "Intellectual Property" Organization embarrassed. 149 | lamp: 150 | matches: [(\s|^)lamp(\s|$)] 151 | template: plaintext_notice 152 | variables: 153 | message: | 154 | I'd just like to interject for one moment. "LAMP" stands for "Linux, Apache, MySQL and PHP"--a common combination of software to use on a web server, except that "Linux" in this context really refers to the GNU/Linux system. So instead of "LAMP" it should be "GLAMP": "GNU, Linux, Apache, MySQL and PHP." 155 | market: 156 | matches: [software market] 157 | template: plaintext_notice 158 | variables: 159 | message: | 160 | I'd just like to interject for one moment. It is misleading to describe the users of free software, or the software users in general, as a "market." 161 | This is not to say there is no room for markets in the free software community. If you have a free software support business, then you have clients, and you trade with them in a market. As long as you respect their freedom, we wish you success in your market. 162 | But the free software movement is a social movement, not a business, and the success it aims for is not a market success. We are trying to serve the public by giving it freedom--not competing to draw business away from a rival. To equate this campaign for freedom to a business' efforts for mere success is to deny the importance of freedom and legitimize proprietary software. 163 | monetize: 164 | matches: [monetize] 165 | template: plaintext_notice 166 | variables: 167 | message: | 168 | I'd just like to interject for one moment. The natural meaning of "monetize" is "convert into money". If you make something and then convert it into money, that means there is nothing left except money, so nobody but you has gained anything, and you contribute nothing to the world. 169 | By contrast, a productive and ethical business does not convert all of its product into money. Part of it is a contribution to the rest of the world. 170 | mp3: 171 | matches: [mp3 player] 172 | template: plaintext_notice 173 | variables: 174 | message: | 175 | I'd just like to interject for one moment. In the late 1990s it became feasible to make portable, solid-state digital audio players. Most support the patented MP3 codec, but not all. Some support the patent-free audio codecs Ogg Vorbis and FLAC, and may not even support MP3-encoded files at all, precisely to avoid these patents. To call such players "MP3 players" is not only confusing, it also puts MP3 in an undeserved position of privilege which encourages people to continue using that vulnerable format. We suggest the terms "digital audio player," or simply "audio player" if context permits. 176 | open: 177 | matches: [open source] 178 | template: plaintext_notice 179 | variables: 180 | message: | 181 | I'd just like to interject for one moment. Please avoid using the term "open" or "open source" as a substitute for "free software". Those terms refer to a different position based on different values. Free software is a political movement; open source is a development model. When referring to the open source position, using its name is appropriate; but please do not use it to label us or our work--that leads people to think we share those views. 182 | pc: 183 | matches: [(\s|^)pcs?(\s|$)] 184 | template: plaintext_notice 185 | variables: 186 | message: | 187 | I'd just like to interject for one moment. It's OK to use the abbreviation "PC" to refer to a certain kind of computer hardware, but please don't use it with the implication that the computer is running Microsoft Windows. If you install GNU/Linux on the same computer, it is still a PC. 188 | The term "WC" has been suggested for a computer running Windows. 189 | ps: 190 | matches: [photoshop] 191 | template: plaintext_notice 192 | variables: 193 | message: | 194 | I'd just like to interject for one moment. Please avoid using the term "photoshop" as a verb, meaning any kind of photo manipulation or image editing in general. Photoshop is just the name of one particular image editing program, which should be avoided since it is proprietary. There are plenty of free programs for editing images, such as the GIMP. 195 | piracy: 196 | matches: [piracy, pirate] 197 | template: plaintext_notice 198 | variables: 199 | message: | 200 | I'd just like to interject for one moment. Publishers often refer to copying they don't approve of as "piracy." In this way, they imply that it is ethically equivalent to attacking ships on the high seas, kidnapping and murdering the people on them. Based on such propaganda, they have procured laws in most of the world to forbid copying in most (or sometimes all) circumstances. (They are still pressuring to make these prohibitions more complete.) 201 | If you don't believe that copying not approved by the publisher is just like kidnapping and murder, you might prefer not to use the word "piracy" to describe it. Neutral terms such as "unauthorized copying" (or "prohibited copying" for the situation where it is illegal) are available for use instead. Some of us might even prefer to use a positive term such as "sharing information with your neighbor." 202 | powerpoint: 203 | matches: [powerpoint, \sppt(\s|$)] 204 | template: plaintext_notice 205 | variables: 206 | message: | 207 | I'd just like to interject for one moment. Please avoid using the term "PowerPoint" to mean any kind of slide presentation. "PowerPoint" is just the name of one particular proprietary program to make presentations, and there are plenty of free program for presentations, such as TeX's beamer class and OpenOffice.org's Impress. 208 | protection: 209 | matches: [protection] 210 | template: plaintext_notice 211 | variables: 212 | message: | 213 | I'd just like to interject for one moment. Publishers' lawyers love to use the term "protection" to describe copyright. This word carries the implication of preventing destruction or suffering; therefore, it encourages people to identify with the owner and publisher who benefit from copyright, rather than with the users who are restricted by it. 214 | It is easy to avoid "protection" and use neutral terms instead. For example, instead of saying, "Copyright protection lasts a very long time," you can say, "Copyright lasts a very long time." 215 | If you want to criticize copyright instead of supporting it, you can use the term "copyright restrictions." Thus, you can say, "Copyright restrictions last a very long time." 216 | The term "protection" is also used to describe malicious features. For instance, "copy protection" is a feature that interferes with copying. From the user's point of view, this is obstruction. So we could call that malicious feature "copy obstruction." More often it is called Digital Restrictions Management (DRM)--see the Defective by Design campaign. 217 | sellsoft: 218 | matches: [sell software, selling software] 219 | template: plaintext_notice 220 | variables: 221 | message: | 222 | I'd just like to interject for one moment. The term "sell software" is ambiguous. Strictly speaking, exchanging a copy of a free program for a sum of money is selling; but people usually associate the term "sell" with proprietary restrictions on the subsequent use of the software. You can be more precise, and prevent confusion, by saying either "distributing copies of a program for a fee" or "imposing proprietary restrictions on the use of a program," depending on what you mean. 223 | softwareindustry: 224 | matches: [software industry] 225 | template: plaintext_notice 226 | variables: 227 | message: | 228 | I'd just like to interject for one moment. The term "software industry" encourages people to imagine that software is always developed by a sort of factory and then delivered to "consumers." The free software community shows this is not the case. Software businesses exist, and various businesses develop free and/or nonfree software, but those that develop free software are not run like factories. 229 | The term "industry" is being used as propaganda by advocates of software patents. They call software development "industry" and then try to argue that this means it should be subject to patent monopolies. The European Parliament, rejecting software patents in 2003, voted to define "industry" as "automated production of material goods." 230 | trustedcomp: 231 | matches: [trusted computing] 232 | template: plaintext_notice 233 | variables: 234 | message: | 235 | I'd just like to interject for one moment. "Trusted computing" is the proponents' name for a scheme to redesign computers so that application developers can trust your computer to obey them instead of you. From their point of view, it is "trusted"; from your point of view, it is "treacherous." 236 | vendor: 237 | matches: [vendor] 238 | template: plaintext_notice 239 | variables: 240 | message: | 241 | I'd just like to interject for one moment. Please don't use the term "vendor" to refer generally to anyone that develops or packages software. Many programs are developed in order to sell copies, and their developers are therefore their vendors; this even includes some free software packages. However, many programs are developed by volunteers or organizations which do not intend to sell copies. These developers are not vendors. Likewise, only some of the packagers of GNU/Linux distributions are vendors. We recommend the general term "supplier" instead. 242 | arch: 243 | matches: (^|\s)arch($|\s) 244 | template: plaintext_notice 245 | variables: 246 | message: | 247 | I'd just like to interject for one moment. Arch has the two usual problems: there's no clear policy about what software can be included, and nonfree blobs are shipped with their kernel. Arch also has no policy about not distributing nonfree software through their normal channels. 248 | centos: 249 | matches: [centos] 250 | template: plaintext_notice 251 | variables: 252 | message: | 253 | I'd just like to interject for one moment. We're not aware of problems in CentOS aside from the two usual ones: there's no clear policy about what software can be included, and nonfree blobs are shipped with the kernel. Of course, with no firm policy in place, there might be other nonfree software included that we missed. 254 | debian: 255 | matches: [debian] 256 | template: plaintext_notice 257 | variables: 258 | message: | 259 | I'd just like to interject for one moment. Debian's Social Contract states the goal of making Debian entirely free software, and Debian conscientiously keeps nonfree software out of the official Debian system. However, Debian also provides a repository of nonfree software. According to the project, this software is "not part of the Debian system," but the repository is hosted on many of the project's main servers, and people can readily learn about these nonfree packages by browsing Debian's online package database. 260 | There is also a "contrib" repository; its packages are free, but some of them exist to load separately distributed proprietary programs. This too is not thoroughly separated from the main Debian distribution. 261 | Previous releases of Debian included nonfree blobs with the kernel. With the release of Debian 6.0 ("squeeze") in February 2011, these blobs have been moved out of the main distribution to separate packages in the nonfree repository. However, the problem partly remains: the installer in some cases recommends these nonfree firmware files for the peripherals on the machine. 262 | fedora: 263 | matches: [fedora] 264 | template: plaintext_notice 265 | variables: 266 | message: | 267 | I'd just like to interject for one moment. Fedora does have a clear policy about what can be included in the distribution, and it seems to be followed carefully. The policy requires that most software and all fonts be available under a free license, but makes an exception for certain kinds of nonfree firmware. Unfortunately, the decision to allow that firmware in the policy keeps Fedora from meeting the free system distribution guidelines. 268 | seal: 269 | matches: [(fuck|screw|go away|die)\s?(you)?\s?(linux|stallman|gpl|rms|richard|linus), 270 | '((linux|stallman|gpl|rms|richard|linus) pls go|Shut your filthy hippy 271 | mouth,? (stallman|rms|richard|linus))', (linux|stallman|gpl|rms|richard|linus)\s+is\s+] 272 | template: plaintext_notice 273 | variables: 274 | message: | 275 | What the fuck did you just fucking say about me, you little proprietary bitch? I'll have you know I graduated top of my class in the FSF, and I've been involved in numerous secret raids on Apple patents, and I have over 300 confirmed bug fixes. I am trained in Free Software Evangelizing and I'm the top code contributer for the entire GNU HURD. You are nothing to me but just another compile time error. I will wipe you the fuck out with precision the likes of which has never been seen before on this Earth, mark my fucking words. You think you can get away with saying that shit to me over the Internet? Think again, fucker. As we speak I am building a GUI using GTK+ and your IP is being traced right now so you better prepare for the storm, maggot. The storm that wipes out the pathetic little thing you call your life. You're fucking dead, kid. I can be anywhere, anytime, and I can decompile you in over seven hundred ways, and that's just with my Model M. Not only am I extensively trained in EMACS, but I have access to the entire arsenal of LISP functions and I will use it to its full extent to wipe your miserable ass off the face of the continent, you little shit. If only you could have known what unholy retribution your little "clever" comment was about to bring down upon you, maybe you would have held your fucking tongue. But you couldn't, you didn't, and now you're paying the price, you goddamn idiot. I will shit Freedom all over you and you will drown in it. 276 | gentoo: 277 | matches: [gentoo] 278 | template: plaintext_notice 279 | variables: 280 | message: | 281 | I'd just like to interject for one moment. I have a low opinion of Gentoo GNU/Linux. 282 | Gentoo is a GNU/Linux distribution, but its developers don't recognize this; they call it "Gentoo Linux". That means they are treating me and the GNU Project disresepectfully. 283 | More importantly, Gentoo steers the user towards nonfree programs, which is why it is not one of our recognized free distros. 284 | mandriva: 285 | matches: [mandriva] 286 | template: plaintext_notice 287 | variables: 288 | message: | 289 | I'd just like to interject for one moment. Mandriva does have a stated policy about what can be included in the main system. It's based on Fedora's, which means that it also allows certain kinds of nonfree firmware to be included. On top of that, it permits software released under the original Artistic License to be included, even though that's a nonfree license. 290 | Mandriva also provides nonfree software through dedicated repositories. 291 | opensuse: 292 | matches: [opensuse] 293 | template: plaintext_notice 294 | variables: 295 | message: | 296 | I'd just like to interject for one moment. OpenSUSE offers its users access to a repository of nonfree software. This is an instance of how "open" is weaker than "free". 297 | redhat: 298 | matches: [redhat, red hat, rhel] 299 | template: plaintext_notice 300 | variables: 301 | message: | 302 | I'd just like to interject for one moment. Red Hat's enterprise distribution primarily follows the same licensing policies as Fedora, with one exception. Thus, we don't endorse it for the same reasons. In addition to those, Red Hat has no policy against making nonfree software available for the system through supplementary distribution channels. 303 | slackware: 304 | matches: [slackware] 305 | template: plaintext_notice 306 | variables: 307 | message: | 308 | I'd just like to interject for one moment. Slackware has the two usual problems: there's no clear policy about what software can be included, and nonfree blobs are included in the kernel. It also ships with the nonfree image-viewing program xv. Of course, with no firm policy in place, there might be other nonfree software included that we missed. 309 | ubuntu: 310 | matches: [ubuntu] 311 | template: plaintext_notice 312 | variables: 313 | message: | 314 | I'd just like to interject for one moment. Ubuntu provides specific repositories of nonfree software, and Canonical expressly promotes and recommends nonfree software under the Ubuntu name in some of their distribution channels. Ubuntu offers the option to install only free packages, which means it also offers the option to install nonfree packages too. In addition, the version of the kernel, included in Ubuntu contains firmware blobs. 315 | Ubuntu's trademark policy prohibits commercial redistribution of exact copies of Ubuntu, denying an important freedom. 316 | bsd: 317 | matches: [freebsd, openbsd, netbsd, bsd] 318 | template: plaintext_notice 319 | variables: 320 | message: | 321 | I'd just like to interject for one moment. FreeBSD, NetBSD, and OpenBSD all include instructions for obtaining nonfree programs in their ports system. In addition, their kernels include nonfree firmware blobs. 322 | Nonfree firmware programs used with the kernel, are called "blobs", and that's how we use the term. In BSD parlance, the term "blob" means something else: a nonfree driver. OpenBSD and perhaps other BSD distributions (called "projects" by BSD developers) have the policy of not including those. That is the right policy, as regards drivers; but when the developers say these distributions "contain no blobs", it causes a misunderstanding. They are not talking about firmware blobs. 323 | No BSD distribution has policies against proprietary binary-only firmware that might be loaded even by free drivers. 324 | compensation: 325 | matches: [compensation] 326 | template: plaintext_notice 327 | variables: 328 | message: | 329 | I'd just like to interject for one moment. To speak of “compensation for authors” in connection with copyright carries the assumptions that (1) copyright exists for the sake of authors and (2) whenever we read something, we take on a debt to the author which we must then repay. The first assumption is simply false, and the second is outrageous. 330 | “Compensating the rights-holders” adds a further swindle: you're supposed to imagine that means paying the authors, and occasionally it does, but most of the time it means a subsidy for the same publishing companies that are pushing unjust laws on us. 331 | consume: 332 | matches: [(^|\s)consume(\s|$)] 333 | template: plaintext_notice 334 | variables: 335 | message: | 336 | I'd just like to interject for one moment. “Consume” refers to what we do with food: we ingest it, after which the food as such no longer exists. By analogy, we employ the same word for other products whose use uses them up. Applying it to durable goods, such as clothing or appliances, is a stretch. Applying it to published works (programs, recordings on a disk or in a file, books on paper or in a file), whose nature is to last indefinitely and which can be run, played or read any number of times, is simply an error. Playing a recording, or running a program, does not consume it. 337 | The term “consume” is associated with the economics of uncopiable material products, and leads people to transfer its conclusions unconsciously to copiable digital works — an error that proprietary software developers (and other publishers) dearly wish to encourage. Their twisted viewpoint comes through clearly in this article, which also refers to publications as “content.” 338 | The narrow thinking associated with the idea that we “consume content” paves the way for laws such as the DMCA that forbid users to break the Digital Restrictions Management (DRM) facilities in digital devices. If users think what they do with these devices is “consume,” they may see such restrictions as natural. 339 | It also encourages the acceptation of “streaming” services, which use DRM to limit use of digital recordings to a form that fits the word “consume.” 340 | Why is this perverse usage spreading? Some may feel that the term sounds sophisticated; if that attracts you, rejecting it with cogent reasons can appear even more sophisticated. Others may be acting from business interests (their own, or their employers'). Their use of the term in prestigious forums gives the impression that it's the “correct” term. 341 | To speak of “consuming” music, fiction, or any other artistic works is to treat them as products rather than as art. If you don't want to spread that attitude, you would do well to reject using the term “consume” for them. We recommend saying that someone “experiences” an artistic work or a work stating a point of view, and that someone “uses” a practical work. 342 | creativecommons: 343 | matches: [creative commons] 344 | template: plaintext_notice 345 | variables: 346 | message: | 347 | I'd just like to interject for one moment. The most important licensing characteristic of a work is whether it is free. Creative Commons publishes seven licenses; three are free (CC BY, CC BY-SA and CC0) and the rest are nonfree. Thus, to describe a work as “Creative Commons licensed” fails to say whether it is free, and suggests that the question is not important. The statement may be accurate, but the omission is harmful. 348 | To encourage people to pay attention to the most important distinction, always specify which Creative Commons license is used, as in “licensed under CC BY-SA.” If you don't know which license a certain work uses, find out and then make your statement. 349 | creator: 350 | matches: [creator] 351 | template: plaintext_notice 352 | variables: 353 | message: | 354 | I'd just like to interject for one moment. The term “creator” as applied to authors implicitly compares them to a deity (“the creator”). The term is used by publishers to elevate authors' moral standing above that of ordinary people in order to justify giving them increased copyright power, which the publishers can then exercise in their name. We recommend saying “author” instead. However, in many cases “copyright holder” is what you really mean. These two terms are not equivalent: often the copyright holder is not the author. 355 | floss: 356 | matches: [floss] 357 | template: plaintext_notice 358 | variables: 359 | message: | 360 | I'd just like to interject for one moment. The term “FLOSS,” meaning “Free/Libre and Open Source Software,” was coined as a way to be neutral between free software and open source. If neutrality is your goal, “FLOSS” is the best way to be neutral. But if you want to show you stand for freedom, don't use a neutral term. 361 | forfree: 362 | matches: [for free] 363 | template: plaintext_notice 364 | variables: 365 | message: | 366 | I'd just like to interject for one moment. If you want to say that a program is free software, please don't say that it is available “for free.” That term specifically means “for zero price.” Free software is a matter of freedom, not price. 367 | Free software copies are often available for free—for example, by downloading via FTP. But free software copies are also available for a price on CD-ROMs; meanwhile, proprietary software copies are occasionally available for free in promotions, and some proprietary packages are normally available at no charge to certain users. 368 | To avoid confusion, you can say that the program is available “as free software.” 369 | foss: 370 | matches: [foss] 371 | template: plaintext_notice 372 | variables: 373 | message: | 374 | I'd just like to interject for one moment. The term “FOSS,” meaning “Free and Open Source Software,” was coined as a way to be neutral between free software and open source, but it doesn't really do that. If neutrality is your goal, “FLOSS” is better. But if you want to show you stand for freedom, don't use a neutral term. 375 | freelyavailable: 376 | matches: [freely available] 377 | template: plaintext_notice 378 | variables: 379 | message: | 380 | I'd just like to interject for one moment. Don't use “freely available software” as a synonym for “free software.” The terms are not equivalent. Software is “freely available” if anyone can easily get a copy. “Free software” is defined in terms of the freedom of users that have a copy of it. These are answers to different questions. 381 | google: 382 | matches: [(^|\s)google(\s|$)] 383 | template: plaintext_notice 384 | variables: 385 | message: | 386 | I'd just like to interject for one moment. Please avoid using the term “google” as a verb, meaning to search for something on the internet. “Google” is just the name of one particular search engine among others. We suggest to use the term “web search” instead. Try to use a search engine that respects your privacy; DuckDuckGo claims not to track its users, although we cannot confirm this. 387 | saas: 388 | matches: [saas, software as a service] 389 | template: plaintext_notice 390 | variables: 391 | message: | 392 | I'd just like to interject for one moment. We used to say that SaaS (short for “Software as a Service”) is an injustice, but then we found that there was a lot of variation in people's understanding of which activities count as SaaS. So we switched to a new term, “Service as a Software Substitute” or “SaaSS.” This term has two advantages: it wasn't used before, so our definition is the only one, and it explains what the injustice consists of. 393 | In Spanish we continue to use the term “software como servicio” because the joke of “software como ser vicio” is too good to give up. 394 | sharingeconomy: 395 | matches: [sharing economy] 396 | template: plaintext_notice 397 | variables: 398 | message: | 399 | I'd just like to interject for one moment. The term “sharing economy” is not a good way to refer to services such as Uber and Airbnb that arrange business transactions between people. We use the term “sharing” to refer to noncommercial cooperation, including noncommercial redistribution of exact copies of published works. Stretching the word “sharing” to include these transactions undermines its meaning, so we don't use it in this context. 400 | A more suitable term for businesses like Uber is the “piecework service economy.” 401 | skype: 402 | matches: [skype] 403 | template: plaintext_notice 404 | variables: 405 | message: | 406 | I'd just like to interject for one moment. Please avoid using the term “Skype” as a verb, meaning any kind of video communication or telephony over the Internet in general. “Skype” is just the name of one particular proprietary program, one that spies on its users. If you want to make video and voice calls over the Internet in a way that respects both your freedom and your privacy, try one of the numerous free Skype replacements. 407 | sourcemodel: 408 | matches: [source model] 409 | template: plaintext_notice 410 | variables: 411 | message: | 412 | I'd just like to interject for one moment. Wikipedia uses the term “source model” in a confused and ambiguous way. Ostensibly it refers to how a program's source is distributed, but the text confuses this with the development methodology. It distinguishes “open source” and ”shared source” as answers, but they overlap — Microsoft uses the latter as a marketing term to cover a range of practices, some of which are “open source”. Thus, this term really conveys no coherent information, but it provides an opportunity to say “open source” in pages describing free software programs. 413 | theft: 414 | matches: [theft] 415 | template: plaintext_notice 416 | variables: 417 | message: | 418 | I'd just like to interject for one moment. The supporters of a too-strict, repressive form of copyright often use words like “stolen” and “theft” to refer to copyright infringement. This is spin, but they would like you to take it for objective truth. 419 | Under the US legal system, copyright infringement is not theft. Laws about theft are not applicable to copyright infringement. The supporters of repressive copyright are making an appeal to authority—and misrepresenting what authority says. 420 | Unauthorized copying is forbidden by copyright law in many circumstances (not all!), but being forbidden doesn't make it wrong. In general, laws don't define right and wrong. Laws, at their best, attempt to implement justice. If the laws (the implementation) don't fit our ideas of right and wrong (the spec), the laws are what should change. 421 | In addition, a US judge, presiding over a trial for copyright infringement, recognized that “piracy” and “theft” are smear-words. 422 | --------------------------------------------------------------------------------