A simple Twitter bot template


#1

Project URL: https://gomix.com/#!/project/twitterbot

Just a quick template for making Twitter bots that uses the Twit node.js library. The README has some useful links to tutorials and open source Twitter bot code.


#2

Saw this on Twitter too :slight_smile: Really cool! Thanks for sharing!


#3

Thanks for submitting this @stefan - we’d love to add it to our community gallery. If you’re interested, we’ve put together a guide covering what makes for a good gallery project - https://creators-guide.gomix.me/.


#4

I just updated the README, but I have a question.

If the setup instructions are more than a few lines, then add a setup.md file to your project and use that to go into the detail.

Right now, I am referencing my own tutorial on setting up a new Twitter app and obtaining the API key/secret. Is this enough, or should I just copy over the relevant portion of the tutorial to SETUP.md?


#5

That tutorial looks pretty comprehensive, and we have some other projects that refer to tutorials elsewhere too, so it’s enough for sure!


#6

Okay, cool, thank you!

In that case, unless you have any suggestions, I think the project is ready :slight_smile:


#7

Thanks, I’ve added it!


#8

Really cool, thank you!


#9

A quick question. I’m trying to find out the most up-to-date information on application idling. Does the app still go to sleep if there are no http requests to it for a while?

The problem is, if you make a bot that posts on a set schedule (for example a cat picture every 25 minutes), it won’t really be getting any traffic.

And the only way I can think of solving this is to periodically ping my app to keep it alive…which I know is frowned upon.

Also, to hijack my own thread, is it possible to create folders in the back-end section?

I’m basically trying to port github.com/fourtonfish/random-image-tweet to Glitch. (Relevant to my question above.)


#10

Apps do go to sleep if there are no request for a while. It is currently difficult to use Glitch for apps that trigger on scheduled events, though we plan to make things like that easier in the future. Until then, you may be able to find a service that will ping and endpoint on your app periodically and use it as a timer to trigger the events.

To create folders on the backend you can enter somefolder/somefile.js when creating a new file and it should automatically create the folder.

Hope this helps :slight_smile:


#11

Thank you!

Yes, @jen actually figured this out, that you can create a folder that way.

Is it possible to upload files to it?

I’m writing a short guide on importing open-source bots to Glitch, using https://github.com/fourtonfish/random-image-tweet as an example.

The real problem here is that the images folder is not carried over after importing.

Also, someone on here discouraged attempting to use an app to ping itself to keep it awake. Is this any different from using a third party service, or has the official stance on this approach changed?


#12

I am curious about any official stance about it to.

My FB bot uses the ‘cron’ node package to perform a cronjob and send scheduled messages.

Is that ok?


#13

The images folder will probably be there after import, it’s just that binary files aren’t shown in the editor, but if you reference them in that folder location they’d work. We do however recommend uploading your images separately to the assets store.


#14

Thank you, I’ll test this later tonight.

Any comments on keeping applications that don’t receive http traffic alive through pinging? (See earlier messages.)


#15

Okay, so I finished the tutorial on random-image-uploading bot (https://botwiki.org/tutorials/random-image-tweet/), and I started working on the github-to-glitch importing guide, and I learned a thing or two about how Glitch works: https://botwiki.org/tutorials/importing-github-glitch/

The Glitch project is a bit “work in progress”, especially after I tried to edit it in my phone while riding the subway.

(And I know the API keys are missing, I don’t have a spare bot to run this on. I’ll get into that in a bit.)

So, I have a few questions.

I figured out that the files in the assets folder aren’t physically uploaded to Glitch, rather to a CDN, and then referenced in .glitch-assets. What happens if I update that file manually? Is there a way to actually delete the files, so that user can upload more images without filling up disk space?

(The idea here being, user sets up the random-image-posting bot, but instead of cycling through the images over and over, each image gets deleted after posting, and user can then upload more images.)

Oh, side note, is there a way to shut down the app? Basically, I’d like to keep the project for remixing, but without running the actual bot.

I do realize I could just export the project to GitHub, and then delete it, so this is mostly a non-issue. But that does prevent the project from being featured in the gallery.


#16

Pinging your app every 25 minutes or so is fine, just search for ‘web cron service’ and you’ll find a bunch of free services.

Ah, if you’re automatically uploading/deleting files, then handling them in a local folder in your project might be easier rather than using the assets store. That’s mostly for manual use.

The app sleeps after 5 minutes, and so long as you’ve created an account (logged-in with GH or FB) it’ll stay around.


More information on technical limitations
#17

I made another template project, this one lets you set up an auto-replying Twitter bot (with a 25 minute delay):


#19

I figured out that the files in the assets folder aren’t physically uploaded to Glitch, rather to a CDN, and then referenced in .glitch-assets. What happens if I update that file manually? Is there a way to actually delete the files, so that user can upload more images without filling up disk space?

Ah, if you’re automatically uploading/deleting files, then handling them in a local folder in your project might be easier rather than using the assets store. That’s mostly for manual use.

Just to follow up on this, my decision to use the assets folder was to make the tutorial/project template more beginner-friendly.

With that being said, is it possible to delete the images programmatically?