From fc614bd6cc30b74e494d245c26929bf893d01439 Mon Sep 17 00:00:00 2001 From: Nikhil Nawgiri Date: Sun, 25 Aug 2024 00:45:45 +0200 Subject: [PATCH] Add main.js --- main.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 main.js diff --git a/main.js b/main.js new file mode 100644 index 0000000..cb1ca19 --- /dev/null +++ b/main.js @@ -0,0 +1,20 @@ +const sdk = require("matrix-bot-sdk"); +const config = require("./config.js"); + +const { MatrixAuth } = sdk; +const { + homeserverUrl, + username, + password, +} = config; + +// This will be the URL where clients can reach your homeserver. Note that this might be different +// from where the web/chat interface is hosted. The server must support password registration without +// captcha or terms of service (public servers typically won't work). +const login = async () => { + const auth = new MatrixAuth(homeserverUrl); + const client = await auth.passwordLogin(username, password); + console.log("Copy this access token to your bot's config: ", client.accessToken); +} + +login();