Skip to content

Instantly share code, notes, and snippets.

@ywindish
Last active June 21, 2023 07:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ywindish/a96197b34aa55e0bea35045b4256f4fd to your computer and use it in GitHub Desktop.
Save ywindish/a96197b34aa55e0bea35045b4256f4fd to your computer and use it in GitHub Desktop.
Mastodonに毎日ランダムな時間で予約投稿するbot
# crontab とかで 0:00 に実行するといい感じ
# encoding: utf-8
require 'mastodon'
require 'date'
message = "らんだむに投稿されるよ"
url = "https://mastodon.example.com"
token = 'xxxxxx'
client = Mastodon::REST::Client.new(base_url: url, bearer_token: token)
scheduled_at = "#{Date.today().strftime('%Y-%m-%d')}T#{rand(23)}:#{rand(59)}+09:00"
client.create_status(message, { scheduled_at: scheduled_at })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment