fastlane-plugin-telegram 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +9 -1
- data/lib/fastlane/plugin/telegram/actions/telegram_action.rb +45 -9
- data/lib/fastlane/plugin/telegram/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bb613367ee2f52519dc686ca4c66f57e189fbf4e8ef54a0c8e390a2ca5f0497e
|
4
|
+
data.tar.gz: 82a2575785148b0121fad4771d4c5e657785d989e11693c7f15beec645763a24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b2140477102429355ed74136f6b30ba36d322d26cddf84fe6446bff4ee5cfdef01b7d15331b9a9c7a1cc9efef333746206909bdd6bcacd709478860e6f56876
|
7
|
+
data.tar.gz: 4759b35b45811ee791b9bff66df6f33c81dee32ccf220af5eddc0e5ce1fee7e9ca58ed568ddb87cac5db5531ab89b3509e3c47651d47a5c3cf99cac27681db8d
|
data/README.md
CHANGED
@@ -14,7 +14,15 @@ fastlane add_plugin telegram
|
|
14
14
|
|
15
15
|
Allows post messages to telegram channel
|
16
16
|
|
17
|
-
|
17
|
+
```ruby
|
18
|
+
telegram(
|
19
|
+
token: ENV['TG_BOT_TOKEN'], # get token from @BotFather
|
20
|
+
chat_id: ENV['TG_CHAT_ID'], # https://stackoverflow.com/questions/33858927/how-to-obtain-the-chat-id-of-a-private-telegram-channel
|
21
|
+
text: "Hello world, Telegram!", # Required
|
22
|
+
file: "file.pdf", # Optional. Please note, Bots can currently send files of any type of up to 50 MB in size.
|
23
|
+
mime_type: "application/pdf" # Required if file exist
|
24
|
+
)
|
25
|
+
```
|
18
26
|
|
19
27
|
## Example
|
20
28
|
|
@@ -8,19 +8,45 @@ module Fastlane
|
|
8
8
|
chat_id = params[:chat_id]
|
9
9
|
text = params[:text]
|
10
10
|
parse_mode = params[:parse_mode]
|
11
|
+
file_path = params[:file]
|
12
|
+
mime_type = params[:mime_type]
|
11
13
|
|
12
|
-
|
14
|
+
file = nil
|
15
|
+
if file_path != nil
|
16
|
+
if File.exist?(file_path)
|
17
|
+
if mime_type == nil
|
18
|
+
UI.user_error!("The mime type, required for send file")
|
19
|
+
end
|
20
|
+
|
21
|
+
file = UploadIO.new(file_path, mime_type)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
if file_path != nil && file == nil
|
26
|
+
UI.message("Can't find file on path location")
|
27
|
+
end
|
28
|
+
|
29
|
+
method = (file == nil ? "sendMessage" : "sendDocument")
|
30
|
+
uri = URI.parse("https://api.telegram.org/bot#{token}/#{method}")
|
13
31
|
|
14
|
-
|
32
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
33
|
+
if params[:proxy]
|
15
34
|
proxy_uri = URI.parse(params[:proxy])
|
16
|
-
http = Net::HTTP.new(uri.host, uri.port, proxy_uri.host, proxy_uri.port)
|
17
|
-
http.use_ssl = true
|
18
|
-
request = Net::HTTP::Post.new(uri.request_uri)
|
19
|
-
request.set_form_data({"chat_id" => chat_id, "text" => text, "parse_mode" => parse_mode})
|
20
|
-
response = http.request(request)
|
21
|
-
else
|
22
|
-
response = Net::HTTP.post_form(uri, {:chat_id => chat_id, :text => text, :parse_mode => parse_mode})
|
35
|
+
http = Net::HTTP.new(uri.host, uri.port, proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password)
|
23
36
|
end
|
37
|
+
http.use_ssl = true
|
38
|
+
|
39
|
+
require 'net/http/post/multipart'
|
40
|
+
text_parameter = (file == nil ? "text" : "caption")
|
41
|
+
request = Net::HTTP::Post::Multipart.new(uri,
|
42
|
+
{
|
43
|
+
"chat_id" => chat_id,
|
44
|
+
text_parameter => text,
|
45
|
+
"parse_mode" => parse_mode,
|
46
|
+
"document" => file
|
47
|
+
})
|
48
|
+
|
49
|
+
response = http.request(request)
|
24
50
|
end
|
25
51
|
|
26
52
|
def self.description
|
@@ -56,6 +82,16 @@ module Fastlane
|
|
56
82
|
description: "Text of the message to be sent",
|
57
83
|
optional: false,
|
58
84
|
type: String),
|
85
|
+
FastlaneCore::ConfigItem.new(key: :file,
|
86
|
+
env_name: "TELEGRAM_FILE",
|
87
|
+
description: "File path to the file to be sent",
|
88
|
+
optional: true,
|
89
|
+
type: String),
|
90
|
+
FastlaneCore::ConfigItem.new(key: :mime_type,
|
91
|
+
env_name: "TELEGRAM_FILE_MIME_TYPE",
|
92
|
+
description: "Mime type of file to be sent",
|
93
|
+
optional: true,
|
94
|
+
type: String),
|
59
95
|
FastlaneCore::ConfigItem.new(key: :parse_mode,
|
60
96
|
env_name: "TELEGRAM_PARSE_MODE",
|
61
97
|
description: "Param (Markdown / HTML) for using markdown or HTML support in message",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-telegram
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sergpetrov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -139,8 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: '0'
|
141
141
|
requirements: []
|
142
|
-
|
143
|
-
rubygems_version: 2.5.2.3
|
142
|
+
rubygems_version: 3.0.3
|
144
143
|
signing_key:
|
145
144
|
specification_version: 4
|
146
145
|
summary: Allows post messages to telegram channel
|