botkit 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -7
- data/lib/botkit/bot.rb +6 -4
- data/lib/botkit/message.rb +3 -3
- data/lib/botkit/runner.rb +2 -2
- data/lib/botkit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 795ad114beff6d289f8729b704aa0163873bda2f
|
4
|
+
data.tar.gz: a9113f03cb380b02d6e396f88270528fdf2fae1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 507feb6318363e512386acf69ee66deb1748bec48a4b5cbdc91b917c0c1b8f54af5a9fbebc8daa5f0c20aaaf14d62928f01d26e9630d027ec79cef7c4d5b7601
|
7
|
+
data.tar.gz: 8c429fe82829f4af5260f74e157b014b9400f378d02ae4947a25a5ac440aae0416a30a1280f540c78d4668f4d7ebf45107131ff2bf517e143ba0b5cee726f0e0
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
# Botkit
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Botkit is a framework for creating chatbots for different services.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
7
|
Add this line to your application's Gemfile:
|
10
8
|
|
11
9
|
```ruby
|
12
|
-
gem
|
10
|
+
gem "botkit"
|
13
11
|
```
|
14
12
|
|
15
13
|
And then execute:
|
@@ -22,7 +20,7 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
To be written.
|
26
24
|
|
27
25
|
## Development
|
28
26
|
|
@@ -32,7 +30,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
30
|
|
33
31
|
## Contributing
|
34
32
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/fnando/botkit. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
34
|
|
37
35
|
## License
|
38
36
|
|
@@ -40,4 +38,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
40
38
|
|
41
39
|
## Code of Conduct
|
42
40
|
|
43
|
-
Everyone interacting in the Botkit project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
41
|
+
Everyone interacting in the Botkit project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fnando/botkit/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/botkit/bot.rb
CHANGED
@@ -8,6 +8,10 @@ module Botkit
|
|
8
8
|
# after the current loop.
|
9
9
|
attr_writer :halt
|
10
10
|
|
11
|
+
def initialize
|
12
|
+
@halt = false
|
13
|
+
end
|
14
|
+
|
11
15
|
# Detect if bot should halt himself from the loop.
|
12
16
|
def halt?
|
13
17
|
@halt
|
@@ -31,15 +35,13 @@ module Botkit
|
|
31
35
|
end
|
32
36
|
end
|
33
37
|
|
34
|
-
def parse_message(input
|
38
|
+
def parse_message(input)
|
35
39
|
input = input.to_s
|
36
40
|
_, command, text = *input.match(%r{\A/([^ @]+)(?:@.*?bot)?(?:\s+(.*?))?\z}i)
|
37
|
-
matches = text.to_s.match(matcher) if matcher
|
38
41
|
|
39
42
|
{
|
40
43
|
command: command,
|
41
|
-
text: command ? text : input
|
42
|
-
matches: matches&.named_captures
|
44
|
+
text: command ? text : input
|
43
45
|
}
|
44
46
|
end
|
45
47
|
|
data/lib/botkit/message.rb
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
module Botkit
|
4
4
|
class Message
|
5
|
-
attr_reader :text, :command, :
|
5
|
+
attr_reader :text, :command, :raw, :options, :channel_id, :id
|
6
6
|
|
7
|
-
def initialize(text:, raw: {}, channel_id: nil, command: nil,
|
7
|
+
def initialize(text:, raw: {}, channel_id: nil, command: nil, options: {}, id: nil)
|
8
8
|
@text = text
|
9
9
|
@command = command
|
10
10
|
@raw = raw
|
11
11
|
@channel_id = channel_id
|
12
12
|
@options = options
|
13
|
-
@
|
13
|
+
@id = id
|
14
14
|
end
|
15
15
|
|
16
16
|
def command?
|
data/lib/botkit/runner.rb
CHANGED
@@ -11,13 +11,13 @@ module Botkit
|
|
11
11
|
|
12
12
|
def call
|
13
13
|
loop do
|
14
|
-
|
14
|
+
tick
|
15
15
|
break if bot.halt?
|
16
16
|
sleep(polling)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
private def
|
20
|
+
private def tick
|
21
21
|
bot.call
|
22
22
|
rescue StandardError => exception
|
23
23
|
bot.report_exception(exception)
|
data/lib/botkit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: botkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aitch
|