stjohann / DiscordWikiBot

Discord bot for Wikimedia projects and MediaWiki wiki sites
https://w.wiki/4nm
MIT License
40 stars 9 forks source link

EventStreams: Some interwiki links in messages do not work #16

Open stjohann opened 2 years ago

stjohann commented 2 years ago

Since MediaWiki only handles some links as forwarding, all links on a typical interwiki map that are not forwarding currently result in link errors such as this: https://ru.wikipedia.org/wiki/translatewiki:MediaWiki:Coll-create_a_book_tooltip/ru?uselang=en

This needs to be fixed. The best way to fix it would be to add some code to Linking that would use default interwiki map for the site (if it exists) to do transformations to the link without any API requests (i. e. replicating much of Linking.AddLink without any API calls for interwiki links), and then use it where the Linking.GetLink is currently used. It should be fairly easy to write this, but code duplication should be avoided. Ideally, EventStreams.ParseComment and Linking.AddLink should call the same function, but the latter should be able to replace basic (requestless) interwiki link handling with more advanced.

Simpler way to solve the same problem is to append Special:GoToInterwiki/ everywhere, but given that interwiki links can follow basically any rules, it would mean handling every link with : in it this way. [This is now done, so links would start to work, but this issue still needs to be fixed in a better way.]