Skip to content

Instantly share code, notes, and snippets.

View Cadair's full-sized avatar

Stuart Mumford Cadair

View GitHub Profile

A Super Rapid Introduction to opsdroid with Matrix

To follow this guide you will need a matrix account for your bot.

You can register using any client such as Element, make note of your full matrix id username in the form "@name:server" and password, as well as the homeserver you register on if it isn't matrix.org. Also you will want to create an unencrypted room (easiest to make it public for the moment) and give it an address, make a note of this as well (and invite your personal matrix account). If you register with Element, make sure you logout, so that there are no encryption-supporting devices on your account.

Next, you will need a working python env, preferably a virtual env or similar, then install opsdroid:

import io
import json
import time
from struct import unpack
import requests
from matrix_client.api import MatrixHttpApi
import appdaemon.plugins.hass.hassapi as hass
import os.path as path
from tempfile import mkdtemp
import ndcube
import numpy as np
from astropy.wcs import WCS
from astropy.wcs.utils import _split_matrix, unbroadcast
from ndcube.utils.wcs_high_level_conversion import values_to_high_level_objects
from urllib.request import urlopen
import astropy.coordinates as coords
import astropy.units as u
import numpy as np
import plotly.io as pio
from astropy.time import Time
from poliastro.earth import EarthSatellite
from poliastro.earth.plotting import GroundtrackPlotter
from poliastro.twobody.propagation import propagate
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/env xonsh
"""
Take over a hangouts portal room once everyone in the room has a matrix account.
Usage:
hangouts_hijack.xsh --bridge-access-token <bridge_access_token> --user-access-token <user_access_token> --room_id [--user-map <map.json>]
This script assumes the owner of --user-access-token is in the room already. It