Twitter image bot not working

Hi!
About four years ago, a friend and I remixed a random image bot to post pics on twitter. We used easycron for it and it ran for about two years until we stopped paying.

We decided we want it to work again, and when we test it on easycron the status says it succeeded, however nothing’s getting posted on our twitter page. We don’t know how to code by the way, so…we really can’t figure it out.
Any ideas? Thanks!

Hi @ed_perkins, author of the original project here.

Could you please modify your code so that it logs any errors?

helpers.loadImage(url, (error, imageData) => {
  console.log("loading image", url);

  if (error){
    console.log("there was an error loading the image:", error);
  } else {
    twitter.postImage(helpers.randomFromArray([]), imageData, (error) => {
      if (error){
        console.log("there was an error posting the image:", error);
      } else {
        let removePostedImages = process.env.REMOVE_POSTED_IMAGES;
        if (removePostedImages === "yes" || removePostedImages === "true") {
          helpers.removeAsset(url);
        }
      }
    });
  }
});

Also, note that pinging a sleeping project is no longer allowed on Glitch, so maybe that’s the real issue here. Glitch banning use of pinging services | Botwiki

this does sound like it would have been (debatably) collateral damage in the block on “pinging.”

you’ll want to make sure that these requests have a “User-Agent” header, or Glitch will send them into a non-project-waking-up black hole.

and I don’t suppose configuring an http header is in easycron’s free plan. and if you’re going to pay to solve this problem, you might as well also consider glitch’s paid plan, which lets you run a project always instead of on demand.

and whichever way you do it, be mindful of using abusively many resources particularly for automated things like this

1 Like