matrix-org / matrix-js-sdk

Matrix Client-Server SDK for JavaScript
Apache License 2.0
1.53k stars 580 forks source link

Make the client only see events from after it was turned on #843

Open alexgleason opened 5 years ago

alexgleason commented 5 years ago

Hi, I'm trying to make a very simple bot that greets users when they enter a room. Source code: https://gitlab.com/alexgleason/solarus-welcome-bot/blob/master/bot.js

Concept:

screenshot from 2019-02-14 15 52 24

The problem is, it keeps getting all these events I don't need. Finally, I realized I could do this:

event.event.unsigned.age < 6000

to check if an event is from the past 60 seconds. This is good enough, but it doesn't seem to always work. For instance, it always greets t2bot's Discord Bridge user (@_discord_bot:t2bot.io) when it starts up, and I don't know why.

My desired behavior is to make the bot start up, mark everything as read, then from that point on respond to room join events.

danielgottbehuet commented 5 years ago

Try startClient(0);