Package: pleroma-bot
Stork (pleroma-bot)Mirror your favorite Twitter accounts in the Fediverse, so you can follow their updates from the comfort of your favorite instance. Or migrate your own to the Fediverse using a Twitterarchive.You can find this project at:GitHubGitlabGiteapleroma-botpleroma-botpleroma-botSupports:MastodonPleromaMisskeyIntroductionAfter using the pretty coolmastodon-botfor a while, I found it was lacking some features which were of use to me.For precisely those cases I've written this Python project that automates them, asking such info toTwitter's APIand updating the relevant fields on thePleroma API/Mastodon API/Misskey APIside.FeaturesSo basically, it does the following:Can parse a Twitterarchive, moving all your tweets to the FediverseCan use an RSS feed as the source of the tweets to postRetrieves latesttweetsand posts them on the Fediverse account if their timestamp is newer than the last post.Can filter out RTs or notCan filter out replies or notSupports Twitter threadsMedia retrieval and upload of multipleattachments. This includes:VideoImagesAnimated GIFsPollsRetrievesprofile infofrom Twitter and updates it in on the Fediverse account. This includes:Display nameProfile pictureBanner imageBio textAdds somemetadata fieldsto the Fediverse account, pointing to the original Twitter account or custom text.InstallationUsing pip$ pip install pleroma-botUsing a package managerHere's a list of the available packages.Package typeLinkMaintainerAUR (Arch)https://aur.archlinux.org/packages/python-pleroma-botrobertoszekUsage$pleroma-bot[-cCONFIG][-lLOG][--noProfile][--daemon][--forceDate[FORCEDATE]][-aARCHIVE]Bot for mirroring one or multiple Twitter accounts in Pleroma/Mastodon.optional arguments:-h, --help            show this help message and exit-c CONFIG, --config CONFIGpath of config file (config.yml) to use and parse. Ifnot specified, it will try to find it in the currentworking directory.-d, --daemon          run in daemon mode. By default it will re-run every60min. You can control this with --pollrate-p POLLRATE, --pollrate POLLRATEonly applies to daemon mode. How often to run theprogram in the background (in minutes). By default is60min.-l LOG, --log LOG     path of log file (error.log) to create. If notspecified, it will try to store it at your config filepath-n, --noProfile       skips Fediverse profile update (no background image,profile image, bio text, etc.)--forceDate [FORCEDATE]forces the tweet retrieval to start from a specificdate. The twitter_username value (FORCEDATE) can besupplied to only force it for that particular user inthe config-s, --skipChecks      skips first run checks-a ARCHIVE, --archive ARCHIVEpath of the Twitter archive file (zip) to use forposting tweets.-t THREADS, --threads THREADSnumber of threads to use when processing tweets-L LOCKFILE, --lockfile LOCKFILEpath of lock file (pleroma-bot.lock) to preventcollisions with multiple bot instances. By default itwill be placed next to your config file.--verbose, -v--version             show program's version number and exitBefore runningThere are multiple options for using the bot.You can either choose to use:A Twitter archiveAn RSS feedGuest tokensTwitter tokenswith a Developer accountYou'll need to create a configuration file and obtain theFediverse tokensfor your accounts no matter what you choose to use.If you plan on retrieving tweets from an account which has their tweetsprotected, you'll also need the following:Consumer Key and Secret. You'll find them on your project app keys and tokens section atTwitter's Developer PortalAccess Token Key and Secret.  You'll also find them on your project app keys and tokens section atTwitter's Developer Portal.
Alternatively, you can obtain the Access Token and Secret by runningthislocally, while being logged in with a Twitter account which follows or is the owner of the protected accountYou'll may also need Elevated access in your Twitter's API project in order for the bot to function properly.Refer to the docsfor more info about this.ConfigurationCreate aconfig.ymlfile in the same path where you are callingpleroma-bot(or use the--configargument to specify a different path).There's a config example in this repo calledconfig.yml.samplethat can help you when filling yours out.For more information you can refer to the"Configuration" pageon the docs.Here's what a minimal config looks like:# Change this to your target Fediverse instancepleroma_base_url:https://pleroma.instance# How many tweets to gather per-user in every execution# Twitter's API hard limit is 3,200max_tweets:40# Twitter bearer tokentwitter_token:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXusers:-twitter_username:User1pleroma_username:MyPleromaUser1# Mastodon/Pleroma bearer tokenpleroma_token:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXRunningIf you're running the bot for the first time it will ask you for the date you wish to start retrieving tweets from (it will gather all from that date up to the present).
If you leave it empty and just press enter it will default to the oldest date that Twitter's API allows ('2010-11-06T00:00:00Z') for tweet retrieval.To force this behaviour in future runs you can use the--forceDateargument (be careful, no validation is performed with the already posted toots/posts by that Fediverse account and you can end up with duplicates posts/toots!).Additionally, you can provide atwitter_usernameif you only want to force the date for one user in your config.For example:$pleroma-bot--forceDateWoolieWoolzIf the--noProfileargument is passed, the profile picture, banner, display name and bio willnotbe updated on the Fediverse account. However, it will still gather and post the tweets following your config's parameters.NOTE: Anerror.logfile will be created at the path from whichpleroma-botis being called.crontab entry example(everyday at 6:15 AM)update profile and(every 10 min.)post new tweets:# Post tweets every 10 min*/10****cd/home/robertoszek/myvenv/&&.bin/activate&&pleroma-botnoProfile# Update pleroma profile with Twitter info every day at 6:15 AM156***cd/home/robertoszek/myvenv/&&.bin/activate&&pleroma-botNOTE: If you have issues with cron running the bot you may have to specify the full path of your Python executable*/10 * * * * /usr/bin/python /usr/local/bin/pleroma-botScreenshotsAcknowledgementsThese projects proved to be immensely useful, they are Python wrappers for the Mastodon API and Twitter API respectively:Mastodon.pytwitter-pythonThey were part of the impetus for this project, challenging myself to not just import them and use them, instead opting to directly do the heavy lifting with built-in python modules.That andmastodon-botnot working after upgrading the Pleroma instance I was admin on 😅. This event lead to repurposing this project (initially it only updated the profile info) and adding the tweet gathering and posting capabilities.ContributingPatches, pull requests, and bug reports are more thanwelcome, please keep the style consistent with the original source.LicenseMIT LicenseCopyright (c) 2023 Roberto Chamorro / project contributorsPermission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.Tested and confirmed working against:Pleroma BE 2.4.2Mastodon v3.2.1Misskey 12.110.1Twitter API v1.1 and v2