Module: MediaWiki::Query::Meta::UserInfo
- Included in:
- Butt, MediaWiki::Query::Meta
- Defined in:
- lib/mediawiki/query/meta/userinfo.rb
Overview
Instance Method Summary collapse
-
#current_user_hasmsg? ⇒ Boolean
Returns whether or not the currently logged in user has any unread messages on their talk page.
-
#get_changeable_groups ⇒ Boolean, Hash<String, Array<String>>
Gets a hash-of-arrays containing all the groups the user can add and remove people from.
-
#get_current_user_meta(prop = nil) ⇒ Hash, Boolean
Gets meta information for the currently logged in user.
-
#get_current_user_name ⇒ String, Boolean
Gets the current user’s username.
-
#get_current_user_options ⇒ Hash<String, Any>
Gets the user’s options.
-
#get_email_address ⇒ String, Nil
Gets the currently logged in user’s email address.
-
#get_realname ⇒ String, Nil
Gets the currently logged in user’s real name.
Instance Method Details
#current_user_hasmsg? ⇒ Boolean
Returns whether or not the currently logged in user has any unread messages on their talk page.
38 39 40 41 42 43 |
# File 'lib/mediawiki/query/meta/userinfo.rb', line 38 def current_user_hasmsg? response = ('hasmsg') return false unless response response['query']['userinfo']['messages'] == '' end |
#get_changeable_groups ⇒ Boolean, Hash<String, Array<String>>
Gets a hash-of-arrays containing all the groups the user can add and remove people from.
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/mediawiki/query/meta/userinfo.rb', line 50 def get_changeable_groups response = ('changeablegroups') return false unless response changeablegroups = response['query']['userinfo']['changeablegroups'] { :add => changeablegroups['add'], :remove => changeablegroups['remove'], :addself => changeablegroups['add-self'], :removeself => changeablegroups['add-self'] } end |
#get_current_user_meta(prop = nil) ⇒ Hash, Boolean
Gets meta information for the currently logged in user.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/mediawiki/query/meta/userinfo.rb', line 11 def (prop = nil) return false unless @logged_in params = { action: 'query', meta: 'userinfo', uiprop: prop } post(params) end |
#get_current_user_name ⇒ String, Boolean
Gets the current user’s username.
27 28 29 30 31 32 33 |
# File 'lib/mediawiki/query/meta/userinfo.rb', line 27 def get_current_user_name return @name if @name name = name = name['query']['userinfo']['name'] if name name end |
#get_current_user_options ⇒ Hash<String, Any>
Gets the user’s options.
90 91 92 93 94 |
# File 'lib/mediawiki/query/meta/userinfo.rb', line 90 def response = ('options') ret = {} response['query']['userinfo']['options'].each { |k, v| ret[k] = v } end |
#get_email_address ⇒ String, Nil
Gets the currently logged in user’s email address.
79 80 81 82 83 84 85 |
# File 'lib/mediawiki/query/meta/userinfo.rb', line 79 def get_email_address response = ('email') email = response['query']['userinfo']['email'] return if email == '' email end |
#get_realname ⇒ String, Nil
Gets the currently logged in user’s real name.
67 68 69 70 71 72 73 |
# File 'lib/mediawiki/query/meta/userinfo.rb', line 67 def get_realname response = ('realname') realname = response['query']['userinfo']['realname'] return if realname == '' realname end |