This is Instagram Direct message bot for IG marketing with real user account. Main functions had been built by Node.js. Codebase look like :
Node.js
(Back-end platform to integrate the npm modules)Express.js
(Back-end framework to host the http server withhttp
module.)Postgres
(Main database to store all data and history from project.)Sequelize
(Database management tools to excute the sql withNoSQL
type of application)EJS
(Front-end to disply the initialize data and validate all of event by using javascript.)
- Used npm modules like this:
- "bcrypt-nodejs": "0.0.3",
- "bluebird": "^3.5.4",
- "body-parser": "^1.19.0",
- "child_process": "^1.0.2",
- "cookie-parser": "~1.4.4",
- "debug": "~2.6.9",
- "ejs": "^2.6.1",
- "express": "~4.16.1",
- "express-ejs-layouts": "^2.5.0",
- "express-session": "^1.16.1",
- "http-errors": "~1.6.3",
- "instagram-private-api": "^0.10.1",
- "jsonwebtoken": "^8.5.1",
- "lodash": "^4.17.11",
- "morgan": "~1.9.1",
- "passport": "^0.4.0",
- "passport-jwt": "^4.0.0",
- "path": "^0.12.7",
- "pg": "^7.11.0",
- "pg-hstore": "^2.3.2",
- "sequelize": "^5.8.6"
- Used thread function and related function based core functions:
-
Threading: child process fork function.
Create bot by fork function:
arrBotProcess.push(fork(path.join(__dirname, '[process].js'))); arrBotProcessName.push(id); arrBotProcess[botNum].on('message', function(data) { if(data == 1) { // Validation part. } }); arrBotProcess[botNum].send(sendData);
Destroy bot by .kill() function:
for(var i = 0; i < arrBotProcessName.length; i++) { if(arrBotProcessName[i] == id) { arrBotProcess[i].kill(); // destroy bot by id arrBotProcessName[i] = "###"; } } // loop for bot list and pop empty bot arrBotProcessBackup = []; arrBotProcessNameBackup = []; for(var kk = 0; kk < arrBotProcessName.length; kk++) { if(arrBotProcessName[kk] != "###") { arrBotProcessBackup.push(arrBotProcess[kk]); arrBotProcessNameBackup.push(arrBotProcessName[kk]); } } // initialize and copy original thread array for bots with backup arraylist arrBotProcess = []; arrBotProcessName = []; arrBotProcess = arrBotProcessBackup.slice(0); arrBotProcessName = arrBotProcessNameBackup.slice(0);
-
Promising: get data from instagram using
instagram-private-api
.Example for promise
var feed = new Client.Feed.Inbox(session); var pFeed = new Promise(function(resolve) { return resolve(feed.get()); }); pFeed.then(function(results) { // manufactoring about results. });
-
Recursive function for sysncronization.
Example for recursive fucntion.
async function getNewInbox() { countResult--; // manufactoring for recursive. if(countResult > 0) { getNewInbox(); } } getNewInbox();
-
express my-new-express-app
Example of create model and migrate database.
sequelize init
sequelize model:create --name Bots --attributes name:string,filters:string,status:integer
sequelize db:migrate
.
├── bin
│ └── www
├── config
│ ├── config.json
│ └── env.js
├── controllers
│ ├── apiController.js
│ ├── boardController.js
│ ├── botController.js
│ ├── newBotProcess.js
│ └── userController.js
├── cookies
│ ├── gamer.wraps.json
│ └── super-sean.json
├── migrations
├── models
│ └── 20190530173910-create-user.js
├── node_modules
├── public
│ ├── app
│ │ ├── css
│ │ └── js
│ └── assets
│ │ ├── fonts
│ │ ├── images
│ │ ├── javascripts
│ │ └── stylesheets
├── routes
│ ├── api.js
│ ├── board.js
│ ├── bots.js
│ ├── index.js
│ └── users.js
├── seeders
├── services
│ ├── botService.js
│ ├── dashBoardService.js
│ └── passport.js
├── views
│ ├── pages
│ │ ├── allbots.ejs
│ │ ├── connect.ejs
│ │ ├── dashboard.ejs
│ │ ├── signup.ejs
│ │ └── login.ejs
│ ├── partials
│ │ ├── footer.ejs
│ │ ├── header.ejs
│ │ ├── scripts.ejs
│ │ └── sidebar.ejs
│ └── layout.ejs
├── .sequelizerc
├── package.json
└── README.md
- Use:
- Install npm-installer (https://nodejs.org/en/download/current/).
- postgres installer (https://www.apachefriends.org/download.html).
- Install nodemon
npm install -g nodemon
- Install sequelize
npm install -g sequelize-cli
Follow this steps:
# install node modules.
npm install
# database migrate.
sequelize db:migrate
# application start.
npm start
https://fezvrasta.github.io/bootstrap-material-design/ https://fezvrasta.github.io/bootstrap-material-design/docs/4.0/getting-started/introduction/ https://xdsoft.net/jqplugins/datetimepicker/
https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons https://use.fontawesome.com/releases/v5.0.6/css/all.css https://material.io/tools/icons/?icon=insert_comment&style=outline https://www.woolha.com/tutorials/node-js-express-persistent-session-store-with-postgresql-sequelize
- child_process
- instagram-privat-api ^0.10.1
- sequelize
- pg, pg-hstore
Please see the changelog for more information on what has changed recently.
We use GitHub Issues as the official bug tracker for the Material Kit. Here are some advices for our users that want to report an issue:
- Make sure that you are using the latest version of the Material Kit. Check the CHANGELOG from your dashboard on our website.
- Providing us reproducible steps for the issue will shorten the time it takes for it to be fixed.
- Some issues may be browser specific, so specifying in what browser you encountered the issue might help.
-
Copyright 2019 Creative Tim (https://www.creative-tim.com/?ref=adn-readme)
-
Licensed under MIT (https://github.com/creativetimofficial/argon-dashboard-nodejs/blob/master/LICENSE.md)
- Tutorials
- Affiliate Program (earn money)
- Blog Creative Tim
- Free Products from Creative Tim
- Premium Products from Creative Tim
- React Products from Creative Tim
- Angular Products from Creative Tim
- VueJS Products from Creative Tim
- More products from Creative Tim
- Check our Bundles here
Twitter: https://twitter.com/CreativeTim?ref=adn-readme
Facebook: https://www.facebook.com/CreativeTim?ref=adn-readme
Dribbble: https://dribbble.com/creativetim?ref=adn-readme
Instagram: https://www.instagram.com/CreativeTimOfficial?ref=adn-readme