Skip to content
This repository has been archived by the owner on May 14, 2023. It is now read-only.

Matrix to Matrix bridge (room) #56

Open
turt2live opened this issue Aug 4, 2017 · 5 comments
Open

Matrix to Matrix bridge (room) #56

turt2live opened this issue Aug 4, 2017 · 5 comments

Comments

@turt2live
Copy link
Owner

No description provided.

@non-Jedi
Copy link

non-Jedi commented Aug 4, 2017

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

@turt2live
Copy link
Owner Author

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

@non-Jedi
Copy link

non-Jedi commented Jul 5, 2018

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.

@JuniorJPDJ
Copy link

@a22sc
Copy link

a22sc commented May 4, 2021

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()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants