This repository has been archived by the owner on Jul 4, 2023. It is now read-only.
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
0 parents
commit 921e407
Showing
8 changed files
with
121 additions
and
0 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,46 @@ | ||
const T = require("./Twit.js"); | ||
const my_user_name = require("./config").userName; | ||
const timeout = 1000 * 60 * 5; // timeout to send the message 5 min | ||
|
||
const AutoDM = () => { | ||
const stream = T.stream("user"); | ||
console.log("Start Sending Auto Direct Message 🚀🚀🚀"); | ||
stream.on("follow", user => { | ||
console.log(" 🎉🎉🎉🎉 New Follower 🎉🎉🎉🎉🎉 "); | ||
const { screen_name, name } = user.source; | ||
|
||
const obj = { | ||
screen_name, | ||
text: GenerateMessage(name) | ||
}; | ||
// the follow stream track if I follow author person too. | ||
if (screen_name != my_user_name) { | ||
setTimeout(() => { | ||
T.post("direct_messages/new", obj) | ||
.catch(err => { | ||
console.error("error", err.stack); | ||
}) | ||
.then(result => { | ||
console.log(`Message sent successfully To ${screen_name} 💪💪`); | ||
}); | ||
}, timeout); | ||
} | ||
}); | ||
}; | ||
|
||
const GenerateMessage = name => { | ||
const days = [ | ||
"Sunday", | ||
"Monday", | ||
"Tuesday", | ||
"Wednesday", | ||
"Thursday", | ||
"Friday", | ||
"Saturday" | ||
]; | ||
const d = new Date(); | ||
const dayName = days[d.getDay()]; | ||
return (text = ` Hi ${name} Thanks for being a part of my social media network. I'am the @PicsrushE founder,A new Online Image Editor completely with web technologies,I'm also a reactjs developer and medium blogger.\n Happy to discuss anytime 😊 \n Happy ${dayName} 😊😊 `); | ||
}; | ||
|
||
module.exports = AutoDM; |
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) 2018 Youssouf EL AZIZI | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
worker: node index.js |
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,17 @@ | ||
# twitter-bot | ||
|
||
Node js twitter bot to send auto direct message | ||
|
||
## how it works | ||
|
||
* start the project | ||
* fork the project | ||
* customize you auto direct message | ||
* create a simple heroku account | ||
* create a twitter app | ||
* go to https://apps.twitter.com/ and click to the boutton "Create New App" | ||
* go to the setting section and give the app accesse to send messages by "read, Write and Access direct messages" | ||
* go to tab key and Access Tokens and click the "generate Acess Token buotton" in the page bottom. | ||
* Now copy all your key `Consumer Key` `Consumer Secret` `Access Token` and `Access Token Secret` we will need it later !! | ||
* set all env variables from your heroku dashboard > twitter_bot > Settings | ||
* go to resources section and activate the worker Dyno and disable the web dyno |
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,5 @@ | ||
const Twit = require("twit"); | ||
const config = require("./config"); | ||
const T = new Twit(config.twitterApp); | ||
|
||
module.exports = T; |
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,12 @@ | ||
const twitterApp = { | ||
consumer_key: process.env.CONSUMER_KEY, | ||
consumer_secret: process.env.CONSUMER_SECRET, | ||
access_token: process.env.ACCESS_TOKEN, | ||
access_token_secret: process.env.ACCESS_TOKEN_SECRET, | ||
timeout_ms: 60 * 1000 // optional HTTP request timeout to apply to all requests. | ||
}; | ||
|
||
module.exports = { | ||
twitterApp, | ||
userName: process.env.USERNAME | ||
}; |
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,5 @@ | ||
const AutoDM = require("./AutoDM.js"); | ||
|
||
console.log("App started successfully 🙌🙌"); | ||
|
||
AutoDM(); |
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,14 @@ | ||
{ | ||
"name": "twitter_bot", | ||
"version": "1.0.0", | ||
"description": "Node js twitter bot to send auto direct message", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "node index.js" | ||
}, | ||
"author": "Youssouf El AZIZI", | ||
"license": "ISC", | ||
"dependencies": { | ||
"twit": "^2.2.9" | ||
} | ||
} |