#post #lemmy #configured #next #config-file #default #publish

bin+lib lemmy-scheduled-post-bot

Make posts to Lemmy based on the next configured post in a TOML file

2 releases

0.1.1 Oct 25, 2024
0.1.0 Oct 25, 2024

#2133 in Command line utilities

Download history 196/week @ 2024-10-23 19/week @ 2024-10-30 6/week @ 2024-11-06

221 downloads per month

GPL-3.0-or-later and AGPL-3.0

33KB
391 lines

lemmy-scheduled-post-bot

Make posts to Lemmy based on the next configured post in a TOML file.

  1. Set up a configuration file as described below.
  2. Run this program with that file as an argument, e.g. lemmy-scheduled-post-bot ./sample.toml.

This program then does the following:

  1. Identifies the configured post whose publish time has most recently passed.
  2. Checks to see if a post with the same instance/community/user/title has already been published, and if so exits early.
  3. Publishes the post.

Note that this does not run as a service, and must be invoked directly to run. It's recommended to use in conjunction with cron or the Windows Task Scheduler.

Configuration

This program takes as an argument the filename of a TOML file. This TOML file can contain the following sections:

settings (required)

The [settings] section must contain the following fields:

  • instance - The domain of an instance of Lemmy, i.e. "lemmy.world".
  • community - The community on that instance to which to post.
  • username_or_email - The login of the account that will make the post.
  • password - The password of the account.
  • enabled - If absent or false, the input file is validated but no server communication is attempted.

defaults (optional)

The [defaults] section can contain all the same fields as [[post]], and if a field is absent in the post, the default field's value is used.

post

One or more [[post]] sections can be supplied, each of which can contain the following fields:

  • post_at (required) - A date and time when the post should be published. Should be a string in ISO 8601 format.
  • title - The name of the post.
  • body - The text content of the post in Markdown format.
  • link - The URL content of the post.
  • thumbnail - A URL to an image that should appear alongside the post.
  • alt_text - A text description of the thumbnail.

Templating

The post fields support limited template substitution. Supply custom fields in the [defaults] or [[post]] sections, and reference them within the post fields within braces like so: "My name is {name}.". Templating is not recursive, and only the defined post fields will be interpolated. See sample.toml for a full example.

License

Copyright (C) 2024 Steven Vergenz Licensed under the terms of the General Public License 3.0 or later

Dependencies

~17–30MB
~475K SLoC