ruboty-reinvite 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/README.md +52 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/ruboty/handlers/reinvite.rb +13 -0
- data/lib/ruboty/reinvite.rb +8 -0
- data/lib/ruboty/reinvite/actions/reinvite.rb +51 -0
- data/lib/ruboty/reinvite/version.rb +5 -0
- data/ruboty-reinvite.gemspec +26 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e34cb385f84173b1a5eb87006d09bfb87b181423
|
4
|
+
data.tar.gz: 63acac24231052a5b184a1e83e5202bf0a90e602
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2de87cfdb0a7bf84196540a8ba287246a5ea66c16c624367194759b6c14f55b9b842432ca904176d95cc2d6d40b9f9ab54946532c1054dd9b90f6bb604976f15
|
7
|
+
data.tar.gz: 2bd1622da2054d46a5480824c405ee8604a3f985a7e8c82175d35af0d52ede86ed5ed715994a4dad32977e0539b9d099666ece495c511d320ac870bcf55ea384
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Ruboty::Reinvite
|
2
|
+
|
3
|
+
An Ruboty Handler + Actions to kick and invite bot to Slack Channel.
|
4
|
+
|
5
|
+
[Ruboty](https://github.com/r7kamura/ruboty) is Chat bot framework. Ruby + Bot = Ruboty
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'ruboty-reinvite'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
## Commands
|
20
|
+
|
21
|
+
|Command|Pattern|Description|
|
22
|
+
|:--|:--|:--|
|
23
|
+
|[reivite](#reivite)|reinvite #<?channel>(.+)|kick and invite bot|
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
### reivite
|
27
|
+
* kick and invite bot
|
28
|
+
|
29
|
+
~~~
|
30
|
+
reinvite #times_tb
|
31
|
+
~~~
|
32
|
+
|
33
|
+
## ENV
|
34
|
+
|
35
|
+
|Name|Description|
|
36
|
+
|:--|:--|
|
37
|
+
|SLACK_API_TOKEN|SlackAPI Token|
|
38
|
+
|
39
|
+
## Dependency
|
40
|
+
|
41
|
+
|Name|Description|
|
42
|
+
|:--|:--|
|
43
|
+
|Slack API|https://api.slack.com/|
|
44
|
+
|Slack API Ruby Client|https://github.com/aki017/slack-ruby-gem|
|
45
|
+
|
46
|
+
## Contributing
|
47
|
+
|
48
|
+
1. Fork it ( https://github.com/tbpgr/ruboty-reinvite/fork )
|
49
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
50
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
51
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
52
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ruboty/reinvite"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "ruboty/reinvite/actions/reinvite"
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module Handlers
|
5
|
+
class Reinvite < Base
|
6
|
+
on /reinvite #(?<channel>.+)/, name: 'reinvite', description: 'reinvite bot'
|
7
|
+
|
8
|
+
def reinvite(message)
|
9
|
+
Ruboty::Reinvite::Actions::Reinvite.new(message).call
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "slack"
|
2
|
+
module Ruboty
|
3
|
+
module Reinvite
|
4
|
+
module Actions
|
5
|
+
class Reinvite < Ruboty::Actions::Base
|
6
|
+
def call
|
7
|
+
message.reply(reinvite)
|
8
|
+
rescue => e
|
9
|
+
message.reply("Error #{e.message}")
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
def reinvite
|
14
|
+
::Slack.configure { |config|config.token = ENV["SLACK_API_TOKEN"] }
|
15
|
+
channel = message[:channel]
|
16
|
+
option = { user: user_id, channel: channel_id(channel) }
|
17
|
+
kick(option)
|
18
|
+
invite(option)
|
19
|
+
":robot_face: success reinvite to #{channel}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def user_id
|
23
|
+
response = ::Slack.users_list
|
24
|
+
validate_response(response)
|
25
|
+
response["members"].find{ |e|e["name"] == ENV["SLACK_USERNAME"] }["id"]
|
26
|
+
end
|
27
|
+
|
28
|
+
def channel_id(channel)
|
29
|
+
response = ::Slack.channels_list
|
30
|
+
validate_response(response)
|
31
|
+
response["channels"].find{ |e|e["name"] == channel }["id"]
|
32
|
+
end
|
33
|
+
|
34
|
+
def kick(option)
|
35
|
+
response = ::Slack.channels_kick(option)
|
36
|
+
validate_response(response)
|
37
|
+
end
|
38
|
+
|
39
|
+
def invite(option)
|
40
|
+
response = ::Slack.channels_invite(option)
|
41
|
+
validate_response(response)
|
42
|
+
end
|
43
|
+
|
44
|
+
def validate_response(response)
|
45
|
+
return if response["ok"]
|
46
|
+
fail response["error"]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ruboty/reinvite/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ruboty-reinvite"
|
8
|
+
spec.version = Ruboty::Reinvite::VERSION
|
9
|
+
spec.authors = ["tbpgr"]
|
10
|
+
spec.email = ["tbpgr@tbpgr.jp"]
|
11
|
+
spec.summary = %q{An Ruboty Handler + Actions to kick and invite bot to Slack Channel.}
|
12
|
+
spec.description = %q{An Ruboty Handler + Actions to kick and invite bot to Slack Channel.}
|
13
|
+
spec.homepage = "https://github.com/tbpgr/ruboty-reinvite"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "ruboty"
|
22
|
+
spec.add_runtime_dependency "slack-api"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruboty-reinvite
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- tbpgr
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruboty
|
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: slack-api
|
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.11'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.11'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description: An Ruboty Handler + Actions to kick and invite bot to Slack Channel.
|
70
|
+
email:
|
71
|
+
- tbpgr@tbpgr.jp
|
72
|
+
executables:
|
73
|
+
- console
|
74
|
+
- setup
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- .gitignore
|
79
|
+
- Gemfile
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/console
|
83
|
+
- bin/setup
|
84
|
+
- lib/ruboty/handlers/reinvite.rb
|
85
|
+
- lib/ruboty/reinvite.rb
|
86
|
+
- lib/ruboty/reinvite/actions/reinvite.rb
|
87
|
+
- lib/ruboty/reinvite/version.rb
|
88
|
+
- ruboty-reinvite.gemspec
|
89
|
+
homepage: https://github.com/tbpgr/ruboty-reinvite
|
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.3.0
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: An Ruboty Handler + Actions to kick and invite bot to Slack Channel.
|
113
|
+
test_files: []
|
114
|
+
has_rdoc:
|