Class: Vetinari::User

Inherits:
Object
  • Object
show all
Defined in:
lib/vetinari/user.rb

Overview

TODO: Actor?

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nick, bot) ⇒ User

Returns a new instance of User.



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/vetinari/user.rb', line 6

def initialize(nick, bot)
  # TODO
  @bot = bot
  @nick = nick
  @user = nil
  @host = nil
  
  @online   = nil
  @observed = false

  @channels = Set.new
  @channels_with_modes = {}
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



4
5
6
# File 'lib/vetinari/user.rb', line 4

def host
  @host
end

#nickObject (readonly)

Returns the value of attribute nick.



4
5
6
# File 'lib/vetinari/user.rb', line 4

def nick
  @nick
end

#observedObject (readonly)

Returns the value of attribute observed.



4
5
6
# File 'lib/vetinari/user.rb', line 4

def observed
  @observed
end

#onlineObject (readonly)

Returns the value of attribute online.



4
5
6
# File 'lib/vetinari/user.rb', line 4

def online
  @online
end

#userObject (readonly)

Returns the value of attribute user.



4
5
6
# File 'lib/vetinari/user.rb', line 4

def user
  @user
end

Instance Method Details

#bot?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/vetinari/user.rb', line 73

def bot?
  self == @bot.user
end

#dcc_send(filepath, filename = nil) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/vetinari/user.rb', line 77

def dcc_send(filepath, filename = nil)
  if @bot.server_manager
    if File.exist?(filepath)
      filename = File.basename(filepath) unless filename
      @bot.server_manager.add_offering(self, filepath, filename)
    else
      raise "File '#{filepath}' does not exist."
    end
  else
    raise 'DCC not available: Missing external IP or ports'
  end
end

#inspectObject



104
105
106
# File 'lib/vetinari/user.rb', line 104

def inspect
  "#<User nick=#{@nick}>"
end

#message(message) ⇒ Object

TODO: ping, version, time methods?



92
93
94
# File 'lib/vetinari/user.rb', line 92

def message(message)
  @bot.raw "PRIVMSG #{@nick} :#{message}"
end

#notice(message) ⇒ Object



96
97
98
# File 'lib/vetinari/user.rb', line 96

def notice(message)
  @bot.raw "NOTICE #{@nick} :#{message}"
end

#online?Boolean

self end

Returns:

  • (Boolean)


63
64
65
66
67
68
69
70
71
# File 'lib/vetinari/user.rb', line 63

def online?
  if @bot.users[@nick]
    @online = true
  else
    # TODO
    # whois if @online.nil?
    # @online
  end
end

#renamed_to(nick) ⇒ Object



100
101
102
# File 'lib/vetinari/user.rb', line 100

def renamed_to(nick)
  @nick = nick
end

#to_sObject



108
109
110
# File 'lib/vetinari/user.rb', line 108

def to_s
  @nick
end