rubychy 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 333bc5bc3aee4fc79a6d6b59708e2b3d385b5ddb
4
- data.tar.gz: 8ee862e01cbcd6674b496db4baf2dc22038a86b1
3
+ metadata.gz: 50e0060532ac7e2f7e3c515c5888ea73a4d0301b
4
+ data.tar.gz: 08a8b60ef510cf7960bf39ca59e10363b45d5997
5
5
  SHA512:
6
- metadata.gz: 5c8339a59ab0946bc6956472fb38a0dbc616aa929bd311c31c7a7054938ca1da8e6227d79a2ee0998e3228ffe59f2ecabc1cefab1492250993a32536f59f5d05
7
- data.tar.gz: fe1c6c9c0dba615116411fd26121d692f78fbae7982ddc4c1035bbb43f1301772eda2839ab3a52506ceb6003f8afc98857a0d6c350bee6f5414a9ad15411c3a1
6
+ metadata.gz: 00b9778296c625eabeabf7d42e6253606fb875bf5e9a294c605f3b0d57d496c35b3dfceb11083c9ec0663f58d26f9c9b74de02409eeb987e7deb1c1c9da95701
7
+ data.tar.gz: 352b817d2e3c5f60ce648a3180161984ef5342e46a1763926fe12797349738db4165212f5117ef9e0910dd63ce5ebe7d7c81e8ccc5d6f8a73c69351098ef4d08
data/README.md CHANGED
@@ -1,2 +1,107 @@
1
1
  # rubychy
2
- A ruby bot client for Kik provided by [Robochy](http://robochy.com)
2
+ A ruby client for the [Kik bot API](https://dev.kik.com/#/docs/getting-started)
3
+
4
+ The rubychy library borrows heavily from the [Telegrammer](https://github.com/mayoral/telegrammer) API, developed by [Luis Mayoral](https://github.com/mayoral)
5
+
6
+ ## Installation
7
+
8
+ Add the gem to your application's Gemfile
9
+
10
+ ```ruby
11
+ gem 'rubychy'
12
+ ```
13
+
14
+ and run the following
15
+
16
+ ```ruby
17
+ $ bundle install
18
+ ```
19
+
20
+ ## Usage
21
+ Create a bot using the [Kik](https://dev.kik.com/#/home) developer portal. Upon registration, you will get to choose a `username` for your bot. Once the `username` is created navigate to the [bot configuration dashboard](https://dev.kik.com/#/engine) where you can find the `API Key`.
22
+
23
+ Witht your bot `username` and the `API Key` you can use `rubychy` like the following:
24
+
25
+ ```ruby
26
+ require 'rubychy'
27
+
28
+ bot = Rubychy::Bot.new('[BOT USERNAME]', '[API KEY]')
29
+ ```
30
+
31
+ If you need to register a `callback` for your bot, do it by calling `config`:
32
+
33
+ ```ruby
34
+ bot.config('[HTTPS CALLBACK URL]')
35
+ ```
36
+
37
+ You can also customize the configuration features by passing the features into the config function:
38
+ ```ruby
39
+ bot.config('[HTTPS CALLBACK URL]', Rubychy::DataTypes::Features.new([YOUR CONFIG]))
40
+ ```
41
+
42
+ ## Sending Messages
43
+ With a created bot you can create messages of different types, attach custom keyboards, and pass them through the `send_message` function as follows:
44
+ ```ruby
45
+ require 'rubychy'
46
+
47
+ bot = Rubychy::Bot.new('[BOT USERNAME]', '[API KEY]')
48
+
49
+ keyboard = Rubychy::DataTypes::Keyboard.new(
50
+ :to => '[RECIPIENT USERNAME]',
51
+ :hidden => true,
52
+ :responses => [
53
+ Rubychy::DataTypes::KeyboardResponse.new(
54
+ type: "text",
55
+ body: "hi"
56
+ ),
57
+ Rubychy::DataTypes::KeyboardResponse.new(
58
+ type: "text",
59
+ body: "bye"
60
+ )
61
+ ]
62
+ )
63
+
64
+ link_message = Rubychy::DataTypes::Link.new(
65
+ :url => 'http://robochy.com',
66
+ :title => "Robochy", # Optional
67
+ :to => "[RECIPIENT USERNAME]",
68
+ :chatId => '[CHATID]'
69
+ )
70
+
71
+ text_message = Rubychy::DataTypes::Text.new(
72
+ :body => 'Hello World!',
73
+ :to => "[RECIPIENT USERNAME]",
74
+ :chatId => '[CHATID]',
75
+ :keyboards => keyboard
76
+ )
77
+
78
+ bot.send_message(link_message, text_message)
79
+ ```
80
+ Rubychy supports the existing data types for Kik. Refer to the library for the details.
81
+
82
+ ## Getting User Information
83
+ ```ruby
84
+ require 'rubychy'
85
+
86
+ bot = Rubychy::Bot.new('[BOT USERNAME]', '[API KEY]')
87
+ user_info = bot.get_user('[TARGET USERNAME]') # user_info is of type Rubychy::DataTypes::User
88
+ ```
89
+
90
+ ## Parsing the Response
91
+
92
+ In your callback servlet:
93
+
94
+ ```ruby
95
+ class Simple < WEBrick::HTTPServlet::AbstractServlet
96
+ def do_POST(request, response)
97
+ kik_response = Rubychy::ApiResponse.parse(request) # kik_response is of type Rubychy::DataTypes::ReceivedMessages
98
+ end
99
+ end
100
+ ```
101
+
102
+ ## Contributing
103
+ - Fork it: https://github.com/nkaviani/rubychy/fork
104
+ - Create your feature branch (`git checkout -b my-new-feature`)
105
+ - Commit your changes (`git commit -am 'Add some feature'`)
106
+ - Push to the branch (`git push origin my-new-feature`)
107
+ - Create a new Pull Request
data/lib/rubychy.rb CHANGED
@@ -4,6 +4,7 @@ require 'multi_json'
4
4
 
5
5
  require 'rubychy/version'
6
6
  require 'rubychy/data_types/base'
7
+ require 'rubychy/data_types/features'
7
8
  require 'rubychy/data_types/attribution'
8
9
  require 'rubychy/data_types/user'
9
10
 
@@ -1,4 +1,4 @@
1
1
  module Rubychy
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubychy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nima Kaviani