New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

matrix-js-basic-bot

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

matrix-js-basic-bot

A basic bot for matrix.org

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

matrix-js-basic-bot

Build Status

A basic bot for matrix.org

It can be used to run basic experiments in chat bot development without going deep in matrix protocol details.

Bot is powered by matrix-js-sdk.

Features:

  • on first startup authenticates and obtains access token and device id, stores them to use on subsequent runs
  • automatically joins rooms on invitation
  • automatically leaves empty rooms
  • supports e2e encryption
  • automatically verifies all users devices in the room on an attempt to send a message to the e2e enabled room

Usage

npm install matrix-js-basic-bot
const BasicMatrixBot = require('matrix-js-basic-bot');
const md = require('markdown-it')();

async function onMessage(content, sender) {
  try {
    const output = `**Echo**: ${content.body}`;
    await this.sendNotice(sender.roomId, output, md.render(output));
  } catch (error) {
    console.log(error);
  }
}

async function run() {
  await servers.connect(serversCredentials);

  const bot = new BasicMatrixBot('myCoolBot', 'StrongPassword', 'https://matrix.org', './localstorage');

  bot.on('error', (error) => {
    console.log(error);
  });

  bot.on('message', onMessage);
  bot.on('e2eMessage', onMessage);

  await bot.start();
}

run()
  .catch((error) => {
    console.log('Unhandled error!');
    console.log(error);
    process.exit(1);
  });

See more examples in examples.

API

docs

License

MIT

Keywords

matrix-org

FAQs

Package last updated on 05 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts