A CLI PHP script that can send a configurable welcome toot to new users of a Mastodon instance from a specified account, and-or make it follow new users.

pezcurrel f481a8cc07 Added useless comment at the bottom in order to hide a typo in previous commit message :)) 2 weeks ago
README.md 2795ef7aee Updated to current help text 2 weeks ago
boolinp.php 458f224012 First commit 3 weeks ago
getopts.php 4850a933b1 Made the explanation text clearer (hopefully) 2 weeks ago
mb_wordwrap.php cd547e9cf8 Removed an useless comment 3 weeks ago
microdate.php 458f224012 First commit 3 weeks ago
mwbot f481a8cc07 Added useless comment at the bottom in order to hide a typo in previous commit message :)) 2 weeks ago
parseconfigfile.php 458f224012 First commit 3 weeks ago

README.md

===[ SYNOPSIS ]===============================================================
mwbot [work directory (default: current directory)] [options]
===[ DESCRIPTION ]============================================================
This is mwbot v0.4.3, a CLI PHP script that can send a configurable welcome
toot to new users of a Mastodon instance from a specified account (we’ll call
it “our account”), and-or make our account follow new users. It detects new
users by periodically reading the “users” table in Mastodon’s database.
===[ OPTIONS ]================================================================
--instance_host, -i
 REQUIRED. Requires as argument the hostname of the Mastodon instance you want
 to publish welcome toots to.
--access_token, -t
 REQUIRED. Requires as argument a valid Mastodon app access token.
 The Mastodon app should have at least “write:statuses” privilege and reside
 on «instance_host» (see option above). You can set up a Mastodon app on any
 account, for example by going to “Preferences” -> “Development” in Mastodon’s
 default web frontend.
--db_host, -H
 Requires as argument the hostname or ip address of the PostgreSQL server
 storing the Mastodon database.
--db_port, -P
 Requires as argument the port on which the PostgreSQL server storing the
 Mastodon database is listening.
--db_name, -d
 Requires as argument the name of the PostgreSQL Mastodon database.
--db_username, -u
 Requires as argument the PostgreSQL username for the Mastodon database.
--db_password, -p
 Requires as argument the password for the PostgreSQL user.
--interval, -I
 Requires as argument the number of seconds for the script to wait after each
 check for new accounts in the database. Must be greater than or equal to 5.
 DEFAULT: 30.
--follow, -f
 Takes as argument a boolean (see “BOOLEAN ARGUMENTS” below) defining whether
 the script should make our account follow each new account. On command line
 it can be called without an argument, in which case it sets to true.
 DEFAULT: false.
--welcome, -w
 Takes as argument a boolean (see “BOOLEAN ARGUMENTS” below) defining whether
 the script should send the welcome toot to each new user. On command line it
 can be called without an argument, in which case it sets to true.
 DEFAULT: false.
 If this option is set to true, the work directory must contain a
 «mwbot.template» file storing the template for the welcome toots to be sent
 (see section “TEMPLATE FILE” below).
--toot_visibility, -V
 Requires as argument the welcome toots visibility, that must be one of
 “public”, “unlisted”, “private” or “direct”. DEFAULT: “direct”.
--verbose, -v
 Takes as argument a boolean (see “BOOLEAN ARGUMENTS” below) defining whether
 info messages should be written to the terminal during runtime. On command
 line it can be called without an argument, in which case it sets to true.
 Note that in any case the script will write info, warning and error messages
 into a log file in the «work directory» (see the “OTHER FILES” section
 below). DEFAULT: false.
--help, -h
 Show this help text and exit.
===( BOOLEAN ARGUMENTS )======================================================
Boolean arguments can be specified with “true”, “t”, “yes”, “y”, “1” for true,
“false”, “f”, “no”, “n”, “0” for false.
===[ CONFIG FILE ]============================================================
If the work directory contains a «mwbot.config» file, mwbot will try and read
options from it. Note that options specified on the command line will always
supersede those specified in the config file.
Each line of «mwbot.config» file can contain one of the options described in
the “OPTIONS” section above, except “help”. Each option must be written in its
“long form” and without the “--”, and must be followed by an “=” sign and an
argument. Empty lines and lines beginning with an “#” sign will be ignored.
--- Begin of sample «mwbot.config» file ---
# this is a comment line and it will be ignored
instance_host=mastodon.example.net
access_token=XXID7XPVXXIAX03HnXlqXXXenPXXXXXFurXXXDT3Xeg
db_username=mastodon
follow=true
welcome=true
toot_visibility=public
interval=60
verbose=true
--- End of sample «mwbot.config» file -----
===[ TEMPLATE FILE ]==========================================================
If mwbot is set to send welcome toots (see option «--welcome» above, in the
“OPTIONS” section), the work directory must contain a «mwbot.template» file
storing the template text for the welcome toots to be sent. Any “%user%”
string in the template text will be substituted with the complete Mastodon
address of the new user, e.g.: “@user@mastodon.example.net” (so, in order for
welcome toots to actually be addressed to each new user, “%user%” must be
specified in the text at least once).
--- Begin of sample «mwbot.template» file ---
Hi %user%, welcome on mastodon.example.net.
Have a nice time :-)
--- End of sample «mwbot.template» file -----
===[ OTHER FILES ]============================================================
Mwbot will write some other files in the work directory:
- mwbot.log: the log file;
- mwbot.lock: the lock file, created at runtime, deleted on shutdown;
- mwbot.lastfollowed: a file storing the account creation timestamp of the
  last followed new user.
- mwbot.lastwelcomed: a file storing the account creation timestamp of the
  last welcomed new user.
===[ EXIT VALUES ]============================================================
0: normal run.
1: initialization error.
2: runtime error.
===[ DISCLAIMER AND LICENSE ]=================================================
This program comes with ABSOLUTELY NO WARRANTY; for details see the source.
This is free software, and you are welcome to redistribute it under certain
conditions; see <http://www.gnu.org/licenses/> for details.