Last active
February 9, 2021 02:20
-
-
Save ywindish/24bd13951801e6db551a532fcee2b932 to your computer and use it in GitHub Desktop.
Images in folder be posted to Mastodon instance at random
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mastodon' # https://github.com/tootsuite/mastodon-api | |
message = '#hashtag' | |
pattern = '/path/to/image_files/*.jpg' | |
path = Dir.glob(pattern).sample | |
client = Mastodon::REST::Client.new(base_url: 'https://fedibird.com', bearer_token: ENV['MASTODON_TOKEN']) | |
media = client.upload_media(File.new(path)) | |
client.create_status(message, media_ids: [media.id]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment