Giter VIP home page Giter VIP logo

remindmeofthistweet's Introduction

RemindMeOfThisTweet

License: GPL v3

As of July 2023, @RemindMe_OfThis is dead, thanks to the Twitter API changes. ๐Ÿ˜ข Thanks for this lovely journey of 4.5 years, everyone!

The Problem

Some guy on Twitter tweets:

In three years, humans will have established a colony on Uranus.

And of course, naturally, you want to check back in three years to see if he was right. But you likely won't remember by that time.

The Solution

Just tweet:

@RemindMe_OfThis in three years

Reminder request screenshot

And when the time is right:

Reminder screenshot

Of course, that's not all you can do! You can set reminders for your own tweets (New Year's Resolutions, anyone?๐Ÿ‘€), too, for instance.

Note that the bot will assume all absolute times are in UTC, so if you want to specify an absolute time, you need to specify a timezone if you're not in UTC/GMT. For instance, "11:30 pm WAT" (West African Time), "10:20 am UTC+0300", "10:20 am GMT-0900". Better yet, sign in on https://remindmeofthis.app and set your timezone.๐Ÿ™‚

PS: I also made @this_vid!

How This Works

Stack

Implementation

The bot uses a number of AWS Lambda functions that work in tandem:

handleAccountActivity

This function serves as the webhook registered to Twitter's Account Activity API. Whenever anyone mentions the bot (or likes or retweets a tweet by the bot), Twitter hits this URL with a payload containing details of the events.

This function iterates through all the mentions and looks for any possible reminder requests (or reminder cancellations). If it finds any requests, it sets a reminder by storing the relevant data (tweet, author, etc) in Redis, with the Redis key being the timestamp (ISO8601โ€”can't remmber why I went with that instead of the UNIX timestamp, but possibly human-readability).

Cancellations (reply "cancel" to the bot's reply) work by storing a Redis entry with the reminder request tweet ID as value and the ID of the bot's response as key. SO when a user replies cancel to a Tweet, we look up the ID of the tweet they're replying to, fetch their original reminder Tweet from there, and then delete th reminder from that Tweet from the datetime-key containing it in Redis.

checkForRemindersAndSend

This function runs once every minute (this means reminders can only have minute precision) and checks for any reminders scheduled for the current time. Assuming the time is 2019-05-03, 11:23, it will check for a Redis key 2019-05-03T11:23:00Z, which should hold all the reminders for that time. Then it iterates over them and dispatches any tweets or push notifications.

getHomePage

Renders the home page of http://remindmeofthis.app

getPage

Renders all other pages on http://remindmeofthis.app. Why are getHomePage and getPage separate, you ask? I honestly do not remember. Maybe I wasn't sure if I could make path parameters optional.๐Ÿค”

startTwitterSignIn

When you click "Sign in With Twitter" on the website, you're redirected to the URL of this function. It retrieves the necessary tokens and passes on to Twitter API to start the sign in process.

completeTwitterSignIn

The URL Twitter redirects you to after you complete the sign in process. This function fetches your profile info from the Twitter API and creates a session for you on the website.

updateSettings

HTTP handler that the form submits to when you update your settings on the website (set a timezone or enable/disable push notifications). Settings are stored in redis, with the user's Twitter handle forming part of the key.

handleTwitterCrc

These are utility functions used only once: when verifying the webhook for Twitter (during setup). See here.

retryFailedTasks

This re-publishes failed tasks (stored in Redis) and attempts to set reminders for them. It can only be triggered manually.

This architecture isn't perfect, and I'm open to criticism and suggestions. It's unlikely I'll change things much (because time, work, etc), but I'm interested in hearing your thoughts.

Development

See the contributing and development guide for details on working on this project.

remindmeofthistweet's People

Contributors

mahveotm avatar olucurious avatar shalvah avatar skoops avatar stevenharman 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

remindmeofthistweet's Issues

feature request: screenshot the tweet for better reference

First off, good work on these bots man! ๐ŸŽ‰

I don't know if this feature is already in here but this is my suggestion. Some people delete tweets (or even change usernames, not sure how Twitter handles such refs). However, a screenshot for the tweet be stored somewhere, using something like Puppeteer?

Or should this be a separate bot? ๐Ÿค”

Storage will be another bridge to cross when we get there... I'm thinking of some hacks around this.

Migrate away from AWS CloudWatch Rules for scheduling reminders

For the last couple of hours, the bot no longer responds to reminder requests. Checked the logs and found this message:

The requested resource exceeds the maximum number allowed.

Apparently, AWS CloudWatch has a limit of 100 rules, which we've reached.

I'd like to migrate to a custom service to handle these scheduled tasks. In the meantime, though, I'll use Redis as a stopgap solution.

Internal improvements

The goal here is to improve the development experience.

  • Make it easier for existing devs (me) to add new features
  • Make it easy for new devs to get started
  • Make it easier to find and fix issues
  • Make it easier to reproduce scenarios. For instance, how do you test that a Firebase notification works locally? How do you test one part of the application without going through Twitter?
  • Make it easier to perform administrative tasks. For instance, if I need to manually force a reminders check.

Achieving these will include things like:

  • Improving the README. The Implementation section may be out of date.
  • Adding a development guide.
  • Setting up better test mocks
  • Setting up reliable local emulation environments
  • Adding better instrumentation
  • Fixing some existing issues logged by Sentry, such as issues with auth.
  • Create runbooks for admin tasks and failure scenarios
  • Reorganizing the code so it's easier to follow

This will be a long-term thing, so I may end up splitting this into multiple issues/PRs.

DST Support

Please add DST because my Country/State hates us and likes to shift the time around randomly by an hour from UTC.

Not picking timezone

If possible, it'll be great if the bot can pickup the time zone from the date time mentioned.
eg: 9PM IST, 10:30 PST etc

Also notify people who liked your confirmation

I love your service.

More often than not I also would like to be notified. But I don't want to spam the comments with more @RemindMeOfThisTweet replies. What if I also get notified, if I like your confirmation?

Or is it already implemented? If so, please let me know.

Thanks!

Missing deployment guide

I would love to improve upon the usability of this bot and also maybe provide translation to other languages, but therefore I'd like to host my own instance. Is there any kind of deployment or configuration guide for this node app, for someone not being familiar with the serverless framework.

Fallback method for Redis concurrent connection limitation

The redislabs.com plan in use has a concurrent connection limit of 30 (Free Plan). This can lead to lots of "ERR too many clients" errors in certain situations:

  • Multiple function instances
  • Parallel operations involving cache

There are a few options here:

  • Adding a retry handler [already have this, but need to follow up and be sure it works]
  • Mitigate the issue by limiting parallel cache ops to a certain number at a time (maybe 20?), or use some kind of pool approach
  • Look into Redis connection pools on AWS Lambda
  • Pay for a bigger plan.

Is it possible to set more than one reminder?

Hello. It's not a bug, but a question: is it possible to set more than one reminder? I'd like to be reminded of a Tweet in 45, 60, 90 and 120 days.
I couldn't find any other user attempting this. If it's possible, how should I format it?

Thanks in advance!

Improve date/time parsing

Here are some requests which fail to parse currently:

  • "in 2023"
  • "4 hours" (no "in")
  • "in 6 months"

RemindMe happily schedules dates in the past

I accidentally asked for a reminder on January 2020 instead of 2021. RemindMe had no issue, and replied it will remind me when the date comes. It should recognize that the date is in the past, and reply with an error message.
ืชืžื•ื ื”

Limit reminder duration

People shouldn't be able to set reminders for a 100 years in the future.๐Ÿ˜• Let's cap it at say, 30 years.

Fixing this should be pretty straightforwardโ€”add a maximum reminder time (there's already a minimumReminderTime):

const minimumReminderInterval = (new Date(Date.now() + (3 * 60 * 1000)));

(If you work on this, don't forget to add a test; you can follow the minimum reminder time test, or let me know if you need help.)

view reminders

Would be great to have a command that returns all outstanding reminders of my Twitter handle.

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.