Skip to content

suntoes/bot-RandomThoughts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

r-bot/RandomThoughts logo

bot/RandomThoughts

banner

A reddit to twitter bot...

Using nodejs, it tweets recent r/RandomThoughts post's title detected with a condition of the author not being the AutoModerator, words being not less than 3, and overall character's length not more than 275.

Host it locally...

To host it is very simple, but the requirements to run it is quite the different matter. Here's the full ordered list:

1. Setting up with firebase

First off, have a clean directory for the project, and then run this on the terminal

> firebase init functions
> ...initialize to a firebase project
> ...select TypeScript
> ...use ESlint? No

After that, you'd have to delete all the files inside the /functions folder, and then replace it in place with everything on this repo.


2. process.env variables

You'll be tasked to fill up the .env variables below and then place the .env file within the functions folder.

CLIENT_ID="Your_Twitter's_Client_ID"
CLIENT_SECRET="Your_Twitter's_Client_Secret"
CALLBACK_URL="Your_Firestore_Callback_URL" // read note#1
TWEET_URL="Your_Firestore_Callback_URL" // read note#1
MONGO_URI="Your_MongoDb_URI" // read note#2

note#1: You'll need to run the scripts upto the firebase serve, and then see the console to get this. See the scripts and commands for the idea.

note#2: Initial document in the database is crucial. Set it up by adding a "bot-datas" collection in your referred database. And then manually insert a document with { name: "random-thoughts", data: [ ] }.


3. scripts and commands

cd first to the /functions folder, and then here's the ordered scripts you'd need to run:

> npm install
  ...
> npm run build
  ...
> firebase serve
  ...
> npm run repeater

You'll need a 2nd terminal for the repeater. And btw wait for each scripts to finish, before applying what follows.