Page MenuHomePhabricator

mwbot-rs: Support operation on multiple wikis
Closed, ResolvedPublic

Description

Originally filed on GitLab.com

We need to support bots that operate on multiple wikis. Ideally these wikis would be able to share login sessions/connection pools.

We likely want to support using a different wiki manually, and also using a different wiki through discovery (like sitematrix).

Details

Related Changes in GitLab:
TitleReferenceAuthorSource BranchDest Branch
Add Bot::clone_for_family()repos/mwbot-rs/mwbot!139legoktmclone_for_familymain
Customize query in GitLab

Event Timeline

Legoktm triaged this task as Medium priority.

@legoktm wrote:

I've been thinking about this in the context of https://github.com/Krinkle/pywiki-fileprotectionsync/

That use case is to hit sibling wikis' APIs to query data and then make edits on the primary wiki.

One API could be Bot::get_sibling_wiki(), where you just need to provide the domain name and it constructs a new Bot instance, but shares the underlying HTTP client (note that we likely need to have mwapi allow creating a new client using an existing HTTP client.

@legoktm wrote:

And for wikis with Extension:SiteMatrix, we could have a get_sibling_via_sitematrix(a_different_identifier).

@legoktm wrote:

The concurrency lock should probably be shared across wikis.

@legoktm wrote:

Another idea, partially inspired by MZ:

In mwbot.toml

[sites.default]
api_url = "..."
rest_url = "..."

[sites.enwiki]
api_url = "..."
rest_url = "..."

[sites.commonswiki]
api_url = "..."
rest_url = "..."

Not exactly sure what it should look like in Rust. Maybe:

let config = Config::from_default().unwrap();
let bot = config.default();
let bot_commons = config.get("commons").unwrap();
Legoktm claimed this task.

This is basically implemented now, I think there are still some rough edges, like the save page message not indicating what wiki the page was saved on, but I've been using it for the past few hours and it's pretty functional. Thanks to @XtexChooser for doing the first part in mwapi last year :)