1

I've been messing around with tweepy as a way to get into learning basic python script writing. I figured out how to tweet via an edited text document to .py script and to send direct messages. Is there a way to send a timed or scheduled direct message in seconds or minutes? Code I use below

import tweepy

auth = tweepy.OAuthHandler("key", "key")

auth.set_access_token("key", "key")

api = tweepy.API(auth)

recipient_id = "twitter id"

api.send_direct_message(recipient_id, "Hey")

Is there anything I can add to set a timer on the direct message?

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • 1. You can use `import time; time.sleep(SECONDS)`. 2. You can pass arguments to your script and call it from outside (cron lets you schedule commands, ...?). – Tin Nguyen May 06 '22 at 14:34
  • Thank you, the import time; time.sleep() code did the trick! – juniorprogrammer88 May 07 '22 at 00:34
  • Take a look onto the [scheduler library](https://github.com/DigonIO/scheduler) for python . See here for an [example on stack overflow](https://stackoverflow.com/questions/47356453/python-schedule-jobs-with-different-timezones/68458018#68458018). – jpotyka May 07 '22 at 15:24

0 Answers0