Giter Club home page Giter Club logo

matrix-bot-sdk's Introduction

matrix-bot-sdk

npm version

TypeScript/JavaScript SDK for Matrix bots. For help and support, visit #matrix-bot-sdk:t2bot.io

Documentation

Documentation for the project is available here.

Matrix version support

The Matrix protocol is versioned to ensure endpoints and functionality can safely rotate in and out of the ecosystem. The bot-sdk will assume it is connected to a homeserver with support for at least one of the last 2 versions, at the time of the bot-sdk's release. This means that if you connect the bot-sdk to a homeserver which is 3 or more Matrix versions out of date, things might not work for you.

It is recommended to update the bot-sdk as frequently as spec releases themselves (or faster) to avoid this situation, and watch the repo for updates in the event a release is delayed.

Note: Currently the bot-sdk does not throw an error if the server appears to be incompatible, however this might change in the future.

matrix-bot-sdk's People

Contributors

andrewferr avatar andrewkvalheim avatar b4dm4n avatar benbz avatar bencevans avatar dependabot[bot] avatar dhenneke avatar gnuxie avatar half-shot avatar jaller94 avatar sethfalco avatar skolmer avatar sorunome avatar tadzik avatar tulir avatar turt2live avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

matrix-bot-sdk's Issues

Appservice Intent ensureJoined

Currently Appservice Intent.ensureJoined() returns undefined if the ghost was already in the room, elsewise it returns the rooms mxid

This is really helpful to detect if a join actually happened, for if you needed to do some additional stuff based on that.

Perhaps consider this a feature, document it and set the return type that function correctly to Promise<string | undefined>

Unhandled promise regection on missconfigured appservice

If an AS is missconfigured this lib throws an unhandled promise rejection as it can't decode JSON:

(node:3853) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at Intent.<anonymous> (/home/sorunome/repos/mx-puppet-bridge/node_modules/matrix-bot-sdk/lib/appservice/Intent.js:135:41)
    at Generator.throw (<anonymous>)
    at rejected (/home/sorunome/repos/mx-puppet-bridge/node_modules/matrix-bot-sdk/lib/appservice/Intent.js:5:65)
    at processTicksAndRejections (internal/process/task_queues.js:86:5)

perhaps handle this?

Build classes for event formats

Nothing is going to drastically change anytime soon, however we should still have event.getContent() style classes to be future-proof.

Getting metrics for appservice users is hard

Because each MatrixClient has it's own metrics counter, which makes them hard to bind to. Can appservices bind all intents to the same metrics counter, or alternatively expose a way for a bridge to bind to every MatrixClient in some way.

Add basic functions for membership syncing?

Something where the bridge can dump a list of remote user objects into a function and have the SDK automatically figure out which ones need to get configured in the room.

[Appservice][Feature Request] Allow onRoomAlias to completly handle room creation or aliasing.

Hi!
I have an usecase where a new room alias can lead to an already existing room.
Unfortunatly I can not query possible room aliases and set them up before the homeserver queries the room.
So at least for my usecase it would be benifitial if I could skip the part where the appservice creates a room and just add an alias to the existing room.

My proposal would add a shortcut to the callback handling true (same as the sdk already handles false and sends a 404).
So an example would look like that:

appservice.on("query.room", async (alias, fn) => {
    /* some userspace code handling setup of the required alias */
    fn(true);
});

This would be fairly easy to implement as it's basicly just adding:

else if (result === true) {
   res.status(200).json({});
}

here: https://github.com/turt2live/matrix-js-bot-sdk/blob/fd950f606e76867d2bf3e8e10913755269ebea4d/src/appservice/Appservice.ts#L655

What Do you think and thanks for your time.

Context-based requests

When an event is raised by the SDK it should have the /sync request/response info, member profile, event itself, room ID, etc all easily accessible to the receiver. This makes it easier to form replies, mentions, etc without the extra API hits.

This should also be opt-in.

AppserviceJoinRoomStrategy fails

if AppserviceJoinRoomStrategy fails due to e.g. the appservice bot not being in that room it doesn't propagate to the next underlyingStrategy

Appservice user events

The appservice user events (room.join, room.invite, room.leave) only easily present the roomId, the userId needs to be fetched via the event.

As the userId is commonly needed for handling those events, perhaps consider making that a parameter

/register logging leaks access token

May-4 19:45:21.845 [DiscordStore] info: Updated database to the latest schema
MatrixLiteClient (REQ-1) POST http://localhost:8008/_matrix/client/r0/register
MatrixLiteClient (REQ-1) body = {"type":"m.login.application_service","username":"_discord_bot"}
MatrixLiteClient (REQ-1 RESP-H200) {"user_id": "@_discord_bot:asreil", "home_server": "asreil", "access_token": "aaaaaaaaaaaaaaa, "device_id": "YXWKYVSJLY"}
May-4 19:45:21.906 [DiscordAS] info: Started listening on port 9555
May-4 19:45:23.266 [DiscordBot] info: Discord bot client logged in.
May-4 19:45:23.267 [PresenceHandler] info: Adding 102444422850945024 (Half-Shot) to the presence queue

Add Appservice getSuffixFromUserId

This can be useful e.g. when somebody invites a ghost to initiate 1:1 conversation to figure out which ghost that is, as usually the suffix is some kind of ID

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.