Skip to main content

Library for talking to a running Urbit ship

Project description

Urlock-py

Urlock-py is a python library for connecting to a running urbit ship.

It consists of a single class Urlock.

__init__(url, code) Constructor url - url to the http interface of the running ship code - the +code of the ship, should never be published

connect() Connect to the running ship

poke(ship, app, mark, j) ship - ship to send the poke app - gall application to send the poke to mark - mark of data sent to the gall application j - json poke data

ack(eventId) Send an acknowledgment of receipt of a message so it's cleared from the ship's queue eventId - id of the event to acknowledge

sse_pipe

subscribe

unsubsribe

delete

#!/usr/bin/python3

import urlock
import baseconvert
import time
import random
import dumper

zod = urlock.Urlock("http://localhost:8080", "lidlut-tabwed-pillex-ridrup")
r = zod.connect()
s = zod.subscribe("zod", "chat-store", "/mailbox/~/~zod/mc")

pipe = zod.sse_pipe()

s = baseconvert.base(random.getrandbits(128), 10, 32, string=True).lower()
uid = '0v' + '.'.join(s[i:i+5] for i in range(0, len(s), 5))[::-1]

p = zod.poke("zod", "chat-hook", "json", {"message": {"path": "/~/~zod/mc",
                                                      "envelope": {"uid": uid,
                                                                   "number": 1,
                                                                   "author": "~zod",
                                                                   "when": int(time.time() * 1000),
                                                                   "letter": {"text": "this shit is new"}}}})


for m in pipe.events():
   dumper.dump(m)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

urlock-0.1.21.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

urlock-0.1.21-py3-none-any.whl (3.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page