Matrix (mw-matrix)
MediaWiki extension for sending notifications to a Matrix webhook from MediaWiki. When a certain event occurs on your MediaWiki wiki, including new edits, they can be sent as a message to a channel on a Matrix server using a webhook.
Multiple webhook URLs are supported and messages will be sent to all of them.
Live demo: https://runescape.wiki (https://matrix.gg/runescapewiki)
Requirements
- Matrix webhook URL: Found by editing a channel -> Integrations -> Webhooks
- MediaWiki: This extension aims to always support the latest LTS release.
- Use the branch that is equal to, or below your current version.
- We do not support versions of MediaWiki that are considered end-of-life.
- The
masterbranch may contain changes that are only applicable to the current alpha version of MediaWiki.
- cURL (likely installed already). Without this, the extension may still work, but requests will be sent inefficiently.
Installation
- Clone this repository to your MediaWiki installation's
extensionsfolder usinggit clone https://github.com/jaydenkieran/mw-matrix.git -b REL1_35 Matrix - Modify your
LocalSettings.phpfile and add:
// Load the extension
wfLoadExtension( 'Matrix' );
// Set the webhook URL(s) (string or array)
$wgMatrixWebhookURL = [ '' ];
For further configuration variables, see below.
Getting a webhook URL
To get a webhook URL for use with this extension, open the Matrix client and go to a server where you have the Manage Webhooks permission. Click the cog icon when hovering over a text channel, switch to the Webhooks tab on the left of the interface, and click 'Create webhook'. The webhook URL can then be copied from that interface.
Configuration
This extension can be configured using the LocalSettings.php file in your MediaWiki installation.
| Variable | Type | Description |
|---|---|---|
$wgMatrixWebhookURL |
string/array | Matrix webhook URLs |
Optional
These parameters aren't required for the extension to work.
| Variable | Type | Description | Default |
|---|---|---|---|
$wgMatrixNoBots |
bool | Do not send notifications that are triggered by a bot account | true |
$wgMatrixNoMinor |
bool | Do not send notifications that are for minor edits | false |
$wgMatrixNoNull |
bool | Do not send notifications for null edits | true |
$wgMatrixSuppressPreviews |
bool | Force previews for links in Matrix messages to be suppressed | true |
$wgMatrixMaxChars |
int | Maximum amount of characters for user-generated text (e.g summaries, reasons). Set to null to disable truncation |
null |
$wgMatrixMaxCharsUsernames |
int | Maximum amount of characters for usernames. Set to null to disable truncation |
25 |
$wgMatrixDisabledHooks |
string array | List of hooks to disable sending webhooks for (see below) | [] |
$wgMatrixDisabledNS |
int array | List of namespace IDs to disable sending webhooks for. (see below) | [] |
$wgMatrixDisabledUsers |
string array | List of users whose performed actions shouldn't send webhooks | [] |
$wgMatrixPrependTimestamp |
bool | Prepend a timestamp (in UTC) to all sent messages. The format can be changed by editing the MediaWiki message matrix-timestampformat |
false |
$wgMatrixUseEmojis |
bool | Prepend emojis to different types of messages to help distinguish them | false |
$wgMatrixEmojis |
string associative array | Map of hook names and their associated emojis to prepend to messages if $wgMatrixUseEmojis is enabled |
See extension.json |
Hooks used
PageSaveComplete- New edits to pages and page creationsPageDeleteComplete- Page deletionsPageUndeleteComplete- Page restorationsArticleRevisionVisibilitySet- Revision visibility changesArticleProtectComplete- Page protectionsPageMoveComplete- Page movesLocalUserCreated- User registrationsBlockIpComplete- User blockedUnblockUserComplete- User unblockedUserGroupsChanged- User rights changedUploadComplete- File was uploadedFileDeleteComplete- File revision was deletedFileUndeleteComplete- File revision was restoredAfterImportPage- Page was importedArticleMergeComplete- Article histories were mergedRenameUserComplete- Rename was completed
Approved Revs
ApprovedRevsRevisionApproved- Revision was approvedApprovedRevsRevisionUnapproved- Revision was unapprovedApprovedRevsFileRevisionApproved- File revision was approvedApprovedRevsFileRevisionUnapproved- File revision was unapproved
Namespaces
As we use namespace IDs the following resources might be helpful:
Translation
You can submit translations for this extension on Translatewiki.net.
License
This extension is available under the MIT license. You can see here for more information.
This extension was inspired by Szmyk's mediawiki-matrix project.
