Merge pull request #141189 from piegamesde/update-appservice-irc
matrix-appservice-irc 0.26.1 -> 0.30.0
This commit is contained in:
commit
ea58baa275
|
@ -25,7 +25,7 @@ import ./make-test-python.nix ({ pkgs, ... }:
|
|||
"bind_address" = "";
|
||||
"port" = 8448;
|
||||
"resources" = [
|
||||
{ "compress" = true; "names" = [ "client" "webclient" ]; }
|
||||
{ "compress" = true; "names" = [ "client" ]; }
|
||||
{ "compress" = false; "names" = [ "federation" ]; }
|
||||
];
|
||||
"tls" = false;
|
||||
|
@ -85,52 +85,108 @@ import ./make-test-python.nix ({ pkgs, ... }:
|
|||
client = { pkgs, ... }: {
|
||||
environment.systemPackages = [
|
||||
(pkgs.writers.writePython3Bin "do_test"
|
||||
{ libraries = [ pkgs.python3Packages.matrix-client ]; } ''
|
||||
import socket
|
||||
from matrix_client.client import MatrixClient
|
||||
from time import sleep
|
||||
{
|
||||
libraries = [ pkgs.python3Packages.matrix-nio ];
|
||||
flakeIgnore = [
|
||||
# We don't live in the dark ages anymore.
|
||||
# Languages like Python that are whitespace heavy will overrun
|
||||
# 79 characters..
|
||||
"E501"
|
||||
];
|
||||
} ''
|
||||
import sys
|
||||
import socket
|
||||
import functools
|
||||
from time import sleep
|
||||
import asyncio
|
||||
|
||||
matrix = MatrixClient("${homeserverUrl}")
|
||||
matrix.register_with_password(username="alice", password="foobar")
|
||||
|
||||
irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
irc.connect(("ircd", 6667))
|
||||
irc.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||
irc.send(b"USER bob bob bob :bob\n")
|
||||
irc.send(b"NICK bob\n")
|
||||
|
||||
m_room = matrix.join_room("#irc_#test:homeserver")
|
||||
irc.send(b"JOIN #test\n")
|
||||
|
||||
# plenty of time for the joins to happen
|
||||
sleep(10)
|
||||
|
||||
m_room.send_text("hi from matrix")
|
||||
irc.send(b"PRIVMSG #test :hi from irc \r\n")
|
||||
|
||||
print("Waiting for irc message...")
|
||||
while True:
|
||||
buf = irc.recv(10000)
|
||||
if b"hi from matrix" in buf:
|
||||
break
|
||||
|
||||
print("Waiting for matrix message...")
|
||||
from nio import AsyncClient, RoomMessageText, JoinResponse
|
||||
|
||||
|
||||
def callback(room, e):
|
||||
if "hi from irc" in e['content']['body']:
|
||||
exit(0)
|
||||
async def matrix_room_message_text_callback(matrix: AsyncClient, msg: str, _r, e):
|
||||
print("Received matrix text message: ", e)
|
||||
if msg in e.body:
|
||||
print("Received hi from IRC")
|
||||
await matrix.close()
|
||||
exit(0) # Actual exit point
|
||||
|
||||
|
||||
m_room.add_listener(callback, "m.room.message")
|
||||
matrix.listen_forever()
|
||||
''
|
||||
class IRC:
|
||||
def __init__(self):
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.connect(("ircd", 6667))
|
||||
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||
sock.send(b"USER bob bob bob :bob\n")
|
||||
sock.send(b"NICK bob\n")
|
||||
self.sock = sock
|
||||
|
||||
def join(self, room: str):
|
||||
self.sock.send(f"JOIN {room}\n".encode())
|
||||
|
||||
def privmsg(self, room: str, msg: str):
|
||||
self.sock.send(f"PRIVMSG {room} :{msg}\n".encode())
|
||||
|
||||
def expect_msg(self, body: str):
|
||||
buffer = ""
|
||||
while True:
|
||||
buf = self.sock.recv(1024).decode()
|
||||
buffer += buf
|
||||
if body in buffer:
|
||||
return
|
||||
|
||||
|
||||
async def run(homeserver: str):
|
||||
irc = IRC()
|
||||
|
||||
matrix = AsyncClient(homeserver)
|
||||
response = await matrix.register("alice", "foobar")
|
||||
print("Matrix register response: ", response)
|
||||
|
||||
response = await matrix.join("#irc_#test:homeserver")
|
||||
print("Matrix join room response:", response)
|
||||
assert isinstance(response, JoinResponse)
|
||||
room_id = response.room_id
|
||||
|
||||
irc.join("#test")
|
||||
# FIXME: what are we waiting on here? Matrix? IRC? Both?
|
||||
# 10s seem bad for busy hydra machines.
|
||||
sleep(10)
|
||||
|
||||
# Exchange messages
|
||||
print("Sending text message to matrix room")
|
||||
response = await matrix.room_send(
|
||||
room_id=room_id,
|
||||
message_type="m.room.message",
|
||||
content={"msgtype": "m.text", "body": "hi from matrix"},
|
||||
)
|
||||
print("Matrix room send response: ", response)
|
||||
irc.privmsg("#test", "hi from irc")
|
||||
|
||||
print("Waiting for the matrix message to appear on the IRC side...")
|
||||
irc.expect_msg("hi from matrix")
|
||||
|
||||
callback = functools.partial(
|
||||
matrix_room_message_text_callback, matrix, "hi from irc"
|
||||
)
|
||||
matrix.add_event_callback(callback, RoomMessageText)
|
||||
|
||||
print("Waiting for matrix message...")
|
||||
await matrix.sync_forever()
|
||||
|
||||
exit(1) # Unreachable
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(run(sys.argv[1]))
|
||||
''
|
||||
)
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
import pathlib
|
||||
|
||||
start_all()
|
||||
|
||||
ircd.wait_for_unit("ngircd.service")
|
||||
|
@ -156,7 +212,6 @@ import ./make-test-python.nix ({ pkgs, ... }:
|
|||
homeserver.wait_for_open_port(8448)
|
||||
|
||||
with subtest("ensure messages can be exchanged"):
|
||||
client.succeed("do_test")
|
||||
client.succeed("do_test ${homeserverUrl} >&2")
|
||||
'';
|
||||
|
||||
})
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
0.30.0
|
|
@ -1,16 +1,22 @@
|
|||
{ pkgs, nodePackages, makeWrapper, nixosTests, nodejs, stdenv, lib, ... }:
|
||||
{ pkgs, nodePackages, makeWrapper, nixosTests, nodejs, stdenv, lib, fetchFromGitHub }:
|
||||
|
||||
let
|
||||
|
||||
packageName = with lib; concatStrings (map (entry: (concatStrings (mapAttrsToList (key: value: "${key}-${value}") entry))) (importJSON ./package.json));
|
||||
|
||||
ourNodePackages = import ./node-composition.nix {
|
||||
inherit pkgs nodejs;
|
||||
inherit (stdenv.hostPlatform) system;
|
||||
};
|
||||
version = builtins.replaceStrings [ "\n" ] [ "" ] (builtins.readFile ./REVISION);
|
||||
in
|
||||
ourNodePackages."${packageName}".override {
|
||||
ourNodePackages.package.override {
|
||||
pname = "matrix-appservice-irc";
|
||||
inherit version;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "matrix-org";
|
||||
repo = "matrix-appservice-irc";
|
||||
rev = version;
|
||||
sha256 = "sha256-EncodJKptrLC54B5XipkiHXFgJ5cD+crcT3SOPOc+7M=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ makeWrapper nodePackages.node-gyp-build ];
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
ROOT="$(realpath "$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")"/../../../..)"
|
||||
|
||||
$(nix-build $ROOT -A nodePackages.node2nix --no-out-link)/bin/node2nix \
|
||||
--nodejs-12 \
|
||||
--nodejs-14 \
|
||||
--node-env ../../../development/node-packages/node-env.nix \
|
||||
--development \
|
||||
--input package.json \
|
||||
--lock ./package-lock-temp.json \
|
||||
--output node-packages.nix \
|
||||
--composition node-composition.nix
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
{pkgs ? import <nixpkgs> {
|
||||
inherit system;
|
||||
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-12_x"}:
|
||||
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-14_x"}:
|
||||
|
||||
let
|
||||
nodeEnv = import ../../../development/node-packages/node-env.nix {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,3 +1,69 @@
|
|||
[
|
||||
{"matrix-appservice-irc": "git+https://github.com/matrix-org/matrix-appservice-irc.git#0.26.1" }
|
||||
]
|
||||
{
|
||||
"name": "matrix-appservice-irc",
|
||||
"version": "0.30.0",
|
||||
"description": "An IRC Bridge for Matrix",
|
||||
"main": "app.js",
|
||||
"bin": "./bin/matrix-appservice-irc",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "npm run build",
|
||||
"build": "tsc --project ./tsconfig.json",
|
||||
"test": "BLUEBIRD_DEBUG=1 jasmine --stop-on-failure=true",
|
||||
"lint": "eslint -c .eslintrc --max-warnings 0 'spec/**/*.js' 'src/**/*.ts'",
|
||||
"check": "npm test && npm run lint",
|
||||
"ci-test": "nyc --report text jasmine",
|
||||
"ci": "npm run lint && npm run ci-test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/matrix-org/matrix-appservice-irc.git"
|
||||
},
|
||||
"author": "",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/matrix-org/matrix-appservice-irc/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sentry/node": "^5.27.1",
|
||||
"bluebird": "^3.7.2",
|
||||
"escape-string-regexp": "^4.0.0",
|
||||
"extend": "^3.0.2",
|
||||
"he": "^1.2.0",
|
||||
"logform": "^2.2.0",
|
||||
"matrix-appservice": "^0.8.0",
|
||||
"matrix-appservice-bridge": "^2.6.1",
|
||||
"matrix-lastactive": "^0.1.5",
|
||||
"matrix-org-irc": "^1.2.0",
|
||||
"nedb": "^1.1.2",
|
||||
"nodemon": "^2.0.7",
|
||||
"nopt": "^3.0.1",
|
||||
"p-queue": "^6.6.2",
|
||||
"pg": "^8.6.0",
|
||||
"quick-lru": "^4.0.1",
|
||||
"request": "^2.54.0",
|
||||
"request-promise-native": "^1.0.9",
|
||||
"sanitize-html": "^2.4.0",
|
||||
"winston": "^3.3.3",
|
||||
"winston-daily-rotate-file": "^4.5.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bluebird": "^3.5.32",
|
||||
"@types/express": "^4.17.7",
|
||||
"@types/extend": "^3.0.1",
|
||||
"@types/he": "^1.1.1",
|
||||
"@types/nedb": "^1.8.11",
|
||||
"@types/nopt": "^3.0.29",
|
||||
"@types/pg": "^8.6.0",
|
||||
"@types/sanitize-html": "^2.3.1",
|
||||
"@typescript-eslint/eslint-plugin": "^4.16.1",
|
||||
"@typescript-eslint/parser": "^4.16.1",
|
||||
"eslint": "^7.21.0",
|
||||
"jasmine": "^3.6.2",
|
||||
"nyc": "^14.1.1",
|
||||
"prom-client": "^13.0.0",
|
||||
"proxyquire": "^1.4.0",
|
||||
"typescript": "^4.2.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash -p nodePackages.node2nix nodejs-12_x curl jq
|
||||
#! nix-shell -i bash -p nodePackages.node2nix nodejs-12_x curl jq nix
|
||||
|
||||
set -euo pipefail
|
||||
# cd to the folder containing this script
|
||||
|
@ -15,10 +15,15 @@ fi
|
|||
|
||||
echo "matrix-appservice-irc: $CURRENT_VERSION -> $TARGET_VERSION"
|
||||
|
||||
sed -i "s/#$CURRENT_VERSION/#$TARGET_VERSION/" package.json
|
||||
rm -f package.json package-lock.json
|
||||
wget https://github.com/matrix-org/matrix-appservice-irc/raw/$TARGET_VERSION/package.json
|
||||
wget -O package-lock-temp.json https://github.com/matrix-org/matrix-appservice-irc/raw/$TARGET_VERSION/package-lock.json
|
||||
echo "$TARGET_VERSION" > ./REVISION
|
||||
|
||||
./generate-dependencies.sh
|
||||
|
||||
rm ./package-lock-temp.json
|
||||
|
||||
# Apparently this is done by r-ryantm, so only uncomment for manual usage
|
||||
#git add ./package.json ./node-packages.nix
|
||||
#git commit -m "matrix-appservice-irc: ${CURRENT_VERSION} -> ${TARGET_VERSION}"
|
||||
|
|
Loading…
Reference in a new issue