Skip to content

Instantly share code, notes, and snippets.

@EsteveSegura
Created September 28, 2019 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EsteveSegura/57003be0a57ab5954c57af8b6f9d2374 to your computer and use it in GitHub Desktop.
Save EsteveSegura/57003be0a57ab5954c57af8b6f9d2374 to your computer and use it in GitHub Desktop.
tfi and simple structure
const tfi = require('tools-for-instagram');
//tfi doing login
let ig = login();
//hashtags on which we are going to act
const hashtags =[
"vegan",
"vegetarian",
"govegan",
"veganfood",
"organic",
]
//We create schedules in which our bot will have activity
const intervals = { schedulesOfTheDay: [
{startHour: 08, startMinute: 00, action: "likes"},
{startHour: 10, startMinute: 00, action: "likes"},
{startHour: 13, startMinute: 00, action: "likes"},
{startHour: 16, startMinute: 00, action: "likes"},
{startHour: 20, startMinute: 00, action: "likes"},
{startHour: 23, startMinute: 00, action: "likes"},
{startHour: 17, startMinute: 00, action: "uploadPhoto"}
]}
//We start our interval
setInterval(() => {
//Every time our interval is executed we get the hour and minute
let currentDate = new Date()
let getHour = currentDate.getHours();
let getMinutes = currentDate.getMinutes();
/*
We check the list of our schedules and compare
it with the current time, if our schedule and
the current time is the same we execute the action
*/
intervals.schedulesOfTheDay.forEach(time => {
if(getHour == time.startHour && getMinutes == time.startMinute && time.action == "likes"){
//This is where we are going to give likes in certain hashtags
}
if(getHour == time.startHour && getMinutes == time.startMinute && time.action == "uploadPhoto"){
//This is where we are going to upload photos to instagram
}
});
//This is the parameter of our interval, which is at 60000ms ( 1 minute )
}, 60000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment