mautrix / facebook Goto Github PK
View Code? Open in Web Editor NEWA Matrix-Facebook Messenger puppeting bridge
Home Page: https://matrix.to/#/#facebook:maunium.net
License: GNU Affero General Public License v3.0
A Matrix-Facebook Messenger puppeting bridge
Home Page: https://matrix.to/#/#facebook:maunium.net
License: GNU Affero General Public License v3.0
Steps to reproduce:
displayname_preference
to something elsename
The bug seems to be at mautrix_facebook/puppet.py:170
async def _update_name(self, info: FBUser) -> bool:
name = self._get_displayname(info)
if name != self.name:
From a glance at the code it's not clear whether self.name
is being loaded from the database or from Facebook, but either way it is always the "Full Name". This means the code doesn't enter the if statement, as name
is always the same as the new display name.
In the last couple of days I don't receive stickers from FB. Log is at the end. Weird stuff is that, Exception says: Sticker' object has no attribute 'url'
, however there is an url part in the MQTT payload. Any idea what went wrong?
Thanks in advance!
May 16 16:10:36 matrix matrix-mautrix-facebook[25634]: [2020-05-16 15:10:36,117]
[DEBUG@fbchat] MQTT payload: /t_ms, {'deltas': [{'attachments': [{'mercury':
{'sticker_attachment': {'id': '383649271796512', 'pack': {'id':
'380362042125235'}, 'label': 'Hug, woman with Hug Me', 'frame_count': 1,
'frame_rate': 83, 'frames_per_row': 1, 'frames_per_column': 1,
'sprite_image_2x': None, 'sprite_image': None, 'padded_sprite_image': None,
'padded_sprite_image_2x': None, 'url':
'https://scontent.xx.fbcdn.net/v/t39.1997-6/
47293479_1074621542699278_3857650959962341376_n.png?_nc_cat=1&_nc_sid=ac3552&
_nc_ohc=r8v47ihQU4wAX8YDHAU&_nc_ad=z-m&_nc_cid=0&_nc_zor=9&_nc_ht=scontent.xx&oh
=5156502806cbd4cf07b4f3eaba3a142a&oe=5EE6443C', 'height': 240, 'width': 240}}}],
'irisSeqId': '689888', 'irisTags': ['DeltaNewMessage', 'is_from_iris_fanout'],
'messageMetadata': {'actorFbId': '1399484626', 'cid':
{'canonicalParticipantFbids': ['1399484626', '100001489252999']}, 'folderId':
{'systemFolderId': 'INBOX'}, 'messageId': 'mid.$cAABa8zpUAlV4T069o1yHgl1Hxn-M',
'offlineThreadingId': '6667441110493069196', 'skipBumpThread': False,
'skipSnippetUpdate': False, 'tags': ['source:chat:web'], 'threadKey':
{'otherUserFbId': '1399484626'}, 'threadReadStateEffect': 'MARK_UNREAD',
'timestamp': '1589641835939', 'unsendType': 'deny_for_non_sender'},
'requestContext': {'apiArgs': {}}, 'stickerId': '383649271796512', 'class':
'NewMessage'}], 'firstDeltaSeqId': 689888, 'lastIssuedSeqId': 689888,
'queueEntityId': 100001489252999}
May 16 16:10:36 matrix matrix-mautrix-facebook[25634]: [2020-05-16 15:10:36,828]
[[email protected].@gergely:horvath.club] Handling facebook event
MessageEvent(author=User(session=<fbchat.Session user_id=100001489252999>,
id='1399484626'), thread=User(session=<fbchat.Session user_id=100001489252999>,
id='1399484626'), message=MessageData(thread=User(session=<fbchat.Session
user_id=100001489252999>, id='1399484626'),
id='mid.$cAABa8zpUAlV4T069o1yHgl1Hxn-M', author='1399484626',
created_at=datetime.datetime(2020, 5, 16, 15, 10, 35, 939000,
tzinfo=datetime.timezone.utc), text=None, mentions=[], emoji_size=None,
is_read=None, read_by=[], reactions={}, sticker=Sticker(id='383649271796512',
pack='380362042125235', is_animated=False, medium_sprite_image=None,
large_sprite_image=None, frames_per_row=1, frames_per_col=1, frame_count=1,
frame_rate=83,
image=Image(url='https://scontent.xx.fbcdn.net/v/t39.1997-6/
47293479_1074621542699278_3857650959962341376_n.png?_nc_cat=1&_nc_sid=ac3552&
_nc_ohc=r8v47ihQU4wAX8YDHAU&_nc_ad=z-m&_nc_cid=0&_nc_zor=9&_nc_ht=scontent.xx&oh
=5156502806cbd4cf07b4f3eaba3a142a&oe=5EE6443C', width=240, height=240),
label='Hug, woman with Hug Me'), attachments=[], quick_replies=[], unsent=False,
reply_to_id=None, replied_to=None, forwarded=False), at=datetime.datetime(2020,
5, 16, 15, 10, 35, 939000, tzinfo=datetime.timezone.utc))
May 16 16:10:36 matrix matrix-mautrix-facebook[25634]: [2020-05-16 15:10:36,830]
[[email protected].@gergely:horvath.club] Failed to handle facebook event
May 16 16:10:36 matrix matrix-mautrix-facebook[25634]: Traceback (most recent
call last):
May 16 16:10:36 matrix matrix-mautrix-facebook[25634]: File
"/usr/lib/python3.8/site-packages/mautrix_facebook/user.py", line 333, in listen
May 16 16:10:36 matrix matrix-mautrix-facebook[25634]: await handler(event)
May 16 16:10:36 matrix matrix-mautrix-facebook[25634]: File
"/usr/lib/python3.8/site-packages/mautrix_facebook/user.py", line 358, in
on_message
May 16 16:10:36 matrix matrix-mautrix-facebook[25634]: await
portal.handle_facebook_message(self, puppet, evt.message)
May 16 16:10:36 matrix matrix-mautrix-facebook[25634]: File
"/usr/lib/python3.8/site-packages/mautrix_facebook/portal.py", line 559, in
handle_facebook_message
May 16 16:10:36 matrix matrix-mautrix-facebook[25634]: event_ids = [await
self._handle_facebook_sticker(intent, message.sticker,
May 16 16:10:36 matrix matrix-mautrix-facebook[25634]: File
"/usr/lib/python3.8/site-packages/mautrix_facebook/portal.py", line 614, in
_handle_facebook_sticker
May 16 16:10:36 matrix matrix-mautrix-facebook[25634]: sticker.url, intent,
encrypt=self.encrypted)
May 16 16:10:36 matrix matrix-mautrix-facebook[25634]: AttributeError: 'Sticker'
object has no attribute 'url'
FB bridge stopped working for me, and server admin found this from the log. Restart
fixed the situation.
touko 13 23:07:00 matrix python[22101]: [2019-05-13 23:07:00,439] [[email protected].@xxxx:matrix.org] Exception in parsing of {'ofd_ts': 1557778020394, 'delta': {'attachments': [], 'body': '<redacted>', 'irisSeqId': '43412', 'irisTags': [], 'messageMetadata': {'actorFbId': '540036593', 'folderId': {'systemFolderId': 'INBOX'}, 'messageId': 'mid.$cAAAAAGfgWYtw5BN_7Fqss43T40RN', 'offlineThreadingId': '6533794581134394445', 'skipSnippetUpdate': False, 'tags': ['source:chat:web'], 'threadKey': {'otherUserFbId': '1204819066'}, 'timestamp': '1557778020332'}, 'requestContext': {'apiArgs': {}}, 'class': 'NewMessage'}, 'type': 'delta', 'iseq': 43412, 'queue': 540036593}
touko 13 23:07:00 matrix python[22101]: Traceback (most recent call last):
touko 13 23:07:00 matrix python[22101]: File "/opt/mautrix-facebook/mautrix-facebook/.venv/lib/python3.6/site-packages/fbchat/_client.py", line 3018, in _parseMessage
touko 13 23:07:00 matrix python[22101]: await self._parseDelta(m)
touko 13 23:07:00 matrix python[22101]: File "/opt/mautrix-facebook/mautrix-facebook/.venv/lib/python3.6/site-packages/fbchat/_client.py", line 2985, in _parseDelta
touko 13 23:07:00 matrix python[22101]: msg=m,
touko 13 23:07:00 matrix python[22101]: File "/opt/mautrix-facebook/mautrix-facebook/mautrix_facebook/user.py", line 235, in onMessage
touko 13 23:07:00 matrix python[22101]: await portal.handle_facebook_message(self, puppet, message_object)
touko 13 23:07:00 matrix python[22101]: File "/opt/mautrix-facebook/mautrix-facebook/mautrix_facebook/portal.py", line 397, in handle_facebook_message
touko 13 23:07:00 matrix python[22101]: await self.main_intent.invite_user(self.mxid, sender.mxid)
touko 13 23:07:00 matrix python[22101]: File "/opt/mautrix-facebook/mautrix-facebook/.venv/lib/python3.6/site-packages/mautrix/appservice/api/intent.py", line 84, in wrapper
touko 13 23:07:00 matrix python[22101]: await __self.ensure_joined(room_id)
touko 13 23:07:00 matrix python[22101]: File "/opt/mautrix-facebook/mautrix-facebook/.venv/lib/python3.6/site-packages/mautrix/appservice/api/intent.py", line 349, in ensure_joined
touko 13 23:07:00 matrix python[22101]: raise ValueError("Room ID not given")
touko 13 23:07:00 matrix python[22101]: ValueError: Room ID not given
Like the Telegram and WhatsApp bridges. Could maybe have a template for group chat names too.
[2019-05-14 01:42:13,769] [[email protected]] Unhandled error while handling command help from @travis:t2l.io (ref: 1557798028)
Traceback (most recent call last):
File "/home/facebook/fbenv/lib/python3.6/site-packages/mautrix/bridge/commands/handler.py", line 366, in handle
await handler(evt)
File "/home/facebook/fbenv/lib/python3.6/site-packages/mautrix/bridge/commands/handler.py", line 267, in __call__
return await self._handler(evt)
File "/home/facebook/fbenv/lib/python3.6/site-packages/mautrix/bridge/commands/meta.py", line 60, in help_cmd
return await evt.reply(_get_management_status(evt) + "\n" + await _get_help_text(evt))
File "/home/facebook/fbenv/lib/python3.6/site-packages/mautrix/bridge/commands/meta.py", line 38, in _get_help_text
if handler.has_help and handler.has_permission(cache_key):
File "/home/facebook/mautrix-facebook/mautrix_facebook/commands/handler.py", line 59, in has_permission
(not self.needs_auth or key.is_logged_in))
AttributeError: 'HelpCacheKey' object has no attribute 'is_logged_in'
Facebook very often flags the appservice as "suspicious activity" and prompts to change my password (without option to skip this). I've hade to change my password more than 20 times in the last few months. Is there some way to avoid this?
I noticed the Dockerfile contains several python packages that aren't listed in the requirements.txt file. In particular: pillow, beautifulsoup4, yaml, idna, and future. I had all of these on my system already due to matrix-synapse.
There currently isn't a way to tell if a message sent in a portal room failed to be bridged, other than logging into another Messenger client or waiting to get a read receipt from a Facebook user (which won't ever happen if your message wasn't bridged). It would be very helpful if there was some kind of warning for when a message failed to be bridged. (This just bit me and it is very embarrassing!)
One idea is to have the Facebook bot user post a read receipt for successfully-bridged messages (like matrix-appservice-discord does), but that isn't an option for 1:1 chat portals which the Facebook bot user is not a member of. The next best thing would be to have the puppet for the non-logged in Facebook user in a 1:1 portal posting a message that is clearly a "failed to bridge" warning message from the appservice and not a message sent from the actual human Facebook user.
Add support for Facebook workplace. According to developer documentation, there are several APIs. There seems to be support for bots too. Here is corresponding issue in matrix wishlist: turt2live/matrix-wishlist#269.
Matrix account puppeting like the Telegram bridge.
After some messing around, I got the bridge up and running. However, after calling !fb sync
for the first time, I was greeted by the following code block:
Traceback (most recent call last):
File "/home/rafael/webservices/matrix/mautrix-facebook/lib/python3.7/site-packages/mautrix/bridge/commands/handler.py", line 371, in handle
await self._run_handler(handler, evt)
File "/home/rafael/webservices/matrix/mautrix-facebook/lib/python3.7/site-packages/mautrix/bridge/commands/handler.py", line 269, in __call__
return await self._handler(evt)
File "/home/rafael/webservices/matrix/mautrix-facebook/lib/python3.7/site-packages/mautrix_facebook/commands/facebook.py", line 68, in sync
threads = await evt.sender.fetchThreads(limit=limit, thread_location=ThreadLocation.INBOX)
File "/home/rafael/webservices/matrix/mautrix-facebook/lib/python3.7/site-packages/fbchat/_client.py", line 380, in fetchThreads
before=last_thread_timestamp, thread_location=thread_location
File "/home/rafael/webservices/matrix/mautrix-facebook/lib/python3.7/site-packages/fbchat/_client.py", line 903, in fetchThreadList
"Unknown thread type: {}, with data: {}".format(_type, node)
fbchat._exception.FBchatException: Unknown thread type: MARKETPLACE, with data: {REDACTED}
This is for a Marktetplace chat. I think you might have simply forgotten that those exist?
Logs currently contain message content and other private information. The logs should be minimized to contain as little private information as possible without reducing usefulness when debugging.
Successful build of .deb packages.
Traceback (most recent call last):
File "setup.py", line 11, in <module>
with open("requirements.txt") as reqs:
FileNotFoundError: [Errno 2] No such file or directory: 'requirements.txt'
I notice that the tarball downloaded in step 3 does not contain the requirements.txt
file. Would it be possible and make sense to have it included in the tarball found on PyPI?
after upgrading to 9264125, login-cookie
isn't work.
Apr 11 21:52:12 archlinux mautrix-facebook[407738]: [2020-04-11 21:52:12,425] [[email protected]] 127.0.0.1 [11/Apr/2020:21:52:12 +0000] "PUT /transactions/350?access_token=SNIP HTTP/1.1" 200 158 "-" "Synapse/1.11.1"
Apr 11 21:52:14 archlinux mautrix-facebook[407738]: [2020-04-11 21:52:14,226] [[email protected].@SNIP:SNIP] Failed loading session
Apr 11 21:52:14 archlinux mautrix-facebook[407738]: Traceback (most recent call last):
Apr 11 21:52:14 archlinux mautrix-facebook[407738]: File "/usr/lib/python3.8/site-packages/fbchat/_client.py", line 184, in set_session
Apr 11 21:52:14 archlinux mautrix-facebook[407738]: self._state = await _state.State.from_cookies(session_cookies, loop=self.loop,
Apr 11 21:52:14 archlinux mautrix-facebook[407738]: File "/usr/lib/python3.8/site-packages/fbchat/_state.py", line 246, in from_cookies
Apr 11 21:52:14 archlinux mautrix-facebook[407738]: return await cls.from_session(session=session)
Apr 11 21:52:14 archlinux mautrix-facebook[407738]: File "/usr/lib/python3.8/site-packages/fbchat/_state.py", line 227, in from_session
Apr 11 21:52:14 archlinux mautrix-facebook[407738]: user_id, fb_dtsg, revision, logout_h = await cls._from_session(session)
Apr 11 21:52:14 archlinux mautrix-facebook[407738]: File "/usr/lib/python3.8/site-packages/fbchat/_state.py", line 209, in _from_session
Apr 11 21:52:14 archlinux mautrix-facebook[407738]: revision = int(text.split('"client_revision":', 1)[1].split(",", 1)[0])
Apr 11 21:52:14 archlinux mautrix-facebook[407738]: IndexError: list index out of range
I have a setup according to https://github.com/spantaleev/matrix-docker-ansible-deploy. I set to put all facebook chats in a community on its own. So my config looks like
...
bridge:
username_template: facebook_{userid}
community_template: unofficial/facebook_{localpart}={server}
...
I then enabled the bridge and successfully connected (after a few attempts) with my Facebook account. All right, a new community was generated and some rooms in this community as well. Older chats were not imported. Seems ok. Yay!
I then wanted to open a chat with a contact I did not chat in a long time. The chat was not generated in the first moment during sync. I thus called sync --contacts
and sync --create
in the control room.
This started a long-running sync process where all chats were readded but without the community. Thus all my chats are now in the main list but not in the community. I seem not to have sufficient rights to change the community to add the rooms to the community manually (although tedious).
I think there is a bug or the documentation needs to be improved that the sync
command is only for internal usage and might break the installation (plus a potential workaround).
Messenger seems to support per-chat nicknames that are visible to everyone, which means the bridge could use those.
Hey there!
I am by far not a snake guy so... I have some difficulties understanding what Python is trying to tell me here?
Basically, I logged in using the cookie method and then ran sync
. And then, this happened:
Traceback (most recent call last):
File "/srv/matrix/facebook/lib/python3.7/site-packages/mautrix/bridge/commands/handler.py", line 359, in handle
await self._run_handler(handler, evt)
File "/srv/matrix/facebook/lib/python3.7/site-packages/mautrix/bridge/commands/handler.py", line 253, in __call__
return await self._handler(evt)
File "/srv/matrix/facebook/lib/python3.7/site-packages/mautrix_facebook/commands/facebook.py", line 68, in sync
threads = await evt.sender.fetch_threads(limit=limit, thread_location=ThreadLocation.INBOX)
File "/srv/matrix/facebook/lib/python3.7/site-packages/fbchat/_client.py", line 270, in fetch_threads
before=last_thread_dt, thread_location=thread_location
File "/srv/matrix/facebook/lib/python3.7/site-packages/fbchat/_client.py", line 774, in fetch_thread_list
j, = await self.graphql_requests(_graphql.from_doc_id("1349387578499440", params))
File "/srv/matrix/facebook/lib/python3.7/site-packages/fbchat/_client.py", line 135, in graphql_requests
util_log=self._util_log))
File "/srv/matrix/facebook/lib/python3.7/site-packages/fbchat/_state.py", line 313, in _graphql_requests
req_log=req_log, util_log=util_log)
File "/srv/matrix/facebook/lib/python3.7/site-packages/fbchat/_state.py", line 285, in _post
resp = _graphql.response_to_json(content)
File "/srv/matrix/facebook/lib/python3.7/site-packages/fbchat/_graphql.py", line 51, in response_to_json
[(key, value)] = x.items()
ValueError: too many values to unpack (expected 1)
How do I fix that? o.o
Kind regards,
Ingwie
Facebook user sends a URL, not received on Matrix. If the same user sends a message, it goes through just fine
Following the setup instructions on Debian buster (raspberry pi), I was unable to get past the pip install step for 0.1.0.dev16. Relevant "yarl" log entries below, same for "ruamel.yaml.clib". sudo apt install python3-dev
resolved it.
Building wheel for yarl (setup.py) ... error
command: /usr/local/src/mautrix-facebook/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-fhzbml9i/yarl/setup.py'"'"'; __file__='"'"'/tmp/pip-install-fhzbml9i/yarl/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-7ocn2b2s
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.7m -I/usr/local/src/mautrix-facebook/include/python3.7m -c yarl/_quoting.c -o build/temp.linux-armv7l-3.7/yarl/_quoting.o
yarl/_quoting.c:4:10: fatal error: Python.h: No such file or directory
#include "Python.h"
^~~~~~~~~~
compilation terminated.
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for yarl
I've been successfully running this bridge for a few weeks now, it's very fully featured and the most solid bridge I've used so far! However, I noticed that after a while (maybe a day or so, not sure) I stop receiving new messages. I'm still able to send replies, but replies from friends don't come through. Once I restart the docker image, I'm able to receive messages again.
For the time being, I've added a systemd time to restart the docker container each night:
# /usr/lib/systemd/system/restart-mautrix-facebook.service
[Unit]
Description=Restart Facebook Matrix bridge so it reconnects
[Service]
Type=simple
ExecStart=docker restart mautrix-facebook
Restart=no
# /usr/lib/systemd/system/restart-mautrix-facebook.timer
[Unit]
Description=Restart Facebook Matrix bridge so it reconnects
[Timer]
OnCalendar=*-*-* 03:00:00
RandomizedDelaySec=7200
[Install]
WantedBy=timers.target
I only added the timer last night, so I can't be sure yet if this is frequent enough. In any case, this is a hacky stopgap to keep it working until the root cause is found.
I set up a homeserver using the ansible playbook and the :latest
docker image and tried using 2FA to log in (after failing repeatedly due to "new location sign in")
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/mautrix/bridge/commands/handler.py", line 366, in handle
await handler(evt)
File "/usr/lib/python3.7/site-packages/mautrix/bridge/commands/handler.py", line 267, in __call__
return await self._handler(evt)
File "/opt/mautrix-facebook/mautrix_facebook/commands/auth.py", line 40, in login
await evt.sender.login(evt.args[0], " ".join(evt.args[1:]), max_tries=1)
File "/usr/lib/python3.7/site-packages/fbchat/_client.py", line 272, in login
log=self._state_log
File "/usr/lib/python3.7/site-packages/fbchat/_state.py", line 133, in login
resp = await _2fa_helper(session, code, resp, log)
File "/usr/lib/python3.7/site-packages/fbchat/_state.py", line 28, in _2fa_helper
soup = find_input_fields(r.text)
File "/usr/lib/python3.7/site-packages/fbchat/_state.py", line 18, in find_input_fields
return bs4.BeautifulSoup(html, "html.parser", parse_only=bs4.SoupStrainer("input"))
File "/usr/lib/python3.7/site-packages/bs4/__init__.py", line 246, in __init__
elif len(markup) <= 256 and (
TypeError: object of type 'method' has no len()
Workaround: open facebook and read the message, then reply via Matrix.
After that messages work fine but the messages sent before joining the room are missing.
If you're already logged in, sending a new login <email> <password>
command would fail with a "Something went wrong" HTML response coming from Facebook.
I'm not sure if this always happens or if it happens only in certain more weird cases (after a password change, 2FA-enabling, etc.), but I could get it to consistently happen to me.
In my case, I had recently enabled 2FA and decided it'd be best if I create a new login session for the bridge, go through the 2FA verification, etc. I found out that all my login attempts would result in an error (Login failed. Check email/password. (Failed on url: https://m.facebook.com/login.php?login_attempt=1)
) -- not very helpful. Upon further debugging, I found out that Facebook replies with HTML that says "Something went wrong". Still not too helpful to figure out what's wrong.
I thought fbchat-asyncio is lagging behind the original fbchat library and has some bug with handling 2FA or verifying that it lands on the homepage, but.. after testing both libraries in a clean environment, I've confirmed that both can successfully complete a 2FA login for my account.
Running this code in the (failing) bridge's container resulted in a successful login:
from fbchat import Client
from fbchat.models import *
client = Client()
import asyncio
async def work():
print(repr(await client.login('EMAIL_ADDRESS', 'PASSWORD')))
if not await client.isLoggedIn():
print('Not logged in')
else:
print('Logged in')
loop = asyncio.get_event_loop()
loop.run_until_complete(work())
loop.close()
This lead me to believe that the library is fine, and it's the Client
object used by the bridge that is somehow contaminated. Having not dug into the bridge's code too much, I'm only guessing but.. I suppose there's a single Client
object associated with my Matrix user id. Given that the bridge is currently doing work for me, this Client
object's session's cookie jar contains some stuff from my existing login session. Trying to do a fresh login()
makes all those old cookies get sent and Facebook doesn't like that for some reason.
I've worked around this by patching fbchat-asyncio's _client.py
file, so that _login()
would do self._resetValues()
first.
This allowed me to replace my existing login session with a new one successfully.
I'm not sending a patch to fbchat-asyncio, as I'm not sure if this is the proper way to solve it. Perhaps resetting values midway can cause other stuff to break.. Perhaps there's a better way for the bridge to gracefully replace an old Client
with a new one?
eg:
/home/facebook/fbenv/bin/python -m mautrix_facebook -c /home/facebook/config.yaml -b /home/facebook/mautrix_facebook/example-config.yaml
results in:
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/facebook/fbenv/lib/python3.6/site-packages/mautrix_facebook/__main__.py", line 62, in <module>
MessengerBridge().run()
File "/home/facebook/fbenv/lib/python3.6/site-packages/mautrix/bridge/bridge.py", line 84, in run
self._prepare()
File "/home/facebook/fbenv/lib/python3.6/site-packages/mautrix/bridge/bridge.py", line 90, in _prepare
self.prepare_config(args.config, args.registration, args.base_config)
File "/home/facebook/fbenv/lib/python3.6/site-packages/mautrix/bridge/bridge.py", line 105, in prepare_config
self.config.update()
File "/home/facebook/fbenv/lib/python3.6/site-packages/mautrix/util/config.py", line 138, in update
raise ValueError("Can't update() without base config")
ValueError: Can't update() without base config
Since Python 3.8
requirements are installed and running in virtualenv, Matrix itself works fine after Upgrade to Python 3.8+
[2019-12-01 18:10:35,167] [[email protected]] Unexpected error in initialization
Traceback (most recent call last):
File "/home/projects/python/.matrix-facebook/lib/python3.8/site-packages/mautrix/bridge/bridge.py", line 112, in _prepare
self.prepare_bridge()
File "/home/projects/python/.matrix-facebook/mautrix_facebook/__main__.py", line 46, in prepare_bridge
self.matrix = context.mx = MatrixHandler(context)
File "/home/projects/python/.matrix-facebook/mautrix_facebook/matrix.py", line 34, in __init__
super().__init__(context.az, context.config, command_processor=c.CommandProcessor(context))
File "/home/projects/python/.matrix-facebook/mautrix_facebook/commands/handler.py", line 76, in __init__
super().__init__(az=context.az, config=context.config, event_class=CommandEvent,
TypeError: __init__() missing 1 required positional argument: 'bridge'
(.matrix-facebook) python@webapps:~/.matrix-facebook$
Matrix -> Messenger requires #1. Messenger mentions are sent as message metadata rather than just text like other formatting.
A separate login interface is needed to prevent passwords from being stored in message history
Use Facebook user account as a relay bridge as Facebook does not support bots.
When reacting with the ๐ on Riot Web (1.5.5), Riot sends the following event:
{
"type": "m.reaction",
"sender": "@kevin:kliu.io",
"content": {
"m.relates_to": {
"rel_type": "m.annotation",
"event_id": "$aIiBcFJwYn9mcXLUhR1M8HsjjBPQ9zdeKFX51CbNWFk",
"key": "๐๏ธ"
}
},
"event_id": "$Hi0PLHhOueAom2zjmbWh3V1XW-FwxmpDptQeGtWk2uo",
"origin_server_ts": 1575218667406,
"unsigned": {
"age": 95809,
"transaction_id": "m1575218667318.25"
},
"room_id": "!ZzJhvgtimjgTccAAKf:kliu.io"
}
Where the ๐ is actually ๐<fe0f>
; that is, the ๐ followed by a Unicode variation selector. This appears to be mentioned in element-hq/element-web#9785. The facebook bridge appears to only map a plain ๐: https://github.com/tulir/mautrix-facebook/blob/2de54e1b48a110052e9be1073105f6ef301e5397/mautrix_facebook/portal.py#L426. Thus, the reaction is not applied on the Facebook side.
Sending from other clients (e.g. RiotX) doesn't appear to have this issue, likely because RiotX just sends a plain ๐.
Hello,
When I do this alembic upgrade head
it crashes because of the password I have for my postgres DB. In my password there is the /
characterโฆ And so it crashes when it is reading this line.
If you need to know something else, tell me and I will give you the information you need.
Thank you in advance and sorry for my bad English (not native).
Would be nice to have 'bridge starting' and 'bridge ready' messages from the bot.
I was just sent a 5MB PDF file from Messenger.
On the Matrix side, it arrived as a 944B file. The file name is correct, but the payload is not.
The actual payload is some HTML like this:
<html><head><meta charset="utf-8" /><meta name="referrer" content="origin" /></head><body><script type="text/javascript">document.location.replace("https:\/\/cdn.fbsbx.com\/v\/more-stuff-here");</script><script type="text/javascript">setTimeout("(new Image()).src=\"\\\/laudit.php?r=ORIGIN_REFERRER_POLICY&u=https\\u00253A\\u00252F\\u00252Fcdn.fbsbx.com\\u00252Fv\\u00252Fmore-stuff-here\";",5000);</script></body></html>
wget
-ing the URL that's the target of document.location.replace
does download the actual file.
Bridge logs are like this (URLs, tokens, etc. have been mangled):
Jun 25 09:54:00 matrix-mautrix-facebook[10524]: [2019-06-25 07:54:00,680] [[email protected].@user:example.com] {'t': 'fullReload', 'seq': 3}
Jun 25 09:54:00 matrix-mautrix-facebook[10524]: [2019-06-25 07:54:00,680] [[email protected].@user:example.com] GET https://0-edge-chat.facebook.com/pull?__rev=2000213456&_
_user=123456789&__a=1&ttstamp=658169781191208484107102895358658169975710510011675113541222&fb_dtsg=BZFNcyFFkfY5:BZFb4idtKq6z&msgs_recv=0&sticky_token=1328&sticky_pool=ratn0c01_chatproxy-regional&
clientid=8c682b5&state=offline&__req=2y1&seq=3
Jun 25 09:54:27 matrix-mautrix-facebook[10524]: [2019-06-25 07:54:27,674] [[email protected].@user:example.com] {'t': 'msg', 'seq': 4, 'u': 123456789, 'ms': [{'type': 'deltafl
ow', 'sequencer': '1496430', 'fbid': '123456789'}]}
Jun 25 09:54:27 matrix-mautrix-facebook[10524]: [2019-06-25 07:54:27,675] [[email protected].@user:example.com] GET https://0-edge-chat.facebook.com/pull?__rev=2000213456&_
_user=123456789&__a=1&ttstamp=658169781191208484107102895358658169975710510011675113541222&fb_dtsg=BZFNcyFFkfY5:BZFb4idtKq6z&msgs_recv=0&sticky_token=1328&sticky_pool=ratn0c01_chatproxy-regional&
clientid=8c682b5&state=offline&__req=2y2&seq=4
Jun 25 09:54:27 matrix-mautrix-facebook[10524]: [2019-06-25 07:54:27,790] [[email protected].@user:example.com] {'t': 'msg', 'seq': 5, 'u': 123456789, 'ms': [{'ofd_ts': 156144
9267615, 'delta': {'attachments': [{'fbid': '1111119692921331', 'fileSize': '5089362', 'filename': 'file.pdf', 'hash': '1111119692921331', 'id': '1111119692921331', 'mercury': {'
blob_attachment': {'__typename': 'MessageFile', 'attribution_app': None, 'attribution_metadata': None, 'filename': 'file.pdf', 'url': 'https://l.facebook.com/l.php?u=https%3A%
2F%2Fcdn.fbsbx.com%2Fv%2Ft23.4932-29608576_n.pdf%2Ffile.pdf%3F_nc_cat%3D105%26_nc_oc%3DAQkzegW_kkk1iJ3k-
9xSd8xS3No%26_nc_ht%3Dcdn.fbsbx.com%26oh%3D0cc1300NVwN4jteV_zNMMWitCtUnKmeyMcwBuTMRvaZvHdLGQW
XVMDOd3yZg7E2cHorag3Mv6CoTk1jvXMz2QDqX0IbeXjmGIsiM5uHjM4Clr9VU0SAA&s=1', 'content_type': 'attach:unknown', 'is_malicious': False, 'message_file_fbid': '1111119692921331', 'url_shimhash': 'AT09TG1V
g12RGMg4Q-_Gp_7RXjw0sW0NSVLaGoOB1jHuesuQ-NH8UO12iqws4Ho1XzEd5nYixMDqxwh2TZ4IsqmQQSC7E8Cuj8O_HtOjmnnpWmpMfcGaMVR1Ls3k5iGJL-sssM-NP0UFTckoQQ_QcQ', 'url_skipshim': True}}, 'mimeType': 'application/p
df', 'otherUserFbIds': ['123456789'], 'titanType': 7, 'useRefCounting': True}], 'irisSeqId': '1496430', 'irisTags': [], 'messageMetadata': {'actorFbId': '123452182', 'folderId': {'systemFolderId'
: 'INBOX'}, 'messageId': 'mid.$cBBBBBBFrv13bxuZITlrjaFaSri_d', 'offlineThreadingId': '6549192867798986717', 'skipBumpThread': False, 'skipSnippetUpdate': False, 'tags': ['source:chat:web'], 'thre
adKey': {'otherUserFbId': '123452182'}, 'threadReadStateEffect': 'MARK_UNREAD', 'timestamp': '1561449267278', 'unsendType': 'deny_for_non_sender'}, 'requestContext': {'apiArgs': {}}, 'class': 'Ne
wMessage'}, 'type': 'delta', 'iseq': 1496430, 'queue': 123456789}]}
Jun 25 09:54:27 matrix-mautrix-facebook[10524]: [2019-06-25 07:54:27,791] [[email protected].@user:example.com] GET https://0-edge-chat.facebook.com/pull?__rev=2000213456&_
_user=123456789&__a=1&ttstamp=658169781191208484107102895358658169975710510011675113541222&fb_dtsg=BZFNcyFFkfY5:BZFb4idtKq6z&msgs_recv=0&sticky_token=1328&sticky_pool=ratn0c01_chatproxy-regional&
clientid=8c682b5&state=offline&__req=2y3&seq=5
Jun 25 09:54:27 matrix-mautrix-facebook[10524]: [2019-06-25 07:54:27,793] [[email protected].@user:example.com] onMessage(Message(text=None, mentions=[], emoji_size=None, uid='mi
d.$cBBBBBBFrv13bxuZITlrjaFaSri_d', author='123452182', timestamp=1561449267278, is_read=None, read_by=[], reactions={}, sticker=None, attachments=[FileAttachment(url='https://l.facebook.com/l.php
?u=https%3A%2F%2Fcdn.fbsbx.com%2Fv%2Ft13.2708-21%2F65205994_3222219696254664_3113314178499608576_n.pdf%2Ffile.pdf%3F_nc_cat%3D105%26_nc_oc%3DAQkzegW_ggk1iJ3K5ceeMxxUxEA9yzGBjcepl
7sPAnLgGj7k-9xCt63VA0DSd8xS3No%26_nc_ht%3Dcdn.fbsbx.com%26oh%3D0cc1300c266d19502cf18c92e977cbd5%26oe%3D5D144664%26dl%3D1&h=AT0OLfmGIsiM5uHjM4Clr9VU0SAA&s=1', size=5089362, name='file.pdf', is_malicious=False, uid='1111119692921331')], quick_replies=
[], unsent=False, reply_to_id=None, replied_to=None, forwarded=False), 123452182, ThreadType.USER)
Jun 25 09:54:28 matrix-mautrix-facebook[10524]: [2019-06-25 07:54:28,023] [[email protected]] POST /_matrix/media/r0/upload <944 bytes> as user @facebook_123452182:example.com
Jun 25 09:54:28 matrix-mautrix-facebook[10524]: [2019-06-25 07:54:28,062] [[email protected]] PUT /_matrix/client/r0/rooms/%21eBijGUKrRwIUPIOfKm%3Aexample.com/send/m.room.messag
e/11561449268062 {"msgtype": "m.file", "body": "file.pdf", "url": "mxc://example.com/kqBoMavpFFvzHfjzFPfMmuRk", "info": {"mimetype": "text/html", "size": 944}} as user @facebo
ok_123452182:example.com
Jun 25 09:54:28 matrix-mautrix-facebook[10524]: [2019-06-25 07:54:28,155] [[email protected]<->123456789] Unhandled Messenger message: Message(text=None, mentions=[], emoji_size=None, uid='mid.$cBBBBBBFrv13bxuZITlrjaFaSri_d', author='123452182', timestamp=1561449267278, is_read=None, read_by=[], reactions={}, sticker=None, attachments=[FileAttachment(url='https://l.facebook.com/l.php?u=https%3A%2F%2Fcdn.fbsbx.com%2Fv%2Ft13.2708-21%2F608576_n.pdf%2Ffile.pdf%3F_nc_cat%3D105%26_nc_oc%3DAQkzxCtNo%26_nc_ht%3Dcdn.fbsbx.com%26od195977cbd5%26oe%3D5D144664%26dl%3D1&h=AT0OLeV_zMNMrag3Mv6Co0SAA&s=1', size=5089362, name='file.pdf', is_malicious=False, uid='1111119692921331')], quick_replies=[], unsent=False, reply_to_id=None, replied_to=None, forwarded=False)
Jun 25 09:54:28 matrix-mautrix-facebook[10524]: [2019-06-25 07:54:28,208] [[email protected].@user:example.com] POST https://www.facebook.com/ajax/mercury/delivery_receipts.php {'__rev': 2000213456, '__user': '123456789', '__a': '1', 'ttstamp': '658169781191208484107102895358658169975710510011675113541222', 'fb_dtsg': 'BZFNcyFFkfY5:BZFb4idtKq6z', 'message_ids[0]': 'mid.$cBBBBBBFrv13bxuZITlrjaFaSri_d', 'thread_ids[123452182][0]': 'mid.$cBBBBBBFrv13bxuZITlrjaFaSri_d', '__req': '2y4', 'seq': 5}
Jun 25 09:54:28 matrix-mautrix-facebook[10524]: [2019-06-25 07:54:28,220] [[email protected]] 172.18.0.7 [25/Jun/2019:07:54:28 +0000] "PUT /transactions/611?access_token=TOKEN HTTP/1.1" 200 158 "-" "Synapse/1.0.0"
I followed the Production setup procedure and tried logging in using the "login" command which failed with the following traceback:
Logging in...
Unhandled error while handling command:
Traceback (most recent call last):
File "/var/lib/synapse/mautrix-facebook/lib/python3.7/site-packages/mautrix/bridge/commands/handler.py", line 371, in handle
await self._run_handler(handler, evt)
File "/var/lib/synapse/mautrix-facebook/lib/python3.7/site-packages/mautrix/bridge/commands/handler.py", line 269, in __call__
return await self._handler(evt)
File "/var/lib/synapse/mautrix-facebook/lib/python3.7/site-packages/mautrix_facebook/commands/auth.py", line 60, in login
user_agent=evt.sender.user_agent)
File "/var/lib/synapse/mautrix-facebook/lib/python3.7/site-packages/fbchat/_client.py", line 274, in login
log=self._state_log
File "/var/lib/synapse/mautrix-facebook/lib/python3.7/site-packages/fbchat/_state.py", line 140, in login
return await cls.from_session(session=session)
File "/var/lib/synapse/mautrix-facebook/lib/python3.7/site-packages/fbchat/_state.py", line 183, in from_session
revision = int(text.split('"client_revision":', 1)[1].split(",", 1)[0])
IndexError: list index out of range
After a prolonged amount of uptime (few days), I get this error when trying to send messages:
[2019-06-09 20:34:59,178] [[email protected]] Exception in Matrix event handler
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/fbchat/_client.py", line 190, in _post
return await check_request(r, as_json=as_json, log=self._util_log)
File "/usr/lib/python3.6/site-packages/fbchat/_util.py", line 210, in check_request
check_json(j)
File "/usr/lib/python3.6/site-packages/fbchat/_util.py", line 175, in check_json
fb_error_message=j["errorDescription"],
fbchat._exception.FBchatFacebookError: Error #1357004 when sending request: Please try closing and re-opening your browser window.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/fbchat/_client.py", line 190, in _post
return await check_request(r, as_json=as_json, log=self._util_log)
File "/usr/lib/python3.6/site-packages/fbchat/_util.py", line 210, in check_request
check_json(j)
File "/usr/lib/python3.6/site-packages/fbchat/_util.py", line 175, in check_json
fb_error_message=j["errorDescription"],
fbchat._exception.FBchatFacebookError: Error #1357004 when sending request: Please try closing and re-opening your browser window.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/fbchat/_client.py", line 190, in _post
return await check_request(r, as_json=as_json, log=self._util_log)
File "/usr/lib/python3.6/site-packages/fbchat/_util.py", line 210, in check_request
check_json(j)
File "/usr/lib/python3.6/site-packages/fbchat/_util.py", line 175, in check_json
fb_error_message=j["errorDescription"],
fbchat._exception.FBchatFacebookError: Error #1357004 when sending request: Please try closing and re-opening your browser window.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/mautrix/appservice/appservice.py", line 208, in try_handle
await handler_func(event)
File "/usr/lib/python3.6/site-packages/mautrix/bridge/matrix.py", line 230, in int_handle_event
await self.handle_message(evt.room_id, evt.sender, evt.content, evt.event_id)
File "/usr/lib/python3.6/site-packages/mautrix/bridge/matrix.py", line 166, in handle_message
await portal.handle_matrix_message(sender, message, event_id)
File "/opt/mautrix-facebook/mautrix_facebook/portal.py", line 346, in handle_matrix_message
fbid = await self._handle_matrix_text(sender, message)
File "/opt/mautrix-facebook/mautrix_facebook/portal.py", line 363, in _handle_matrix_text
return await sender.send(FBMessage(text=message.body), self.fbid, self.fb_type)
File "/usr/lib/python3.6/site-packages/fbchat/_client.py", line 1374, in send
return await self._doSendRequest(data)
File "/usr/lib/python3.6/site-packages/fbchat/_client.py", line 1333, in _doSendRequest
j = await self._post(self.req_url.SEND, data, fix_request=True, as_json=True)
File "/usr/lib/python3.6/site-packages/fbchat/_client.py", line 200, in _post
error_retries=error_retries - 1,
File "/usr/lib/python3.6/site-packages/fbchat/_client.py", line 200, in _post
error_retries=error_retries - 1,
File "/usr/lib/python3.6/site-packages/fbchat/_client.py", line 200, in _post
error_retries=error_retries - 1,
File "/usr/lib/python3.6/site-packages/fbchat/_client.py", line 190, in _post
return await check_request(r, as_json=as_json, log=self._util_log)
File "/usr/lib/python3.6/site-packages/fbchat/_util.py", line 210, in check_request
check_json(j)
File "/usr/lib/python3.6/site-packages/fbchat/_util.py", line 175, in check_json
fb_error_message=j["errorDescription"],
This reminds me of Schmavery/facebook-chat-api#555 which is also experienced by matrix-puppet-facebook. The only solution they found was to create a supervisor script that restarts the bridge every ~8 hours.
Sessions, Matrix room state and puppet/portal info is currently spread across many files. Need to move it to a central SQLAlchemy database before anyone uses the bridge so that a migration wouldn't be needed.
Ever since the MQTT changes (supposedly), voice message bridging fails.
Here are some logs:
[2020-01-05 13:31:25,030] [[email protected].@facebook_11111111111111111111:example.com] POST /_matrix/media/r0/upload <199343 bytes>
[2020-01-05 13:31:25,061] [[email protected].@user:example.com] Failed to parse MQTT message: {'deltas': [{'attachments': [{'fbid': '22222222222', 'fileSize': '199343', 'filename': 'audioclip-33333333333333-24002.aac', 'genericMetadata': {'duration': '24002', 'isVoicemail': '0', 'type': 'fb_voice_message', 'call_id': ''}, 'hash': '22222222222', 'id': '22222222222', 'mercury': {'blob_attachment': {'__typename': 'MessageAudio', 'attribution_app': None, 'attribution_metadata': None, 'filename': 'audioclip-33333333333333-24002.aac', 'playable_url': '.....', 'playable_duration_in_ms': 24002, 'is_voicemail': False, 'audio_type': 'VOICE_MESSAGE', 'url_shimhash': '......', 'url_skipshim': True}}, 'mimeType': 'audio/aac', 'otherUserFbIds': ['444444444'], 'titanType': 6, 'useRefCounting': True}], 'irisSeqId': '55555555', 'irisTags': ['DeltaNewMessage', 'is_from_iris_fanout'], 'messageMetadata': {'actorFbId': '11111111111111111111', 'folderId': {'systemFolderId': 'INBOX'}, 'messageId': 'mid.$cBBBa3B...', 'offlineThreadingId': '66666666666666', 'skipBumpThread': False, 'skipSnippetUpdate': False, 'tags': ['source:titan:orca', 'app_id:7777777777777'], 'threadKey': {'otherUserFbId': '11111111111111111111'}, 'threadReadStateEffect': 'MARK_UNREAD', 'timestamp': '1578231084710', 'unsendType': 'deny_for_non_sender'}, 'requestContext': {'apiArgs': {}}, 'class': 'NewMessage'}], 'firstDeltaSeqId': 55555555, 'lastIssuedSeqId': 55555555, 'queueEntityId': 444444444}
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/fbchat/_client.py", line 2875, in _try_parse_mqtt
await self._parse_mqtt(event_type, event_data)
File "/usr/lib/python3.7/site-packages/fbchat/_client.py", line 2893, in _parse_mqtt
await self._parse_delta({"delta": delta})
File "/usr/lib/python3.7/site-packages/fbchat/_client.py", line 2609, in _parse_delta
msg=m,
File "/opt/mautrix-facebook/mautrix_facebook/user.py", line 363, in on_message
await portal.handle_facebook_message(self, puppet, message_object)
File "/opt/mautrix-facebook/mautrix_facebook/portal.py", line 502, in handle_facebook_message
for attachment in message.attachments])
File "/opt/mautrix-facebook/mautrix_facebook/portal.py", line 555, in _handle_facebook_attachment
relates_to=self._get_facebook_reply(reply_to))
File "/usr/lib/python3.7/site-packages/mautrix/appservice/api/intent.py", line 87, in wrapper
return await __method(*args, **kwargs)
File "/usr/lib/python3.7/site-packages/mautrix/appservice/api/intent.py", line 289, in send_message_event
return await super().send_message_event(room_id, event_type, content, **kwargs)
File "/usr/lib/python3.7/site-packages/mautrix/client/api/events.py", line 294, in send_message_event
resp = await self.api.request(Method.PUT, url, content, **kwargs)
File "/usr/lib/python3.7/site-packages/mautrix/api/http.py", line 199, in request
content = json.dumps(content)
File "/usr/lib/python3.7/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.7/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.7/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.7/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type timedelta is not JSON serializable
[2019-05-15 04:23:39,140] [[email protected].@travis:t2l.io] Failed to sync threads
Traceback (most recent call last):
File "/home/facebook/mautrix-facebook/mautrix_facebook/user.py", line 155, in sync_threads
await portal.create_matrix_room(self, thread)
File "/home/facebook/mautrix-facebook/mautrix_facebook/portal.py", line 243, in create_matrix_room
await self._create_matrix_room(source, info)
File "/home/facebook/mautrix-facebook/mautrix_facebook/portal.py", line 251, in _create_matrix_room
info = await self.update_info(source=source, info=info)
File "/home/facebook/mautrix-facebook/mautrix_facebook/portal.py", line 173, in update_info
loop=self.loop))
File "/home/facebook/mautrix-facebook/mautrix_facebook/portal.py", line 219, in _update_participants
await p.Puppet.get_by_fbid(info.uid).update_info(source=source, info=info)
File "/home/facebook/mautrix-facebook/mautrix_facebook/puppet.py", line 133, in update_info
loop=self.loop))
File "/home/facebook/mautrix-facebook/mautrix_facebook/puppet.py", line 151, in _update_photo
self.default_mxid_intent)
File "/home/facebook/mautrix-facebook/mautrix_facebook/portal.py", line 192, in _reupload_fb_photo
return await intent.upload_media(data, mime_type=mime, filename=filename), mime, len(data)
File "/home/facebook/fbenv/lib/python3.6/site-packages/mautrix/client/api/modules/media_repository.py", line 54, in upload_media
headers=headers, query_params=query)
File "/home/facebook/fbenv/lib/python3.6/site-packages/mautrix/api/http.py", line 206, in request
return await self._send(method, endpoint, content, query_params, headers or {})
File "/home/facebook/fbenv/lib/python3.6/site-packages/mautrix/api/http.py", line 146, in _send
errcode=errcode, message=message)
mautrix.errors.request.MUnknown: Unexpected Error
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/mautrix/bridge/commands/handler.py", line 366, in handle
await handler(evt)
File "/usr/lib/python3.6/site-packages/mautrix/bridge/commands/handler.py", line 267, in __call__
return await self._handler(evt)
File "/usr/lib/python3.6/site-packages/mautrix/bridge/commands/meta.py", line 60, in help_cmd
return await evt.reply(_get_management_status(evt) + "\n" + await _get_help_text(evt))
File "/usr/lib/python3.6/site-packages/mautrix/bridge/commands/meta.py", line 38, in _get_help_text
if handler.has_help and handler.has_permission(cache_key):
File "/opt/mautrix-facebook/mautrix_facebook/commands/handler.py", line 59, in has_permission
(not self.needs_auth or key.is_logged_in))
AttributeError: 'HelpCacheKey' object has no attribute 'is_logged_in'
using the docker image and asking for help as the first thing (before login)
Facebook seems to use a markdown-ish syntax that's parsed receiver-side. https://www.facebook.com/help/147348452522644
Can probably copy mautrix-telegram's formatting stuff (and optionally make it generic and put it into mautrix-python's utils)
Matrix -> Facebook requires #8
Facebook frequently logs me out for security reasons (suspicious activity..) and forces me to reset my account's password.
This seems to destroy all old sessions, which seems to put the bridge in a weird state.
Checking the logs, it's spamming messages like this:
Jul 30 06:26:01 matrix-mautrix-facebook[12289]: [2019-07-30 04:26:01,954] [[email protected].@user:DOMAIN] {'t': 'refresh', 'reason': 110, 'seq': 0}
Jul 30 06:26:01 matrix-mautrix-facebook[12289]: [2019-07-30 04:26:01,954] [[email protected].@user:DOMAIN] GET https://0-edge-chat.facebook.com/pull?__rev=2000886212&__user=123456789&__a=1&ttstamp=658113687367511701046610499486311783227297100586581725108&fb_dtsg=BBQhBAqCDI5c:QQB5uBEChc0X&msgs_recv=0&sticky_token=1328&sticky_pool=ratn0c01_chatproxy-regional&clientid=987654321&state=offline&__req=d3&seq=0
Jul 30 06:26:02 matrix-mautrix-facebook[12289]: [2019-07-30 04:26:02,072] [[email protected].@user:DOMAIN] {'t': 'refresh', 'reason': 110, 'seq': 0}
Jul 30 06:26:02 matrix-mautrix-facebook[12289]: [2019-07-30 04:26:02,073] [[email protected].@user:DOMAIN] GET https://0-edge-chat.facebook.com/pull?__rev=2000886212&__user=123456789&__a=1&ttstamp=658113687367511701046610499486311783227297100586581725108&fb_dtsg=BBQhBAqCDI5c:QQB5uBEChc0X&msgs_recv=0&sticky_token=1328&sticky_pool=ratn0c01_chatproxy-regional&clientid=987654321&state=offline&__req=d4&seq=0
There's a pair of messages like this roughly every 100ms.
Restarting the bridges makes it get out of this loop and fail early with a "Failed loading session" error.
I imagine that until I do that, my account's activity is indeed highly suspicious - one request every 100ms (until forever?) is definitely not nice.
When a facebook user sends a post as message (Share -> Send as Message), no notification/message is sent to Matrix.
Here are the logs, with user ids changed:
_user=123456789&__a=1&ttstamp=658169781191208484107102895358658169975710510011675113541222&fb_dtsg=AQENwxTTkfY5:AQEa9idtKq6z&msgs_recv=0&sticky_token=1111&sticky_pool=ratn0c01_chatproxy-regional&
clientid=2a222a2&state=offline&__req=32z&seq=14
Jun 25 11:04:56 matrix-mautrix-facebook[10524]: [2019-06-25 09:04:56,146] [[email protected].@user:example.com] onMessage(Message(text=None, mentions=[], emoji_size=None, uid='mi
d.$cBBBBBBFZab1yuybNf1rjeFGGETwT', author='123456051', timestamp=1561453495679, is_read=None, read_by=[], reactions={}, sticker=None, attachments=[ShareAttachment(author=None, url='https://l.face
book.com/l.php?u=https%3A%2F%2Fwww.xda-developers.com%2Foneplus-7-pro-almond-hands-on%2F&h=AT2-RMiuanBsEMTSVQCP-htsyN9b4EU4dXFysrV7J83TktRAefS-SVDzPEs17Bv5TTZw_9TXYXCqnD6sEx_Ny28INbAixmlPlWiCShAE
Un4aCdwbzldNwjxyDCcbLByOucyFbyh2ek4x&s=1', original_url='https://www.xda-developers.com/oneplus-7-pro-almond-hands-on/', title='[Update 2: Available Now] Hands-on with the OnePlus 7 Pro in Almond
, now available for purchase', description='The OnePlus 7 Pro in Almond is available in the US and Canada with 8GB of RAM and 256GB of storage for $699 starting today.', source='xda-developers.co
m', image_url='https://external-frt3-2.xx.fbcdn.net/safe_image.php?d=AQCkNlZPDB9teO6h&w=960&h=960&url=https%3A%2F%2Fwww.xda-developers.com%2Ffiles%2F2019%2F06%2Foneplus-7-pro-almond-5.jpg&_nc_has
h=AQBh73B5CVByx8ey', original_image_url='https://www.xda-developers.com/files/2019/06/oneplus-7-pro-almond-5.jpg', image_width=960, image_height=720, attachments=[], uid='ee.mid.$cAAAAAAVDhb5xvyb
Nf1rjeGFFITwT')], quick_replies=[], unsent=False, reply_to_id=None, replied_to=None, forwarded=False), 123456051, ThreadType.USER)
Jun 25 11:04:56 matrix-mautrix-facebook[10524]: [2019-06-25 09:04:56,146] [[email protected]<->123456789] Unsupported attachment type: ShareAttachment(author=None, u
rl='https://l.facebook.com/l.php?u=https%3A%2F%2Fwww.xda-developers.com%2Foneplus-7-pro-almond-hands-on%2F&h=AT2-RMiuanBsEMTSVQCP-htsyN9b4EU4dXFysrV7J83TktRAefS-SVDzPEs17Bv5TTZw_9TXYXCqnD6sEx_Ny2
8INbAixmlPlWiCShAEUn4aCdwbzldNwjxyDCcbLByOucyFbyh2ek4x&s=1', original_url='https://www.xda-developers.com/oneplus-7-pro-almond-hands-on/', title='[Update 2: Available Now] Hands-on with the OnePl
us 7 Pro in Almond, now available for purchase', description='The OnePlus 7 Pro in Almond is available in the US and Canada with 8GB of RAM and 256GB of storage for $699 starting today.', source=
'xda-developers.com', image_url='https://external-frt3-2.xx.fbcdn.net/safe_image.php?d=AQCkNlZPDB9teO6h&w=960&h=960&url=https%3A%2F%2Fwww.xda-developers.com%2Ffiles%2F2019%2F06%2Foneplus-7-pro-al
mond-5.jpg&_nc_hash=AQBh73B5CVByx8ey', original_image_url='https://www.xda-developers.com/files/2019/06/oneplus-7-pro-almond-5.jpg', image_width=960, image_height=720, attachments=[], uid='ee.mid
.$cBBBBBBFZab1yuybNf1rjeFGGETwT')
Jun 25 11:04:56 matrix-mautrix-facebook[10524]: [2019-06-25 09:04:56,147] [[email protected]<->123456789] Unhandled Messenger message: Message(text=None, mentions=[]
, emoji_size=None, uid='mid.$cBBBBBBFZab1yuybNf1rjeFGGETwT', author='123456051', timestamp=1561453495679, is_read=None, read_by=[], reactions={}, sticker=None, attachments=[ShareAttachment(author
=None, url='https://l.facebook.com/l.php?u=https%3A%2F%2Fwww.xda-developers.com%2Foneplus-7-pro-almond-hands-on%2F&h=AT2-RMiuanBsEMTSVQCP-htsyN9b4EU4dXFysrV7J83TktRAefS-SVDzPEs17Bv5TTZw_9TXYXCqnD
6sEx_Ny28INbAixmlPlWiCShAEUn4aCdwbzldNwjxyDCcbLByOucyFbyh2ek4x&s=1', original_url='https://www.xda-developers.com/oneplus-7-pro-almond-hands-on/', title='[Update 2: Available Now] Hands-on with t
he OnePlus 7 Pro in Almond, now available for purchase', description='The OnePlus 7 Pro in Almond is available in the US and Canada with 8GB of RAM and 256GB of storage for $699 starting today.',
source='xda-developers.com', image_url='https://external-frt3-2.xx.fbcdn.net/safe_image.php?d=AQCkNlZPDB9teO6h&w=960&h=960&url=https%3A%2F%2Fwww.xda-developers.com%2Ffiles%2F2019%2F06%2Foneplus-
7-pro-almond-5.jpg&_nc_hash=AQBh73B5CVByx8ey', original_image_url='https://www.xda-developers.com/files/2019/06/oneplus-7-pro-almond-5.jpg', image_width=960, image_height=720, attachments=[], uid
='ee.mid.$cBBBBBBFZab1yuybNf1rjeFGGETwT')], quick_replies=[], unsent=False, reply_to_id=None, replied_to=None, forwarded=False)
Jun 25 11:04:56 matrix-mautrix-facebook[10524]: [2019-06-25 09:04:56,147] [[email protected].@user:example.com] POST https://www.facebook.com/ajax/mercury/delivery_receipts
.php {'__rev': 1000870724, '__user': '123456789', '__a': '1', 'ttstamp': '658169781191208484107102895358658169975710510011675113541222', 'fb_dtsg': 'AQENwxTTkfY5:AQEa9idtKq6z', 'message_ids[0]':
'mid.$cBBBBBBFZab1yuybNf1rjeFGGETwT', 'thread_ids[123456051][0]': 'mid.$cBBBBBBFZab1yuybNf1rjeFGGETwT', '__req': '330', 'seq': 14}```
I followed the wiki, correctly.
The command to generate the registration python -m mautrix_facebook -g
give me this :
[2019-12-01 21:37:25,877] [[email protected]] Configuration error: appservice.as_token not configured. Did you forget to generate the registration?
So, unless you make a real tutorial with the possible mistakes, etc, issues are going to be the only way to have our problems solved.
Thank you in advance.
PS : and concerning the issue with DB and parser, no I do not use a %
character in my password, so it IS the /
that making the problem (now I can not check as I changed the OS of my Raspberry Pi).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.