amoorion.utilities

Small helpers around the methods: markdown posts, the tunnel.

amoorion.utilities.open_tunnel(port, vault, forward=None)[source]

Make a local port reachable from outside by ngrok, for hooks: the secret ngrok/token.

Anyone with the address reaches that port, so only the API, whose methods need their token and whose hooks verify themselves, belongs behind it. ngrok is not a dependency: pip install ngrok. Returns the listener (.url(), .close()).

Parameters:
  • port (int)

  • vault (Vault)

  • forward (Callable[[...], Any] | None)

Return type:

Any

amoorion.utilities.post_from_markdown(source, values=None)[source]

A Markdown text or file as a post, and the platforms its front matter names.

— title: Hello tags: [news] links: [https://example.org] to: [mastodon, bluesky] — The text of the post.

values fill the names of a template (a dollar and the name), after parsing: they can’t change the settings.

Parameters:
  • source (str | Path)

  • values (dict[str, str] | None)

Return type:

tuple[Post, list[str]]

amoorion.utilities.read_env(path)[source]

An env file as a dict; comments and quotes dealt with.

Parameters:

path (str | Path)

Return type:

dict[str, str | None]

amoorion.utilities.write_env(path, **values)[source]

Set values in an env file, made if missing; other lines and comments stay as they are.

Parameters:
  • path (str | Path)

  • values (str)

Return type:

Path

Modules

base

Small helpers that aren't methods: nothing here reaches a platform by itself.

llm

Asking a language model, through the API most of them speak: OpenAI's chat completions.