Module: MediaWiki::Administration
- Included in:
- Butt
- Defined in:
- lib/mediawiki/administration.rb
Instance Method Summary collapse
-
#block(user, expiry = '2 weeks', reason = nil, nocreate = true) ⇒ Fixnum
Blocks the user.
-
#unblock(user, reason = nil) ⇒ Fixnum
Unblocks the user.
Instance Method Details
#block(user, expiry = '2 weeks', reason = nil, nocreate = true) ⇒ Fixnum
Blocks the user.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mediawiki/administration.rb', line 13 def block(user, expiry = '2 weeks', reason = nil, nocreate = true) params = { action: 'block', user: user, expiry: expiry } token = get_token params[:reason] = reason if reason params[:nocreate] = '1' if nocreate params[:token] = token response = post(params) if response.key?('error') raise MediaWiki::Butt::BlockError.new(response.dig('error', 'code') || 'Unknown error code') end response['id'].to_i end |
#unblock(user, reason = nil) ⇒ Fixnum
Unblocks the user.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/mediawiki/administration.rb', line 41 def unblock(user, reason = nil) params = { action: 'unblock', user: user } token = get_token params[:reason] = reason if reason params[:token] = token response = post(params) if response.key?('error') raise MediaWiki::Butt::BlockError.new(response.dig('error', 'code') || 'Unknown error code') end response['id'].to_i end |