generated from array-in-a-matrix/matrix-bot-template
Compare commits
5 commits
a0aada111e
...
40800c8f61
Author | SHA1 | Date | |
---|---|---|---|
40800c8f61 | |||
7619024098 | |||
c71a8203bb | |||
e87652c055 | |||
1635454988 |
|
@ -26,8 +26,9 @@ cd nimbotsdk/src/ && pnpm install
|
|||
|
||||
### Tests
|
||||
|
||||
Procedures that have been tested to work are imported into `src/nimbotsdk.nim`.
|
||||
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:
|
||||
|
||||
```sh
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
# Things here have been tested to work
|
||||
|
||||
import nimbotsdk/matrixTypes
|
||||
export ICryptoStorageProvider, Storage, CryptoStore, Client, Content,
|
||||
Unsigned, Event, Filter, Appservice
|
||||
export ICryptoStorageProvider, Storage, Client, Content, Unsigned, Event, Filter, Appservice
|
||||
|
||||
import nimbotsdk/MatrixAuth
|
||||
export newMatrixAuth, passwordLogin
|
||||
|
@ -24,3 +23,6 @@ export newSimpleFsStorageProvider
|
|||
|
||||
import nimbotsdk/RichRepliesPreprocessor
|
||||
export newRichRepliesPreprocessor
|
||||
|
||||
import nimbotsdk/RustSdkCryptoStorageProvider
|
||||
export RustSdkCryptoStorageProvider
|
|
@ -1,9 +1,10 @@
|
|||
{.emit:"import { MatrixClient } from 'matrix-bot-sdk';".}
|
||||
|
||||
import matrixTypes
|
||||
|
||||
proc newMatrixClient*(homeserver, token: cstring): Client {.importjs: "new MatrixClient(#, #)".}
|
||||
proc newMatrixClient*(homeserver, token: cstring, storage: Storage): Client {.importjs: "new MatrixClient(#, #, #)".}
|
||||
proc newMatrixClient*(homeserver, token: cstring, storage: Storage, cryptoStore: CryptoStore): Client {.importjs: "new MatrixClient(#, #, #, #)".}
|
||||
proc newMatrixClient*(homeserver, token: cstring, storage: Storage, cryptoStore: ICryptoStorageProvider): Client {.importjs: "new MatrixClient(#, #, #, #)".}
|
||||
|
||||
proc onRoomMessage*(client: Client, callback: proc(roomId: cstring, event: Event)) {.importjs: "#.on('room.message', #)".}
|
||||
|
||||
|
@ -12,6 +13,13 @@ proc onRoomTopic*(client: Client, callback: proc(roomId: cstring, event: Event))
|
|||
proc onRoomEvent*(client: Client, callback: proc(roomId: cstring, event: Event)) {.importjs: "#.on('room.event', #)".}
|
||||
|
||||
proc onRoomJoin*(client: Client, callback: proc(roomId: cstring, event: Event)) {.importjs: "#.on('room.join', #)".}
|
||||
|
||||
proc onRoomLeave*(client: Client, callback: proc(roomId: cstring, event: Event)) {.importjs: "#.on('room.leave', #)".}
|
||||
|
||||
proc onAccountData*(client: Client, callback: proc(event: Event)) {.importjs: "#.on('account_data', #)".}
|
||||
|
||||
proc onRoomAccountData*(client: Client, callback: proc(roomId: cstring, event: Event)) {.importjs: "#.on('onRoomAccountData', #)".}
|
||||
|
||||
# TODO: add more for each event type
|
||||
|
||||
proc impersonateUserId*(client: Client, userId: cstring = nil): void {.importjs: "#.impersonateUserId(#)".}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{.emit:"import { RichRepliesPreprocessor } from 'matrix-bot-sdk';".}
|
||||
|
||||
import matrixTypes
|
||||
|
||||
proc newRichRepliesPreprocessor*(): IPreprocessor {.importjs: "new RichRepliesPreprocessor()".}
|
||||
|
|
6
src/nimbotsdk/RustSdkCryptoStorageProvider.nim
Normal file
6
src/nimbotsdk/RustSdkCryptoStorageProvider.nim
Normal file
|
@ -0,0 +1,6 @@
|
|||
{.emit:"import { RustSdkCryptoStorageProvider } from 'matrix-bot-sdk';".}
|
||||
|
||||
import matrixTypes
|
||||
|
||||
proc newRustSdkCryptoStorageProvider*(storagePath: cstring): ICryptoStorageProvider {.importjs: "new RustSdkCryptoStorageProvider(#)"}
|
||||
proc newRustSdkCryptoStorageProvider*(storagePath: cstring, storageType: cstring): ICryptoStorageProvider {.importjs: "new RustSdkCryptoStorageProvider(#, #)"}
|
|
@ -2,8 +2,6 @@ type ICryptoStorageProvider* = ref object
|
|||
|
||||
type Storage* = ref object
|
||||
|
||||
type CryptoStore* = ref object
|
||||
|
||||
type Client* = ref object
|
||||
homeserverUrl*: cstring
|
||||
accessToken*: cstring
|
||||
|
|
Loading…
Reference in a new issue