Nim wrapper for the Matrix bot SDK.
Go to file
array-in-a-matrix 2306cdf55d fix typo 2024-03-26 13:42:03 -04:00
.vscode vscode recommended extensions for workplace 2023-12-09 18:31:52 -05:00
examples fix typo 2024-03-26 13:42:03 -04:00
src file structure changes 2024-03-26 13:41:44 -04:00
tests relative syslinks 2024-02-06 12:52:30 -05:00
.gitignore example using crypto 2024-02-15 12:09:10 -05:00
LICENSE Initial commit 2023-12-03 17:41:40 -05:00
README.md Update README.md 2024-02-15 13:16:12 -05:00
nimbotsdk.nimble Update nimbotsdk.nimble 2024-01-15 00:12:25 -05:00

README.md

Nim Bot SDK

Nim wrapper for the Matrix bot SDK.

This library aims to take TypeScript functions, classes and whatever else that is needed from the Matrix bot SDK and expose them to Nim code with a JavaScript target.

Development

Nim files inside src/nimbotsdk/ are named after the original TypeScript file they wrap (MatrixAuth.nim warps MatrixAuth.d.ts). matrixTypes.nim defines the object types used throughout the entire library.

Development Setup

To start developing, make sure you have the needed dependencies installed:

  • Nim
  • Nimble (comes with Nim compiler) (For tests)
  • Node.js (For tests)
  • pnpm

Clone the repository and download the SDK:

git clone https://git.inamatrix.xyz/array-in-a-matrix/nimbotsdk
cd nimbotsdk/src/ && pnpm install

Tests

Procedures that have been checked to work are imported into src/nimbotsdk.nim.

Copy credentials.nim.example to credentials.nim and add the needed values before running tests. Run tests:

nimble test

Usage

Project Setup

You will need the following installed:

  • Nim
  • Nimble (comes with Nim compiler)
  • Node.js (Not needed if you plan on running the code in the browser, this has not been tested yet.)
  • JavaScript package manager (pnpm, yarn, npm, etc.)

You can install this library using nimble:

nimble install https://git.inamatrix.xyz/array-in-a-matrix/nimbotsdk

Now you will be able to import and use it in your Nim code:

# imports everything
import nimbotsdk

# imports only select modules (recommemded, smaller output)
import nimbotsdk/[matrixTypes, MatrixClient]

You can compile your Nim code without downloading the NPM module but it will not work. To deal with this, download the Matrix bot SDK if you haven't already:

# If using pnpm
pnpm add matrix-bot-sdk

#If using yarn
yarn add matrix-bot-sdk

#If using npm
npm install matrix-bot-sdk

Now you can run your compiled Nim code or compile and run directly:

nim js printToken.nim && node printToken.js

nim js -r printToken.nim

There are code examples inside the examples/ directory.