Class: Rubeechat::Privmsg

Inherits:
Object
  • Object
show all
Defined in:
lib/rubeechat/privmsg.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, user, channel, message) ⇒ Privmsg

Returns a new instance of Privmsg.



14
15
16
# File 'lib/rubeechat/privmsg.rb', line 14

def initialize(server, user, channel, message)
  @server, @user, @channel, @message = server, user, channel, message
end

Instance Attribute Details

#channelObject (readonly)

Returns the value of attribute channel.



12
13
14
# File 'lib/rubeechat/privmsg.rb', line 12

def channel
  @channel
end

#messageObject (readonly)

Returns the value of attribute message.



12
13
14
# File 'lib/rubeechat/privmsg.rb', line 12

def message
  @message
end

#serverObject (readonly)

Returns the value of attribute server.



12
13
14
# File 'lib/rubeechat/privmsg.rb', line 12

def server
  @server
end

#userObject (readonly)

Returns the value of attribute user.



12
13
14
# File 'lib/rubeechat/privmsg.rb', line 12

def user
  @user
end

Class Method Details

.parse(signal, data) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/rubeechat/privmsg.rb', line 4

def self.parse(signal, data)
  server, _ = signal.split(',')

  if data =~ /:([^ ]+) PRIVMSG (#?[^ ]+) :(.*)/
    self.new(server, $1, $2, $3)
  end
end

Instance Method Details

#about_me?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/rubeechat/privmsg.rb', line 49

def about_me?
  message =~ /#{nick_ptrn_str}/
end

#bufferObject

lazily construct a buffer object associated with this privmsg



38
39
40
41
42
43
44
45
46
47
# File 'lib/rubeechat/privmsg.rb', line 38

def buffer
  unless @buffer
    if ptr = Weechat.buffer_search('irc', buffer_name)
      @buffer = InfoList.buffer(ptr)
    else
      raise "Could not find buffer named: #{buffer_name.inspect}"
    end
  end
  @buffer
end

#buffer_nameObject

the buffer name that is related to this message



33
34
35
# File 'lib/rubeechat/privmsg.rb', line 33

def buffer_name
  "#{server}.#{channel}"
end

#hostnameObject



28
29
30
# File 'lib/rubeechat/privmsg.rb', line 28

def hostname
  @hostname ||= user[/@(.*)$/, 1]
end

#in_current_buffer?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/rubeechat/privmsg.rb', line 61

def in_current_buffer?
  buffer.current_buffer?
end

#involves_me?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/rubeechat/privmsg.rb', line 57

def involves_me?
  about_me? or to_me?
end

#loginObject



24
25
26
# File 'lib/rubeechat/privmsg.rb', line 24

def 
  @login ||= user[/!~([^@]+)@/, 1]
end

#nickObject



20
21
22
# File 'lib/rubeechat/privmsg.rb', line 20

def nick
  @nick ||= user[/^([^!]+)!/, 1]
end

#to_me?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/rubeechat/privmsg.rb', line 53

def to_me?
  message =~ /^#{nick_ptrn_str}/
end