.vscode | ||
examples | ||
src | ||
tests | ||
.gitignore | ||
LICENSE | ||
nimbotsdk.nimble | ||
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:
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
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.