{"id":13639948,"url":"https://github.com/baudtack/urlock-py","last_synced_at":"2025-04-20T02:32:17.816Z","repository":{"id":48525387,"uuid":"268663397","full_name":"baudtack/urlock-py","owner":"baudtack","description":null,"archived":false,"fork":false,"pushed_at":"2021-03-04T17:44:27.000Z","size":6,"stargazers_count":28,"open_issues_count":3,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-01T07:11:30.452Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/baudtack.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-02T00:30:57.000Z","updated_at":"2023-09-12T15:43:38.000Z","dependencies_parsed_at":"2022-09-19T11:21:24.398Z","dependency_job_id":null,"html_url":"https://github.com/baudtack/urlock-py","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baudtack%2Furlock-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baudtack%2Furlock-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baudtack%2Furlock-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baudtack%2Furlock-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baudtack","download_url":"https://codeload.github.com/baudtack/urlock-py/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223816298,"owners_count":17207833,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T01:01:06.412Z","updated_at":"2024-11-09T10:30:32.623Z","avatar_url":"https://github.com/baudtack.png","language":"Python","funding_links":[],"categories":["Developer Tools"],"sub_categories":["HTTP APIs"],"readme":"# Urlock-py\n\nUrlock-py is a python library for connecting to a running urbit ship.\n\nIt consists of a single class `Urlock`. Methods are below.\n\n`__init__(url, code)`\n\n    Constructor\n\n    `url` - url to the http interface of the running ship\n\n    `code` - the `+code` of the ship, should never be published\n\n\n`connect()`\n\n    Connect to the running ship\n\n\n`poke(ship, app, mark, j)`\n\n    `ship` - ship to send the poke\n\n    `app` - gall application to send the poke to\n\n    `mark` - mark of data sent to the gall application\n\n    `j` - json poke data\n\n\n`ack(eventId)`\n\n    Send an acknowledgment of receipt of a message so it's cleared from the ship's queue \n\n    `eventId` - id of the event to acknowledge\n\n\n`sse_pipe()`\n\n    returns the sseclient object\n\n\n`subscribe(ship, app, path)`\n\n    `ship` - ship on which the gall application lives\n\n    `app` - gall application to subscribe to\n\n    `path` - path to subscribe on\n\n\nFollows is a simple script to send a message and subscribe to a chat channel. The specifics require an understanding of the `chat-store` and `chat-hook` interfaces.\n\n```\n#!/usr/bin/python3\n\nimport urlock\nimport baseconvert\nimport time\nimport random\nimport dumper\n\nzod = urlock.Urlock(\"http://localhost:8080\", \"lidlut-tabwed-pillex-ridrup\")\nr = zod.connect()\ns = zod.subscribe(\"zod\", \"chat-store\", \"/mailbox/~/~zod/mc\")\n\npipe = zod.sse_pipe()\n\ns = baseconvert.base(random.getrandbits(128), 10, 32, string=True).lower()\nuid = '0v' + '.'.join(s[i:i+5] for i in range(0, len(s), 5))[::-1]\n\np = zod.poke(\"zod\", \"chat-hook\", \"json\", {\"message\": {\"path\": \"/~/~zod/mc\",\n                                                      \"envelope\": {\"uid\": uid,\n                                                                   \"number\": 1,\n                                                                   \"author\": \"~zod\",\n                                                                   \"when\": int(time.time() * 1000),\n                                                                   \"letter\": {\"text\": \"hello world!\"}}}})\n\n\nfor m in pipe.events():\n   dumper.dump(m)\n   dumper.dump(zod.ack(int(m.id)))\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaudtack%2Furlock-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaudtack%2Furlock-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaudtack%2Furlock-py/lists"}