0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Line Bot API usuall depend on rack but it cause newer rack cannot working correctly, so I create yet another library for it.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.12
~> 0.8
~> 2.0
~> 10.0
~> 3.0
~> 0.11
 Project Readme

Line Bot Lite

Rubygems Build Status Coverage Status Code Climate

Yet another line bot SDK implement. This version use all ruby builtin library and without dependencies problem like rack version is lock down to >= 0

Installation

Add this line to your application's Gemfile:

gem 'line-bot-lite'

And then execute:

$ bundle

Or install it yourself as:

$ gem install line-bot-lite

Usage

Current only implemented send_text method, and still need refactor to support all types message.

require 'line/bot'
require 'json'

def client
  @client ||= Line::Bot::Client.new(
    channel_id: ENV['LINE_CHANNEL_ID'],
    channel_secret: ENV['LINE_CHANNEL_SECRET'],
    channel_mid: ENV['LINE_CHANNEL_MID']
  )
end

post '/callback' do
  signature = request.env['HTTP_X_LINE_CHANNELSIGNATURE']
  unless client.certentials.validate_signature(request.body.read, signature)
    error 400 do 'Bad Request' end
  end

  request.body.rewind
  events = Line::Bot::Response.new(request.body.read)

  events.each do |event|
    case event.event_type
    when Line::Bot::Receive::EventType::MESSAGE
      client.send_text(event.from_mid, event.content[:text])
    end
  end

  "OK"
end

WARNING: The API will changed until it stable, and next release will provide response parser helper.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/elct9620/line-bot. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.