Class: Atheme::User

Inherits:
EntityBase show all
Defined in:
lib/atheme/entities/user.rb

Instance Attribute Summary

Attributes inherited from EntityBase

#token

Instance Method Summary collapse

Methods inherited from EntityBase

#error?, #initialize, #method_missing, #success?

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

#accountObject

Returns the account name of the user as an Atheme::User object



14
15
16
# File 'lib/atheme/entities/user.rb', line 14

def 
  Atheme::User.new(@session, match(/\(account\s([^\(]+)\):/))
end

#emailObject

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_idObject

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

#flagsObject

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

#groupsObject

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

#languageObject

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_seenObject

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

#nameObject

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

#nicksObject

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

#protectedObject 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_addressObject

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

#registeredObject

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_seenObject

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

#vhostObject

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