improved readme

This commit is contained in:
array-in-a-matrix 2024-01-12 15:24:40 -05:00
parent e58c282dfc
commit ee95dc2c78

View file

@ -4,16 +4,35 @@ Nim wrapper for the [Matrix bot SDK](https://github.com/turt2live/matrix-bot-sdk
## Setup
Run `pnpm add matrix-bot-sdk` after cloning template.
Make sure you have [Nim](https://nim-lang.org/install.html) and [Node.js](https://nodejs.org/) installed before starting your own project or to contribute.
## Usage
The library needs the [Matrix Bot SDK](https://github.com/turt2live/matrix-bot-sdk) JavaScript module:
To import the entire library, your Nim program only needs to import the `nimbotsdk.nim` from the root of the repository. To import a specific module you need to import `matrixTypes.nim` and the needed module(s) from `nimbotsdk/`.
There are code examples inside the `examples/` directory.
```sh
pnpm add matrix-bot-sdk
```
## Development
Nim files inside `nimbotsdk/` are named after the file they wrap (`MatrixAuth.nim` is a wrapper to `MatrixAuth.d.ts`). `matrixTypes.nim` defines the object types used throughout the entire library.
Procedures that have been tested to work are imported into `nimbotsdk.nim` in the root of the project.
Procedures that have been tested to work are imported into `nimbotsdk.nim` in the root of the project.
## Usage
To use the library in your Nim program, import `nimbotsdk.nim` from the root of the repository. To import a specific module without importing the whole library, you can import `matrixTypes.nim` and the needed module(s) from `nimbotsdk/`.
There are code examples inside the `examples/` directory.
Make sure the homeserver URL and token (or username and password) are valid then you can compile and run code:
```sh
nim js -r printToken.nim
```
You can compile and run code this way too. You can inspect the produced JavaScript this way:
```sh
nim js printToken.nim
node printToken.js
```