Closed cmakasy closed 2 months ago
Hi, Your access token match an other deviceId. You need to log again and get a new accessToken. My advice on every new device you log your bot, use MatrixAuth and passwordlogin function.
Thanks a lot, I've tried it and it works. ;-)
For a project I have installed matrix-bot-sdk as well as typescript and I created some sample requests. For not encrypted rooms it works fine, but as soon as I have introduced RustSdkCryptoStorageProvider it fails.
Please see my implementation:
import { StoreType } from "@matrix-org/matrix-sdk-crypto-nodejs"; import { MatrixClient, SimpleFsStorageProvider, AutojoinRoomsMixin, RustSdkCryptoStorageProvider, } from "matrix-bot-sdk";
const homeserverUrl = "https:/xxx.yyy.fr"; const accessToken = "someToken"; const storage = new SimpleFsStorageProvider("hello-bot.json"); const crypto = new RustSdkCryptoStorageProvider("./cryptoBot", StoreType.Sled);
const client = new MatrixClient(homeserverUrl, accessToken, storage, crypto); AutojoinRoomsMixin.setupOnClient(client);
(async function () {
client.on("room.message", (roomId: string, event: any) => { console.log("message: room", roomId); console.log("message: event", event["content"]); if (event["content"]?.["msgtype"] !== "m.text") return; const body = event["content"]["body"]; if (!body?.startsWith("!!")) return; client.replyNotice( roomId, event, "automated response : Hello world!" ); }); await client.start().then(() => console.log("Bot started!")); })();
After the compilation with "npx tsc --watch botTest.ts" I tried to run node botTest.js and it fails with
MatrixHttpClient (REQ-6) { errcode: 'M_NOT_FOUND', error: 'Event not found.' } or MatrixHttpClient (REQ-12) { errcode: 'M_UNKNOWN', error:
One time key signed_curve25519:AAAAAAAAABo already exists. Old key: {"key":"---","signatures":{"@-":{"--"}}}; key: {'key': '--', 'signatures': {'@-': {'ed-': '-'}}}
What am i doing wrong ? Many thanks in advance for your help !