-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added license and a link to twitterbot-cron.
- Loading branch information
Glitch (twitterbot)
committed
Apr 20, 2020
1 parent
64f7247
commit 346ac69
Showing
4 changed files
with
54 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,5 +23,6 @@ | |
"twitter", | ||
"twitterbot", | ||
"bot" | ||
] | ||
], | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); | ||
} ); |