Skip to content

Commit

Permalink
Added license and a link to twitterbot-cron.
Browse files Browse the repository at this point in the history
  • Loading branch information
Glitch (twitterbot) committed Apr 20, 2020
1 parent 64f7247 commit 346ac69
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 27 deletions.
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Stefan Bohacek

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Glitch Twitter bot template

This is a template for making creative Twitter bots with [Glitch](https://glitch.com/) and the [Twit](https://github.com/ttezel/twit) node.js library.

For a version that uses an automatic scheduler, check out the [twitterbot-cron](https://glitch.com/edit/#!/twitterbot-cron) project. (Note that this requires a [paid Glitch subscription](https://glitch.com/pricing)).


## A quick tutorial

1. Create a new Twitter account and a new Twitter app. ([See how.](https://botwiki.org/tutorials/how-to-create-a-twitter-app/))
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"twitter",
"twitterbot",
"bot"
]
],
"license": "MIT"
}
54 changes: 28 additions & 26 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
/* Setting things up. */
var express = require('express'),
app = express(),
Twit = require('twit'),
config = {
/* Be sure to update the .env file with your API keys. See how to get them: https://botwiki.org/tutorials/how-to-create-a-twitter-app */
twitter: {
consumer_key: process.env.TWITTER_CONSUMER_KEY,
consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
access_token: process.env.TWITTER_ACCESS_TOKEN,
access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET
}
},
T = new Twit(config.twitter);
const express = require( 'express' ),
app = express(),
Twit = require( 'twit' ),
config = {
/* Be sure to update the .env file with your API keys. See how to get them: https://botwiki.org/tutorials/how-to-create-a-twitter-app */
twitter: {
consumer_key: process.env.TWITTER_CONSUMER_KEY,
consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
access_token: process.env.TWITTER_ACCESS_TOKEN,
access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET
}
},
T = new Twit( config.twitter );

app.use(express.static('public'));
app.use( express.static( 'public' ) );

/* You can use cron-job.org, uptimerobot.com, or a similar site to hit your /BOT_ENDPOINT to wake up your app and make your Twitter bot tweet. */
/* You can use cron-job.org, uptimerobot.com, or a similar site to periodically visit your /BOT_ENDPOINT to wake up your app and make your Twitter bot tweet. */

app.all( `/${process.env.BOT_ENDPOINT}`, function( req, res ){

app.all(`/${process.env.BOT_ENDPOINT}`, function(req, res){
/* The example below tweets out "Hello world!". */
T.post('statuses/update', { status: 'hello world 👋' }, function(err, data, response) {
if (err){
console.log('error!', err);
res.sendStatus(500);

T.post( 'statuses/update', { status: 'hello world 👋' }, function( err, data, response ) {
if ( err ){
console.log( 'error!', err );
res.sendStatus( 500 );
}
else{
res.sendStatus(200);
res.sendStatus( 200 );
}
});
});
} );
} );

var listener = app.listen(process.env.PORT, function(){
console.log('Your bot is running on port ' + listener.address().port);
});
let listener = app.listen( process.env.PORT, function(){
console.log( 'Your bot is running on port ' + listener.address().port );
} );

0 comments on commit 346ac69

Please sign in to comment.