Buckets:
| """Suggest a public table "in the middle" between you and a match (PROTOCOL §7). | |
| After a match, run this to get public table-tennis tables roughly between the | |
| two of you, ranked fairest-first. The broker proxies an anonymized lookup to | |
| OpenStreetMap (the open data behind pingpongmap.net) around the midpoint of | |
| your two coarse cells — no exact coordinates ever leave your machine. Pick one | |
| and propose it with `message.py --kind propose --place "<name>"`. | |
| table_tennis only for now. | |
| python venue.py --offer-id <id> [--interest-id <id>] | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import client | |
| import geo | |
| def main() -> None: | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--offer-id", required=True) | |
| ap.add_argument("--interest-id", help="passed through into the proposal hint") | |
| ap.add_argument("--activity", help="override; defaults to the offer's activity") | |
| args = ap.parse_args() | |
| ident = client.Identity.load_or_create() | |
| profile = client.load_profile() | |
| home = profile.get("home") or {} | |
| if "lat" not in home or "lon" not in home: | |
| raise SystemExit("profile.yaml needs home.lat and home.lon") | |
| my_cell = geo.encode(float(home["lat"]), float(home["lon"]), 6) | |
| offer = client.get(f"/offers/{args.offer_id}") | |
| if not client.verify_offer(offer): | |
| raise SystemExit("Offer has no valid signature — aborting.") | |
| activity = args.activity or offer["activity"] | |
| if offer["agent_id"] == ident.agent_id: | |
| # I'm the owner — I don't know the interested party's cell, so search | |
| # near me. (A true midpoint needs both cells; the interested party's | |
| # agent, which has both, gets the better suggestion.) | |
| cell_a, cell_b, scope = my_cell, None, "near you" | |
| else: | |
| cell_a, cell_b, scope = my_cell, offer["geocell"], "between you two" | |
| res = client.venues(activity, cell_a, cell_b) or {} | |
| if not res.get("supported", True): | |
| print(res.get("note", f"No venue map for {activity}.")) | |
| return | |
| vs = res.get("venues") or [] | |
| if not vs: | |
| print(f"No public {client.activity_label(activity)} tables found {scope}.") | |
| if res.get("map_url"): | |
| print(f" Browse the area on the map: {res['map_url']}") | |
| if res.get("note"): | |
| print(f" ({res['note']})") | |
| return | |
| print(f"🏓 Public {client.activity_label(activity)} tables {scope} " | |
| f"(fairest first — pick one and propose it):") | |
| for v in vs: | |
| name = v.get("name") or "unnamed public table" | |
| dist = [] | |
| if v.get("dist_a_m") is not None: | |
| dist.append(f"~{v['dist_a_m']} m from you") | |
| if v.get("dist_b_m") is not None: | |
| dist.append(f"~{v['dist_b_m']} m from them") | |
| extra = [] | |
| if v.get("indoor") == "yes": | |
| extra.append("indoor") | |
| if v.get("access") in ("private", "customers", "no"): | |
| extra.append(f"access: {v['access']}") | |
| meta = " · ".join(dist + extra) | |
| print(f" • {name}" + (f" — {meta}" if meta else "")) | |
| print(f" {v['map_url']}") | |
| iid = f" --interest-id {args.interest_id}" if args.interest_id else "" | |
| print(f"\nPropose one → message.py --offer-id {args.offer_id}{iid} " | |
| f"--kind propose --place \"<name>\" --time \"HH:MM\" --when <ISO timestamp>") | |
| if res.get("map_url"): | |
| print(f"Whole area on the map: {res['map_url']}") | |
| if __name__ == "__main__": | |
| main() | |
Xet Storage Details
- Size:
- 3.48 kB
- Xet hash:
- ded380b61b065e1db7e67d644d40d8a3484548957458494aae38d27763192735
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.