Closed mrvdb closed 5 years ago
Let's define entities. They could be:
I see several workarounds how updates from sources could be delivered to telegram
ActivityPub side
Telegram side
So, which one of this is closest to your usecase
My usecase with the defined entities:
tg_bot
added as admin to channel or group, close to realtime posting)ap_bot
subscribes to actors, (just ap_user
in this usecase, possibly filtered) (so, item 1. in your examples, perhaps item 3, but I read that as 'manual trigger' which is not what I'm after)Got it. I think I can implement it this weekend. Could you also tell more about filtering
Re:filtering, things which I would like to be able to control are for example:
It would make sense to me to arrange for that in the ap_bot
side of things, but perhaps it's easier to do this in tg_bot
Thanks, good stuff! As soon as I am back from traveling I will test and provide feedback
it's not finished yet, I marked PR as wip
@mrvdb so, I've made it)) for now bot broadcasts in both directions text and photos demo chain:
Thanks, I'm setting it up now
I think I'm missing something,
Using postman as client, I created a user 'ap_bot', with the given details set to channel 'mrb-aptest'
So, after this I'm unsure what to do. I'm assuming I want to let 'ap_bot' follow my accounts (say 'https://todon.nl/@mrb' ) through a call to <host>/ap_bot/outbox
(follow) after which it replicates the output of https://todon.nl/@mrb
to the channel configured. (the bot is joined in the channel as admin)
@mrvdb yes, that's correct. Using mentioned call you can follow your accounts (you can check if it is successful by call <host>/ap_bot/following
, 'https://todon.nl/@mrb' should be present in that list). Take into account that pubgate will not fetch existing posts (same as mastodon). New toots should go through the bridge to tg
The 'follow' doesn't seem to work. I get a 401 response and the following collection is not updated. I get this on both my accounts on todon.nl and pixelfed.social. What am I missing?
Redacted log:
POST http://activitypubbot.qua.name/ap_bot/outbox 201 18
<CIMultiDict('content-type': 'text/plain', 'user-agent': 'PostmanRuntime/7.11.0', 'accept': '*/*', 'cache-control': 'no-cache', 'postman-token': '3a2d0dfc-9960-4ed1-87bc-b20a889d2adb', 'host': 'activitypubbot.qua.name', 'accept-encoding': 'gzip, deflate', 'content-length': '64', 'connection': 'keep-alive', 'x-ssl-cipher': 'TLSv1.2/ECDHE-RSA-AES256-GCM-SHA384 TLSv1.2 Kx=ECDH Au=RSA Enc=AESGCM(256) Mac=AEAD', 'x-forwarded-for': '213.125.12.138')>
{'actor': 'http://activitypubbot.qua.name/ap_bot',
'id': 'http://activitypubbot.qua.name/ap_bot/activity/b9746051e8388dc9',
'object': 'https://todon.nl/@mrb',
'type': 'Follow'}
[2019-04-30 19:23:36 +0200] [29209] [INFO] ------
[2019-04-30 19:23:36 +0200] [29209] [INFO] Delivering Follow ===>> https://todon.nl/@mrb
[2019-04-30 19:23:36 +0200] [29209] [INFO] Fetch https://todon.nl/@mrb, status: 200, OK
[2019-04-30 19:23:36 +0200] [29209] [INFO] Post to inbox https://todon.nl/users/mrb/inbox, status: 401, Unauthorized
Tested with my instance. Looks like there is some issue with todon.nl. I'll look into it
[2019-04-30 17:40:45 +0000] - (sanic.access)[INFO][1:2]: 46.96.32.178 --->> POST http://pubgate.autogestion.org/testtgbot/outbox 201 18
[2019-04-30 17:40:45 +0000] [26214] [INFO] Delivering Follow ===>> https://todon.nl/@mrb
[2019-04-30 17:40:45 +0000] [26214] [INFO] Fetch https://todon.nl/@mrb, status: 200, OK
[2019-04-30 17:40:46 +0000] - (sanic.access)[INFO][1:2]: 173.249.16.10 --->> GET http://pubgate.autogestion.org/testtgbot 200 1868
[2019-04-30 17:40:47 +0000] - (sanic.access)[INFO][1:2]: 173.249.16.10 --->> GET http://pubgate.autogestion.org/.well-known/host-meta 404 53
[2019-04-30 17:40:47 +0000] [26214] [INFO] Post to inbox https://todon.nl/users/mrb/inbox, status: 401, Unauthorized
[2019-04-30 17:42:22 +0000] - (sanic.access)[INFO][1:2]: 46.96.32.178 --->> POST http://pubgate.autogestion.org/testtgbot/outbox 201 18
[2019-04-30 17:42:22 +0000] [26214] [INFO] Delivering Follow ===>> https://mastodon.social/@siderus
[2019-04-30 17:42:22 +0000] [26214] [INFO] Fetch https://mastodon.social/@siderus, status: 200, OK
[2019-04-30 17:42:22 +0000] [26214] [INFO] Post to inbox https://mastodon.social/users/siderus/inbox, status: 202, Accepted
[2019-04-30 17:42:23 +0000] [26214] [INFO] Fetch https://mastodon.social/users/siderus#main-key, status: 200, OK
[2019-04-30 17:42:23 +0000] - (sanic.access)[INFO][1:2]: 136.243.88.169 --->> POST http://pubgate.autogestion.org/testtgbot/inbox 202 18
@mrvdb I fixed following pixelfed. successfully delivered image from SneekyPeet@pixelfed.social to @galiabarda . there was problem with http sig. todon.nl still an issue to play with pixelfed you should update pubgate to last (0.2.11) version
todon.nl is tricky) it has same version as mastodon.social (2.8.0), and accepts follow requests from other mastodon instances. mastodon.social accepts requests from pubgate and todon.nl refuses to
@mrvdb todon issue is solved as well))
[2019-04-30 20:38:23 +0000] [9782] [INFO] Delivering Follow ===>> https://todon.nl/@mrb
[2019-04-30 20:38:23 +0000] [9782] [INFO] Fetch https://todon.nl/@mrb, status: 200, OK
[2019-04-30 20:38:23 +0000] - (sanic.access)[INFO][1:2]: 173.249.16.10 --->> GET http://pubgate.autogestion.org/utest4 200 1491
[2019-04-30 20:38:24 +0000] - (sanic.access)[INFO][1:2]: 173.249.16.10 --->> GET http://pubgate.autogestion.org/.well-known/webfinger?resource=acct:utest4@pubgate.
autogestion.org 200 262
[2019-04-30 20:38:24 +0000] - (sanic.access)[INFO][1:2]: 173.249.16.10 --->> GET http://pubgate.autogestion.org/utest4/outbox 200 6413
[2019-04-30 20:38:24 +0000] - (sanic.access)[INFO][1:2]: 173.249.16.10 --->> GET http://pubgate.autogestion.org/utest4/following 200 519
[2019-04-30 20:38:24 +0000] - (sanic.access)[INFO][1:2]: 173.249.16.10 --->> GET http://pubgate.autogestion.org/utest4/followers 200 640
[2019-04-30 20:38:25 +0000] [9782] [INFO] Post to inbox https://todon.nl/users/mrb/inbox, status: 202, Accepted
This succesful follow is for pubgate user which was created as "profile": {"type": "Person",.... You created a bot user, which has "profile": {"type": "Service", There is some #nobot issue in fediverse, to restrict bots from following users. So, maybe in your account preferences, or in settings of todon.nl instance there is restriction for bots
So, to broadcast from todon, there are 2 ways
Still not working for me, behaviour slightly different for pixelfed, todon.nl the same
Pixelfed:
[2019-05-01 10:56:27 +0200] [5494] [INFO] Delivering Follow ===>> https://pixelfed.social/mrb
[2019-05-01 10:56:27 +0200] [5494] [INFO] Fetch https://pixelfed.social/mrb, status: 200, OK
[2019-05-01 10:56:27 +0200] [5494] [INFO] Post to inbox https://pixelfed.social/users/mrb/inbox, status: 400, Bad Request
{'@context': 'https://www.w3.org/ns/activitystreams',
'actor': 'http://activitypubbot.qua.name/ap_bot',
'id': 'http://activitypubbot.qua.name/ap_bot/activity/619d05623647716b',
'object': 'https://pixelfed.social/mrb',
'type': 'Follow'}
Also noticed unfollow is always delivered to pubgate user on mastodon.social
(at least according to log)
[2019-05-01 10:56:14 +0200] [5494] [INFO] Delivering Unfollow ===>> https://mastodon.social/users/pubgate
[2019-05-01 10:56:14 +0200] [5494] [INFO] Fetch https://mastodon.social/users/pubgate, status: 200, OK
[2019-05-01 10:56:14 +0200] [5494] [INFO] Post to inbox https://mastodon.social/users/pubgate/inbox, status: 401, Unauthorized
{'@context': 'https://www.w3.org/ns/activitystreams',
'actor': 'http://activitypubbot.qua.name/ap_bot',
'id': 'http://activitypubbot.qua.name/ap_bot/activity/7fbe15942150507b',
'object': 'https://pixelfed.social/mrb',
'type': 'Unfollow'}
could you also change "METHOD" in config/conf.cfg to "https"
That was already the case.
I got todon.nl to work by:
user id starts with http
same was the value of "METHOD" when user was created. I think this cause bad request in pixelfed
it could be updated in mongodb, in
user.uri
or you can try create new user
as for todon, I don't think that 2 actions really affected. preferredUsername is what mastodon shows at first place when you see user's toot (then goes username with @). maybe todon has some timeout, after which it refetch profile (and discovered that bot is not bot anymore)
yes, my mistake. that value on the screen, which I marked as "preferredUsername" is a value of "name" attribute. I guess some time before it was opposite in mastodon)
Ok, follow works, but unfollow is not unregistering:
Subsequent calls to unfollow issue internal server error
@mrvdb Actually, it's unregistering server error happens after db was updated and Unfollow was sent to remote server, when rendering API response. you can drop that duplicates in following list by calling outbox with Unfollow object with corresponding number of requests. Earlier, mastodon refuses to accept Follow requests, if it is already accepted one. Looks like its behavior changed, now mastodon just sends accept on every follow request
I'll provide a patch later today, with API response fix and with restriction to send multiple follow requests to same user, if it already accepted follow. Both this issues do not break operability of the bot, simply create confusion
ok, thanks.
Two suggestions: perhaps use parse_mode=html
(default is markdown
) and link_preview=False
for the default send_message
call?
following issues fixed
good point with parse_mode
. As for link preview, as it was first approach, I implemented delivering images in such way, that bot extract image url from AP object, and sends it to Telegram as a text. So if preview enabled, it allows to see picture at tg client at once, I guess. It is possible to download image by url, and to send it to Telegram as file. But I'm not sure it's better way, than sending url
There are, if I recall correctly two sorts of preview;
got it. could you add this arguments to send_message
and create PR?
Sure, will do tomorrow
This can be closed, right?
implemented
Rather than post from Telegram to an ActivityPub server, I have got a reverse usecase where I would like to post to Telegram channels, typically just to my own, from ActivityPub sources, to provide access to my feeds.
The base usecase is where I want telegram friends to be able to follow my feeds, say pixelfed posts, without them having to create an account there. A first extension could be a number of feeds from me in the same channel, like an aggregator.
Another advantage I see is that the source feeds from me regularly change, which I could make transparent for the people not on those platforms. That is, if you are following me through a (Telegram) channel that aggregates my feeds, I can change those feeds without the followers needing to do anything.
So far i've tried to solve this with atom to telegram bots or rss feeds through ifttt.com but they all are rather primitive and don't give the user much control over how an when information comes into the channel.