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 +4 -4
- data/README.md +106 -1
- data/lib/rubychy.rb +1 -0
- data/lib/rubychy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50e0060532ac7e2f7e3c515c5888ea73a4d0301b
|
4
|
+
data.tar.gz: 08a8b60ef510cf7960bf39ca59e10363b45d5997
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00b9778296c625eabeabf7d42e6253606fb875bf5e9a294c605f3b0d57d496c35b3dfceb11083c9ec0663f58d26f9c9b74de02409eeb987e7deb1c1c9da95701
|
7
|
+
data.tar.gz: 352b817d2e3c5f60ce648a3180161984ef5342e46a1763926fe12797349738db4165212f5117ef9e0910dd63ce5ebe7d7c81e8ccc5d6f8a73c69351098ef4d08
|
data/README.md
CHANGED
@@ -1,2 +1,107 @@
|
|
1
1
|
# rubychy
|
2
|
-
A ruby
|
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
data/lib/rubychy/version.rb
CHANGED