matrix-wishlist icon indicating copy to clipboard operation
matrix-wishlist copied to clipboard

Matrix to Matrix bridge (room)

Open turt2live opened this issue 7 years ago • 5 comments

turt2live avatar Aug 04 '17 03:08 turt2live

https://github.com/non-Jedi/matrix_relay probably will fit this description when I finally get around to working on it again.

non-Jedi avatar Aug 04 '17 11:08 non-Jedi

Closing this for https://github.com/non-Jedi/matrix_relay :)

turt2live avatar Aug 14 '17 15:08 turt2live

That project never actually got to a workable state, and I've moved on to other things since then. @turt2live I recommend reopening this one.

non-Jedi avatar Jul 05 '18 14:07 non-Jedi

https://github.com/matrix-org/matrix-doc/pull/2923

JuniorJPDJ avatar Jan 18 '21 02:01 JuniorJPDJ

I just wrote a small python snippets checking via cron if a secondary user was invited, joins and invites the primary user. I use it to combine several work accounts to my major account. Maybe it will help s.o.

#!/usr/bin/python3
"""adds a main (primary) user to a group where the seconday user was invited to"""

import requests


# of secondary user
homeserver_url = 'https://matrix.org'          # change

# of secondary user
matrix_token = "MDabcdefghijklmnopqrstuvwA..." # change

# primary user
user_to_join = "@user:matrix.org"              # change


def send_matrix_sync() :
    headers = {"Authorization": f"Bearer {matrix_token}"} 
    response = requests.get(
        f"{homeserver_url}/_matrix/client/r0/sync",
        headers=headers)
    response = response.json()
    new_rooms = response["rooms"]['invite']
    if len(new_rooms):
        for room_id, val in new_rooms.items():
            response = requests.post(
                f"{homeserver_url}/_matrix/client/r0/rooms/{room_id}/join",
                headers=headers)
            joined_rooms = []
            while room_id not in joined_rooms:
                response = requests.get(
                    f"{homeserver_url}/_matrix/client/r0/joined_rooms",
                    headers=headers)
                joined_rooms = response.json()
                joined_rooms = joined_rooms['joined_rooms']

            response = requests.post(
                f"{homeserver_url}/_matrix/client/r0/rooms/{room_id}/invite",
                headers=headers, json={"user_id": user_to_join})


if __name__ == "__main__":

    send_matrix_sync()

a22sc avatar May 04 '21 14:05 a22sc