Project

ruby-vibe

0.0
No release in over a year
Ruby client for Viber API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.0
~> 0.14.1
~> 13.0.3

Runtime

~> 2.1.0
 Project Readme

ruby-vibe

Ruby client for Viber REST API

Installation

Install from source:

git clone https://www.github.com/ademdc/ruby-vibe.git \
&& cd ruby-vibe \
&& bundle install

To build gem and install it locally:

# clone repo from previous step
rake build
gem install pkg/ruby-vibe-2.0.3.gem

From Gemfile:

gem 'ruby-vibe', '2.0.3'

...followed with:

bundle install

Usage

Run yard to generate documentation.

To initialize new bot, call Bot with viber authentication token:

bot = RubyVibe::Bot.new(token: <YOUR_AUTH_TOKEN>)

Also, it is possible to add a ruby-vibe.rb file in in the initializers folder with the following content:

RubyVibe::TOKEN = <YOUR_AUTH_TOKEN>
RubyVibe::NAME = <YOUR_SENDER_NAME>
RubyVibe::AVATAR = <AVATAR_HTTPS_URL>

In this case the bot can be initialized without any params: bot = RubyVibe::Bot.new

Send message

bot.send_message(text: 'hello viber from ruby!', receiver: 'someone')

If you configure token as constant RubyVibe::TOKEN, you can use class (shortcut) methods:

RubyVibe::Message[text: 'my message', receiver: 'user_id']

RubyVibe::GetOnline[user_id]

Get account info

bot.get_account_info

Response

:hash changed to :data to make rubocop happy

The reponse of each method is a Struct with three keys: success?, data and error_message. \

For a send message request the response could look like this:

#<struct :success?=true, data={"status"=>0, "status_message"=>"ok", "message_token"=>5595771666503728439, "chat_hostname"=>"SN-CHAT-16_"}, error_message=nil> 

Tests

  • Run rspec to execute all tests. Feel free to write new ones!
  • Run rubocop to inspect code quality. .rubocop_todo.yml contain current issues that need to be solved in future.

Thank you for using RubyVibe!