Page MenuHomePhabricator

mwbot-rs: Add function to protect a page
Open, MediumPublic

Description

Originally filed on GitLab.com

https://www.mediawiki.org/wiki/API:Protect - note that any new errors need to be added to mwapi_errors.
Ideally the function would be named mwbot::Page::protect(...).
You be able to borrow some code from https://github.com/legoktm/tfa-protector-bot/blob/f1a933552ce790cbcf2fa9318988da51aff04a2a/src/main.rs#L207


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

Details

Related Changes in GitLab:
TitleReferenceAuthorSource BranchDest Branch
Add Page::protectrepos/mwbot-rs/mwbot!115galstarprotect-pagemain
Customize query in GitLab

Event Timeline

Legoktm triaged this task as Medium priority.

@F1rst_LastNam3 awesome, let us know if you have any questions! (We also chat in Matrix/IRC if that's more convenient)

@F1rst_LastNam3: Hi! This task has been assigned to you a while ago. Could you maybe share an update? Do you still plan to work on this task, or do you need any help?

Hi, can I do this ? I am a newbie in open source , any help would be appreciated .
Regards

also is the api that is used in https://github.com/legoktm/tfa-protector-bot/blob/f1a933552ce790cbcf2fa9318988da51aff04a2a/src/main.rs#L207 , i have to use the same by using mediawiki crate or i have to use the ApiError ?

@Priyanshu_Chahal Hi! You may implement your code in the mwbot crate: https://gitlab.wikimedia.org/repos/mwbot-rs/mwbot/-/tree/main/mwbot.

Most common errors are already handled by mwbot: https://gitlab.wikimedia.org/repos/mwbot-rs/mwbot/-/blob/main/mwbot/src/error/mod.rs#L234 , so they can be simply converted from ApiError to Error.

For the listed possible errors, those of invalid parameter format (e.g. invalidexpiry) and missing parameters (e.g. notoken), should be ignored, because mwbot-rs should simply avoid these missing parameter errors, by having a strong typing system. For other errors, such as create-titleexists, you MAY add them to Error or just ignore them (I am fine with ignoring, not sure how @Legoktm think).