class TelegramMeetupBot::MessageParser

Constants

User

Attributes

message[R]

Public Class Methods

new(message) click to toggle source
# File lib/telegram_meetup_bot/message_parser.rb, line 6
def initialize(message)
  @message = message
end

Public Instance Methods

author() click to toggle source
# File lib/telegram_meetup_bot/message_parser.rb, line 10
def author
  from = message.from
  User.new(from.id, from.username, from.first_name)
end
command() click to toggle source
# File lib/telegram_meetup_bot/message_parser.rb, line 15
def command
  parse_message do |words|
    cmd, bot_name = words.first.split('@')
    cmd if bot_name.nil? || bot_name == Initializers::ConfigLoader.bot_name
  end
end
params() click to toggle source
# File lib/telegram_meetup_bot/message_parser.rb, line 22
def params
  parse_message { |words| words.drop(1) } || []
end

Private Instance Methods

parse_message() { |text.split(' ')| ... } click to toggle source
# File lib/telegram_meetup_bot/message_parser.rb, line 28
def parse_message(&block)
  if message.text && message.text[0] == '/' && message.text.length > 1
    yield message.text[1..-1].split(' ')
  end
end