Skip to content
This repository has been archived by the owner on Oct 11, 2021. It is now read-only.

A small javascript utility to determine when a user was last active.

License

Notifications You must be signed in to change notification settings

Half-Shot/matrix-lastactive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️ Deprecated ⚠️

This functionality has now been merged into matrix-appservice-bridge here. Users wishing to track activity can import that component into their project freely.

matrix-lastactive

A small utility to determine when a user was last active.

How to use

Install with

npm i matrix-lastactive

To use

import { MatrixActivityTracker } from "matrix-lastactive";

// Create the tracker object.
const tracker = new MatrixActivityTracker({
    homeserverUrl: "https://localhost",
    accessToken: "ABCDE",
    serverName: "localhost",
    defaultOnline: false,
});

tracker.isUserOnline(
    "@Half-Shot:half-shot.uk"
    1000 * 60 * 60 * 24 // 24 hours
).then((isOnline) => {
    if (isOnline) {
        console.log("Half-Shot is online");
    } else {
        console.log("Half-Shot is offline");
    }
});


// You could also plug the library into an event handler..
myfakeemitter.on("event", (event) => {
    // ..and keep track of how long ago you saw a message from a user.
    tracker.bumpLastActiveTime(event.sender);
});

Contact

If you need help with this library, please contact @Half-Shot:half-shot.uk

About

A small javascript utility to determine when a user was last active.

Resources

License

Stars

Watchers

Forks

Packages

No packages published