Class: Vetinari::User
- Inherits:
-
Object
- Object
- Vetinari::User
- Defined in:
- lib/vetinari/user.rb
Overview
TODO: Actor?
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#nick ⇒ Object
readonly
Returns the value of attribute nick.
-
#observed ⇒ Object
readonly
Returns the value of attribute observed.
-
#online ⇒ Object
readonly
Returns the value of attribute online.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #bot? ⇒ Boolean
- #dcc_send(filepath, filename = nil) ⇒ Object
-
#initialize(nick, bot) ⇒ User
constructor
A new instance of User.
- #inspect ⇒ Object
-
#message(message) ⇒ Object
TODO: ping, version, time methods?.
- #notice(message) ⇒ Object
-
#online? ⇒ Boolean
self end.
- #renamed_to(nick) ⇒ Object
- #to_s ⇒ Object
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
#host ⇒ Object (readonly)
Returns the value of attribute host.
4 5 6 |
# File 'lib/vetinari/user.rb', line 4 def host @host end |
#nick ⇒ Object (readonly)
Returns the value of attribute nick.
4 5 6 |
# File 'lib/vetinari/user.rb', line 4 def nick @nick end |
#observed ⇒ Object (readonly)
Returns the value of attribute observed.
4 5 6 |
# File 'lib/vetinari/user.rb', line 4 def observed @observed end |
#online ⇒ Object (readonly)
Returns the value of attribute online.
4 5 6 |
# File 'lib/vetinari/user.rb', line 4 def online @online end |
#user ⇒ Object (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
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 |
#inspect ⇒ Object
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 () @bot.raw "PRIVMSG #{@nick} :#{}" end |
#notice(message) ⇒ Object
96 97 98 |
# File 'lib/vetinari/user.rb', line 96 def notice() @bot.raw "NOTICE #{@nick} :#{}" end |
#online? ⇒ Boolean
self end
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_s ⇒ Object
108 109 110 |
# File 'lib/vetinari/user.rb', line 108 def to_s @nick end |