plane-notify
plane-notify copied to clipboard
How do I delay a tweet?
How do I delay a tweet? I have plane bot that I don't want suspended. It's still live. How do I delay the tweet? Also, I heard you have to delay by 24 hours. Is that true?
Why not just use some sql tool or even simpler a csv and store the alerts. Then add it to your process to check the stored alerts each time it runs and if something is now old enough to send the alert? Seems like an easier process than to queue something to send to Twitter later.
For help with Twitter Policy you should Contact Twitter.
As far as I can tell, this code does not natively allow delayed tweets, you would need to create a storage and tweet from that storage, or come up with another means.
I'm going to look into doing this, I have plans for a major redesign of this project to integrate an SQL database, probably Postgres by choice. Configs are stored in the database instead. Log flights etc... would live output to all platforms except Twitter. Another Micro service would tweet 24 hours after the flight. (Yes @bell-kevin 24 hours is correct I think they said like "next-day")
https://github.com/LandonTClipp/plane-spotter
I will be adding a delay functionality to my project soon. I think getting heavyweight databases involved would discourage people from creating their own instance. You can instead use something like celery which is specifically meant for fanning out jobs to worker processes. It's used a lot in Django apps.
Of course, a database would make it harder to set up, but I've been meaning to do this as I want to build a web frontend that connects to this and log flights. @makrsmark as someone who uses the bot, any comment?
@Jxck-S you should look into Django, it's a python web framework that has tons of history and support. There are a lot of pre-packaged solutions for exactly the kind of thing you're looking for. Django has native integration for job queues (like celery) which would be good for posting delayed tweets. Also a lot of automated tooling for creating database models, like storing config, plane-specific information, or whatever. All packaged into django for you.
Not sure if you're looking more for a personal project but I would be willing to lend my time to help with that where possible.
I use this app via docker, so it shouldn't be terrible to add a DB and pass through persistent storage through docker compose. As for the delay, I'll just take the twitter ban and move elsewhere (already wip) if my bot ever gets big enough. There's also a lot of ask for just providing this as a service, which you'd need a db for anyway, but at that point, I'd probably just be a customer instead of running my own. I'm willing to help, but I don't want to dictate the direction of the project.
So, I've been doing some testing with Zapier for the required delay. It will take a Discord message to a specific channel/server, delays it for however long you ask it to, then reformats it to post on a Twitter account. Downside is that if you generate too many messages, they will start charging you for what they call "tasks". But there is a free account if you can stay under the limit. It can at least be a stop gap until a delay is written into the code.
Can you give us the process for how you did/do it @brickhousetech ?
It's pretty simple, really. Below is a screen shot where you create the trigger, delay action, then tweet action. You just set the delay to 24 hours. It even posts the image as native in Twitter. When I look at their pricing plans, it would require the $30 a month plan because it has two actions. But this can help until Jack and others can write a delay method within the project.
I'll post what it looks like on Twitter once I'm ready to disclose what I'm tracking, or just try it yourself. Tracking a couple of police helicopters to start off, which will probably piss them off. The agency has them LADD flagged, which I find fascinating because the single sentence in the 2018 FAA reauth act that supposedly prompted the FAA to create LADD and PIA mentions only private aircraft owner/operators have the ability to block their registration from being disclosed. Personally, I don't believe anyone has a reasonable expectation of privacy when they transmit signals using public airwaves and make use of public airspace. No different than driving your car down the road. That's what drew me to this project and seeing how I could use it to better help the public understand how their tax money is being used with these government aircraft. I fully support what Jack is doing and glad to see the project continue to be developed. Very grateful he decided to make the code public.

It's pretty simple, really. Below is a screen shot where you create the trigger, delay action, then tweet action. You just set the delay to 24 hours. It even posts the image as native in Twitter. When I look at their pricing plans, it would require the $30 a month plan because it has two actions. But this can help until Jack and others can write a delay method within the project.
I'll post what it looks like on Twitter once I'm ready to disclose what I'm tracking, or just try it yourself. Tracking a couple of police helicopters to start off, which will probably piss them off. The agency has them LADD flagged, which I find fascinating because the single sentence in the 2018 FAA reauth act that supposedly prompted the FAA to create LADD and PIA mentions only private aircraft owner/operators have the ability to block their registration from being disclosed. Personally, I don't believe anyone has a reasonable expectation of privacy when they transmit signals using public airwaves and make use of public airspace. No different than driving your car down the road. That's what drew me to this project and seeing how I could use it to better help the public understand how their tax money is being used with these government aircraft. I fully support what Jack is doing and glad to see the project continue to be developed. Very grateful he decided to make the code public.
![]()
Yooo didn't know zapier has a delay ill have to use this till I update the program to have a delay feature for twitter
Yooo didn't know zapier has a delay ill have to use this till I update the program to have a delay feature for twitter
Glad it can be of some help. Just be aware that each successful "Zap", meaning the trigger worked, that includes a delay counts for two tasks. They count each action as a task. I've added another to mine in order to reformat the date as it comes in a bit wonky otherwise. It could get expensive for more than light use.
This is what I ended up with as a working step by step. Lost some posts due to changing the Zap while tasks were delayed.
1). Post made in selected Discord channel. 2). Filter out any post with "Sel. Alt." in it as those are just noise. 3). Reformat date/time to be more user friendly and readable. 4). Delay 24 hours 5). Post Tweet.
Any questions, feel free to reach out and I'll be glad to help.

I could write a simple workaround (meaning temporary fix), ugly and poor, but I think it'd work fine till a permanent change is done. It would consist on, instead of posting to twitter, save the info to a csv file (bellow I use a '|||' separated file lol) and make the script read the file every loop to check. Let me know if it would be usefull and I can try to code it.
main.py:
#Setup Tweepy
if self.config.getboolean('TWITTER', 'ENABLE') and Plane.main_config.getboolean('TWITTER', 'ENABLE'):
import tweepy
"blah"
# The loop checks if delay
sch_tweet_list = open("configs/sch_tweets").read().splitlines()
for i, line in enumerate(sch_tweet_list): # Check lines in "data base" lol
plane_time, map_file_name, status, icao, alt_text= line.split("|||") # informations needed to post a tweet, IDK what they are
if ((self.config.getint('TWITTER', 'ENABLE')*60) - (datetime.now() - datetime.strptime(plane_time, "%Y/%m/%d - %H:%M:%S")).total_seconds()) < 0:
# If all good, posts tweet
import tweepy
try:
twitter_media_map_obj = self.tweet_api.media_upload(map_file_name)
self.tweet_api.create_media_metadata(media_id= twitter_media_map_obj.media_id, alt_text= alt_text)
self.latest_tweet_id = self.tweet_api.update_status(status=status, media_ids=[twitter_media_map_obj.media_id]).id
except tweepy.errors.TweepyException as e:
raise
planeClass.py:
#Twitter
if self.config.getboolean('TWITTER', 'ENABLE') and Plane.main_config.getboolean('TWITTER', 'ENABLE'):
try:
icao = Plane.main_config.get("DATA","ICAO")
plane_time = str(datetime.now().strftime("%Y/%m/%d - %H:%M:%S"))
map_file_name = self.map_file_name
alt_text = f"Reg: {self.reg} On Ground: {str(self.on_ground)} Alt: {str(self.alt_ft)} Last Contact: {str(time_since_contact)} Trigger: {trigger_type}"
status = (self.twitter_title + " " + message).strip()()
tweet_line = f"{plane_time}|||{map_file_name}|||{status}|||{alt_text}\n" # Probably missing few info here
with open("configs/sch_tweets", "a+") as elon:
elon.write(tweet_line)
except Exception as e:
raise
I made https://github.com/Jxck-S/plane-notify-delayed seems to be working so far.