Class: ICQ::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/icqbot/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_h) ⇒ Event

Returns a new instance of Event.



16
17
18
19
20
21
22
23
# File 'lib/icqbot/event.rb', line 16

def initialize event_h
  @event_h = event_h
  @type = event_h['type']
  @text = event_h['payload']['text']
  @msg_id = event_h['payload']['msgId']
  @chat_id = event_h['payload']['chat']['chatId']
  @from = event_h['payload']['from']
end

Instance Attribute Details

#chat_idObject (readonly)

Returns the value of attribute chat_id.



14
15
16
# File 'lib/icqbot/event.rb', line 14

def chat_id
  @chat_id
end

#fromObject (readonly)

Returns the value of attribute from.



14
15
16
# File 'lib/icqbot/event.rb', line 14

def from
  @from
end

#msg_idObject (readonly)

Returns the value of attribute msg_id.



14
15
16
# File 'lib/icqbot/event.rb', line 14

def msg_id
  @msg_id
end

#textObject (readonly)

Returns the value of attribute text.



14
15
16
# File 'lib/icqbot/event.rb', line 14

def text
  @text
end

#typeObject (readonly)

Returns the value of attribute type.



14
15
16
# File 'lib/icqbot/event.rb', line 14

def type
  @type
end

Instance Method Details

#prefix?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/icqbot/event.rb', line 25

def prefix?
  @text[0] == ICQ::BOT_PREFIX
end

#to_hObject



29
# File 'lib/icqbot/event.rb', line 29

def to_h; @event_h end