SmallBot
import { SmallBot } from "https://raw.githubusercontent.com/cybertim/SmallBotMatrix/main/mod.ts";
Wrapper to interact with the matrix.org client API
§Constructors
Create an instance of SmallBot
const client = new SmallBot({
accessToken: "mysecretaccesstoken",
homeserverUrl: "https://matrix.org/",
eventHandler: async (client, roomId, event) => {
if (event.sender !== client.ownUserId) {
await client.sendRoomNotice(roomId, "You said: <b>" + event.content.body + "</b>");
}
}
});
§Properties
§Methods
Returns MatrixRoomStateResponse
of the given room id containing the current display name
ID of Room to get the display name
Listens for new events on /sync
with a timeout based on syncTimeout
This method is looped automatically when start()
is called
token used to sync events from a specific point in time
Returns MatrixUserProfileResponse
containing the current display name of the userId
const profile = await client.getUserProfile(event.sender);
ID of the user to retrieve the profile
Send a custom message to a room
await client.sendMessage(roomId, "m.text", "<b>hello world</b>");
ID of the Room
type like m.text
or m.notice
the HTML body of the message formatHTMLtoPlain
will be used to create the plain-text version
Alias of sendMessage
with msgType m.notice
ID of the Room
the HTML body of the message formatHTMLtoPlain
will be used to create the plain-text version
Alias of sendMessage
with msgType m.text
ID of the Room
the HTML body of the message formatHTMLtoPlain
will be used to create the plain-text version