cinch-wit 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5e72601388b8efb16d35ee3cf148f445fb0a7c1a
4
+ data.tar.gz: adfe7a9921ca2623220ff752839b41c638369541
5
+ SHA512:
6
+ metadata.gz: cb0a2095ebec96d1ca76ddf94f968b96e70d2d1bcb76c3b95630390e5de7b7640c2b09b668b3742539174506ce206cc84fddad3b3673ea7aaf12a709b4d4ec69
7
+ data.tar.gz: 8bd9eba68f14d5d93edd4a92ba8d6efc8befa27a63d4a4581368dea39839b852e2c533051419416addf1f0fcf2dfbdf7147ce7395d354f63ac9bcce66aa4dc28
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1,6 @@
1
+ Cinch Wit Plugin Changes
2
+ ========================
3
+
4
+ ## v0.0.1 - *2013-11-08*
5
+
6
+ - First version.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Justin Workman
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,82 @@
1
+ Wit Plugin for Cinch
2
+ ====================
3
+
4
+ This plugin lets you use [Wit's natural language processing][1] in your [Cinch][2] IRC bot.
5
+ You will need an access key from Wit in order for this to work.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ``` ruby
12
+ gem 'cinch-wit'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ ``` shell
18
+ $ bundle
19
+ ```
20
+
21
+ Or install it yourself as:
22
+
23
+ ``` shell
24
+ $ gem install cinch-wit
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ Note: This guide expects you to already have basic familiarity of [Cinch][2] and [Wit][1].
30
+
31
+ After installing the gem, register the plugin in your Cinch bot, like so:
32
+
33
+ ``` ruby
34
+ require 'cinch/plugins/wit'
35
+
36
+ bot = Cinch::Bot.new do
37
+ configure do |c|
38
+ c.plugins.plugins << Cinch::Plugins::Wit
39
+ c.plugins.options[Cinch::Plugins::Wit][:access_token] = 'YOUR_WIT_ACCESS_TOKEN'
40
+ end
41
+
42
+ # ...
43
+ end
44
+ ```
45
+
46
+ You will have to train Wit before doing anything interesting. Here is an example
47
+ which handles Wit's default "Hello" and "Goodbye" intents:
48
+
49
+ ``` ruby
50
+ bot = Cinch::Bot.new do
51
+ # ...
52
+
53
+ on :intent do |msg, outcome|
54
+ response = case outcome['intent']
55
+ when 'hello' then "Hello, #{msg.user}!"
56
+ when 'good_bye' then "See you later, #{msg.user}."
57
+ end
58
+ msg.reply(response) unless response.nil?
59
+ end
60
+ end
61
+ ```
62
+
63
+ You can also enumerate `outcome['entities']` to get the entities, or check the confidence value
64
+ with `outcome['confidence']`
65
+
66
+ ## Contributing
67
+
68
+ 1. Fork it
69
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
70
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
71
+ 4. Push to the branch (`git push origin my-new-feature`)
72
+ 5. Create new Pull Request
73
+
74
+ ## License
75
+
76
+ Copyright © 2013 [Justin Workman](mailto:xtagon@gmail.com)
77
+
78
+ MIT License, see LICENSE.txt
79
+
80
+
81
+ [1]: https://wit.ai/
82
+ [2]: https://github.com/cinchrb/cinch
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,20 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'cinch-wit'
3
+ spec.version = '0.0.1'
4
+ spec.authors = ['Justin Workman']
5
+ spec.email = ['xtagon@gmail.com']
6
+ spec.summary = "A Cinch plugin for the Wit API"
7
+ spec.description = "A Cinch plugin to use Wit's natural language processing in your IRC bot"
8
+ spec.license = 'MIT'
9
+
10
+ spec.files = `git ls-files`.split($/)
11
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
12
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
13
+ spec.require_paths = ['lib']
14
+
15
+ spec.add_runtime_dependency 'cinch'
16
+ spec.add_runtime_dependency 'wit'
17
+
18
+ spec.add_development_dependency 'bundler', '~> 1.3'
19
+ spec.add_development_dependency 'rake'
20
+ end
@@ -0,0 +1,31 @@
1
+ module Cinch
2
+ module Plugins
3
+ class Wit
4
+ include Cinch::Plugin
5
+
6
+ require 'wit'
7
+
8
+ # Match when the bot's name is mentioned at the START.
9
+ # e.g. "Bot, how are you?"
10
+ match lambda { |msg| /\A\s*#{msg.bot.nick}[:,](.+)/i }, use_prefix: false
11
+
12
+ # Match when the bot's name is mentioned at the END.
13
+ # e.g. "Hello, Bot."
14
+ match lambda { |msg| /(.+),\s+#{msg.bot.nick}[.?!\s]*\s*\Z/i }, use_prefix: false
15
+
16
+ # Send a message to the Wit API and dispatch an event with the outcome.
17
+ def execute(msg, message)
18
+ wit_response = wit_client.message(message.strip)
19
+ outcome = wit_response['outcome']
20
+ debug outcome.to_s
21
+ msg.bot.handlers.dispatch :intent, msg, outcome
22
+ end
23
+
24
+ private
25
+
26
+ def wit_client
27
+ @wit_client ||= ::Wit::Client.new(config[:access_token])
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ module Cinch
2
+ module Wit
3
+ VERSON = '0.0.1'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cinch-wit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Justin Workman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cinch
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: wit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: A Cinch plugin to use Wit's natural language processing in your IRC bot
70
+ email:
71
+ - xtagon@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .rspec
78
+ - CHANGES.md
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - cinch-wit.gemspec
84
+ - lib/cinch/wit.rb
85
+ - lib/cinch/wit/version.rb
86
+ homepage:
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.0.3
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: A Cinch plugin for the Wit API
110
+ test_files: []
111
+ has_rdoc: