FTB-Gamepedia / MediaWiki-Butt-Ruby

A Ruby library for the MediaWiki API
https://rubygems.org/gems/mediawiki-butt
MIT License
9 stars 2 forks source link

Support protection API #79

Open elifoster opened 4 years ago

elifoster commented 4 years ago

Add support for the protection API. Not exactly sure how this should work because the protection API is pretty complicated. @xbony2 ?

elifoster commented 4 years ago

Here's a rough start for a protection method: https://github.com/elifoster/gp-work-utils/blob/01f3b54e160e9e4fc3f4298d96ec6fb5a5e555c3/lib/butt_extensions.rb#L21-L31

    def protect(page)
      params = {
        action: 'protect',
        title: page,
        cascade: true,
        protections: 'edit=sysop|move=sysop',
        expiry: 'never|never',
        reason: 'High traffic page',
        token: get_token
      }
      post(params)
    end
xbony2 commented 4 years ago

Doesn't look awful. I would add more parameters of course, and perhaps String constants for the expiration date. Or the method would take whatever Ruby's time stamp object is, and we could have constants for the max value of that, and just convert that to the String "never" if equal.