Module: Telegruby

Defined in:
lib/telegruby.rb

Defined Under Namespace

Classes: Bot, Message, Update

Class Method Summary collapse

Class Method Details

.collect_msgs(update) ⇒ Object

Given an Update object, gets messages as structs.



318
319
320
321
322
# File 'lib/telegruby.rb', line 318

def collect_msgs(update)
  update.result.map { |msg|
    Message.new(msg)
  }
end

.read_config(filename) ⇒ Object

Reads an API token from a JSON file. The result of this should be passed to Telegruby::Bot.new



303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/telegruby.rb', line 303

def read_config(filename)
  begin
    data = JSON.parse(File.read(filename))

    if !data.key? "token"
      return false
    end

    return data
  rescue
    return false
  end
end