Bot for mirroring one or multiple Twitter accounts in Pleroma/Mastodon.

Overview

Stork (pleroma-bot)

Build Status Version AUR version codecov Python 3.6 License

Stork

Mirror one or multiple Twitter accounts in Pleroma/Mastodon.

Documentation

Introduction

After using the pretty cool mastodon-bot for a while, I found it was lacking some actions which were of use to me.

For precisely those cases I've written this Python project that automates them, asking such info to Twitter's API and updating the relevant fields on the Pleroma API/Mastodon API side.

Features

So basically, it does the following:

  • Retrieves tweets and posts them on the Fediverse account if their timestamp is newer than the last post.
    • Can filter out RTs or not
    • Can filter out replies or not
  • Media retrieval and upload of multiple attachments. This includes:
    • Video
    • Images
    • Animated GIFs
    • Polls
  • Retrieves profile info from Twitter and updates it in on the Fediverse account. This includes:
    • Display name
    • Profile picture
    • Banner image
    • Bio text
  • Adds some metadata fields to the Fediverse account, pointing to the original Twitter account or custom text.

Installation

Using pip

$ pip install pleroma-bot

Using a package manager

Here's a list of the available packages.

Package type Link Maintainer
AUR (Arch) https://aur.archlinux.org/packages/python-pleroma-bot robertoszek

Usage

$ pleroma-bot [--noProfile] [--forceDate [FORCEDATE]] [-c CONFIG]
Bot for mirroring one or multiple Twitter accounts in Pleroma/Mastodon.

optional arguments:
  -h, --help            show this help message and exit
  -c CONFIG, --config CONFIG
                        path of config file (config.yml) to use and parse. If
                        not specified, it will try to find it in the current
                        working directory.
  -n, --noProfile       skips Fediverse profile update (no background image,
                        profile image, bio text, etc.)
  --forceDate [FORCEDATE]
                        forces the tweet retrieval to start from a specific
                        date. The twitter_username value (FORCEDATE) can be
                        supplied to only force it for that particular user in
                        the config
  -s, --skipChecks      skips first run checks
  --verbose, -v
  --version             show program's version number and exit

Before running

You'll need the following:

If you plan on retrieving tweets from an account which has their tweets protected, you'll also need the following:

  • Consumer Key and Secret. You'll find them on your project app keys and tokens section at Twitter's Developer Portal
  • Access Token Key and Secret. You'll also find them on your project app keys and tokens section at Twitter's Developer Portal. Alternatively, you can obtain the Access Token and Secret by running this locally, while being logged in with a Twitter account which follows or is the owner of the protected account

Create a config.yml file in the same path where you are calling pleroma-bot. There's a config example in this repo called config.yml.sample that can help you when filling yours out:

twitter_base_url: https://api.twitter.com/1.1
# Change this to your Fediverse instance
pleroma_base_url: https://pleroma.robertoszek.xyz
# (optional) Change this to your preferred nitter instance
nitter_base_url: https://nitter.net
# How many tweets to get in every execution
# Twitter's API hard limit is 3,200
max_tweets: 40
# Twitter bearer token
twitter_token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# List of users and their attributes
users:
- twitter_username: KyleBosman
  pleroma_username: KyleBosman
  # Mastodon/Pleroma token obtained by following the README.md
  pleroma_token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  # (optional) keys and secrets for using OAuth 1.0a (for protected accounts)
  consumer_key: xxxxxxxxxxxxxxxxxxxxxxxxx
  consumer_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  access_token_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  access_token_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  # If you want to add a link to the original status or not
  signature: true
  # (optional) If you want to download Twitter attachments and add them to the Pleroma posts.
  # By default they are not
  media_upload: true
  # (optional) If twitter links should be changed to nitter ones. By default they are not
  nitter: true
  # (optional) If mentions should be transformed to links to the mentioned Twitter profile
  rich_text: true
  # (optional) visibility of the post. Must one of the following: public, unlisted, private, direct
  # by default is "unlisted"
  visibility: "unlisted"
  # (optional) Force all posts for this account to be sensitive or not
  # The NSFW banner for the instance will be shown for attachments as a warning if true
  # If not defined, the original tweet sensitivity will be used on a tweet by tweet basis
  sensitive: false
  # (optional) Include the creation date of the tweet on the Fediverse post body
  original_date: true
  # (optional) Date format to use when adding the creation date of the tweet to the Fediverse post
  original_date_format: "%Y/%m/%d %H:%"
  # (optional) If RTs are to be also be posted in the Fediverse account. By default they are included
  include_rts: false
  # (optional) If replies are to be also posted in the Fediverse account. By default they are included
  include_replies: false
  # (optional) List of hashtags to use for filtering out tweets which don't include any of them
  hashtags:
    - sponsored
  # (optional) How big attachments can be before being ignored and not being uploaded to the Fediverse post
  # Examples: "30MB", "1.5GB", "0.5TB"
  file_max_size: 500MB
  # additional custom-named attributes
  support_account: robertoszek
  # you can use any attribute from 'user' inside a string with {{ attr_name }} and it will be replaced
  # with the attribute value. e.g. {{ support_account }}
  bio_text: "\U0001F916 BEEP BOOP \U0001F916 \nI'm a bot that mirrors {{ twitter_username }} Twitter's\
    \ account. \nAny issues please contact @{{ support_account }} \n \n " # username will be replaced by its value
  # Optional metadata fields and values for the Pleroma profile
  fields:
  - name: "\U0001F426 Birdsite"
    value: "{{ twitter_url }}"
  - name: "Status"
    value: "I am completely operational, and all my circuits are functioning perfectly."
  - name: "Source"
    value: "https://gitea.robertoszek.xyz/robertoszek/pleroma-twitter-info-grabber"
# Mastodon instance example
- twitter_username: WoolieWoolz
  pleroma_username: 24660
  pleroma_base_url: https://botsin.space
  pleroma_token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  # Mastodon doesn't support rich text!
  rich_text: false
  signature: true
  nitter: true
  visibility: "unlisted"
  media_upload: true
  max_tweets: 50
  bio_text: "\U0001F916 BEEP BOOP \U0001F916 \nI'm a bot that mirrors {{ twitter_username }} Twitter's\
    \ account. \nAny issues please contact @{{ support_account }} \n \n " # username will be replaced by its value
  fields:
  - name: "\U0001F426 Birdsite"
    value: "{{ twitter_url }}"
  - name: "Status"
    value: "I am completely operational, and all my circuits are functioning perfectly."
  - name: "Source"
    value: "https://gitea.robertoszek.xyz/robertoszek/pleroma-twitter-info-grabber"
# Minimal config example
- twitter_username: arstechnica
  pleroma_username: mynewsbot
  pleroma_token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  bio_text: ""

Changing the users to the desired ones. You can add as many users as needed.

Also change the following to your Pleroma/Mastodon instance URL:

pleroma_base_url: https://pleroma.robertoszek.xyz

Running

If 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 --forceDate argument (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 a twitter_username if you only want to force the date for one user in your config.

For example:

$ pleroma-bot --forceDate WoolieWoolz

If the --noProfile argument is passed, only new tweets will be posted. The profile picture, banner, display name and bio will not be updated on the Fediverse account.

NOTE: An error.log file will be created at the path from which pleroma-bot is 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-bot noProfile

# Update pleroma profile with Twitter info every day at 6:15 AM
15 6 * * * cd /home/robertoszek/myvenv/ && . bin/activate && pleroma-bot

Screenshots

Screenshot

Screenshot

Acknowledgements

These projects proved to be immensely useful, they are Python wrappers for the Mastodon API and Twitter API respectively:

They 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 and mastodon-bot not working after upgrading the Pleroma instance I was admin on 😅 . This event lead to repurposing it and adding the tweet gathering and posting capabilities.

Contributing

Patches, pull requests, and bug reports are more than welcome, please keep the style consistent with the original source.

License

MIT License

Copyright (c) 2021 Roberto Chamorro / project contributors

Permission 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.0.50-2547-g5c2b6922-develop
  • Mastodon v3.2.1
  • Twitter API v1.1 and v2
Comments
  • requests.exceptions.HTTPError: 422 Client Error: Unprocessable Entity for url:

    requests.exceptions.HTTPError: 422 Client Error: Unprocessable Entity for url:

    For some reason, some of the twitter account result in error, and previously those accounts worked. Last one is @Ultrekillblast and before that it was official @startrek account. I got this:

    ... ℹ 2022-02-22 18:23:31,681 - pleroma_bot - INFO - tweets gathered: 27 ℹ 2022-02-22 18:23:34,148 - pleroma_bot - INFO - tweets to post: 27 ℹ 2022-02-22 18:23:34,150 - pleroma_bot - INFO - (1/27) ✖ 2022-02-22 18:23:34,402 - pleroma_bot - ERROR - Exception occurred (cli.py:502) Traceback (most recent call last): File "/home/mastodon/.local/lib/python3.8/site-packages/pleroma_bot/_pleroma.py", line 103, in post_pleroma response.raise_for_status() File "/home/mastodon/.local/lib/python3.8/site-packages/requests/models.py", line 960, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 422 Client Error: Unprocessable Entity for url: https://salocha.online/api/v1/media

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): File "/home/mastodon/.local/lib/python3.8/site-packages/pleroma_bot/cli.py", line 482, in main post_id = user.post_pleroma( File "/home/mastodon/.local/lib/python3.8/site-packages/pleroma_bot/_pleroma.py", line 117, in post_pleroma response.raise_for_status() File "/home/mastodon/.local/lib/python3.8/site-packages/requests/models.py", line 960, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 422 Client Error: Unprocessable Entity for url: https://salocha.online/api/v1/media ...

    bug 
    opened by vserbu 38
  • UnicodeEncodeError Logger exception with iso8859_2 encoding (non UTF-8)

    UnicodeEncodeError Logger exception with iso8859_2 encoding (non UTF-8)

    I've got an error, what can I do? This is the error log:

    2022-02-12 08:55:45,426 pleroma_bot ERROR: Exception occurred Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/pleroma_bot/cli.py", line 363, in main config = yaml.safe_load(stream) File "/usr/local/lib/python3.8/dist-packages/yaml/init.py", line 125, in safe_load return load(stream, SafeLoader) File "/usr/local/lib/python3.8/dist-packages/yaml/init.py", line 81, in load return loader.get_single_data() File "/usr/local/lib/python3.8/dist-packages/yaml/constructor.py", line 49, in get_single_data node = self.get_single_node() File "/usr/local/lib/python3.8/dist-packages/yaml/composer.py", line 36, in get_single_node document = self.compose_document() File "/usr/local/lib/python3.8/dist-packages/yaml/composer.py", line 58, in compose_document self.get_event() File "/usr/local/lib/python3.8/dist-packages/yaml/parser.py", line 118, in get_event self.current_event = self.state() File "/usr/local/lib/python3.8/dist-packages/yaml/parser.py", line 193, in parse_document_end token = self.peek_token() File "/usr/local/lib/python3.8/dist-packages/yaml/scanner.py", line 129, in peek_token self.fetch_more_tokens() File "/usr/local/lib/python3.8/dist-packages/yaml/scanner.py", line 223, in fetch_more_tokens return self.fetch_value() File "/usr/local/lib/python3.8/dist-packages/yaml/scanner.py", line 577, in fetch_value raise ScannerError(None, None, yaml.scanner.ScannerError: mapping values are not allowed here in "/usr/local/lib/python3.8/dist-packages/pleroma_bot/config.yml", line 2, column 17

    bug 
    opened by vserbu 28
  • Support for OAuth 1.0a (needed for protected accounts)

    Support for OAuth 1.0a (needed for protected accounts)

    Hiyo!

    First off apologies on not getting around to testing 0.7.0 until now (#28, #29). Things were working initially for the first run it seems, but I am now getting an error:

    pleroma_bot - ERROR - Exception occurred
    Traceback (most recent call last):
      File "/home/jimmy/.local/lib/python3.8/site-packages/pleroma_bot/cli.py", line 286, in main
        if tweets["meta"]["result_count"] > 0:
    KeyError: 'meta'
    

    It appears to be getting "stuck" at the same Twitter account during each run. Is there anything else I can provide to help troubleshoot?

    enhancement 
    opened by jimmybrancaccio 26
  • Add RSS feeds as a source

    Add RSS feeds as a source

    Twitter API is too difficult to apply for, I wonder if I can migrate tweets through RSS. I found a project : https://github.com/DIYgod/RSSHub It would be much easier if it could be migrated through RSS.

    enhancement 
    opened by SurpriseLon 20
  • Twitter v2 essential api errors

    Twitter v2 essential api errors

    Hi, I am just setting up this bot for the first time. When I run the bot it gives me an error

    ✖ 2021-12-10 15:11:38,072 - pleroma_bot - ERROR - Exception occurred (cli.py:423) 
    Traceback (most recent call last):
      File "/usr/local/lib/python3.8/dist-packages/pleroma_bot/cli.py", line 303, in main
        for user_item in user_dict[:]:
    TypeError: unhashable type: 'slice'
    

    I have installed using pip3 on ubuntu 20.04 my config looks like this:

    twitter_base_url: https://api.twitter.com/2
    pleroma_base_url: https:///bae.st
    max_tweets: 40
    twitter_token: mytoken
    users:
      pleroma_token: mytoken
      consumer_key: mykey
      consumer_secret: mysecret
      access_token_key: myaccess
      access_token_secret: myaccesssecret
      signature: false
      media_upload: true
      nitter: false
      rich_text: true
      visibility: "public"
      sensitive: true
      original_date: false
      original_date_format: "%Y/%m/%d %H:%"
      include_rts: true
      include_replies: false
      file_max_size: 500MB
    

    Please let me know what I should do or how I can help.

    opened by Cknight70 18
  • Allow to preserve threads

    Allow to preserve threads

    A thread like https://nitter.it/ecb/status/1592896729091047429#m is currently posted dismembered and in random order https://mamot.fr/@[email protected]/109354553131059238 .

    It would be nice to post replies as replies. This probably requires also posting single-threaded, as the order is otherwise difficult to guarantee. Screenshot_20221116_191207

    enhancement 
    opened by nemobis 12
  • Gets stuck on

    Gets stuck on "Processing tweets..."

    Sometimes this happens:

    ℹ 2022-04-04 10:14:59,842 - pleroma_bot - INFO - ====================================== 
    ℹ 2022-04-04 10:14:59,842 - pleroma_bot - INFO - Processing user:       108070211019592095 
    ℹ 2022-04-04 10:14:59,842 - pleroma_bot - INFO - It seems like pleroma-bot is running for the first time for this Twitter user: linagalvezmunoz 
    ℹ 2022-04-04 10:15:00,903 - pleroma_bot - INFO - How far back should we retrieve tweets from the Twitter account? 
    ℹ 2022-04-04 10:15:00,903 - pleroma_bot - INFO - 
    Enter a date (YYYY-MM-DD):
    [Leave it empty to retrieve *ALL* tweets or enter 'continue'
    if you want the bot to execute as normal (checking date of 
    last post in the Fediverse account)]  
    ⚠ 2022-04-04 10:15:01,106 - pleroma_bot - WARNING - No posts were found in the target Fediverse account (_pleroma.py:43) 
    ℹ 2022-04-04 10:15:01,106 - pleroma_bot - INFO - How far back should we retrieve tweets from the Twitter account? 
    ℹ 2022-04-04 10:15:01,106 - pleroma_bot - INFO - 
    Enter a date (YYYY-MM-DD):
    [Leave it empty to retrieve *ALL* tweets or enter 'continue'
    if you want the bot to execute as normal (checking date of 
    last post in the Fediverse account)]  
    ℹ 2022-04-04 10:15:02,614 - pleroma_bot - INFO - tweets gathered:        50 
    Processing tweets...  \^C
    

    This was stuck for 45 min there. Maybe there's a need of a hard timeout somewhere.

    The error seems to be somehow user-dependent, in that I've seen it more than once for some users.

    duplicate 
    opened by nemobis 10
  • Allow user to copy tweets ordered by date

    Allow user to copy tweets ordered by date

    Upon executing pleroma-bot to copy tweets with a certain hashtag from my twitter account, I noticed that the order in which the tweets are copied over is seemingly random (when no start date is specified).

    For example, when copying tweets with the hashtag #tinkering, like these: https://twitter.com/search?q=%40amoslightnin%20%23tinkering&src=typed_query&f=live

    One of the first statuses copied over was this one: https://masto.amosamos.net/notice/A9e0sWGhO6Da69j7rc

    Which is from a tweet from 2018. https://twitter.com/AmosLightnin/status/1020098097110806529?s=20

    But there are tweets with the #tinkering hashtag from earlier years on my twitter timeline.

    Again - this is fantastic software already, and I recognize that the user base this would be useful for may be fairly small. But then again, I think it's nice if we can provide ways for people to migrate their content from the big platforms onto their own little pleroma / activitypub instances, especially when they've used twitter as a repository for documentation, notes, or experiments, as I have. Thanks again for making and sharing this software!

    bug 
    opened by lightnin 10
  • Do not include link to Twitter image gallery when signature set to false

    Do not include link to Twitter image gallery when signature set to false

    Hello again. I noticed that when posting an image from Twitter to Pleroma, the bot will also post a link to the Tweet's image gallery eg: https://twitter.com/syuhu_Ako3/status/1469274434326302721/photo/1

    This can be a problem for private accounts or accounts which do not wish to be discovered on Twitter. I am suggesting that when signature: false is set, these links to not appear.

    enhancement 
    opened by Cknight70 9
  • Getting Error in get_date_last_pleroma_post

    Getting Error in get_date_last_pleroma_post

    Greetings!

    I was able to run this once and it worked wonderfully, but then it started to fail with:

    pleroma_bot - ERROR - Exception occurred
    Traceback (most recent call last):
      File "/home/jimmy/.local/lib/python3.8/site-packages/pleroma_bot/cli.py", line 185, in main
        date_pleroma = user.get_date_last_pleroma_post()
      File "/home/jimmy/.local/lib/python3.8/site-packages/pleroma_bot/_pleroma.py", line 41, in get_date_last_pleroma_post
        datetime.strptime(
      File "/usr/lib/python3.8/_strptime.py", line 568, in _strptime_datetime
        tt, fraction, gmtoff_fraction = _strptime(data_string, format)
      File "/usr/lib/python3.8/_strptime.py", line 349, in _strptime
        raise ValueError("time data %r does not match format %r" %
    ValueError: time data '2021-01-07T16:47:58.915Z' does not match format '%Y-%m-%dT%H:%M:%S.000Z'
    

    However, unless if it's not obvious those do match. 2021-01-07T16:47:58.915Z uses the format %Y-%m-%dT%H:%M:%S.000Z.

    Any ideas? I really hope it's not something obvious, I'm going to feel so stupid haha 😝

    opened by jimmybrancaccio 9
  • Exception if not first_time run but no previous post available

    Exception if not first_time run but no previous post available

    Thank you for this bot, I love how easy it is to configure!

    I interrupted the first run, so I had no posts on the target mastodon account, and upon the second try I got:

    Traceback (most recent call last):
      File "/home/federico/git/federico/mastodon/lib64/python3.9/site-packages/pleroma_bot/cli.py", line 378, in main
        date_pleroma = user.get_date_last_pleroma_post()
      File "/home/federico/git/federico/mastodon/lib64/python3.9/site-packages/pleroma_bot/_pleroma.py", line 35, in get_date_last_pleroma_post
        response.raise_for_status()
      File "/home/federico/git/federico/mastodon/lib64/python3.9/site-packages/requests/models.py", line 943, in raise_for_status
        raise HTTPError(http_error_msg, response=self)
    requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://mastodon.technology//api/v1/accounts/<username>/statuses
    

    I could easy work around this by using --forceDate, which is mentioned in https://robertoszek.github.io/pleroma-bot/gettingstarted/usage/#first-run , so no big deal, but maybe the date should fall back to the default?

    bug 
    opened by nemobis 8
  • Cron on Debian

    Cron on Debian

    I had some problem to configure the cron on Debian 11 (bot installed with PyPi).

    Solved with complete path to Python and Stork like this:

    */10 * * * * /usr/bin/python /usr/local/bin/pleroma-bot -c /path/to/config.yml -l /path/to/error.log 1> /dev/null
    

    Maybe this information can be somewhere in the documentation

    opened by bugsysop 3
  • allow users to gather tweets from a shared user timeline

    allow users to gather tweets from a shared user timeline

    OK, this one may be problematic. Feel free to tell me if it isn't workable. :-)

    I'm hoping to minimize latency between the time a tweet is posted and the time it's mirrored into a fediverse post, so I'm hitting the 300 requests per 15 minutes rate limiter pretty often. I'm guessing this is because the bot is making a tweets requests from Twitter for each configured account, and I have 45 in there at the moment and would like to be able to support way more than that.

    (This is for https://twitter.oksocial.net/about; that page describes the service.)

    I'm pretty sure Twitter's API lets you give it a list of accounts to pull tweets from on each request, rather than just a single account, so it should be possible for the bot to batch all the accounts for which it does not have specific login info into a single request?

    I suspect that's much more complicated than adding the bot attribute was, but thanks for considering it. :-)

    -robin

    enhancement 
    opened by us3r1d 20
  • cohost support

    cohost support

    I'm thinking on maybe adding support for mirroring to cohost accounts. It's not part of the Fediverse but perhaps there's enough demand for using it as a target.

    So far, I have a little proof of concept that logs in, retrieves profile info and the date of the last post. Haven't been able to continue working on it as my account can't post anything yet (30,000 accounts ahead of mine waiting for activation). 😅

    Their API is a little wonky (no tokens, so only password or cookies can be used for authentication) but looking at this project would be at least helpful to start with: https://github.com/valknight/Cohost.py

    question 
    opened by robertoszek 0
  • Some tweets have their links or media skipped (unified cards)

    Some tweets have their links or media skipped (unified cards)

    Some fancy accounts seem to be using some Twitter feature which pleroma-bot doesn't support yet.

    This is typically spotted in tweets which follow the trend of containing a mere "↓" as warning that the main content of the update is actually somewhere else, like this: https://respublicae.eu/@EU_Commission/108092396818818757 https://nitter.eu/EU_Commission/status/1512123194785898503 which is just a link to https://ec.europa.eu/commission/presscorner/detail/en/statement_22_2331 . These tweets look like just any other tweet whose main URL has been "eaten" by Twitter and shown only as attached "card", but they seem to be different.

    Others are more complicated like https://respublicae.eu/@EU_Commission/108103776666586079 https://nitter.eu/EU_Commission/status/1512777762909655043 which contains a "broadcast": https://nitter.eu/i/broadcasts/1BRJjnyZoZdJw . I guess there isn't much to do about these, other than documenting it somewhere so that people make informed decisions about the nitter and signature configs.

    opened by nemobis 14
  • Do not ask to enter date when --forceDate is provided

    Do not ask to enter date when --forceDate is provided

    I have to populate a number of accounts for the first time, so it's annoying to have to require manual input like this:

    ℹ 2022-04-03 13:35:08,271 - pleroma_bot - INFO - ====================================== 
    ℹ 2022-04-03 13:35:08,271 - pleroma_bot - INFO - Processing user:       108067315577208905 
    ℹ 2022-04-03 13:35:08,272 - pleroma_bot - INFO - It seems like pleroma-bot is running for the first time for this Twitter user: eucopresident 
    ℹ 2022-04-03 13:35:10,628 - pleroma_bot - INFO - How far back should we retrieve tweets from the Twitter account? 
    ℹ 2022-04-03 13:35:10,629 - pleroma_bot - INFO - 
    Enter a date (YYYY-MM-DD):
    [Leave it empty to retrieve *ALL* tweets or enter 'continue'
    if you want the bot to execute as normal (checking date of 
    last post in the Fediverse account)]
    

    Am I supposed to use --forceDate together with --skipChecks the first time? Currently I'm using a silly patch like this in _utils.py after logger.info(date_msg):

        # input_date = input()
        if True:
    

    I don't quite understand what cli.py is trying to do here:

                if (
                    (args.forceDate and args.forceDate in user.twitter_username)
                    or args.forceDate == "all"
                    or user.first_time
                ) and not args.skipChecks:
                    date_pleroma = user.force_date()
                else:
                    if user.instance == "misskey":  # pragma
                        date_pleroma = user.get_date_last_misskey_post()
                    else:
                        date_pleroma = user.get_date_last_pleroma_post()
    

    It feels like date_pleroma is never set to args.forceDate.

    enhancement 
    opened by nemobis 7
  • Migrate remaining enpoints using v1.1 to v2

    Migrate remaining enpoints using v1.1 to v2

    Twitter introduced a new tier of access (Elevated) to their API projects and although existing projects were promoted automatically, new users by default will get Essential access instead, which is not allowed to make requests to API v1.1.

    Users can apply for Elevated access here, but it should not be a hard requirement.

    We should move the little that's left of v1.1 to v2 and once fully migrated, remove the redundant twitter_base_url mapping from the config samples (and continue to use twitter_base_url_v2 internally, so we don't break old config.yml files created by users before these changes).

    Endpoints which we still use v1.1 as of the time of writing:

    • /users/show.json?screen_name={screen_name}
      • bio_text
      • profile_image_url_https
      • profile_banner_url
      • name
        • https://developer.twitter.com/en/docs/twitter-api/users/lookup/migrate/standard-to-twitter-api-v2
    • /statuses/show.json?id={id}
      • extended_entities: media (video)
        • https://developer.twitter.com/en/docs/twitter-api/tweets/lookup/migrate/standard-to-twitter-api-v2

    https://developer.twitter.com/en/docs/twitter-api/migrate/data-formats/standard-v1-1-to-v2

    https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api#v2-access-level https://blog.twitter.com/developer/en_us/topics/tools/2021/build-whats-next-with-the-new-twitter-developer-platform

    enhancement 
    opened by robertoszek 4
Releases(1.2.0)
  • 1.2.0(Jan 2, 2023)

    New year, new release! 🎉

    Fixed

    • Bug: Handle exception when media attachments are geoblocked (403 Unauthorized).
    • Regression: Take into account new structure of Twitter's archive (tweet.js changed to tweets.js)
    • Bug: Handle special media types that don't include link to media in some cases. Thanks @tewhalen!
    • Bug: Align max_tweets minimum value (10) with the warning message and actual value. Thanks @nemobis!
    • Bug: Multiple video attachments cause HTTP 422 on Mastodon when posting.
    • Bug: Exception when post was manually pinned on the Fedi account and later one was pinned on the Twitter account. Thanks @selyod-ka!

    Enhancements

    • Archive offline support, you no longer need a Twitter developer account or access to their API to process an archive.
    • Mastodon limits, make URLs count as 23 characters (or the instance configured value) when determining if truncating is necessary.
    • Added progress bars when gathering, processing and posting tweets
    • Pleroma and Mastodon rate limits, handle HTTP 429 more gracefully (wait until they reset and continue)
    • Added fallback for unknown software on target instance.

    Added

    • RSS support, you can now use an RSS feed as a source of tweets to post. Take a look at the docs for more info.
    • Thread support, now mirrored users should be able to reply to their own posts and create reply threads.
    • Native retweet support, now users in your config should be able to reblog their own and each other's posts if they are on the same instance.
    • bot config mapping, for setting the bot flag on the target account.
    • --lockerfile argument, for specifying the path of the locker file that prevents collisions between multiple concurrent bot executions.
    • guest mapping, for enabling the use of Guest Tokens (so you don't need a Twitter Developer account). If no twitter_token is present in your config it will default to true
    • proxy_pool mapping, list of proxies to use when being rate limited with Guest Tokens
    • proxy mapping, for enabling or disabling the use of proxies when using guest tokens
    • Caching IDs of posts published and skip mirroring tweet if associated published post is found to avoid duplicates. You can change this with the avoid_duplicates mapping.
    • application_name mapping, for specifying the Fediverse application name to use as a filter when getting the date of the latest published post by the bot. Thanks @reorx!
    • Configuration wizard, which generates a minimal config if none is found
    • content_warnings, for specifying keywords that if found will add a content warning to the Fediverse post
    • custom_replacements for replacing any text (Twitter handles that differ from the Fedi handle, for example) Thanks @selyod-ka!
    • software config mapping, for sidestepping the automatic detection of the type of software (mastodon, pleroma, misskey) running on the target instance and forcing a specific value. If your target is a fork of another project, for example, you would be able to force the bot to use whichever software (mastodon, pleroma, misskey) is the closest match for their API.
    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Jun 6, 2022)

    Fixed

    • Bug: Tweet media getting dropped if one of the attachments returned 404 Not Found
    • Regression: visibility's value not being honored when defined as a global mapping in the config
    • Bug: Handle exception when the tweet is empty (no attachments, polls or body) due to dropping malformed attachments
    • Bug: Handle exception when expanded URL is unreachable or returns any code other than 200
    • Regression: Not asking for date when passing a specific Twitter username with --forceDate
    • Bug: Trying to find previously pinned post on empty Fediverse account resulted in an unhandled exception
    • Bug: Truncating when exceeding post max length resulted in signature links being broken if original date was enabled
    • Bug: Videos not being mirrored in some cases with extended tweets

    Enhancements

    • Target instance's character limits when posting are taken into account and posts text are truncated if necessary
    • The rest of the users of the config are processed, even if another one fails (errors will be logged accordingly and pleroma-bot will exit with non-zero exit code)
    • Recover from hitting rate limits for Twitter's API (HTTP 429 Too Many Requests)
    • Twitter bio links are now expanded by default if the Fedi instance bio's maximum length is not exceeded
    • Maximum number of attachments allowed per post are now taken into account depending on the instance type (Mastodon, Pleroma or Misskey)
    • Alt text/Image descriptions are now mirrored on the Fediverse post image description/comment

    Added

    • include_quotes config mapping, for including or excluding quoted tweets
    • random_user_order global config mapping, for randomizing the order in which users are processed. Thanks @nemobis!
    • {{ website }} can be used on the metadata fields config and will be replaced with the website listed on the Twitter's account profile
    • no_profile config mapping, for skipping profile update (picture, banner, display name and bio) on a per-user basis
    Source code(tar.gz)
    Source code(zip)
  • 1.0.2(Feb 21, 2022)

    Added

    • Support for Misskey instances! 🎉

    Fixed

    • Logger standard output for systems not using UTF-8 encoding
    • Profile update: Regression when Twitter account does not have a profile image or banner
    • Media attachments being added to the Fediverse post in the wrong order in some cases

    Enhancements

    • RTs text no longer gets truncated
    • Info message when media upload returns 422 (Unprocessable Entity) due to Paperclip/file identifying the wrong mimetype
    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Feb 10, 2022)

    Fixed

    • Locale issue on Mac if the LANG environment variables were not set
    • RTs media attachments being duplicated if the referenced tweet was nested too deep
    • Pinned tweets being posted twice if they were part of the more recent batch of retrieved tweets

    Added

    • pleroma-bot can be run as a daemon now by using the flag --daemon. (more info on the docs)
    • A systemd service is automatically installed with the AUR package (and can be found in the repo as pleroma-bot.service)
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Jan 16, 2022)

    v1.0.0 is out! 🎉

    Fixed

    • max_tweets not accepting values higher than 100
    • Video: Not getting the best bitrate version of video attachments in some cases
    • Polls: not being retrieved for accounts with protected tweets
    • RTs: not getting original tweet media attachments

    Added

    • twitter_username value can be a list now, for having multiple Twitter accounts as sources for one target Fediverse account.
    • A Twitter archive can be provided with --archive(more info in the docs)
    • Links to Twitter attachments (video, images) are no longer explicitly included on the post's body text by default. You can choose to keep adding them with keep_media_links. This option does not affect the upload of attachments.
    • Youtube links can be replaced with invidious and invidious_base_url

    Enhancements

    • bio_text is no longer a mandatory mapping on the config
    • Hugely improved performance (around 4x) when processing tweets
    • Implemented safety measures for avoiding collision with multiple instances of the bot running at the same time
    Source code(tar.gz)
    Source code(zip)
  • 0.8.9(Dec 5, 2021)

    Added

    • original_date and original_date_format for adding the original tweet's creation date to the post body

    Fixed

    • URL expansion when regex match doesn't include protocol (http, https)
    Source code(tar.gz)
    Source code(zip)
  • 0.8.8(May 15, 2021)

    Added

    • twitter_bio mapping for allowing the user to choose if they want to retrieve and append the Twitter bio to their Fediverse user or not.
    Source code(tar.gz)
    Source code(zip)
  • 0.8.7(May 1, 2021)

    Added

    • delay_post mapping, for setting how long to wait (in seconds) between each post request to avoid hitting rate limits of the target Fediverse instance
    • hashtags mapping (list), for filtering out tweets which don't match any of them
    • tweet_ids mapping, for listing specific tweets to retrieve and post on the Fediverse account

    Enhancements

    • Provide a more meaningful exception message when an HTTP error code 422 is returned when updating the Fediverse profile
    • Referenced more directly in the documentation the need to use an account ID instead of a username when targeting a Mastodon instance
    Source code(tar.gz)
    Source code(zip)
  • 0.8.6(Feb 27, 2021)

  • 0.8.5(Feb 23, 2021)

    Added

    • Argument --config, the user can specify a custom path for the config.yml file to be parsed
    • Argument --log, the user can specify a custom path for the error.log to create during execution
    • Support for localization

    Enhancements

    Source code(tar.gz)
    Source code(zip)
  • 0.8.0(Feb 3, 2021)

    Added

    • Support for OAuth 1.0a authentication (needed if retrieving tweets from protected accounts)
    • Verbose argument -v for debugging
    • twitter_username can take a list as a value. They are internally broken apart into multiple User objects

    Fixed

    • HTML character entities incorrect escaping in tweet's body
    • First run skip condition if the Fediverse had no posts/tweets published as a result of a manual first run

    Enhancements

    • Provide feedback when long operations are running (speeen)
    • Color output based on logging level

    Upgrade notes

    If you're in a previous version, simply run this command to update to the latest stable version:

    pip install --upgrade pleroma-bot
    
    Source code(tar.gz)
    Source code(zip)
  • 0.7.0(Jan 19, 2021)

    Added

    • New and shiny help page
    • Checks for first run (no posts/toots on the Fediverse account, or no user folder present)
    • Argument --forceDate to allow setting a starting date for tweet retrieval (optionally forcing it on a user-by-user basis by providing twitter_username to identify the user on the config file)

    Fixed

    • Handle instances being unreachable when trying to get version info to identify their platform

    Enhancements

    • Reworked how arguments are parsed and processed with argparse
    • Pagination implemented for tweet retrieval (which allows tweets older than one week to be retrieved)
    Source code(tar.gz)
    Source code(zip)
  • 0.6.8(Jan 13, 2021)

    Added

    • New config attribute added (include_replies) which allows filtering tweets which are replies. Users now can choose whether to drop reply tweets or not (by default include_replies is true)

    Fixed

    • Exception when Twitter display name is longer than 30 Characters and target instance platform is Mastodon (which supports only up to 30)

    Enhancements

    • Refactored and aligned the format of old code
    • More readable console output when mirroring multiple users
    Source code(tar.gz)
    Source code(zip)
  • 0.6.2(Jan 7, 2021)

  • 0.6.1(Jan 7, 2021)

    Added

    • New attribute include_rts allows choosing whether if retweets are to be posted or ignored.
    • New attribute file_max_size allows setting a maximum size limit for attachments. If exceeded, the attachment will be dropped and won't be uploaded to the Fediverse instance.
    • Settings to use different nitter instances (thanks zoenglinghou!)

    Fixed

    • Timestamp format for Mastodon instances adjustments
    • Sensitivity boolean ignored by Mastodon instances if capitalized

    Enhancements

    • Improved Mastodon compatibility

    Upgrade notes

    If you're in a previous version simply run this command to update to the latest stable version:

    pip install --upgrade pleroma-bot
    
    Source code(tar.gz)
    Source code(zip)
  • 0.5.0(Nov 20, 2020)

    Added

    • Support for using the original tweet sensitivity (nsfw flag) when posting on the Fediverse account

    Fixed

    • Exception when no tweets are found within the last week (/tweets/search/recent)

    Upgrade notes

    • Remove the attribute 'sensitive' from your user section in your config.yml if you want to honor the original tweet's sensitivity instead of forcing it globally for all the posts by that user.
    Source code(tar.gz)
    Source code(zip)
  • 0.4.0(Oct 24, 2020)

    Added

    • Added support for polls 🎉 (thanks zoenglinghou!)
    • Migrated to Twitter API v2 (falling back to v1.1 for video attachments and animated gifs)

    Enhancements

    Fixed

    • Fixed posting only the first media element in a multiple media tweet
    • Fixed video attachments not being downloaded (and uploaded to the Fediverse post)
    • Fixed the exception when Twitter user has no profile and/or banner images (thanks zoenglinghou!)

    Upgrade notes

    • Place/move your config.yml to whichever path you want to run pleroma-bot
    • If you were using cron, change:
      • python3 /path/to/updateInfoPleroma.py noProfile
      • to cd /path/to/your/venv/ && . bin/activate && pleroma-bot noProfile
    Source code(tar.gz)
    Source code(zip)
  • 0.3.0(Oct 7, 2020)

    Added

    • Dynamic attribute loading for the User object from the config file
    • Rich text for linking mentions to their Twitter profile
    • Allow visibility and sensitivity to be set in the config file

    Fixed

    • Replacing the wrong strings in tweet body while expanding URLs
    • nitter.net replacement in twitter.com links misbehaviour
    • Default to retrieve tweets from the last 48h if Pleroma user has no posts (thanks zoenglinghou!)

    Upgrade notes

    1. Replace the field name pleroma_url with pleroma_base_url on your config.yml
    2. Replace the field name twitter_url with twitter_base_url on your config.yml
    Source code(tar.gz)
    Source code(zip)
  • 0.2.0(Aug 24, 2020)

    Added

    • Support for tweet attachments
    • Allow different usernames for Pleroma and Twitter accounts
    • Expand shortened URLs on tweet body
    • Support for pinned tweets
    • nitter.net URL replacement
    • Metadata fields can be defined in config.yml

    Fixed

    • RTs only showed body text, with no indicators of being a retweet

    Upgrade notes

    1. Update config.yml values and fields as described in the README.md
    Source code(tar.gz)
    Source code(zip)
  • 0.1.0(Aug 24, 2020)

Discord RPC for Notion written in Python

Discord RPC for Notion This is a program that allows you to add your Notion workspace activities to your Discord profile. This project is currently un

Thuliumitation 1 Feb 10, 2022
Video Stream: an Advanced Telegram Bot that's allow you to play Video & Music on Telegram Group Video Chat

Video Stream is an Advanced Telegram Bot that's allow you to play Video & Music on Telegram Group Video Chat 🧪 Get SESSION_NAME from below: Pyrogram

Jonathan 6 Feb 08, 2022
Telegram vc userbot

Telegram Vc Userbot Available Commands /ping :- To check whether userbot is up or not /joinvc :- To join vc /leavevc :- To leave vc /join_group :- To

NandyDark 7 Nov 18, 2022
🚀🔥使用Python连接阿里云盘, 实现了官方大部分功能 👍👍

aligo 🚀 🔥 使用Python连接阿里云盘, 实现了官方大部分功能 👍 👍 为了完善代码提示, 方便大家代码书写, aligo 引入了一些 python 3.8 的新特性, 所以要求 python = 3.8.* pip install aligo 或 pip install ali

455 Jan 08, 2023
A Telegram Userbot to play Audio and Video songs / files in Telegram Voice Chats.

VC UserBot A Telegram Userbot to play Audio and Video songs / files in Telegram Voice Chats. It's made with PyTgCalls and Pyrogram Requirements Python

조던 1 Nov 29, 2021
Discord Token Generator - Python (Generates Tokens and Joins your Server Automatically) hCaptcha Bypass **FREE**

Best Discord Token Generator {hCaptcha bypass FREE Unlimited Memberboost} Install few requirements & run main.py it will redirect you to the Download

1 Oct 27, 2021
A free sniper bot built to work with PancakeSwap: Router V2

Pancakeswap Sniper Bot PancakeSwap sniper bot. Automated sniping bot to snipe crypto coin launches. How it works The sniping bot can be used in three

89 Aug 06, 2022
Scripts to help you win the Pizza Express

Slice of the Prizes Slice of the Prizes is a Python Script designed to enter the "Slice of the Action" competition hosted by Pizza Express the competi

Luke Bendall 1 Nov 04, 2021
API Basica per a synologys Active Backup For Buissiness

Synology Active Backup for Business API-NPP Informació Per executar el programa

Nil Pujol 0 May 13, 2022
A simple Spamming software made in python

Spam-qlk Warning!!! 'I' am not responsible for the 'damage or harm' caused by this 'Software'!!! Use at your own risk!!! Input the message. After you

Aditya kumar 1 Nov 30, 2021
Desktop Backup Client for Borg

Vorta Backup Client Vorta is a backup client for macOS and Linux desktops. It integrates the mighty BorgBackup with your desktop environment to protec

BorgBase.com 1.5k Jan 03, 2023
Rust UserBot, Telegram istifadəsini asanlaşdıran bir proyektdir.

RUST USERBOT 🇦🇿 Rust UserBot, Telegram istifadəsini asanlaşdıran bir proyektdir. Qurulum Heroku Serverə qurulum git clone https://github.com/rustres

1 Oct 25, 2021
🔍 Google Search unofficial API for Python with no external dependencies

Python Google Search API Unofficial Google Search API for Python. It uses web scraping in the background and is compatible with both Python 2 and 3. W

Avi Aryan 204 Dec 28, 2022
Petit webhook manager by moi (wassim)

Webhook Manager By wassim oubliez pas de ⭐ le projet Installations il te faut python sinon quand tu va lancer le start.bat sa va tout installer tout s

wassim 9 Jul 08, 2021
对hermit 的API进行简单的封装,做成了这个python moudle

hermit-py 对hermit 的API进行简单的封装,做成了这个Python Moudle,推荐通过wheel的方式安装。 目前对点击、滑动、模拟输入、找组件、等支持较好,支持查看页面的实时布局信息,再通过布局信息进行点击滑动等操作。 支持剪贴板相关的操作,支持设置剪贴的任意语言内容。

LookCos 40 Jun 25, 2022
FTX auto lending bot with python

FTX auto lending bot Get the API key Check my article for step by step + screenshots Setup & Run Install python 3 Install dependency pip install -r re

Patompong Manprasatkul 1 Dec 24, 2021
Using AWS Batch jobs to bulk copy/sync files in S3

Using AWS Batch jobs to bulk copy/sync files in S3

AWS Samples 14 Sep 19, 2022
A Slack bot for playing Texas Hold 'Em where the currency is various workout tasks e.g. pushups

A Slack app/bot for playing Texas Hold 'Em where the currency is various workout tasks e.g. pushups. The intent is to make the workday more fun & active for remote teams.

Kyle McIntyre 3 Sep 19, 2022
Huggingface inference with GPU Docker on AWS

This repository contains code to containerize and deploy a GPU docker on AWS for summarization task. Find a detailed blogpost here Youtube Video Versi

Ramsri Goutham Golla 21 Dec 30, 2022
Ciclo 1 - MisiónTIC - UIS (Retos)

misiontic_uis Ciclo 1 - MisiónTIC - UIS Reto 1: Fundamentos del Lenguaje Python Reto 2: Estructuras de Control Condicional Reto 3: Estructuras de Cont

9 May 24, 2022