Class: Atheme::User
- Inherits:
-
EntityBase
- Object
- EntityBase
- Atheme::User
- Defined in:
- lib/atheme/entities/user.rb
Instance Attribute Summary
Attributes inherited from EntityBase
Instance Method Summary collapse
-
#account ⇒ Object
Returns the account name of the user as an Atheme::User object.
-
#email ⇒ Object
Returns the user’s email.
-
#entity_id ⇒ Object
Unique entity ID.
-
#fdrop! ⇒ Object
Forcefully removes the account, including all nicknames, channel access and memos attached to it.
-
#fetch! ⇒ Object
:nodoc:.
-
#flags ⇒ Object
Returns the user’s flags as an array, e.g.
-
#freeze!(reason) ⇒ Object
freeze allows operators to “freeze” an abusive user’s account.
-
#groups ⇒ Object
Returns the user’s groups as an array,.
-
#language ⇒ Object
Returns the user’s language.
-
#last_seen ⇒ Object
Date object of the time when the nick was last seen.
-
#mark!(reason) ⇒ Object
mark allows operators to attach a note to an account.
-
#name ⇒ Object
Returns the nickname (not account name) of the user.
-
#nicks ⇒ Object
Returns an array of linked nicknames to this nick/account.
-
#protected ⇒ Object
(also: #protected?)
Returns true if the user enabled nick protection, false otherwise.
-
#real_address ⇒ Object
Real address of the user’s connection.
-
#registered ⇒ Object
Date object which is set to the time when the nick was registered.
-
#remove_vhost! ⇒ Object
Removes a previously added vhost from the account.
-
#reset_password! ⇒ Object
Sets a random password for this account.
-
#unfreeze! ⇒ Object
Unfreeze an previously frozen account.
-
#unmark! ⇒ Object
Unmark a previously marked account.
-
#user_seen ⇒ Object
Date object of the time when the user was last seen.
-
#vhost ⇒ Object
Returns the vhost of the nick if set.
-
#vhost!(vhost = nil) ⇒ Object
vhost allows operators to set a virtual host (also known as a spoof or cloak) on an account.
Methods inherited from EntityBase
Constructor Details
This class inherits a constructor from Atheme::EntityBase
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Atheme::EntityBase
Instance Method Details
#account ⇒ Object
Returns the account name of the user as an Atheme::User object
14 15 16 |
# File 'lib/atheme/entities/user.rb', line 14 def account Atheme::User.new(@session, match(/\(account\s([^\(]+)\):/)) end |
#email ⇒ Object
Returns the user’s email
54 55 56 |
# File 'lib/atheme/entities/user.rb', line 54 def email match(/Email\s+:\s+([^\s]+)/) end |
#entity_id ⇒ Object
Unique entity ID. Available only if the user is currently connected
24 25 26 |
# File 'lib/atheme/entities/user.rb', line 24 def entity_id match(/Entity\sID\s+:\s+([A-F0-9]+)$/) end |
#fdrop! ⇒ Object
Forcefully removes the account, including all nicknames, channel access and memos attached to it. Only opers may use this.
82 83 84 |
# File 'lib/atheme/entities/user.rb', line 82 def fdrop! @session.nickserv.fdrop(self.name) end |
#fetch! ⇒ Object
:nodoc:
4 5 6 |
# File 'lib/atheme/entities/user.rb', line 4 def fetch! #:nodoc: @session.nickserv.info(@token) end |
#flags ⇒ Object
Returns the user’s flags as an array, e.g. HideMail
64 65 66 |
# File 'lib/atheme/entities/user.rb', line 64 def flags match(/Flags\s+:\s+(.+)$/).split rescue [] end |
#freeze!(reason) ⇒ Object
freeze allows operators to “freeze” an abusive user’s account. This logs out all sessions logged in to the account and prevents further logins. Thus, users cannot obtain the access associated with the account.
90 91 92 |
# File 'lib/atheme/entities/user.rb', line 90 def freeze!(reason) @session.nickserv.freeze(self.name, :on, reason) end |
#groups ⇒ Object
Returns the user’s groups as an array,
75 76 77 |
# File 'lib/atheme/entities/user.rb', line 75 def groups match(/Groups\s+:\s+(.+)$/).split rescue [] end |
#language ⇒ Object
Returns the user’s language
59 60 61 |
# File 'lib/atheme/entities/user.rb', line 59 def language match(/Language\s+:\s+([\w]+)$/) end |
#last_seen ⇒ Object
Date object of the time when the nick was last seen
39 40 41 |
# File 'lib/atheme/entities/user.rb', line 39 def last_seen Date.parse(match(/Last\sseen\s+:\s+(\w+ [0-9]{2} [0-9(:?)]+ [0-9]{4})/)) end |
#mark!(reason) ⇒ Object
mark allows operators to attach a note to an account. For example, an operator could mark the account of a spammer so that others know the user has previously been warned.
103 104 105 |
# File 'lib/atheme/entities/user.rb', line 103 def mark!(reason) @session.nickserv.mark(self.name, :on, reason) end |
#name ⇒ Object
Returns the nickname (not account name) of the user
9 10 11 |
# File 'lib/atheme/entities/user.rb', line 9 def name match(/^Information\son\s([^\s]+)/) end |
#nicks ⇒ Object
Returns an array of linked nicknames to this nick/account
49 50 51 |
# File 'lib/atheme/entities/user.rb', line 49 def nicks match(/Nicks\s+:\s+([^\s]+(?:\s[^\s]+)*)$/).split rescue [] end |
#protected ⇒ Object Also known as: protected?
Returns true if the user enabled nick protection, false otherwise
69 70 71 |
# File 'lib/atheme/entities/user.rb', line 69 def protected match(/has\s(enabled)\snick\sprotection/) ? true : false end |
#real_address ⇒ Object
Real address of the user’s connection
34 35 36 |
# File 'lib/atheme/entities/user.rb', line 34 def real_address match(/Real\saddr\s+:\s+([^\s]+)$/) end |
#registered ⇒ Object
Date object which is set to the time when the nick was registered
19 20 21 |
# File 'lib/atheme/entities/user.rb', line 19 def registered Date.parse(match(/Registered\s+:\s+(\w+ [0-9]{2} [0-9(:?)]+ [0-9]{4})/)) end |
#remove_vhost! ⇒ Object
Removes a previously added vhost from the account
122 123 124 |
# File 'lib/atheme/entities/user.rb', line 122 def remove_vhost! @session.nickserv.vhost(self.name, :off) end |
#reset_password! ⇒ Object
Sets a random password for this account. Only opers may use this.
128 129 130 |
# File 'lib/atheme/entities/user.rb', line 128 def reset_password! @session.nickserv.resetpass(self.name) end |
#unfreeze! ⇒ Object
Unfreeze an previously frozen account.
95 96 97 |
# File 'lib/atheme/entities/user.rb', line 95 def unfreeze! @session.nickserv.freeze(self.name, :off) end |
#unmark! ⇒ Object
Unmark a previously marked account.
108 109 110 |
# File 'lib/atheme/entities/user.rb', line 108 def unmark! @session.nickserv.mark(self.name, :off) end |
#user_seen ⇒ Object
Date object of the time when the user was last seen
44 45 46 |
# File 'lib/atheme/entities/user.rb', line 44 def user_seen Date.parse(match(/User\sseen\s+:\s+(\w+ [0-9]{2} [0-9(:?)]+ [0-9]{4})/)) rescue nil end |
#vhost ⇒ Object
Returns the vhost of the nick if set
29 30 31 |
# File 'lib/atheme/entities/user.rb', line 29 def vhost match(/vHost\s+:\s+([^\s]+)$/) end |
#vhost!(vhost = nil) ⇒ Object
vhost allows operators to set a virtual host (also known as a spoof or cloak) on an account. This vhost will be set on the user immediately and each time they identify If no vhost is given, the current one will be deleted.
117 118 119 |
# File 'lib/atheme/entities/user.rb', line 117 def vhost!(vhost=nil) vhost.nil? ? remove_vhost! : @session.nickserv.vhost(self.name, :on, vhost) end |