Add main.js

This commit is contained in:
Nikhil Nawgiri 2024-08-25 00:45:45 +02:00
parent da6881d3bc
commit fc614bd6cc

20
main.js Normal file
View file

@ -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();