ruboty-slack_rtm-emoji_changed 0.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
+ SHA256:
3
+ metadata.gz: b843e8d2024c71784294e972d9623a710de28d258266b4192b669d0c45404f7e
4
+ data.tar.gz: f30af18696436429edf3809b6315a481133f770c4f221eff138746738eb908fe
5
+ SHA512:
6
+ metadata.gz: d423cb58f2d9244ec6186bfa38f154922473ee18cd070660384aa882b460aae65a98823407e081d4f06f73f50f4ca927bd60e8176d6e858a0f88bf55c3a64b2f
7
+ data.tar.gz: a66a65888c3bee06e71b4c758d7677541a70d6ac92f4fff3634cf729271323510958fb3e97cbba34a1c16675a742654306168273ed0fc0de4952b58d09bb47c6
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ruboty-slack_rtm-emoji_changed.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Kazuhiro NISHIYAMA
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Ruboty::SlackRTM::EmojiChanged
2
+
3
+ Notify when [emoji_changed](https://api.slack.com/events/emoji_changed) with [ruboty-slack_rtm](https://rubygems.org/gems/ruboty-slack_rtm).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ruboty-slack_rtm-emoji_changed'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ruboty-slack_rtm-emoji_changed
20
+
21
+ ## Usage
22
+
23
+ - Create `#emoji` or set `SLACK_EMOJI_CHANGED_CHANNEL=#emoji_channel` to env.
24
+
25
+ - Add emoji
26
+ - Add alias of emoji
27
+ - Remove emojis
28
+
29
+ ### Do not notify when removed
30
+
31
+ - Set `SLACK_EMOJI_IGNORE_REMOVED=1` to env.
32
+
33
+ If you want to be compatible with [emoy_webhook](https://github.com/sue445/emoy_webhook).
34
+
35
+ ## Development
36
+
37
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
38
+
39
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/znz/ruboty-slack_rtm-emoji_changed.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ruboty/slack_rtm/emoji_changed"
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ruboty
4
+ module SlackRTM
5
+ module EmojiChanged
6
+ CHANNEL = ENV['SLACK_EMOJI_CHANGED_CHANNEL'] || '#emoji'
7
+ IGNORE_REMOVED = ENV['SLACK_EMOJI_IGNORE_REMOVED']
8
+
9
+ def on_emoji_changed(data)
10
+ case data['subtype']
11
+ when 'add'
12
+ color = 'good'
13
+ emoji_name = data['name']
14
+ message = +"A new emoji is added :#{emoji_name}: `:#{emoji_name}:`"
15
+ value = data['value']
16
+ if value.start_with?('alias:')
17
+ origin_emoji = value.sub(/\Aalias:/, '')
18
+ message << " (alias of `:#{origin_emoji}:`)"
19
+ end
20
+ when 'remove'
21
+ return if IGNORE_REMOVED
22
+ color = 'danger'
23
+ message = +"Removed emoji: #{data['names'].join(', ')}"
24
+ end
25
+ if message
26
+ attachments = [
27
+ {
28
+ fallback: message,
29
+ text: message,
30
+ color: color,
31
+ },
32
+ ]
33
+ channel = CHANNEL
34
+ channel = resolve_channel_id(channel[1..-1]) if channel.start_with?('#')
35
+ client.chat_postMessage(
36
+ username: robot.name,
37
+ channel: channel,
38
+ attachments: attachments.to_json,
39
+ )
40
+ end
41
+ end
42
+ end
43
+
44
+ if ::Ruboty::Adapters.const_defined?(:SlackRTM)
45
+ ::Ruboty::Adapters::SlackRTM.include EmojiChanged
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,7 @@
1
+ module Ruboty
2
+ module SlackRTM
3
+ module EmojiChanged
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+ require_relative 'lib/ruboty/slack_rtm/emoji_changed/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "ruboty-slack_rtm-emoji_changed"
5
+ spec.version = Ruboty::SlackRTM::EmojiChanged::VERSION
6
+ spec.authors = ["Kazuhiro NISHIYAMA"]
7
+ spec.email = ["zn@mbf.nifty.com"]
8
+
9
+ spec.summary = %q{notify when emoji_changed with ruboty-slack_rtm}
10
+ spec.description = %q{notify when emoji_changed with ruboty-slack_rtm}
11
+ spec.homepage = "https://github.com/znz/ruboty-slack_rtm-emoji_changed"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+ spec.metadata["source_code_uri"] = "https://github.com/znz/ruboty-slack_rtm-emoji_changed"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruboty-slack_rtm-emoji_changed
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kazuhiro NISHIYAMA
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-05-22 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: notify when emoji_changed with ruboty-slack_rtm
14
+ email:
15
+ - zn@mbf.nifty.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - Gemfile
22
+ - LICENSE
23
+ - README.md
24
+ - Rakefile
25
+ - bin/console
26
+ - bin/setup
27
+ - lib/ruboty/slack_rtm/emoji_changed.rb
28
+ - lib/ruboty/slack_rtm/emoji_changed/version.rb
29
+ - ruboty-slack_rtm-emoji_changed.gemspec
30
+ homepage: https://github.com/znz/ruboty-slack_rtm-emoji_changed
31
+ licenses: []
32
+ metadata:
33
+ homepage_uri: https://github.com/znz/ruboty-slack_rtm-emoji_changed
34
+ source_code_uri: https://github.com/znz/ruboty-slack_rtm-emoji_changed
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 2.3.0
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubygems_version: 3.1.2
51
+ signing_key:
52
+ specification_version: 4
53
+ summary: notify when emoji_changed with ruboty-slack_rtm
54
+ test_files: []