brutalismbot 1.7.1 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/brutalismbot/reddit/post.rb +13 -10
- data/lib/brutalismbot/slack/auth.rb +0 -16
- data/lib/brutalismbot/slack/client.rb +10 -5
- data/lib/brutalismbot/twitter/client.rb +9 -16
- data/lib/brutalismbot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc9aa96ddf426ba53cd94234a85ab6b3b11237dcdfb8414ca522f983a58c807c
|
4
|
+
data.tar.gz: 87ccc44e65a2565e31a3e60c399ab2d6725f6594a12da582c273e9b95292020d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8160fd997677a8ab632be035009b1cea925c4791cc45109c9cba086eda92408b4d931394efa92a1b438357a9784206b2479ccf191397dd66f0beeb809af7d6f
|
7
|
+
data.tar.gz: bba9c3dda2a30a14209d74599a4bcd01e0cce55caa138970135fd001a0a9db79272c8acdb4d0bef6dce89970ac0cda8bbfca181d7d4febb0bcb8103e581e96f0
|
@@ -108,6 +108,19 @@ module Brutalismbot
|
|
108
108
|
is_self? ? to_slack_text : to_slack_image
|
109
109
|
end
|
110
110
|
|
111
|
+
def to_twitter
|
112
|
+
max = 280 - permalink.length - 1
|
113
|
+
status = title.length <= max ? title : "#{title[0...max - 1]}…"
|
114
|
+
status << "\n#{permalink}"
|
115
|
+
{status: status, media_url: is_self? ? nil : media_url}
|
116
|
+
end
|
117
|
+
|
118
|
+
def url
|
119
|
+
data["url"]
|
120
|
+
end
|
121
|
+
|
122
|
+
private
|
123
|
+
|
111
124
|
def to_slack_image
|
112
125
|
{
|
113
126
|
blocks: [
|
@@ -152,16 +165,6 @@ module Brutalismbot
|
|
152
165
|
],
|
153
166
|
}
|
154
167
|
end
|
155
|
-
|
156
|
-
def to_twitter
|
157
|
-
max = 280 - permalink.length - 1
|
158
|
-
text = title.length <= max ? title : "#{title[0...max - 1]}…"
|
159
|
-
[text, permalink].join("\n")
|
160
|
-
end
|
161
|
-
|
162
|
-
def url
|
163
|
-
data["url"]
|
164
|
-
end
|
165
168
|
end
|
166
169
|
end
|
167
170
|
end
|
@@ -20,22 +20,6 @@ module Brutalismbot
|
|
20
20
|
File.join("team=#{team_id}", "channel=#{channel_id}", "oauth.json")
|
21
21
|
end
|
22
22
|
|
23
|
-
def push(post, dryrun:nil)
|
24
|
-
body = post.to_slack.to_json
|
25
|
-
uri = URI.parse(webhook_url)
|
26
|
-
Brutalismbot.logger.info("POST #{"DRYRUN " if dryrun}#{uri}")
|
27
|
-
unless dryrun
|
28
|
-
ssl = uri.scheme == "https"
|
29
|
-
req = Net::HTTP::Post.new(uri, "content-type" => "application/json")
|
30
|
-
req.body = body
|
31
|
-
Net::HTTP.start(uri.host, uri.port, use_ssl: ssl) do |http|
|
32
|
-
http.request(req)
|
33
|
-
end
|
34
|
-
else
|
35
|
-
Net::HTTPOK.new("1.1", "204", "ok")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
23
|
def team_id
|
40
24
|
@item.dig("team_id")
|
41
25
|
end
|
@@ -37,11 +37,16 @@ module Brutalismbot
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
def push(
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
def push(body:, webhook_url:, dryrun:nil)
|
41
|
+
Brutalismbot.logger.info("POST #{"DRYRUN " if dryrun}#{webhook_url}")
|
42
|
+
unless dryrun
|
43
|
+
uri = URI.parse(webhook_url)
|
44
|
+
ssl = uri.scheme == "https"
|
45
|
+
req = Net::HTTP::Post.new(uri, "content-type" => "application/json")
|
46
|
+
req.body = body.to_json
|
47
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: ssl) {|http| http.request(req) }
|
48
|
+
else
|
49
|
+
Net::HTTPOK.new("1.1", "204", "ok")
|
45
50
|
end
|
46
51
|
end
|
47
52
|
|
@@ -19,22 +19,15 @@ module Brutalismbot
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def push(
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
def push_image(post, dryrun:nil)
|
33
|
-
Brutalismbot.logger.info("GET #{post.media_uri}")
|
34
|
-
Brutalismbot.logger.info("PUSH #{"DRYRUN " if dryrun}twitter://@brutalismbot")
|
35
|
-
post.media_uri.open do |media|
|
36
|
-
@client.update_with_media(post.to_twitter, media)
|
37
|
-
end unless dryrun
|
22
|
+
def push(status:, media_url:nil, dryrun:nil)
|
23
|
+
if media_url.nil?
|
24
|
+
Brutalismbot.logger.info("PUSH #{"DRYRUN " if dryrun}twitter://@brutalismbot")
|
25
|
+
@client.update(status) unless dryrun
|
26
|
+
else
|
27
|
+
Brutalismbot.logger.info("GET #{media_url}")
|
28
|
+
Brutalismbot.logger.info("PUSH #{"DRYRUN " if dryrun}twitter://@brutalismbot")
|
29
|
+
URI.open(media_url) {|media| @client.update_with_media(status, media) } unless dryrun
|
30
|
+
end
|
38
31
|
end
|
39
32
|
end
|
40
33
|
end
|
data/lib/brutalismbot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brutalismbot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Mancevice
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: twitter
|