linkfy / Tools-for-Instagram

Automation scripts for Instagram
MIT License
502 stars 76 forks source link

Alert when post with hashtag is posted #23

Closed quintendewilde closed 3 years ago

quintendewilde commented 4 years ago

Is it possible to create an alert of a message every time a hashtag is used in a post?

linkfy commented 4 years ago

Post published by your account or external account? Or by any post around all instagram?

quintendewilde commented 4 years ago

The latter or at least a substantial group?

Possible?

On Thu, 30 Apr 2020 at 11:51, linkfy notifications@github.com wrote:

Post published by your account or external account? Or by any post around the hole instagram?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/linkfy/Tools-for-Instagram/issues/23#issuecomment-621731530, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOARUMAIMUDPU5OWDATVSDRPFCY7ANCNFSM4MTVVCVA .

linkfy commented 4 years ago

There is a limit of requests per minute in instagram, that's why it is difficult to analyze all hashtags, you need to set a new time interval and get the recent activity every X minutes.

let posts = await recentHashtagList(ig, hashtag);

quintendewilde commented 4 years ago

Cool, I got your tool to work. Very nice!

where exactly should I put that?

If this would work every ten minutes that would be awesome!!

Oyetomi commented 4 years ago

Put the whole process in a function, and Use Cron or a scheduler to automate the process

On Sun, 3 May 2020, 5:39 pm QuintenDeWilde, notifications@github.com wrote:

Cool, I got your tool to work. Very nice!

where exactly should I put that?

If this would work every ten minutes that would be awesome!!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/linkfy/Tools-for-Instagram/issues/23#issuecomment-623139403, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFB4NEXOJYY6KGCWXKGQRSDRPWM4DANCNFSM4MTVVCVA .

quintendewilde commented 4 years ago

Which process or do you mean a certain bot in the bots folder. Cron job I can do easily. But the code is a bit harder for me to comprehend.

Oyetomi commented 4 years ago

Post the code here

On Sun, 3 May 2020, 5:45 pm QuintenDeWilde, notifications@github.com wrote:

Which process or do you mean a certain bot in the bots folder. Cron job I can do easily. But the code is a bit harder for me to comprehend.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/linkfy/Tools-for-Instagram/issues/23#issuecomment-623140932, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFB4NEUJHN2N6DFUCRYAIJDRPWNQ7ANCNFSM4MTVVCVA .

quintendewilde commented 4 years ago

Yeah I noticed that my es6 is even worse then my basic js knowledge.

For the moment I just cleaned an existing code to the bare minimum of fetching the count of the hashtags.

I will need to figure out how to send that number via osc. Thats another question for another place probably.

But what I can't figure out is that I can't seem to end the code and get back to the cli. Because that would be easier to create my cron job eventually?

Thanks again!

require('../src/tools-for-instagram.js');

(async() => {

    let hashtag = "cat";
    console.log("\n -- Hashtag counter --\n".bold.underline);
    let ig = await login();

    let posts = await recentHashtagList(ig, hashtag);
    console.log("Posts received with hashtag: ".cyan + posts.length);
    let promises = [];
    for (let i = 0; i < posts.length; i++) {
        let post = posts[i];

    }
    Promise.all(promises).then(function() {
        console.log("end");
    });

})();
Oyetomi commented 4 years ago

Looks like you just posted half part of your script 😏....

require('../src/tools-for-instagram.js');
var schedule = require('node-schedule');

//install node-schedule with
//npm i node-schedule

(async() => {
  Console.log("Hashtag Script")

  async function hashtag(ig) {
    let hashtag = "cat";
    console.log("\n -- Hashtag counter --\n".bold.underline);
    let ig = await login();

    let posts = await recentHashtagList(ig, hashtag);
    console.log("Posts received with hashtag: ".cyan + posts.length);
    let promises = [];
    for (let i = 0; i < posts.length; i++) {
        let post = posts[i];

    }
    Promise.all(promises).then(function() {
        console.log("end");
    });
  }
// every 10 minutes do hashtag job
     schedule.scheduleJob('*/10 * * * *', async function () { await hashtag(ig)});

})();
Oyetomi commented 4 years ago

If it worked close the issue

quintendewilde commented 4 years ago

Hi,

I would have run the corn job as a terminal python script. But this node-schedule is better. Only thing is npm i node-schedule or others wont install or appear in my node_modules. And I tried the link for linux (working on mac) for errors with npm. But the link is not working.

let ig = await login();

seems to be a duplicate declaration, no? I'm still struggling with the promise aspect of js. So my apologies if I'm wrong.

Otherwise, you pretty much solved the whole thing for me so thanks ahead for that alone!

Oyetomi commented 4 years ago

Yes sorry, I've edited the script , Make sure you're using the latest node version, all installation should be ran at the root of the directory. You're welcome.

On Tue, 5 May 2020, 1:35 pm QuintenDeWilde, notifications@github.com wrote:

Hi,

I would have run the corn job as a terminal python script. But this node-schedule is better. Only thing is npm i node-schedule or others wont install or appear in my node_modules.

let ig = await login();

seems to be a duplicate declaration, no? I'm still struggling with the promise aspect of js. So my apologies if I'm wrong.

Otherwise, you pretty much solved the whole thing for me so thanks ahead for that alone!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/linkfy/Tools-for-Instagram/issues/23#issuecomment-624028847, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFB4NETJ46ANONSHNFOO47LRQABZPANCNFSM4MTVVCVA .

Oyetomi commented 4 years ago

Close the issue

quintendewilde commented 4 years ago

I have to reopen this because I can't find the solution somewhere else.

I get this error

/home/pi/Tools-for-Instagram/bots/hashtagcount.js:14
    leg ig = await login();  
        ^^

SyntaxError: Unexpected identifier
    at Object.compileFunction (vm.js:344:18)
    at wrapSafe (internal/modules/cjs/loader.js:1106:15)
    at Module._compile (internal/modules/cjs/loader.js:1140:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10)
    at Module.load (internal/modules/cjs/loader.js:1040:32)
    at Function.Module._load (internal/modules/cjs/loader.js:929:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

and used this code that you gave me @virginsince1997

require('../src/tools-for-instagram.js');
var schedule = require('node-schedule');

//install node-schedule with
//npm i node-schedule

(async() => {
  Console.log("Hashtag Script")

  async function hashtag(ig) {
    let hashtag = "cat";
    console.log("\n -- Hashtag counter --\n".bold.underline);
    let ig = await login();

    let posts = await recentHashtagList(ig, hashtag);
    console.log("Posts received with hashtag: ".cyan + posts.length);
    let promises = [];
    for (let i = 0; i < posts.length; i++) {
        let post = posts[i];

    }
    Promise.all(promises).then(function() {
        console.log("end");
    });
  }

// every 10 minutes do hashtag job schedule.scheduleJob('/10 *', async function () { await hashtag(ig)});

})();

Oyetomi commented 4 years ago
require('../src/tools-for-instagram.js');
var schedule = require('node-schedule');

//install node-schedule with
//npm i node-schedule

(async() => {
  Console.log("Hashtag Script")
let ig = await login();

  async function hashtag(ig) {
    let hashtag = "cat";
    console.log("\n -- Hashtag counter --\n".bold.underline);

    let posts = await recentHashtagList(ig, hashtag);
    console.log("Posts received with hashtag: ".cyan + posts.length);
    let promises = [];
    for (let i = 0; i < posts.length; i++) {
        let post = posts[i];

    }
    Promise.all(promises).then(function() {
        console.log("end");
    });
  }
// every 10 minutes do hashtag job
     schedule.scheduleJob('*/10 * * * *', async function () { await hashtag(ig)});

})();
Oyetomi commented 4 years ago

Let me know if it works, I'm not always here

quintendewilde commented 4 years ago

It works it was a very stupid mistake! Thanks thoug!

Op di 12 mei 2020 om 15:15 schreef virginsince1997 <notifications@github.com

Let me know if it works, I'm not always here

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/linkfy/Tools-for-Instagram/issues/23#issuecomment-627337119, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOARUKGQ5CK5N23OAHWPW3RRFDX3ANCNFSM4MTVVCVA .

Oyetomi commented 4 years ago

It works it was a very stupid mistake! Thanks thoug! Op di 12 mei 2020 om 15:15 schreef virginsince1997 <notifications@github.com Let me know if it works, I'm not always here — You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub <#23 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOARUKGQ5CK5N23OAHWPW3RRFDX3ANCNFSM4MTVVCVA .

OK sir, no worries.

quintendewilde commented 4 years ago

@virginsince1997 I'm sorry I have to bother you with this somewhat non related question. But as I'm stuck with this last piece of my project I'm in despair to find solutions for it. And again it's the part I know least of, the javascript.

I got the example (perfectly working code! :)) you gave me. I want the value or number of the hashtag to be used in another function. This function is a small osc nodejs based code that sends a value to my main project. And I want the number of hashtags to be the value that's send to my other software (sonicpi). But for some reason the basic javascript I know is not working (real basic I mean ofcourse)

I figured out that this works asynchronous. But I have no clue how to get this working and I'm running out of time for the project :/

If you find the time to spare to just take a look at this? I'd would be very greatly appreciated!


require('../src/tools-for-instagram.js');
var schedule = require('node-schedule');

(async() => {
    console.log("Hashtag Script")
    let ig = await login();

    async function hashtag(ig) {
        let hashtag = "cat";
        console.log("\n -- Hashtag counter --\n".bold.underline);

        let posts = await recentHashtagList(ig, hashtag);
        console.log("Posts received with hashtag: ".cyan + posts.length);

    const OSC = require('osc-js')

    const config = { udpClient: { port: 4560 } }
    const osc = new OSC({ plugin: new OSC.BridgePlugin(config) })

    osc.open(); // start a WebSocket server on port 8080

    // For most Ports, send() should only be called after the "ready" event fires.
        oscPort.on("ready", function() {
            oscPort.send({
                address: "/osc*/play/note",
                args: [{
                    type: "f",
                    value: 440 // here should the number of the hashtag result come...
                }]
            });
        });
        let promises = [];
        for (let i = 0; i < posts.length; i++) {
            let post = posts[i];

        }
        Promise.all(promises).then(function() {
            console.log("end");
        });
    }
    // every 10 minutes do hashtag job
    schedule.scheduleJob('*/10 * * * *', async function() { await hashtag(ig) });

})();
quintendewilde commented 4 years ago

Looks like you just posted half part of your script 😏....

require('../src/tools-for-instagram.js');
var schedule = require('node-schedule');

//install node-schedule with
//npm i node-schedule

(async() => {
  Console.log("Hashtag Script")

  async function hashtag(ig) {
    let hashtag = "cat";
    console.log("\n -- Hashtag counter --\n".bold.underline);
    let ig = await login();

    let posts = await recentHashtagList(ig, hashtag);
    console.log("Posts received with hashtag: ".cyan + posts.length);
    let promises = [];
    for (let i = 0; i < posts.length; i++) {
        let post = posts[i];

    }
    Promise.all(promises).then(function() {
        console.log("end");
    });
  }
// every 10 minutes do hashtag job
     schedule.scheduleJob('*/10 * * * *', async function () { await hashtag(ig)});

})();

Hey, I've been using this script for a while now. I thought this worked but I see that whatever keyword I give or how many times I run it. The result is always either 84,85,86 is this coincidence or is the script not working?

Any help is kindly appriciated!

linkfy commented 4 years ago

recent hashtag list are the last posted ones on that hashtag, right now there ate 2 options: -scans the same hashtag every x minutes and make a database, -use the web api and get older hashtags by using the "next cursor" -modify the current library to accept a new parameter to scan older recent hashtags recentHashtagList(ig, hashtag) to something like recentHashtagList(ig, hashtag, defaultIterations = 1)