Class: MediaWiktory::Wikipedia::Actions::Block

Inherits:
Post
  • Object
show all
Defined in:
lib/mediawiktory/wikipedia/actions/block.rb

Overview

Block a user.

Usage:

api.block.user(value).perform # returns string with raw output
# or
api.block.user(value).response # returns output parsed and wrapped into Response object

See Base for generic explanation of working with MediaWiki actions and Response for working with action responses.

All action's parameters are documented as its public methods, see below.

Instance Method Summary collapse

Methods inherited from Post

#perform

Methods inherited from Base

#inspect, #merge, #name, #perform, #response, #to_h, #to_param, #to_url

Methods included from GlobalParams

#assert, #assertuser, #centralauthtoken, #curtimestamp, #errorformat, #errorlang, #errorsuselocal, #format, #maxage, #maxlag, #origin, #requestid, #responselanginfo, #servedby, #smaxage, #uselang

Instance Method Details

#allowusertalkself

Allow the user to edit their own talk page (depends on $wgBlockAllowsUTEdit).

Returns:

  • (self)


92
93
94
# File 'lib/mediawiktory/wikipedia/actions/block.rb', line 92

def allowusertalk()
  merge(allowusertalk: 'true')
end

#anononlyself

Block anonymous users only (i.e. disable anonymous edits for this IP address).

Returns:

  • (self)


57
58
59
# File 'lib/mediawiktory/wikipedia/actions/block.rb', line 57

def anononly()
  merge(anononly: 'true')
end

#autoblockself

Automatically block the last used IP address, and any subsequent IP addresses they try to login from.

Returns:

  • (self)


71
72
73
# File 'lib/mediawiktory/wikipedia/actions/block.rb', line 71

def autoblock()
  merge(autoblock: 'true')
end

#expiry(value) ⇒ self

Expiry time. May be relative (e.g. 5 months or 2 weeks) or absolute (e.g. 2014-09-18T12:34:56Z). If set to infinite, indefinite, or never, the block will never expire.

Parameters:

  • value (String)

Returns:

  • (self)


42
43
44
# File 'lib/mediawiktory/wikipedia/actions/block.rb', line 42

def expiry(value)
  merge(expiry: value.to_s)
end

#hidenameself

Hide the username from the block log. (Requires the hideuser right).

Returns:

  • (self)


85
86
87
# File 'lib/mediawiktory/wikipedia/actions/block.rb', line 85

def hidename()
  merge(hidename: 'true')
end

#nocreateself

Prevent account creation.

Returns:

  • (self)


64
65
66
# File 'lib/mediawiktory/wikipedia/actions/block.rb', line 64

def nocreate()
  merge(nocreate: 'true')
end

#noemailself

Prevent user from sending email through the wiki. (Requires the blockemail right).

Returns:

  • (self)


78
79
80
# File 'lib/mediawiktory/wikipedia/actions/block.rb', line 78

def noemail()
  merge(noemail: 'true')
end

#reason(value) ⇒ self

Reason for block.

Parameters:

  • value (String)

Returns:

  • (self)


50
51
52
# File 'lib/mediawiktory/wikipedia/actions/block.rb', line 50

def reason(value)
  merge(reason: value.to_s)
end

#reblockself

If the user is already blocked, overwrite the existing block.

Returns:

  • (self)


99
100
101
# File 'lib/mediawiktory/wikipedia/actions/block.rb', line 99

def reblock()
  merge(reblock: 'true')
end

#tags(*values) ⇒ self

Change tags to apply to the entry in the block log.

Parameters:

  • values (Array<String>)

    Allowed values: "ProveIt edit", "WPCleaner", "huggle", "large plot addition".

Returns:

  • (self)


114
115
116
# File 'lib/mediawiktory/wikipedia/actions/block.rb', line 114

def tags(*values)
  values.inject(self) { |res, val| res._tags(val) or fail ArgumentError, "Unknown value for tags: #{val}" }
end

#token(value) ⇒ self

A "csrf" token retrieved from action=query&meta=tokens

Parameters:

  • value (String)

Returns:

  • (self)


127
128
129
# File 'lib/mediawiktory/wikipedia/actions/block.rb', line 127

def token(value)
  merge(token: value.to_s)
end

#user(value) ⇒ self

Username, IP address, or IP address range to block. Cannot be used together with userid

Parameters:

  • value (String)

Returns:

  • (self)


26
27
28
# File 'lib/mediawiktory/wikipedia/actions/block.rb', line 26

def user(value)
  merge(user: value.to_s)
end

#userid(value) ⇒ self

User ID to block. Cannot be used together with user.

Parameters:

  • value (Integer)

Returns:

  • (self)


34
35
36
# File 'lib/mediawiktory/wikipedia/actions/block.rb', line 34

def userid(value)
  merge(userid: value.to_s)
end

#watchuserself

Watch the user's or IP address's user and talk pages.

Returns:

  • (self)


106
107
108
# File 'lib/mediawiktory/wikipedia/actions/block.rb', line 106

def watchuser()
  merge(watchuser: 'true')
end