This repository has been archived by the owner on Oct 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
41 additions
and
3 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,36 @@ | ||
const Twit = require('twit') | ||
const unique = require('unique-random-array') | ||
const config = require('../config') | ||
|
||
const param = config.twitterConfig | ||
const randomReply = unique(param.randomReply.split(',')) | ||
|
||
const bot = new Twit(config.twitterKeys) | ||
|
||
// function: tweets back to user who followed | ||
function tweetNow(text) { | ||
let tweet = { | ||
status: text | ||
} | ||
|
||
bot.post('statuses/update', tweet, (err, data, response) => { | ||
if (err) { | ||
console.log('ERRORDERP Reply', err) | ||
} | ||
console.log('SUCCESS: Replied: ', text) | ||
}) | ||
} | ||
|
||
// function: replies to user who followed | ||
const reply = (event) => { | ||
// get user's twitter handler/screen name | ||
let screenName = event.source.screen_name | ||
|
||
const response = randomReply() | ||
|
||
const res = response.replace('${screenName}', screenName); | ||
|
||
tweetNow(res) | ||
} | ||
|
||
module.exports = reply |
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