VC 31aea7e1a6 Merge branch 'fix_french_inclusive_writing' into 'master'
feat: allow user to remove some links, replace some links by others

See merge request veretcle/scootaloo!38
2022-11-23 12:49:46 +00:00
2020-03-01 09:35:19 +01:00
2022-08-11 13:50:52 +02:00
2022-11-23 09:00:44 +01:00
2022-11-23 09:00:44 +01:00
2021-04-20 11:39:43 +02:00
2020-03-01 09:38:26 +01:00
2022-11-23 13:17:00 +01:00

A Twitter to Mastodon copy bot written in Rust

It:

  • copies the content (text) of the original Tweet
  • dereferences the links
  • gets every attached media (photo, video or gif)

If any of the last steps failed, the Toot gets published with the exact same text as the Tweet.

RT are excluded, replies are included when considered part of a thread (reply to self), not the actual replies to other Twitter users.

Usage

Configuring

First up, create a configuration file (default path is /usr/local/etc/scootaloo.toml). It will look like this:

[scootaloo]
db_path = "/var/lib/scootaloo/scootaloo.sqlite" ## file containing the SQLite Tweet corresponding Toot DB, must be writeable
cache_path = "/tmp/scootaloo" ## a dir where the temporary files will be download, must be writeable
rate_limiting = 4 ## optional, default 4, number of accounts handled simultaneously
## optional, this should be omitted the majority of the time
## sometimes, twitter try to use french inclusive writting, but instead of using `·` (median point), theyre using `.`
## this makes twitter interpret it as a URL, which is wrong
## this parameter allows you to catch such URLs and apply the `display_url` (i.e. `tout.es`) instead of the `expanded_url` (i.e. `http://tout.es`)
## in those particular cases
## (!) use with caution, it might have some undesired effects
show_url_as_display_url_for = "^http(s)://(.+)\\.es$"
## optional, this allows you to replace the host for popular services such as YouTube of Twitter, or any other
## with their more freely accessible equivalent
[scootaloo.alternative_services_for]
"tamere.lol" = "tonpere.mdr" ## quotes are necessary for both parameters
"you.pi" = "you.pla"
"www.you.pi" = "you.pla" ## this is an exact match, so youll need to lay out all the possibilities

[twitter]
## Consumer/Access key for Twitter (can be generated at https://developer.twitter.com/en/apps)
page_size = 20 ## optional, default 200, max number of tweet retrieved
consumer_key = "MYCONSUMERKEY"
consumer_secret = "MYCONSUMERSECRET"
access_key = "MYACCESSKEY"
access_secret = "MYACCESSSECRET"

[mastodon]

Then run the command with the init subcommand to initiate the DB:

scootaloo init

This subcommand is completely idempotent.

Then run the command with the register subcommand:

scootaloo register --host https://m.nintendojo.fr

This will give you the end of the TOML file. It will look like this:

[mastodon.nintendojofr] ## account
twitter_screen_name = "NintendojoFR" ## User Timeline to copy
mastodon_screen_name = "nintendojofr" ## optional, Mastodon account name used for smart mentions
base = "https://m.nintendojo.fr"
client_id = "MYCLIENTID"
client_secret = "MYCLIENTSECRET"
redirect = "urn:ietf:wg:oauth:2.0:oob"
token = "MYTOKEN"

You can add other account if you like, after the [mastodon] moniker. Scootaloo would theorically support an unlimited number of accounts.

You can also add a custom twitter page size in this section that would override the global (under the twitter moniker) and default one (200), like so:

twitter_page_size = 40

Running

You can then run the application via cron for example. Here is the generic usage:

A Twitter to Mastodon bot

USAGE:
    scootaloo [OPTIONS] [SUBCOMMAND]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -c, --config <CONFIG_FILE>    TOML config file for scootaloo (default /usr/local/etc/scootaloo.toml)
    -l, --loglevel <LOGLEVEL>     Log level.Valid values are: Off, Warn, Error, Info, Debug

SUBCOMMANDS:
    help        Prints this message or the help of the given subcommand(s)
    init        Command to init Scootaloo DB
    migrate     Command to migrate Scootaloo DB
    register    Command to register to a Mastodon Instance

Quirks

Scootaloo does not respect the spam limits imposed by Mastodon: it will make a 429 error if too much Tweets are converted to Toots in a short amount of time (and it will not recover from it). By default, it gets the last 200 tweets from the user timeline (which is a lot!). It is recommended to put a Tweet number into the DB file before copying an old account.

You can insert that Tweet number, by connecting to the DB you created:

sqlite3 /var/lib/scootaloo/scootaloo.sqlite

And inserting the data:

INSERT INTO tweet_to_toot VALUES ("<twitter_screen_name>", 1383782580412030982, "<twitter_screen_name>");

The last value is supposed to be the Toot ID. It cannot be null, so you better initialize it with something unique, like the Twitter Screen Name for example.

Migrating from Scootaloo ⩽ 0.6.1

The DB scheme has change between version 0.6.x and 0.7.x (this is due to the multi-account nature of Scootaloo from 0.7.x onward). You need to migrate your DB. You can do so by issuing the command:

scootaloo migrate

You can optionnally specify a screen name with the --name option. By default, itll take the first screen name in the config file.

Description
A Twitter to Mastodon copy bot written in Rust
Readme WTFPL 282 KiB
Languages
Rust 100%