ruboty-callng 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e4b2426f7a38862bc7d19a96abb88639810caebd
4
+ data.tar.gz: e4986ce9c274b4ff9c13f5c464d2dee0a5eaa5e7
5
+ SHA512:
6
+ metadata.gz: ba0a368113eb2a32b15699655911942e08c62af6a0df9a0c31facf4de82207695ee4a096e0b44aae27839a3312026fb77f7115a7adf155e7e14619c0966253e2
7
+ data.tar.gz: c16134867566cc262740cf8b19e50bbf6698438ade48684a168f1525bd7336e05403171847627f81d9ff55ba24831228b795213de93b17c95ea5ecac2fc4e8f9
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ruboty-callng.gemspec
4
+ gemspec
5
+
6
+ gem "ruboty-slack_rtm"
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 block_given?, Ryota Arai
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.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Ruboty::Callng
2
+
3
+ ruboty plugin for make a call to you. This plugin is fork of [ruboty-call](https://github.com/blockgiven/ruboty-call)
4
+
5
+ ## Requirements
6
+
7
+ - ruboty-slack\_rtm
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'ruboty-callng'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install ruboty-callng
24
+
25
+ ## Usage
26
+
27
+ You need to get [Twilio](https://jp.twilio.com/) account and set these environment variables
28
+
29
+ | env | description |
30
+ | ------------------- | ------------------- |
31
+ | TWILIO_ACCOUNT_SID | twilio account sid |
32
+ | TWILIO_AUTH_TOKEN | twilio auth token |
33
+ | RUBOTY_PHONE_NUMBER | twilio phone number |
34
+
35
+ ```
36
+ #general> ruboty call +81xxxxxxxxx
37
+ #general< Calling
38
+ ```
39
+
40
+ Ruboty will call the number and say like "YOURNAME calls you at general channel at Slack. Please open Slack"
41
+
42
+ ### Arbitrary message
43
+
44
+ ```
45
+ > ruboty call +81xxxxxxxxxx Good morning
46
+ < Calling
47
+ ```
48
+
49
+ Ruboty accepts English and Japanese message.
50
+
51
+ ## Contributing
52
+
53
+ 1. Fork it ( https://github.com/ryotarai/ruboty-callng/fork )
54
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
55
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
56
+ 4. Push to the branch (`git push origin my-new-feature`)
57
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,77 @@
1
+ require 'twilio-ruby'
2
+ require 'uri'
3
+
4
+ module Ruboty
5
+ module Callng
6
+ module Actions
7
+ class Call < Ruboty::Actions::Base
8
+ def call
9
+ phone_call(generate_text)
10
+ end
11
+
12
+ def call_with_message
13
+ phone_call(message[:text])
14
+ end
15
+
16
+ private
17
+
18
+ def from
19
+ ENV['RUBOTY_PHONE_NUMBER']
20
+ end
21
+
22
+ def generate_text
23
+ channel = message.original[:channel] ? "at #{message.original[:channel]['name']} channel" : ''
24
+ "#{message.original[:user]['name']} calls you #{channel} in Slack. Please open Slack"
25
+ end
26
+
27
+ def phone_call(text)
28
+ twilio_client.account.calls.create({
29
+ :to => to,
30
+ :from => from,
31
+ :url => twiml_url(text),
32
+ :method => 'GET',
33
+ :fallback_method => 'GET',
34
+ :status_callback_method => 'GET',
35
+ })
36
+ message.reply("Calling")
37
+ rescue => err
38
+ message.reply("Calling failed: #{err}")
39
+ end
40
+
41
+ def to
42
+ message[:to]
43
+ end
44
+
45
+ def twilio_client
46
+ # put your own credentials here
47
+ account_sid = ENV['TWILIO_ACCOUNT_SID']
48
+ auth_token = ENV['TWILIO_AUTH_TOKEN']
49
+
50
+ Twilio::REST::Client.new account_sid, auth_token
51
+ end
52
+
53
+ def detect_language(text)
54
+ case text
55
+ when /\A[[:ascii:]]+\z/
56
+ 'en-US'
57
+ else
58
+ 'ja-JP'
59
+ end
60
+ end
61
+
62
+ def twiml(text)
63
+ <<TWIML
64
+ <?xml version="1.0" encoding="UTF-8"?>
65
+ <Response>
66
+ <Say voice="alice" language="#{detect_language(text)}">#{text}</Say>
67
+ </Response>
68
+ TWIML
69
+ end
70
+
71
+ def twiml_url(text)
72
+ "http://twimlets.com/echo?Twiml=#{URI.escape(twiml(text))}"
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,5 @@
1
+ module Ruboty
2
+ module Callng
3
+ VERSION = "1.1.0"
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ require "ruboty/callng/version"
2
+ require "ruboty/callng/actions/call"
3
+ require "ruboty/handlers/callng"
4
+
5
+ module Ruboty
6
+ module Callng
7
+ # Your code goes here...
8
+ end
9
+ end
@@ -0,0 +1,31 @@
1
+ module Ruboty
2
+ module Handlers
3
+ class Callng < Base
4
+ class Error < StandardError; end
5
+
6
+ env :TWILIO_ACCOUNT_SID, 'twilio account sid'
7
+ env :TWILIO_AUTH_TOKEN, 'twilio auth token'
8
+ env :RUBOTY_PHONE_NUMBER, 'twilio phone number'
9
+
10
+ on /call \+(?<to>\d+) (?<text>.*)/, name: 'phone_call_with_message', description: "make a call with specific message"
11
+ on /call \+(?<to>\d+)$/, name: 'phone_call', description: "make a call"
12
+
13
+ def initialize(*args)
14
+ super
15
+ unless defined?(Ruboty::SlackRTM)
16
+ raise Error, "ruboty-slack_rtm is not installed. ruboty-callng supports only ruboty-slack_rtm for now"
17
+ end
18
+ end
19
+
20
+ # call is already used in ruboty
21
+ def phone_call(message)
22
+ Ruboty::Callng::Actions::Call.new(message).call
23
+ end
24
+
25
+ # call is already used in ruboty
26
+ def phone_call_with_message(message)
27
+ Ruboty::Callng::Actions::Call.new(message).call_with_message
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ruboty/callng/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ruboty-callng"
8
+ spec.version = Ruboty::Callng::VERSION
9
+ spec.authors = ["block_given?", "Ryota Arai"]
10
+ spec.email = ["block_given@outlook.com", "ryota.arai@gmail.com"]
11
+ spec.summary = %q{ruboty plugin for make a call to you.}
12
+ spec.homepage = "https://github.com/ryotarai/ruboty-callng"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency "ruboty"
21
+ spec.add_runtime_dependency "twilio-ruby"
22
+ spec.add_development_dependency "bundler", "~> 1.7"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ end
data/screenshot.png ADDED
Binary file
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruboty-callng
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - block_given?
8
+ - Ryota Arai
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-06-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: ruboty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: twilio-ruby
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.7'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.7'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '10.0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '10.0'
70
+ description:
71
+ email:
72
+ - block_given@outlook.com
73
+ - ryota.arai@gmail.com
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - lib/ruboty/callng.rb
84
+ - lib/ruboty/callng/actions/call.rb
85
+ - lib/ruboty/callng/version.rb
86
+ - lib/ruboty/handlers/callng.rb
87
+ - ruboty-callng.gemspec
88
+ - screenshot.png
89
+ homepage: https://github.com/ryotarai/ruboty-callng
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.5.1
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: ruboty plugin for make a call to you.
113
+ test_files: []