• Stars
    star
    408
  • Rank 102,425 (Top 3 %)
  • Language
    JavaScript
  • License
    GNU General Publi...
  • Created over 5 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ€– Twitter bot to set reminders for tweets.

RemindMeOfThisTweet

License: GPL v3

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.

More Repositories

1

DownloadThisVideo

Twitter bot for easily downloading videos/GIFs off tweets
JavaScript
663
star
2

indie-tools

Low-cost, high-quality tools for Indie hackers. You don't need a big budget to build amazing stuff!
154
star
3

Free-for-students

Because software is expensive, money is elusive and piracy is...evil!
140
star
4

oldtweets.today

"On This Day" for Twitter #TwitterThrowback
JavaScript
113
star
5

burns

Manage your application's events without writing spaghetti code
JavaScript
87
star
6

aargh

Selectively handle errors in JavaScript
JavaScript
84
star
7

twittersignin

"Sign In With Twitter", minus the fuckery.
JavaScript
75
star
8

cors-escape

JavaScript
69
star
9

laravel-jsend

Simple helpers to generate JSend-compliant JSON responses
PHP
59
star
10

simple-cors-escape

JavaScript
37
star
11

twitter-error-handler

Handle errors from Twitter API calls
JavaScript
27
star
12

strive

Try a couple of different approaches to complete a task πŸ’ͺ
JavaScript
26
star
13

simple-db

Get your Android app's SQLite database set up in five minutes!
Java
25
star
14

clara

πŸ”Š Simple, pretty, testable console output for PHP CLI apps.
PHP
24
star
15

volgnie

Get rid of your Twitter followers
Ruby
22
star
16

pusher-chatkit-laravel

Laravel wrapper for the Chatkit PHP SDK. ChatKit is shutting down πŸ˜• - https://blog.pusher.com/narrowing-our-product-focus
PHP
22
star
17

shalvah.github.io

HTML
21
star
18

ype

[Beta] Runtime type assertions for JS function arguments (or anything, really)
TypeScript
19
star
19

ensure

Clean alternative syntax for enforcing business requirements
PHP
19
star
20

botrivia

Facebook Messenger trivia bot, built with Laravel
PHP
17
star
21

upgrader

PHP
12
star
22

monolog-pusher

Monolog Handler for sending logs to Pusher channels
PHP
11
star
23

laravel-realtime-analytics-dashboard

[Demo]
PHP
11
star
24

tattletale

[Tutorial] Realtime push notifications for your web app, powered by Pusher
HTML
10
star
25

pollser

[Demo] Real-time polls app
JavaScript
8
star
26

poster

[Demo] Node app implementing Twitter's real-time likes count feature with Pusher
JavaScript
8
star
27

advent-of-code-solutions

https://adventofcode.com
Ruby
7
star
28

syringe

Small dependency injection container for PHP (PHP 7+)
PHP
7
star
29

TheCensorshipAPI

PHP
6
star
30

eka

Quickly run Elasticsearch, Kibana and APM Server locally with Docker Compose.
6
star
31

lngnr

Server-side redirects of shortened URLs. Useful if your network can't access the short link.
Ruby
6
star
32

dotfiles

PowerShell scripts I use for setting up and configuring my Windows machine(s)
PowerShell
6
star
33

shalvah

JavaScript
5
star
34

unnportal-php

Build apps for UNN students with the best authentication possible
PHP
5
star
35

stockt-audited

[Demo] Stock management app built with Laravel, with a realtime audit dashboard
PHP
5
star
36

laravel-mongodb-starter

Laravel 5.6 + MongoDB with Eloquent πŸŽ‰ 😎 πŸ’ƒ
PHP
4
star
37

elastic-stack-starter-kit

Elastic Stack components for observability + web apps to help you get started
C#
3
star
38

rethinkdb-pusher-node-demo

[Tutorial] Demo app showing realtime functionality with RethinkDB and Pusher Channels
JavaScript
3
star
39

WhatTheyTweeted

[Abandoned] Mirror someone's tweets from a time in the past.
JavaScript
2
star
40

just-api

πŸ’₯ Easy and Flexible REST, GraphQL API Testing https://kiranz.github.io/just-api/
JavaScript
2
star
41

avengers-jla-chat

[Demo] Chat app built with Laravel, powered by Chatkit
PHP
2
star
42

stockt

[Demo] Stock management app built with Laravel
PHP
2
star
43

giphyapp

Solution to the Giphy App Challenge http://codeclass.com.ng/challenge/4a690150-7f1c-11e6-8e8d-ef6b3777edab
PHP
2
star
44

chirper

[Demo] Implement Twitter's Real-time Likes count with Laravel and Pusher
PHP
2
star
45

live-game-updates-laravel

PHP
1
star
46

XOdroid

A simple Android app for two users to play tic-tac-toe (X and O)
1
star
47

express-realtime-analytics-dashboard

[Demo]
JavaScript
1
star
48

programming-challenges

My solutions to programmming challenges
JavaScript
1
star
49

rcam

[Demo] Realtime site comments with auto moderation using Pusher Channels
PHP
1
star
50

Digitable

An Android app for managing students' class and assignment schedule in order to enhance productivity.
Java
1
star
51

JSON-Prettify

A simple web app to make a JSON string easier to read
PHP
1
star
52

faktory-php

PHP
1
star
53

tvass

[Demo] That Very Awesome Serverless Site 😎😎 - serverless site showing count of page viewers in realtime
JavaScript
1
star
54

realtime-laravel-logs

[Tutorial] Demo Laravel app to view logs in realtime using Pusher Channels and Laravel 5.6+ log channels
PHP
1
star
55

stockup-gql

[Demo] raphQL API for stock management, built on AWS Lambda
JavaScript
1
star
56

hng-request

PHP package for making requests to the Hotels.ng CRS API
PHP
1
star
57

countess

PHP
1
star
58

TelcoHelper

An Android app for accessing network USSD functions (eg recharge, check airtime balance) without having to dial
Java
1
star
59

codeclass-spam-detector

Solution to CodeClass Spam Detector challenge <http://codeclass.com.ng/challenge/7a6eba10-aa55-11e6-ba05-354f4470e305>
PHP
1
star