npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

matrix-revolt-parser

v1.0.9

Published

Convert between Matrix and Revolt messages

Readme

matrix-revolt-parser

This package is a message parser for sending messages between Matrix and Revolt. For that, it has two parsers: RevoltMessageParser and MatrixMessageParser.

This is a fork of @deurstann/matrix-discord-parser, itself a fork of matrix-discord-parser.

RevoltMessageParser

Example code:

import { RevoltMessageParser, IRevoltMessageParserOpts } from "matrix-revolt-parser";

const parser = new RevoltMessageParser();

const opts = {
    callbacks: {
        getUser: async (id: string) => null,
        getChannel: async (id: string) => null,
        getEmoji: async (id: string) => null;
    },
} as IRevoltMessageParserOpts;
const message = msg; // Type Message from revolt.js
const result = await parser.FormatMessage(opts, msg);
console.log(result.body); // the body of the matrix message
console.log(result.formattedBody); // the formatted body of the matrix message
console.log(result.msgtype); // the msgtype of the matrix message

All options of IRevoltMessageParserOpts:

  • callbacks: IRevoltMessageParserCallbacks, the callbacks to handle
    • getUser: async (id: string) => Promise<IRevoltMessageParserEntity | null>, resolves to either the information on the specified Revolt user or to null
    • getChannel: async (id: string) => Promise<IRevoltMessageParserEntity | null>, resolves to either the information of the specified Revolt channel or to null
    • getEmoji: async (id: string) => Promise<IRevoltEmojiEntity | null>, resolves to either the mxc uri of the specified Revolt emoji or to null

All properties of IRevoltMessageParserEntity:

  • name: string, the name of the entity
  • mxid: string, the resulting matrix ID of the entity

All properties of IRevoltEmojiEntity:

  • name: string, the name of the emoji
  • mxc: string, the MXC URI for the emoji

All properties of IRevoltMessageParserResult:

  • body: string, the body of the result
  • formattedBody: string, the formatted (html) body of the result
  • msgtype: string, the matrix msgtype of the result

MatrixMessageParser

Example code:

import { MatrixMessageParser, IMatrixMessageParserOpts } from "matrix-revolt-parser";

const parser = new MatrixMessageParser();

const opts = {
    callbacks: {
        getUserId: async (mxid: string) => null,
        getChannelId: async (mxid: string) => null,
        getEmoji: async (mxc: string, name: string) => null,
        mxcUrlToHttp: async (mxc: string) => "http://example.com",
    },
    displayname: "Alice",
    determineCodeLanguage: true,
} as IMatrixMessageParserOpts;

const msg = { // raw matrix event content
    msgtype: "m.text",
    body: "**blah**",
    format: "org.matrix.custom.html",
    formatted_body: "<strong>blah</strong>",
};

const parsed = await parser.FormatMessage(opts, msg);
msg.send(parsed); // send this message to discord

All options of IMatrixMessageParserOpts:

  • callbacks: IMatrixMessageParserCallbacks, the callbacks to handle
    • getUserId: async (mxid: string) => Promise<string | null>, return the discord user ID given an mxid, or null
    • getChannelId: async (mxid: string) => Promise<string | null>, return the discord channel ID given an mxid, or null
    • getEmoji: async (mxc: string, name: string) => Promise<string | null>, return a Revolt emoji ID given an mxc uri and a name, or null
    • mxcUrlToHttp: async (mxc: string) => Promise<string>, resolve an mxc uri to a publicly available http url.
  • displayname: string, the display name of the sender of the message (used for m.emote parsing)
  • determineCodeLanguage: Boolean (default false), whether the language of code-blocks should be auto-determined, if not specified

Returned is a Revolt-formatted string, ready to be sent.