Skip to content
Extraits de code Groupes Projets

Comparer les révisions

Les modifications sont affichées comme si la révision source était fusionnée avec la révision cible. En savoir plus sur la comparaison des révisions.

Source

Sélectionner le projet cible
No results found
Sélectionner une révision Git
  • cherry-pick-moise
  • develop
  • rebase-v4
  • renovate/configure
4 résultats

Cible

Sélectionner le projet cible
  • arise/matrix-appservice-discord
  • Deurstann/matrix-appservice-discord
2 résultats
Sélectionner une révision Git
  • cherry-pick-moise
  • develop
  • fix-oversized-file-transfer
  • implement-discord-markdown-update
  • matrix-answer-modified-fix
  • matrix-attachment-order-fix
  • matrix-attachments-order-fix
7 résultats
Afficher les modifications
Validations sur la source (80)
Affichage de avec 263 ajouts et 122 suppressions
......@@ -18,6 +18,7 @@
"no-trailing-spaces": "error",
"max-classes-per-file": ["warn", 1],
"object-literal-sort-keys": "off",
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/typedef": "warn",
......
* @matrix-org/bridges
\ No newline at end of file
<!--
Hi there 👋, please check you've read the [CONTRIBUTING](../CONTRIBUTING.md) guide before submitting a PR (it's worth it, honestly).
-->
name: Container Image
on:
push:
branches: [ develop ]
tags: [ 'v*' ]
pull_request:
branches: [ develop ]
env:
IMAGE_NAME: ${{ github.repository }}
REGISTRY: ghcr.io
jobs:
push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
name: Newsfile
on:
push:
branches: ["develop", "release-*"]
pull_request:
workflow_dispatch:
jobs:
changelog:
if: ${{ github.base_ref == 'develop' || contains(github.base_ref, 'release-') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- uses: actions/setup-python@v2
- run: pip install towncrier==21.9.0
- run: scripts/check-newsfragment
env:
PULL_REQUEST_NUMBER: ${{ github.event.number }}
name: Contribution requirements
on:
pull_request:
types: [opened, edited, synchronize]
jobs:
signoff:
uses: matrix-org/backend-meta/.github/workflows/sign-off.yml@v1.4.0
name: CI
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 16
- run: yarn
- run: yarn lint
test:
runs-on: ubuntu-latest
strategy:
matrix:
node_version: [16, 18]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node_version }}
- run: yarn
- run: yarn test
......@@ -38,6 +38,10 @@ jspm_packages
# Optional npm cache directory
.npm
# Optional local Yarn settings
.yarn
.yarnrc
# Optional REPL history
.node_repl_history
......@@ -49,3 +53,9 @@ build
*.db
*.db.backup
.vscode/
*.code-workspace
# Local History for Visual Studio Code
.history/
engine-strict = true
@mx-puppet:registry="https://gitlab.com/api/v4/packages/npm/"
dist: xenial
language: node_js
install: yarn
cache:
directories:
- node_modules
jobs:
include:
- stage: lint
script: yarn lint
node_js: "14"
- stage: unit tests
script: yarn test
node_js: "12"
- node_js: "14"
- stage: coverage
script: yarn coverage
node_js: "14"
# NOTE: This is unused atm
# notifications:
# webhooks:
# urls:
# - "https://scalar.vector.im/api/neb/services/hooks/dHJhdmlzLWNpLyU0MEhhbGYtU2hvdCUzQWhhbGYtc2hvdC51ay8lMjFxUE5PblVzTnNaclRvRlpxeEIlM0FoYWxmLXNob3QudWs"
# on_success: change # always|never|change
# on_failure: always
# on_start: never
3.1.1 (2022-11-10)
==================
Bugfixes
--------
- Fix a crash caused by processing metrics for Matrix events. ([\#869](https://github.com/matrix-org/matrix-appservice-discord/issues/869))
3.1.0 (2022-11-03)
==================
Features
--------
- Adds a config value, in order to disable forwarding room topic changes from Matrix to Discord (`disableRoomTopicNotifications`, false by default). ([\#836](https://github.com/matrix-org/matrix-appservice-discord/issues/836))
Bugfixes
--------
- Include the domain name in the regular expression. ([\#834](https://github.com/matrix-org/matrix-appservice-discord/issues/834))
- Remove usage of unreliable field `age` on events, allowing the bridge to work with non-Synapse homeserver implementations. ([\#842](https://github.com/matrix-org/matrix-appservice-discord/issues/842))
- Prevent crashes when handling messages sent to voice channels. ([\#858](https://github.com/matrix-org/matrix-appservice-discord/issues/858))
3.0.0 (2022-08-12)
==================
Bugfixes
--------
- Make sure we don't lose errors thrown when checking usage limits. ([\#823](https://github.com/matrix-org/matrix-appservice-discord/issues/823))
- Fix Docker instances not starting due to being unable to load a dynamic library in the latest unstable image. ([\#828](https://github.com/matrix-org/matrix-appservice-discord/issues/828))
- Remove matrix.to hyperlinks when relaying non-Discord user mentions to Discord.
Fix mentioning Matrix users in Discord. ([\#829](https://github.com/matrix-org/matrix-appservice-discord/issues/829))
Deprecations and Removals
-------------------------
- Minimum required Node.js version is now 16. ([\#825](https://github.com/matrix-org/matrix-appservice-discord/issues/825))
Internal Changes
----------------
- Remove unused variables. ([\#657](https://github.com/matrix-org/matrix-appservice-discord/issues/657))
- Add workflow for building docker images, and push new docker images to ghcr.io. ([\#826](https://github.com/matrix-org/matrix-appservice-discord/issues/826))
- Remove `git config` workaround to pull a dependency from github.com. ([\#830](https://github.com/matrix-org/matrix-appservice-discord/issues/830))
2.0.0 (2022-08-05)
==================
Improved Documentation
----------------------
- Update `CONTRIBUTING.md` guide to reference the newly-updated guide for all of the matrix.org bridge repos. ([\#794](https://github.com/matrix-org/matrix-appservice-discord/issues/794))
Deprecations and Removals
-------------------------
- Node.JS 12 is now unsupported, please upgrade to Node.JS 14 or later. Node.JS 16 becomes the new default version. ([\#811](https://github.com/matrix-org/matrix-appservice-discord/issues/811))
Internal Changes
----------------
- Add automatic changelog generation via [Towncrier](https://github.com/twisted/towncrier). ([\#787](https://github.com/matrix-org/matrix-appservice-discord/issues/787))
- Use `yarn` instead of `npm` for package management and scripts. ([\#796](https://github.com/matrix-org/matrix-appservice-discord/issues/796))
- Add new CI workflow to check for signoffs. ([\#818](https://github.com/matrix-org/matrix-appservice-discord/issues/818))
Hello! It's awesome that you want to contribute to the Discord bridge, by doing
so you are helping our users and the wider Matrix ecosystem. This document
lists the requirements for your work to be accepted into our repository.
Hi there! Please read the [CONTRIBUTING.md](https://github.com/matrix-org/matrix-appservice-bridge/blob/develop/CONTRIBUTING.md) guide for all matrix.org bridge
projects.
For clarity reasons, work can either be a pull request or an issue. We find
both quite valuable to the project. Please note that your work must abide by
the Apache 2 license found in the LICENSE file.
## matrix-appservice-discord Guidelines
Most importantly we are a welcoming project and will be happy to review any
works, no matter the skill level of the submitter. Everyone must start
somewhere!
## TL;DR
* Always work off the **develop** branch. We won't accept merges into any other branches.
* We follow the [Matrix Code of Conduct](https://matrix.org/docs/guides/code_of_conduct.html) and will not accept or entertain works from individuals who break it. We believe in considerate and respectful members above accepting works, regardless of quality.
* This includes possible bans from any room(s) involved with the project.
* We are limited to accepting work over Github. Please use its interface when submitting work items.
* Discussion of ideas for the bridge and work items should be in [#discord:half-shot.uk](https://matrix.to/#/#discord:half-shot.uk).
* Everything submitted as a PR should have at least one test, the only exception being non-code items.
......@@ -36,53 +22,17 @@ inside the `MatrixEventProcessor` class.
## Setting up
* You will need to [setup the bridge](https://github.com/Half-Shot/matrix-appservice-discord/tree/develop#setup-the-bridge) similarly to how we describe,
but you should setup a homeserver locally on your development machine. We would recommend [Synapse](https://github.com/matrix-org/synapse#id11).
## Writing an issue
When writing an issue, please be as verbose as you can. Remember the issue is
there to either document a feature request, or report a bug so it can be fixed.
The issue board is NOT there to complain about a broken or missing feature.
We leave it to the author's discretion to decide what to include rather than
provide a template, but good items are:
* Shorter titles are better than long rambling ones, but please don't make it too vague.
* A good example is "Ability to bridge an existing matrix room into a discord channel"
* A brief description of the problem.
* If you are a user of another person's bridge, please can you let us know the name of the service provider.
* If you would like to keep the details private, please PM @Half-Shot:half-shot.uk or @sorunome:sorunome.de discreetly.
* Relevant logging from Synapse/your homeserver AND the bridge (if applicable).
* The more verbose, the better but please don't include sensitive details like access tokens.
* A screenshot is always useful.
* Please mention which direction a failure is in, e.g. Matrix -> Discord, if applicable.
We will assign each issue a tag, which will allow us to categorise the problems.
While we realise some issues are more important than others, please do not "demand"
for an issue to be fixed. Issues will be worked on in the timeframe that best fits
the needs of the team.
## PR Process
We've tried our best to keep the PR process relatively simple:
* Create a new branch based off the `develop` branch.
* This can be done with `git checkout develop` followed by `git checkout -b featurename`.
* Create a PR on Github, making sure to give a brief discription of your changes and link to the issue it fixes, if any.
* If your change is not complete but you would like feedback, create it as a draft.
* Ensure the linter and tests are not failing, as we will not accept code that breaks either.
* If your tests fail and are having trouble fixing them, you may push your changes and we will help you fix them.
* Github automatically pokes TravisCI to run both linting and tests.
* Someone from the team will review your work and decide what to do with the PR.
* Usually we will have feedback for the PR and will submit more comments.
* We may decide to reject it, if a feature does not fit with the project goals.
but you should setup a homeserver locally on your development machine. We would recommend [Synapse](https://github.com/matrix-org/synapse).
* The bridge uses `yarn` for dependency management and package scripts instead of `npm`.
For details, view the full setup instructions in the [README](README.md#set-up-the-bridge).
## Testing
Testing the bridge is easy enough, you just need to run `npm run build`,
`npm run lint` and `npm run test`. If all pass without errors, congratulations!
CI will lint and test your code automatically,
but you can save yourself some time by checking locally before submitting code.
Refer to the main matrix.org bridge contributing guide for instructions on how to
[lint](https://github.com/matrix-org/matrix-appservice-bridge/blob/develop/CONTRIBUTING.md#%EF%B8%8F-code-style) and
[test](https://github.com/matrix-org/matrix-appservice-bridge/blob/develop/CONTRIBUTING.md#-tests--ci).
Please bear in mind that you will need to cover the whole, or a reasonable
degree of your code. You can check to see if you have with `npm run
coverage`.
degree of your code. You can check to see if you have with `yarn coverage`.
FROM node:14-alpine AS BUILD
FROM node:16-slim AS BUILD
COPY . /tmp/src
# install some dependencies needed for the build process
RUN apk add --no-cache -t build-deps make gcc g++ python ca-certificates libc-dev wget git
RUN apt update && apt install -y build-essential make gcc g++ python3 ca-certificates libc-dev wget git
RUN cd /tmp/src \
&& npm install \
&& npm run build
&& yarn
FROM node:14-alpine
FROM node:16-slim
ENV NODE_ENV=production
COPY --from=BUILD /tmp/src/build /build
COPY --from=BUILD /tmp/src/config /config
......
......@@ -27,12 +27,17 @@ Please also be aware that this is an unoffical project worked on in our spare ti
The bridge has been tested against the [Synapse](https://github.com/matrix-org/synapse) homeserver, although any homeserver
that implements the [AS API](https://matrix.org/docs/spec/application_service/r0.1.0.html) should work with this bridge.
The bridge supports any version of Node.js >= v12.X, including all [current releases](https://nodejs.org/en/about/releases/).
The bridge supports any version of Node.js between v14.X - v18.X. View the [releases](https://nodejs.org/en/about/releases/) for more details.
The bridge uses Yarn for dependency management and package scripts.
For the time being, **only Yarn Classic / v1 is supported.** To install it, follow [these instructions](https://classic.yarnpkg.com/en/docs/install).
If you already have Yarn 2+ installed, you may configure just this project to use Yarn Classic
by running ``yarn set version classic`` in the directory where you cloned this repository.
### Set up the bridge
* Run ``npm install`` to grab the dependencies. `npm` may complain about peer dependencies, but you can safely ignore these.
* Run ``npm run build`` to build the typescript into javascript.
* Run ``yarn`` to grab the dependencies.
* Copy ``config/config.sample.yaml`` to ``config.yaml`` and edit it to reflect your setup.
* Note that you are expected to set ``domain`` and ``homeserverURL`` to your **public** host name.
While localhost would work, it does not resolve correctly with Webhooks/Avatars.
......@@ -93,9 +98,9 @@ should show up in the network list on Element and other clients.
### Setting up Discord
* Create a new application via https://discordapp.com/developers/applications
* Create a new application via https://discord.com/developers/applications
* Make sure to create a bot user. Fill in ``config.yaml``
* Run ``npm run addbot`` to get a authorisation link.
* Run ``yarn addbot`` to get a authorisation link.
* Give this link to owners of the guilds you plan to bridge.
* Finally, you can join a room with ``#_discord_guildid_channelid``
* These can be taken from the url ("/$GUILDID/$CHANNELID") when you are in a channel.
......@@ -108,7 +113,7 @@ should show up in the network list on Element and other clients.
### Running the Bridge
* For the bot to appear online on Discord you need to run the bridge itself.
* ``npm start``
* ``yarn start``
* Particular configuration keys can be overridden by defining corresponding environment variables. For instance, `auth.botToken` can be set with `APPSERVICE_DISCORD_AUTH_BOT_TOKEN`.
[Howto](./docs/howto.md)
......
......@@ -36,8 +36,14 @@ bridge:
disableJoinLeaveNotifications: false
# Disable Invite echos from matrix
disableInviteNotifications: false
# Disable Room Topic echos from matrix
disableRoomTopicNotifications: false
# Auto-determine the language of code blocks (this can be CPU-intensive)
determineCodeLanguage: false
# MXID of an admin user that will be PMd if the bridge experiences problems. Optional
adminMxid: '@admin:localhost'
# The message to send to the bridge admin if the Discord token is not valid
invalidTokenMessage: 'Your Discord bot token seems to be invalid, and the bridge cannot function. Please update it in your bridge settings and restart the bridge'
# Authentication configuration for the discord bot.
auth:
# This MUST be a string (wrapped in quotes)
......@@ -111,6 +117,6 @@ ghosts:
usernamePattern: ":username#:tag"
# Prometheus-compatible metrics endpoint
metrics:
enabled: false
enable: false
port: 9001
host: "127.0.0.1"
......@@ -30,6 +30,18 @@ properties:
type: "boolean"
disableInviteNotifications:
type: "boolean"
disableRoomTopicNotifications:
type: "boolean"
userActivity:
type: "object"
required: ["minUserActiveDays", "inactiveAfterDays"]
properties:
minUserActiveDays:
type: "number"
inactiveAfterDays:
type: "number"
userLimit:
type: "number"
auth:
type: "object"
required: ["botToken", "clientID"]
......@@ -131,7 +143,7 @@ properties:
metrics:
type: "object"
properties:
enabled:
enable:
type: "boolean"
port:
type: "number"
......
......@@ -15,8 +15,8 @@ is formatted as https://discord.com/channels/``guildid``/``channelid``
* The ``adminme`` script is provided to set Admin/Moderator or any other custom power level to a specific user.
* e.g. To set Alice to Admin on her ``example.com`` HS on default config. (``config.yaml``)
* ``npm run adminme -- -r '!AbcdefghijklmnopqR:example.com' -u '@Alice:example.com' -p '100'``
* Run ``npm run adminme -- -h`` for usage.
* ``yarn adminme -r '!AbcdefghijklmnopqR:example.com' -u '@Alice:example.com' -p '100'``
* Run ``yarn adminme -h`` for usage.
Please note that `!AbcdefghijklmnopqR:example.com` is the internal room id and will always begin with `!`.
You can find this internal id in the room settings in Element.
......
......@@ -39,5 +39,5 @@ You should be able to puppet with 2FA enabled on your account
* Follow https://discordhelp.net/discord-token to find your discord token.
* Stop the bridge, if it is running.
* Run `npm run usertool -- --add` and follow the instructions.
* Run `yarn usertool --add` and follow the instructions.
* If all is well, you can start the bridge.
{
"name": "matrix-appservice-discord",
"version": "1.0.0",
"version": "3.1.1",
"description": "A bridge between Matrix and Discord",
"main": "discordas.js",
"engines": {
"npm": "please-use-yarn",
"node": ">=16 <=18"
},
"scripts": {
"test": "mocha -r ts-node/register test/config.ts test/test_*.ts test/**/test_*.ts",
"lint": "eslint -c .eslintrc --max-warnings 200 src/**/*.ts test/**/*.ts",
"coverage": "tsc && nyc mocha build/test/config.js build/test",
"build": "tsc",
"postinstall": "npm run build",
"start": "npm run-script build && node ./build/src/discordas.js -c config.yaml",
"debug": "npm run-script build && node --inspect ./build/src/discordas.js -c config.yaml",
"postinstall": "yarn build",
"start": "yarn build && node ./build/src/discordas.js -c config.yaml",
"debug": "yarn build && node --inspect ./build/src/discordas.js -c config.yaml",
"addbot": "node ./build/tools/addbot.js",
"adminme": "node ./build/tools/adminme.js",
"usertool": "node ./build/tools/userClientTools.js",
......@@ -36,7 +40,8 @@
},
"homepage": "https://github.com/Half-Shot/matrix-appservice-discord#readme",
"dependencies": {
"better-discord.js": "git://github.com/Sorunome/better-discord.js.git#b5a28499899fe2d9e6aa1aa3b3c5d693ae672117",
"@deurstann/matrix-discord-parser": "1.10.7",
"better-discord.js": "github:matrix-org/better-discord.js#5024781db755259e88abe915630b7d5b3ba5f48f",
"better-sqlite3": "^7.1.0",
"command-line-args": "^5.1.1",
"command-line-usage": "^6.1.0",
......@@ -44,10 +49,8 @@
"escape-string-regexp": "^4.0.0",
"js-yaml": "^3.14.0",
"marked": "^1.2.2",
"matrix-bot-sdk": "0.5.4",
"matrix-discord-parser": "0.1.5",
"matrix-appservice-bridge": "^5.0.0",
"mime": "^2.4.6",
"node-html-parser": "^1.2.19",
"p-queue": "^6.4.0",
"pg-promise": "^10.5.6",
"prom-client": "^12.0.0",
......@@ -57,8 +60,6 @@
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@typescript-eslint/eslint-plugin": "^2.14.0",
"@typescript-eslint/parser": "^2.14.0",
"@types/better-sqlite3": "^5.4.1",
"@types/chai": "^4.2.11",
"@types/command-line-args": "^5.0.0",
......@@ -67,15 +68,17 @@
"@types/marked": "^1.1.0",
"@types/mime": "^2.0.2",
"@types/mocha": "^7.0.2",
"@types/node": "^12",
"@types/node": "^14",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"chai": "^4.2.0",
"eslint": "^7.4.0",
"mocha": "^8.0.1",
"nyc": "^15.1.0",
"proxyquire": "^1.7.11",
"source-map-support": "^0.5.19",
"ts-node": "^8.10.2",
"typescript": "^3.9.5",
"why-is-node-running": "^2.2.0",
"eslint": "^7.4.0"
"typescript": "^4.2.3",
"why-is-node-running": "^2.2.0"
}
}