This post consists of notes to myself, so that I can remember the commands to create a Node.js Twitterbot hosted on Heroku.
Create a Github repo and clone it locally
.env
.DS_Store
node_modules/
npm init
npm asks questions and builds a package.json file.
npm install dotenv
npm install twit
npm install express
CONSUMER_KEY = ...
CONSUMER_SECRET = ...
ACCESS_KEY = ...
ACCESS_SECRET = ...
const express = require('express');
const app = express();
require('dotenv').config();
const Twit = require('twit');
// const T = new Twit({
// consumer_key: process.env.CONSUMER_KEY,
// consumer_secret: process.env.CONSUMER_SECRET,
// access_token: process.env.ACCESS_KEY,
// access_token_secret: process.env.ACCESS_SECRET,
// timeout_ms: 60*1000, // optional HTTP request timeout to apply to all requests.
// strictSSL: true, // optional - requires SSL certificates to be valid.
// });
// yr code here
app.listen(
process.env.PORT || 3000,
()=>console.log("bot running")
);
Write your code in index.js
node index.js
CONSUMER_KEY = ...
CONSUMER_SECRET = ...
ACCESS_KEY = ...
ACCESS_SECRET = ...
git checkout -b Github_Public
git push -u origin Github_Public
Go to the website for the Github repo, click Settings > Branches, and change Github_Public to be the default branch
Commit/push the Github_Public branch. Switch to the master/main branch.
worker: node index.js
heroku login
heroku git:remote -a goodnitebot
git add .
git commit -am "make it better"
git push heroku master
RECENT POSTS