Add /ping command

This commit is contained in:
Cadence Ember
2026-01-30 19:22:32 +13:00
parent e3e38b9f24
commit 44208b6fd5
4 changed files with 227 additions and 1 deletions

View File

@@ -128,6 +128,19 @@ async function getEventForTimestamp(roomID, ts) {
return root
}
/**
* @param {string} roomID
* @param {"b" | "f"} dir
* @param {{from?: string, limit?: any}} [pagination]
* @param {any} [filter]
*/
async function getEvents(roomID, dir, pagination = {}, filter) {
filter = filter && JSON.stringify(filter)
/** @type {Ty.Pagination<Ty.Event.Outer<any>>} */
const root = await mreq.mreq("GET", path(`/client/v3/rooms/${roomID}/messages`, null, {...pagination, dir, filter}))
return root
}
/**
* @param {string} roomID
* @returns {Promise<Ty.Event.StateOuter<any>[]>}
@@ -583,6 +596,7 @@ module.exports.leaveRoom = leaveRoom
module.exports.leaveRoomWithReason = leaveRoomWithReason
module.exports.getEvent = getEvent
module.exports.getEventForTimestamp = getEventForTimestamp
module.exports.getEvents = getEvents
module.exports.getAllState = getAllState
module.exports.getStateEvent = getStateEvent
module.exports.getStateEventOuter = getStateEventOuter