Skip to content

Instantly share code, notes, and snippets.

@EsteveSegura
Created September 28, 2019 13:44
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/6257f1836929dfe45eece10030d00a28 to your computer and use it in GitHub Desktop.
Save EsteveSegura/6257f1836929dfe45eece10030d00a28 to your computer and use it in GitHub Desktop.
tfi instagram structute
const tfi = require('tools-for-instagram');
//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"}
]}
setTimeout(async() => {
let ig = await login();
let allPosts = await getPostsFromHashtags(ig,hashtags)
//We start our interval
setInterval(async() => {
//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(async (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);
}, 400);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment