Class: ICQ::Event
- Inherits:
-
Object
- Object
- ICQ::Event
- Defined in:
- lib/icqbot/event.rb
Instance Attribute Summary collapse
-
#chat_id ⇒ Object
readonly
Returns the value of attribute chat_id.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#msg_id ⇒ Object
readonly
Returns the value of attribute msg_id.
-
#query_id ⇒ Object
readonly
Returns the value of attribute query_id.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(event_h) ⇒ Event
constructor
A new instance of Event.
- #prefix? ⇒ Boolean
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(event_h) ⇒ Event
Returns a new instance of Event.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/icqbot/event.rb', line 18 def initialize event_h # TODO: больше информации @event_h = event_h @type = event_h['type'] @from = event_h['payload']['from'] if @type != ICQ::TypeEvent::CALLBACK @text = event_h['payload']['text'] @msg_id = event_h['payload']['msgId'] @chat_id = event_h['payload']['chat']['chatId'] else @data = event_h['payload']['callbackData'] @query_id = event_h['payload']['queryId'] @chat_id = event_h['message']['chat']['chatId'] end end |
Instance Attribute Details
#chat_id ⇒ Object (readonly)
Returns the value of attribute chat_id.
15 16 17 |
# File 'lib/icqbot/event.rb', line 15 def chat_id @chat_id end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
15 16 17 |
# File 'lib/icqbot/event.rb', line 15 def data @data end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
15 16 17 |
# File 'lib/icqbot/event.rb', line 15 def from @from end |
#msg_id ⇒ Object (readonly)
Returns the value of attribute msg_id.
15 16 17 |
# File 'lib/icqbot/event.rb', line 15 def msg_id @msg_id end |
#query_id ⇒ Object (readonly)
Returns the value of attribute query_id.
15 16 17 |
# File 'lib/icqbot/event.rb', line 15 def query_id @query_id end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
15 16 17 |
# File 'lib/icqbot/event.rb', line 15 def text @text end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
15 16 17 |
# File 'lib/icqbot/event.rb', line 15 def type @type end |
Instance Method Details
#prefix? ⇒ Boolean
34 35 36 |
# File 'lib/icqbot/event.rb', line 34 def prefix? @text[0] == ICQ::BOT_PREFIX if @text end |
#to_h ⇒ Object
38 |
# File 'lib/icqbot/event.rb', line 38 def to_h; @event_h end |
#to_s ⇒ Object
39 |
# File 'lib/icqbot/event.rb', line 39 def to_s; "Event(#{@type}" + (@text ? ", #{@text}" : '') + ')' end |