slack-big-emoji 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/slack_big_emoji.rb +4 -4
- data/lib/slack_big_emoji/uploader.rb +29 -10
- data/lib/slack_big_emoji/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 38855d83a1df5924df61d4921d9a899dc0727b420aa89d016e7b4ab816666aa6
|
4
|
+
data.tar.gz: 8fee74c779c257dba1096656c8998cbd268b2b9b80e410a60ca4d51ec84daec1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b154c46ecdcc8ccf01bb150e3e4cc1862ef07e008f4ecb4751c6c18a8dd93aac4c2dd08f4c1914996cb4046041070e342b237a5610c4387a7de858de8a140729
|
7
|
+
data.tar.gz: cbf84d4d743fa140ef6343d2730f59a696000b803a53800483edbc347a965b4693d1a7c2884022707009c7779bff8c4ea8af004e2c38da864dd6240f11141d2a
|
data/lib/slack_big_emoji.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module SlackBigEmoji
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
require_relative 'slack_big_emoji/version'
|
3
|
+
require_relative 'slack_big_emoji/cli'
|
4
|
+
require_relative 'slack_big_emoji/converter'
|
5
|
+
require_relative 'slack_big_emoji/uploader'
|
6
6
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'highline/import'
|
2
2
|
require 'mechanize'
|
3
|
+
require 'logger'
|
3
4
|
|
4
|
-
# Grabbed from https://github.com/
|
5
|
+
# Grabbed from https://github.com/decomoji/slack-reaction-decomoji/blob/fd1f9b6a12b95ee27b9ad4173560db9ae3015ea0/scripts/import.rb
|
5
6
|
module SlackBigEmoji
|
6
7
|
class Uploader
|
7
8
|
BASE_DIR = File.expand_path(File.dirname(__FILE__))
|
@@ -11,7 +12,7 @@ module SlackBigEmoji
|
|
11
12
|
@page = nil
|
12
13
|
@agent = Mechanize.new
|
13
14
|
end
|
14
|
-
attr_accessor :page, :agent
|
15
|
+
attr_accessor :page, :agent, :team_name, :token
|
15
16
|
|
16
17
|
def upload_emojis
|
17
18
|
move_to_emoji_page
|
@@ -21,21 +22,23 @@ module SlackBigEmoji
|
|
21
22
|
private
|
22
23
|
|
23
24
|
def login
|
24
|
-
team_name
|
25
|
+
@team_name = ask('Your slack team name(subdomain): ')
|
25
26
|
email = ask('Login email: ')
|
26
|
-
password = ask('Login password
|
27
|
+
password = ask('Login password(hidden): ') { |q| q.echo = false }
|
27
28
|
|
28
|
-
emoji_page_url = "https://#{team_name}.slack.com/
|
29
|
+
emoji_page_url = "https://#{team_name}.slack.com/customize/emoji"
|
29
30
|
|
30
31
|
page = agent.get(emoji_page_url)
|
31
32
|
page.form.email = email
|
32
33
|
page.form.password = password
|
33
34
|
@page = page.form.submit
|
35
|
+
@token = @page.body[/(?<=api_token":")[^"]+/]
|
34
36
|
end
|
35
37
|
|
36
38
|
def enter_two_factor_authentication_code
|
37
39
|
page.form['2fa_code'] = ask('Your two factor authentication code: ')
|
38
40
|
@page = page.form.submit
|
41
|
+
@token = @page.body[/(?<=api_token":")[^"]+/]
|
39
42
|
end
|
40
43
|
|
41
44
|
def move_to_emoji_page
|
@@ -53,19 +56,35 @@ module SlackBigEmoji
|
|
53
56
|
end
|
54
57
|
|
55
58
|
def push_emojis
|
59
|
+
emojis = list_emojis
|
56
60
|
Dir.glob("#{@dir}/*.png").sort.each do |path|
|
57
61
|
basename = File.basename(path, '.*')
|
58
62
|
|
59
63
|
# skip if already exists
|
60
|
-
next if
|
64
|
+
next if emojis.include?(basename)
|
61
65
|
|
62
66
|
puts "importing #{basename}..."
|
63
67
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
+
params = {
|
69
|
+
name: basename,
|
70
|
+
image: File.new(path),
|
71
|
+
mode: 'data',
|
72
|
+
token: token
|
73
|
+
}
|
74
|
+
agent.post("https://#{@team_name}.slack.com/api/emoji.add", params)
|
68
75
|
end
|
69
76
|
end
|
77
|
+
|
78
|
+
def list_emojis
|
79
|
+
emojis = []
|
80
|
+
loop.with_index(1) do |_, n|
|
81
|
+
params = { query: '', page: n, count: 100, token: token }
|
82
|
+
res = JSON.parse(agent.post("https://#{team_name}.slack.com/api/emoji.adminList", params).body)
|
83
|
+
raise res['error'] if res['error']
|
84
|
+
emojis.push(*res['emoji'].map { |e| e['name'] })
|
85
|
+
break if res['paging']['pages'] == n || res['paging']['pages'] == 0
|
86
|
+
end
|
87
|
+
emojis
|
88
|
+
end
|
70
89
|
end
|
71
90
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack-big-emoji
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kinduff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mechanize
|
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
142
|
version: '0'
|
143
143
|
requirements: []
|
144
144
|
rubyforge_project:
|
145
|
-
rubygems_version: 2.
|
145
|
+
rubygems_version: 2.7.7
|
146
146
|
signing_key:
|
147
147
|
specification_version: 4
|
148
148
|
summary: Command-line tool to create big emojis for Slack.
|