class ICQ::Event

Attributes

chat_id[R]
data[R]
from[R]
msg_id[R]
query_id[R]
text[R]
type[R]

Public Class Methods

new(event_h) click to toggle source
# 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

Public Instance Methods

prefix?() click to toggle source
# File lib/icqbot/event.rb, line 34
def prefix?
  @text[0] == ICQ::BOT_PREFIX if @text
end
to_h() click to toggle source
# File lib/icqbot/event.rb, line 38
def to_h; @event_h end
to_s() click to toggle source
# File lib/icqbot/event.rb, line 39
def to_s; "Event(#{@type}" + (@text ? ", #{@text}" : '') + ')' end