GithubHelp home page GithubHelp logo

reidjs / markdown-tweet-scheduler Goto Github PK

View Code? Open in Web Editor NEW
101.0 5.0 9.0 33 KB

Schedule daily tweets from markdown files in your repo, posted via github actions.

License: MIT License

Go 100.00%
twitter twitter-api markdown hacktoberfest hacktoberfest-2022

markdown-tweet-scheduler's Introduction

โš ๏ธ This may not work anymore given the recent Twitter (X) API changes, sorry!

markdown-tweet-scheduler

Schedule tweets from markdown files in your repo, posted to twitter via github actions.

Now supports .txt as well as .md files!

Why

  • View, edit, and post your tweets without logging into twitter
  • Keep source controlled backups of your tweets
  • Free and open source

Setup

  1. Clone this repo and push it to your own private repo.
  2. Get your credentials by creating a twitter app (https://developer.twitter.com/apps)
  3. Add your twitter credentials to the repository's secrets (https://docs.github.com/en/actions/reference/encrypted-secrets)
    • API_KEY (known as consumer_key in twitter API)
    • API_SECRET_KEY (known as consumer_secret in twitter API)
    • ACCESS_TOKEN
    • ACCESS_TOKEN_SECRET

Scheduling Tweets By Date

  1. Create a markdown file in the ./tweets/ folder with a future date in either the YYYY-Mon-DD or Month dd, YYYY format, for example, 2021-Sep-05.md or September 5, 2021.md, and write the content of your tweet in it.
  2. Commit the file(s) and push to the remote repo. When the daily action runs on the specified date, the tweet should be posted.

Configuration

  1. By default, posts tweets around 7:02AM PT (2:02 UTC). To change the time of day tweets are posted:

    • Set the cron section of .github/workflows/go.yml to the time you want the tweet to post https://cron.help/
  2. Changing the tweet directory:

    • Change the FILE_PATH environment variable in .github/workflows/go.yml

Running locally

  1. rename .env-SAMPLE to .env and fill in your twitter credentials
    • consumer_key == API_KEY
    • consumer_secret == API_SECRET_KEY
  2. In your terminal, from the root directory: go run .

Notes

  1. Fails silently on bad credentials, make sure you set those correctly.
  2. Only allows one tweet per day by design. If requested, this can be modified to allow tweets by the minute or hour.
  3. Tweets will not be posted exactly at the cron time set in go.yml. In my experience in can be 5-10 minutes late. If you need minute precision, run this script locally on a cronjob.

markdown-tweet-scheduler's People

Contributors

caioeverest avatar privateger avatar reidjs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

markdown-tweet-scheduler's Issues

Is there a way to embed images from markdown?

Hello,

Thanks for the project, it is really interesting and looks to be super useful.

Just a few quick questions.

  1. Does this support image embeds via md syntax? If yes, can some examples be included in docs. If not, what actions/changes required at overview level?
  2. Can I pick/specify link previews from the target page, like in Buffer? See image below.
image

Feature Request: Schedule Multiple Tweets Per Day

If hour and minutes are present in a Tweet's filename, a github action to post that tweet should run at the given datetime. If only Month, Day, Year are in the filename, it should run at the default time of day.

Example:
August 17, 2021.md posts at regular time
August 17, 2021 11:53.md posts at 11:53am GMT
August 17, 2021 14:22.md posts at 2:22pm GMT

It would be even better if there was a config var called 'TIMEZONE' in the .env so instead of GMT it would set it to local time ๐Ÿค”

Add tests

Tests to write:

  1. if no scheduled tweets, posts a queued tweet
  2. if no queued tweets, fails gracefully
  3. check renaming scheme (posted, failed, attempted)

Add a queue system

Allow queueing daily posts to prevent having to pick a date to post
Idea:
file names starting with the letter q are picked in order, (lowest q goes first)
q0.md
q1.md
q2.md
q12.md
etc

Queueing system will post the same tweet post if user doesn't rename the file after posting

Queueing system shouldn't be used until this is fixed (Post by date should be unaffected)

The github action doesn't rename the file in the repo, so it will just post the highest priority tweet every day (q-1).

After posting a queued tweet, we have to automatically:

  1. rename the file to something that doesn't start with q-, ideally the name should be updated to the date it was posted
  2. commit the name change and,
  3. push the updated file to the repo.

Otherwise, at the next run it will attempt to tweet the same thing again.

Allow different date format

IA Writer only allows you to quick insert dates as

  • July 26, 2021
  • June 4, 2021
  • February 19, 2021
  • etc
    It would be nice to allow this format as well

Add an interface to check the order of tweets at a glance

I want to know the next tweet(s) to be posted from the remote repo using my local machine

One way this could work is that on push it generates a file of future tweets, in order of when they will be posted in descending order.

It would be cool if that file would act as the source of truth and would be parsed by the script to determine the next tweet

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.