I’ve updated the bot and added the possibility of translating hardcoded links (like this one: https://lemmy.world/post/2355178 or this one: https://lemmy.world/comment/1863672) to posts/comments with links from your instance when you mention him. I’ll show an example in comments.
@[email protected] - you can just summon the bot like this and it should reply.
Hi there! Here are all the fixed links for your instance:
Let’s try it!
Oh, should have mentioned, it reads the links from the comment/post you’re replying to, so in this case from my comment which doesn’t contain any links. You can try it as a direct reply to the post.
Oh, got it. What if I include a link in my own comment, like this?
I hereby summon you!
Hi there! Here are all the fixed links for your instance:
Yay! Good Bot!
That won’t work as well. It always checks the parent of your comment. I felt it better suits the natural flow of conversation - someone posts a link, you can’t click it, so you summon the bot to fix it for you.
Makes sense, thanks for the info!
I’m sorry, I couldn’t find any links that I could fix. If you believe this is a mistake, please contact @[email protected].
Sadly I failed to fetch the correct links. Possibly because no one from your instance is subscribed to the community this comment originates from.
You may contact @[email protected] and he will check what went wrong.
I’m sorry, I couldn’t find any links that I could fix. If you believe this is a mistake, please contact @[email protected].
Wouldn’t that result in too much spam if in the same thread there are users from many different instances summoning it?
Possibly, but I leave it up to the mods and individual users. Overall I’m happy to tweak the bot in a way that suits the mods/admins, so feel free to reach me, if you feel like the bot should behave differently.
deleted by creator
I believe there is already a browser add on for this. Cannot remember the name right now.
Edit: I think this should be in Lemmy core.
deleted by creator
With all due respect, it seems like a janky solution to have a bot post public comments on request with transformed links specific to a given user’s own instance (that no other users would be likely to care about), just so that they can refresh the page and click on them… If something like this went into widespread use, threads would just become cluttered with comments containing transformed links, and I could see that being really annoying to other users who are trying to properly participate in discussion.
Back on Reddit, I always thought the !remindme bot was pretty dumb. Certain threads would just be spammed with comments for the bot to pick up to remind that specific user on some date to come back and check the thread. We can do better than that here. It was a janky solution to something that was a problem best left to the end-user to manage separately (just set a reminder in your own calendar…).
This is best left to client-side code in the form of a browser addon, or ideally, the Lemmy frontend itself.
It should be trivial to make an enhancement to the official Lemmy frontend such that links to any other Lemmy communities/posts/comments/etc are transformed to the context of the user’s home instance. It could be a togglable setting in the user’s own settings, or maybe both the original link and the transformed link could be presented to the user on click (to accommodate both desktop and mobile browsing).
I’m actually really surprised this isn’t already implemented given how simple it is to do.
Well, I agree! Until it’s there, you can do one of these: a) ignore the bot, b) block the bot, c) block all bots, d) contribute to Lemmy UI. Even though it may sound trivial to you, it really isn’t, due to the federated nature of Lemmy. The IDs are specific to each instance, it’s not a simple string replacement.
It is actually trivial. Here’s a walkthrough with one solution for how to do it: https://lm.williampuckering.com/comment/723311
Yeah, that link requires authentication. Anyway, I’ve just implemented it in the bot, I know how hard it is.
Ah sorry, just remembered I put my entire instance behind authentication except for the API endpoints required for federation. The comment I was linking to is in this thread. Just describes how all the info you need to properly transform the links is right there in the database records of the entities you want to transform, so this functionality can easily be added without much work.
Maybe you could help the devs sort it out? I honestly think this is holding back lemmy to new users, as it was the one big hurdle in the beginning to getting the communities I wanted to subscribe to.
I’ve read the discussion on this, IDs are specific to each instance so you’d have to fetch from the instance then translate the ID to your instance’s own version. It’s in progress but kind of stalled because of that for some reason.
It’s actually easy, here’s an explanation for one simple way you could do it.
On my instance, this post has the URL: https://lm.williampuckering.com/post/171615
On the instance the post originated on, the URL is: https://lemmings.world/post/175809
So on my instance, the post has the ID: 171615
On the originating instance, the ID is: 175809
In the database on my instance, this query will retrieve the post:
select * from post where id = 171615
Also in the database on my instance, this query will retrieve the post:
select * from post where ap_id = 'https://lemmings.world/post/175809'
Using the second query and finding the post by URL, I can see if the post is federated to my own instance or not. If so, I can look at the
id
field in the database and merely swap it out with the originating instance’s ID, and form the URL to access the post as it exists on my own instance. If the post isn’t federated on my own instance, then of course this won’t work. But that makes total sense, since you won’t be able to transform links for external instances to the corresponding entity on your own instance, because it doesn’t exist there.tl;dr - You can look up local entities by ID, and you can lookup remote entities by original URL. Then you just need to swap the ID in the URL to the ID (primary key in the table) in the database, if it exists, to convert a remote link to a local link. If a link can’t be converted, you can just leave it as-is.
The capability needed to add this functionality is already there. Someone just needs to decide how to handle it on the frontend elegantly from a UI perspective, and decide how the backend will pass what’s required to the frontend to drive the functionality. But the plumbing is already there.
One practical way to go about this would be to add one or more API endpoints to transform remote entities (URLs) to local entities, if they exist. Whenever posts/comments/whatever are loaded into the client’s browser, Lemmy UI can have code that takes any links that match patterns for Lemmy entities, and use the API endpoints to transform the remote URLs to local URLs, if it can be done. For those that can be done, swap the remote URLs on the frontend for the local ones (at this point it’s essentially just find/replace). That’s one quick and simple way to do it that shouldn’t be all that performance-impacting. There might be more elegant and efficient ways I can think of if I put more effort into thinking about this, but that for sure would work and be a decent first-cut solution. You could even add a caching mechanism (or maybe even a new database table) to persist the mapping as it happens so that you don’t need to do it on each request for a given entity, only the first time. Also, doing it this way allows for content that is not yet federated to work if one day it becomes federated (ie. try to do this mapping or each entity, everytime, if it never works, until one day it does).
Neat, thanks!