Download the PHP package crell/mastobot without Composer

On this page you can find all versions of the php package crell/mastobot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package mastobot

Mastobot

Latest Version on Packagist Total Downloads

Mastobot is a simple scheduled-post bot for Mastodon. It is intended for single-user situations, where someone wants to self-host Mastodon automation. It is intended to run via a cron task.

Common use cases include posting daily quotes from a set collection, or a slowly serialized (but automated) story.

Installation

The easiest way to install Mastobot and keep it up to date is to clone the Git repository, and then check out the latest tag.

Then run composer install to install the necessary dependencies.

Finally, set up cron (or the scheduling tool of your choice) to run the following command fairly frequently:

Mastobot will only post messages when cron runs, so, for example, if the bot runs hourly then all posts will happen on the hour. If you'd prefer to have a random-seeming schedule, use a prime number of minutes (say, every 13 or 17 minutes).

Configuration

Mastobot is controlled via a mastobot.yaml file in project root. The available keys are below.

app_name (required)

The name of your bot. Should be a short, semi-unique human-readable name. "Mastobot" is a reasonable default.

accounts (required)

This is a named dictionary of account connection information. There are four properties, all required. The name of each account definition will be used by the posters list below, but is otherwise an arbitrary string.

app_instance (required)

The Mastodon instance to which the bot will post. It should be just the domain name, no http or anything. So mastodon.social, phpc.social, etc.

Authentication information (required)

There are three identifiers you need from your profile to authenticate any Mastodon bot. Mastobot does not include a mechanism to auto-generate those for you, by design, but they're simple to generate from the UI.

In your Settings page, select the "Development" tab. Click the "New Application" button. Provide a name for the application that is specific to you.

You may leave the rest of the settings at their default. Or, if you'd rather lock down the bot's access, write:statuses and write:media are the only required permissions.

Click "Save Changes" when you're done.

The next page will show you three hash values: "Client Key", "Client Secret", and "Your access token". Those are the three values we need. Copy those values into mastobot.yaml as client_key, client_secret, and token, respectively.

defaults

This optional array property lets you set default configuration values for each post. They may be overriden per-post (see below).

There are three properties that are meaningful to set here.

state_file

Mastobot will store application state after each run in a JSON file on disk. The default is to use a file named mastobot_state.json in the project root. If your project root is not writeable (which is often a good for security), you may also specify a relative or absolute path to any other file name, as long as the file is writeable.

In most cases you can skip this field.

posters

This is an array property that defines the auto-poster services that will run. You may have any number of posters (although 0 is rather pointless). Each poster uses a different strategy, which may have its own configuration.

At this time there are two available strategys: random and sequence.

Both strategies have three required configuration parameters:

Whenever a post is made, Mastobot will generate a random timestamp between minHours and maxHours in the future and record that value. The next time the bot runs, it will check if the current time is now past that timestamp. If not, it wil do nothing. If so, it will post the next status message and re-record the next-timestamp.

Example configuration

For clarity, here's an example of a possible (likely) configuration:

In this example, a random message in the posts/quotes directory will be posted every 20-30 hours (that is, the gap between posts will be between 72,000 and 108,000 seconds). Additionally, posts from the /home/me/posts/story directory will be posted in lexical order, with a gap of between 18,000 and 21,600 seconds between them. Both will be posted to the account on phpc.social defined by the crell account block.

Post directories

Each strategy relies on a directory that contains status messages to post. Mastobot supports six formats for posts, including both files and directories, all of which can be mixed-and-matched. For the sequence strategy, files and directories are included together in the same lexical list.

Simple messages

For most posts, a simple text message (a file ending in .txt) is sufficient. The entire value of the text file will be included verbatim as the body of the post.

JSON messages

Alternatively, a simple JSON message (a file ending in .json) allows specifying values beyond the message body. A complete example with possible values is below:

YAML messages

A status may be defined using YAML as well. The above example in YAML would be:

Directory definitions

A status may also be defined as a directory. That allows for the inclusion of attached media, as well as metadata for that media. At this time only images are supported, not audio or video.

If a directory contains a status.txt, status.json, or status.yaml file (checked in that order), it will be parsed the same way as a stand-alone file.

Additionally, any .gif, .png, .jpg, .jpeg, or .webp files in the directory will be attached to the status message, in lexical order.

Optionally, you may also include a json or yaml file with a name matching the image file. That file contains additional metadata for the image, such as alt-text. The potential values are listed below.

You are strongly encouraged to always at least include a description, for accessibility.

Why not use scheduled posts?

The ActivityPub and Mastodon API supports scheduled posts. However, most Mastodon UIs do not include a way to review, modify, or cancel modified posts. While it would be possible, and perhaps more efficient, for Mastobot to just push all posts at once with a scheduled time, that would allow no way to modify or clean up scheduled posts without building a complete UI for it as part of Mastobot.

That's out of scope for now, so instead it just posts normally. However, you may use the scheduled_at property in a JSON post to cause the post to be scheduled instead of published immediately.

Contributing

Please see CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email larry at garfieldtech dot com instead of using the issue tracker.

Credits

License

The Affero GPL version 3 or later. Please see License File for more information.


All versions of mastobot with dependencies

PHP Build Version
Package Version
Requires php Version ~8.1
colorfield/mastodon-api Version dev-master
pimple/pimple Version ^3.0
crell/serde Version ^0.5.0
psr/clock Version ^1.0.0
symfony/yaml Version ^6.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package crell/mastobot contains the following files

Loading the files please wait ....