Page MenuHomePhabricator

mwbot-rs: Allow bots to set and access extra config in mwbot.toml
Open, MediumPublic

Description

mwbot allows bots to be configured using a mwbot.toml file. We want bots to be able to extend it for their own configuration. For example:

[custom]
my_key = "foo"

[custom.even_more]
another_key = "bar"

We would store custom as Option<toml::Value>, and then add a function like Bot::get_custom_config<T: serde::de::DeserializeOwned>(&self) -> Result<T> to allow for getting the custom configuration while still being type-safe.


Also take a look at mwbot-rs's contributing instructions.

Event Timeline

Legoktm triaged this task as Medium priority.

Hey I am interested for taking up this task can you please guide me more on this.

Hi! Thanks for your interest in mwbot-rs.
First of all, to let others know that you are working on this task, you should claim this task, by clicking "Edit Task" at the right of this page, and add yourself to "Assignee".
Then you need to clone the repository (if you does not have a WMF GitLab account, you can clone with HTTP before your account is activated) and make code changes.
The general idea of ​this task has been clearly explained in the description (if you still have other questions, you can ask here or just do as what you think is right).
To submit your code, you will need to request for an account on https://gitlab.wikimedia.org/ first, then make a merge request to https://gitlab.wikimedia.org/repos/mwbot-rs/mwbot .

Actually I am not able to make a account on https://gitlab.wikimedia.org/ as its showing

Your account is pending approval from your GitLab administrator and hence blocked. Please contact your GitLab administrator if you think this is an error.
This comment was removed by Nischay3333.

@Nischay3333 There is a banner on top of gitlab.wikimedia.org which explains "How to register an account on GitLab."
What exactly is unclear with its content, so we could improve it?

The banner is not visible on the page.

Making it not dismissable sounds good to me (:

btw it seems that the GitLab approval request queue is now suspended and requests are not being handled for unknown reasons (:

I came up with a solution and did these changes:-

  • Added BotConfig struct in bot_config.rs to handle bot configuration.
  • Implemented get_custom_config method in BotConfig to retrieve custom configuration in a type-safe manner.
  • Updated main.rs to read and parse mwbot.toml file, and retrieve custom configuration.
  • Added necessary dependencies (serde and toml) to Cargo.toml.
  • Created mwbot.toml file with example custom configuration.

but as I made a PR to the main branch it says Access denied

My account is now verified on gitlab.

Have you forked the repository? I couldn't see your fork repository on gitlab.