twitter
twitter copied to clipboard
How should I bridge two Twitter accounts?
I have two Twitter accounts and I want to manage their messages together.
However, mautrix-twitter’s Twitter Bridge Bot can only login one account ones. So I started thinking whether I could start 2 mautrix-twitter bridges to catch all messages.
I think I’m 90% done: I could login using the second twitter bot, however, I could not receive messages because there’re still some conflicts.
Here is how I deploy the second bridge:
Creating the second database
docker exec postgres createdb -U synapse_user -O synapse_user matrix_twitter_s1
Making a new directory and config for new bridge
mkdir mautrix-twitter-s1
docker run --rm -v `pwd`/mautrix-twitter-s1:/data:z dock.mau.dev/mautrix/twitter:latest
In mautrix-twitter-s1/config.yaml
(only listing changes)
homeserver:
address: http://synapse:8008
domain: example.com
appservice:
address: http://mautrix-twitter-s1:29328
port: 29328
database: postgres://synapse_user:hello@postgres/matrix_twitter_s1?sslmode=disable
id: twitter-s1
bot_username: twitterbot-s1
bot_displayname: Twitter bridge bot s1
bridge:
username_template: twitter_s1_{userid}
displayname_template: "{displayname} (Twitter)"
double_puppet_server_map:
matrix.server: https://example.com
login_shared_secret_map:
example.com: <redacted>
command_prefix: "!tw1"
permissions:
example.com: user
"@admin:example.com": admin
Register the new bridge
After editing the config, I run
docker run --rm -v `pwd`/mautrix-twitter-s1:/data:z dock.mau.dev/mautrix/twitter:latest
again to get registration.yaml
:
id: twitter-s1
as_token: <redacted>
hs_token: <redacted>
namespaces:
users:
- exclusive: true
regex: '@twitter_s1_.*:example\.com'
- exclusive: true
regex: '@twitterbot\-s1:example\.com'
aliases: []
url: http://mautrix-twitter-s1:29328
sender_localpart: <redacted>
rate_limited: false
de.sorunome.msc2409.push_ephemeral: true
push_ephemeral: true
Then I register the bridge to synapse:
cp mautrix-twitter-s1/registration.yaml synapse/tw-s1-registration.yaml
sudo chown 991:991 synapse/tw-s1-registration.yaml
And in synapse/homeserver.yaml
:
app_service_config_files:
- /data/tw-s1-registration.yaml
Start the container
Then I edit the docker-compose.yml, adding lines below. I have already set another bridge by then, so here I show thier config together.
mautrix-twitter:
hostname: mautrix-twitter
container_name: mautrix-twitter
image: dock.mau.dev/mautrix/twitter:latest
restart: unless-stopped
depends_on:
synapse:
condition: service_healthy
volumes:
- ./mautrix-twitter:/data
networks:
- matrix-net
mautrix-twitter-s1:
hostname: mautrix-twitter-s1
container_name: mautrix-twitter-s1
image: dock.mau.dev/mautrix/twitter:latest
restart: unless-stopped
depends_on:
synapse:
condition: service_healthy
volumes:
- ./mautrix-twitter-s1:/data
networks:
- matrix-net
Encounter problems
Then I use docker-compose up -d
to start my service, start a chat with @twitterbot-s1:example.com
.
I could successfully login:
...but when the brige try to sync msgs, it encounter such problems:
[2022-12-26 04:02:50,819] [[email protected].@arcsionlin:example.com] Failed to update own puppet info
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/mautrix_twitter/user.py", line 326, in _try_sync_puppet
await puppet.update_info(user_info)
File "/usr/lib/python3.10/site-packages/mautrix_twitter/puppet.py", line 114, in update_info
update = await self._update_name(info) or update
File "/usr/lib/python3.10/site-packages/mautrix_twitter/puppet.py", line 132, in _update_name
await self.default_mxid_intent.set_displayname(self.name)
File "/usr/lib/python3.10/site-packages/mautrix/appservice/api/intent.py", line 126, in wrapper
await __self.ensure_registered()
File "/usr/lib/python3.10/site-packages/mautrix/appservice/api/intent.py", line 625, in ensure_registered
await self._register()
File "/usr/lib/python3.10/site-packages/mautrix/api.py", line 401, in request
resp_data, resp = await self._send(
File "/usr/lib/python3.10/site-packages/mautrix/api.py", line 256, in _send
raise make_request_error(
mautrix.errors.request.MExclusive: This user ID is reserved by an application service.
I tried to change displayname_template from "{displayname} (Twitter)"
to "{displayname} (Twitter-s1)"
in order to solve possible conflicts, but problem remains.
Could anyone give me some ideas on how should I solve this? Or, should I attach the configration of my first twitter brige (which works fine)?
Perhaps you've resolved it at this point, but it's probably that the namespaces for the two bridges are overlapping.
If your first bridge uses @twitter_.*:example\.com''
, that's going to overlap with @twitter_s1_.*:example\.com'