pindo 5.10.9 → 5.11.2
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 +4 -4
- data/lib/pindo/command/android/autobuild.rb +38 -22
- data/lib/pindo/command/android/autoresign.rb +332 -0
- data/lib/pindo/command/android/build.rb +19 -12
- data/lib/pindo/command/android/{debug.rb → keystore.rb} +20 -25
- data/lib/pindo/command/android.rb +4 -3
- data/lib/pindo/command/{ipa/output.rb → appstore/adhocbuild.rb} +17 -17
- data/lib/pindo/command/{ipa → appstore}/autoresign.rb +11 -11
- data/lib/pindo/command/appstore/iap.rb +8 -8
- data/lib/pindo/command/{ipa → appstore}/import.rb +18 -18
- data/lib/pindo/command/appstore/itcapp.rb +8 -8
- data/lib/pindo/command/appstore/metadata.rb +8 -8
- data/lib/pindo/command/appstore/screenshots.rb +8 -8
- data/lib/pindo/command/appstore/upload.rb +8 -8
- data/lib/pindo/command/appstore.rb +6 -2
- data/lib/pindo/command/deploy/bundleid.rb +8 -8
- data/lib/pindo/command/deploy/cert.rb +10 -10
- data/lib/pindo/command/deploy/check.rb +8 -8
- data/lib/pindo/command/deploy.rb +1 -3
- data/lib/pindo/command/env/dreamstudio.rb +14 -12
- data/lib/pindo/command/env/quarkenv.rb +13 -11
- data/lib/pindo/command/env/swarkenv.rb +13 -11
- data/lib/pindo/command/env/workhard.rb +14 -12
- data/lib/pindo/command/env.rb +1 -1
- data/lib/pindo/command/gplay.rb +1 -1
- data/lib/pindo/command/ios/autobuild.rb +23 -15
- data/lib/pindo/command/ios/autoresign.rb +16 -16
- data/lib/pindo/command/ios/build.rb +12 -10
- data/lib/pindo/command/ios/{debug.rb → cert.rb} +26 -27
- data/lib/pindo/command/{lib/lint.rb → ios/podlint.rb} +6 -6
- data/lib/pindo/command/{lib/forcepush.rb → ios/podpush.rb} +123 -23
- data/lib/pindo/command/{lib/update.rb → ios/podupdate.rb} +5 -5
- data/lib/pindo/command/ios.rb +6 -2
- data/lib/pindo/command/jps/upload.rb +1 -1
- data/lib/pindo/command/jps.rb +1 -1
- data/lib/pindo/command/repo.rb +1 -1
- data/lib/pindo/command/unity/apk.rb +33 -22
- data/lib/pindo/command/unity/autobuild.rb +15 -21
- data/lib/pindo/command/unity/ipa.rb +28 -18
- data/lib/pindo/command/unity/{pack.rb → packbuild.rb} +17 -10
- data/lib/pindo/command/unity/{initpack.rb → packinit.rb} +10 -16
- data/lib/pindo/command/unity/{upload.rb → packpush.rb} +13 -19
- data/lib/pindo/command/unity/web.rb +26 -14
- data/lib/pindo/command/unity.rb +4 -4
- data/lib/pindo/command/{dev → utils}/feishu.rb +14 -14
- data/lib/pindo/command/{dev → utils}/repoinit.rb +8 -8
- data/lib/pindo/command/{dev → utils}/tag.rb +19 -19
- data/lib/pindo/command/utils.rb +9 -6
- data/lib/pindo/command/web/autobuild.rb +8 -2
- data/lib/pindo/command/web.rb +1 -1
- data/lib/pindo/command.rb +1 -4
- data/lib/pindo/module/android/android_build_config_helper.rb +83 -10
- data/lib/pindo/module/android/android_res_helper.rb +50 -0
- data/lib/pindo/version.rb +1 -1
- metadata +16 -22
- data/lib/pindo/command/dev.rb +0 -21
- data/lib/pindo/command/feishu/send_message.rb +0 -103
- data/lib/pindo/command/feishu.rb +0 -50
- data/lib/pindo/command/ios/adhoc.rb +0 -245
- data/lib/pindo/command/ipa.rb +0 -16
- data/lib/pindo/command/lib/push.rb +0 -157
- data/lib/pindo/command/lib.rb +0 -16
data/lib/pindo/command.rb
CHANGED
|
@@ -38,14 +38,11 @@ module Pindo
|
|
|
38
38
|
require 'pindo/module/appstore/appstore_metadata_connect_api_helper'
|
|
39
39
|
|
|
40
40
|
require 'pindo/command/deploy'
|
|
41
|
-
require 'pindo/command/dev'
|
|
42
41
|
require 'pindo/command/env'
|
|
43
|
-
require 'pindo/command/lib'
|
|
44
42
|
require 'pindo/command/utils'
|
|
45
43
|
require 'pindo/command/jps'
|
|
46
44
|
require 'pindo/command/setup'
|
|
47
|
-
require 'pindo/command/repo'
|
|
48
|
-
require 'pindo/command/ipa'
|
|
45
|
+
# require 'pindo/command/repo'
|
|
49
46
|
require 'pindo/command/appstore'
|
|
50
47
|
require 'pindo/command/gplay'
|
|
51
48
|
require 'pindo/command/unity'
|
|
@@ -23,7 +23,7 @@ module Pindo
|
|
|
23
23
|
app_id_suffix = workflow_packname.gsub(/[^a-zA-Z0-9]/, '').downcase
|
|
24
24
|
application_id = "com.heroneverdie101.#{app_id_suffix}"
|
|
25
25
|
package_scheme = workflow_packname.gsub(/[^a-zA-Z0-9]/, '').downcase
|
|
26
|
-
bundle_scheme
|
|
26
|
+
# bundle_scheme 现在在 update_application_id 中处理
|
|
27
27
|
|
|
28
28
|
# 1. 更新 App Name
|
|
29
29
|
success_app_name = update_app_name_with_packagename(
|
|
@@ -46,16 +46,10 @@ module Pindo
|
|
|
46
46
|
puts " ✓ 已添加Scheme: #{package_scheme} (基于 Package Name)"
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
#
|
|
50
|
-
|
|
51
|
-
project_dir: project_dir,
|
|
52
|
-
scheme_name: bundle_scheme
|
|
53
|
-
)
|
|
54
|
-
if success_bundle_scheme
|
|
55
|
-
puts " ✓ 已添加Scheme: #{bundle_scheme} (基于 Application ID)"
|
|
56
|
-
end
|
|
49
|
+
# 注意:基于 Application ID 的 Scheme 将在 update_application_id 方法中添加
|
|
50
|
+
# 因为 Application ID 可能在后续流程中被覆盖
|
|
57
51
|
|
|
58
|
-
return success_app_name && success_app_id && success_package_scheme
|
|
52
|
+
return success_app_name && success_app_id && success_package_scheme
|
|
59
53
|
end
|
|
60
54
|
|
|
61
55
|
# 更新Android工程版本号
|
|
@@ -539,6 +533,85 @@ module Pindo
|
|
|
539
533
|
end
|
|
540
534
|
end
|
|
541
535
|
|
|
536
|
+
# 添加基于 Application ID 的 Scheme
|
|
537
|
+
# 读取当前项目的 Application ID 并添加对应的 Scheme
|
|
538
|
+
# @param project_dir [String] Android项目目录路径
|
|
539
|
+
# @return [Boolean] 是否成功添加
|
|
540
|
+
def self.add_application_id_based_scheme(project_dir: nil)
|
|
541
|
+
# 参数验证
|
|
542
|
+
if project_dir.nil? || !File.directory?(project_dir)
|
|
543
|
+
Funlog.instance.fancyinfo_error("项目路径无效: #{project_dir}")
|
|
544
|
+
return false
|
|
545
|
+
end
|
|
546
|
+
|
|
547
|
+
begin
|
|
548
|
+
# 获取主模块
|
|
549
|
+
main_module = Pindo::AndroidProjectHelper.get_main_module(project_dir)
|
|
550
|
+
|
|
551
|
+
# 支持多种项目结构
|
|
552
|
+
module_paths = []
|
|
553
|
+
module_paths << File.join(project_dir, main_module) if main_module
|
|
554
|
+
module_paths << File.join(project_dir, "app")
|
|
555
|
+
module_paths << File.join(project_dir, "unityLibrary/launcher")
|
|
556
|
+
module_paths << File.join(project_dir, "launcher")
|
|
557
|
+
|
|
558
|
+
gradle_file = nil
|
|
559
|
+
module_paths.each do |module_path|
|
|
560
|
+
next unless File.exist?(module_path)
|
|
561
|
+
|
|
562
|
+
if File.exist?(File.join(module_path, "build.gradle"))
|
|
563
|
+
gradle_file = File.join(module_path, "build.gradle")
|
|
564
|
+
break
|
|
565
|
+
elsif File.exist?(File.join(module_path, "build.gradle.kts"))
|
|
566
|
+
gradle_file = File.join(module_path, "build.gradle.kts")
|
|
567
|
+
break
|
|
568
|
+
end
|
|
569
|
+
end
|
|
570
|
+
|
|
571
|
+
if gradle_file.nil?
|
|
572
|
+
Funlog.instance.fancyinfo_error("未找到build.gradle文件,无法读取 Application ID")
|
|
573
|
+
return false
|
|
574
|
+
end
|
|
575
|
+
|
|
576
|
+
# 读取gradle文件,提取当前的 Application ID
|
|
577
|
+
content = File.read(gradle_file)
|
|
578
|
+
application_id = nil
|
|
579
|
+
|
|
580
|
+
# 匹配各种 applicationId 格式
|
|
581
|
+
if content =~ /applicationId\s+["']([^"']+)["']/
|
|
582
|
+
application_id = $1
|
|
583
|
+
elsif content =~ /applicationId\s*=\s*["']([^"']+)["']/
|
|
584
|
+
application_id = $1
|
|
585
|
+
end
|
|
586
|
+
|
|
587
|
+
if application_id.nil?
|
|
588
|
+
Funlog.instance.fancyinfo_error("无法从 gradle 文件中读取 Application ID")
|
|
589
|
+
return false
|
|
590
|
+
end
|
|
591
|
+
|
|
592
|
+
# 将 Application ID 转换为合法的 scheme 名称(只保留字母和数字)
|
|
593
|
+
bundle_scheme = application_id.gsub(/[^a-zA-Z0-9]/, '').downcase
|
|
594
|
+
|
|
595
|
+
# 添加 Scheme
|
|
596
|
+
success_scheme = add_test_scheme(
|
|
597
|
+
project_dir: project_dir,
|
|
598
|
+
scheme_name: bundle_scheme
|
|
599
|
+
)
|
|
600
|
+
|
|
601
|
+
if success_scheme
|
|
602
|
+
puts " ✓ 已添加Scheme: #{bundle_scheme} (基于 Application ID: #{application_id})"
|
|
603
|
+
return true
|
|
604
|
+
else
|
|
605
|
+
Funlog.instance.fancyinfo_error("添加 Scheme 失败: #{bundle_scheme}")
|
|
606
|
+
return false
|
|
607
|
+
end
|
|
608
|
+
|
|
609
|
+
rescue StandardError => e
|
|
610
|
+
Funlog.instance.fancyinfo_error("添加基于 Application ID 的 Scheme 失败: #{e.message}")
|
|
611
|
+
return false
|
|
612
|
+
end
|
|
613
|
+
end
|
|
614
|
+
|
|
542
615
|
# 添加测试scheme到Android工程
|
|
543
616
|
# @param project_dir [String] Android项目目录路径
|
|
544
617
|
# @param scheme_name [String] 要添加的scheme名称
|
|
@@ -240,6 +240,9 @@ module Pindo
|
|
|
240
240
|
update_manifest_to_standard(manifest_path: manifest_path)
|
|
241
241
|
end
|
|
242
242
|
|
|
243
|
+
# 3.5 更新所有 XML 文件中的图标引用
|
|
244
|
+
update_all_xml_icon_references(proj_dir: proj_dir)
|
|
245
|
+
|
|
243
246
|
# 4. 安装标准 icon 文件
|
|
244
247
|
success_count = 0
|
|
245
248
|
densities_installed = []
|
|
@@ -289,6 +292,53 @@ module Pindo
|
|
|
289
292
|
end
|
|
290
293
|
end
|
|
291
294
|
|
|
295
|
+
# 更新所有 XML 文件中的图标引用(从旧名称更新为标准名称)
|
|
296
|
+
# @param proj_dir [String] Android项目目录
|
|
297
|
+
# @return [Boolean] 是否成功更新
|
|
298
|
+
def self.update_all_xml_icon_references(proj_dir: nil)
|
|
299
|
+
return false unless proj_dir && File.directory?(proj_dir)
|
|
300
|
+
|
|
301
|
+
begin
|
|
302
|
+
updated_files = []
|
|
303
|
+
|
|
304
|
+
# 查找所有 XML 文件
|
|
305
|
+
xml_files = Dir.glob(File.join(proj_dir, "**/*.xml"))
|
|
306
|
+
.reject { |f| f.include?("/build/") || f.include?("/.gradle/") }
|
|
307
|
+
|
|
308
|
+
xml_files.each do |xml_file|
|
|
309
|
+
content = File.read(xml_file)
|
|
310
|
+
original_content = content.dup
|
|
311
|
+
|
|
312
|
+
# 替换所有旧的图标引用为标准名称
|
|
313
|
+
# app_icon -> ic_launcher
|
|
314
|
+
# app_icon_round -> ic_launcher_round
|
|
315
|
+
content.gsub!('@mipmap/app_icon_round', '@mipmap/ic_launcher_round')
|
|
316
|
+
content.gsub!('@mipmap/app_icon', '@mipmap/ic_launcher')
|
|
317
|
+
content.gsub!('@drawable/app_icon_round', '@drawable/ic_launcher_round')
|
|
318
|
+
content.gsub!('@drawable/app_icon', '@drawable/ic_launcher')
|
|
319
|
+
|
|
320
|
+
# 如果内容有变化,保存文件
|
|
321
|
+
if content != original_content
|
|
322
|
+
File.write(xml_file, content)
|
|
323
|
+
relative_path = xml_file.sub(proj_dir + '/', '')
|
|
324
|
+
updated_files << relative_path
|
|
325
|
+
puts " ✓ 更新图标引用: #{relative_path}"
|
|
326
|
+
end
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
if updated_files.empty?
|
|
330
|
+
puts " ✓ 所有 XML 文件的图标引用已是标准配置"
|
|
331
|
+
else
|
|
332
|
+
puts " ✓ 已更新 #{updated_files.length} 个文件的图标引用"
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
return true
|
|
336
|
+
rescue => e
|
|
337
|
+
Funlog.instance.fancyinfo_error("更新 XML 图标引用失败: #{e.message}")
|
|
338
|
+
return false
|
|
339
|
+
end
|
|
340
|
+
end
|
|
341
|
+
|
|
292
342
|
end
|
|
293
343
|
|
|
294
344
|
end
|
data/lib/pindo/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pindo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.11.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- wade
|
|
@@ -314,10 +314,14 @@ files:
|
|
|
314
314
|
- lib/pindo/command.rb
|
|
315
315
|
- lib/pindo/command/android.rb
|
|
316
316
|
- lib/pindo/command/android/autobuild.rb
|
|
317
|
+
- lib/pindo/command/android/autoresign.rb
|
|
317
318
|
- lib/pindo/command/android/build.rb
|
|
318
|
-
- lib/pindo/command/android/
|
|
319
|
+
- lib/pindo/command/android/keystore.rb
|
|
319
320
|
- lib/pindo/command/appstore.rb
|
|
321
|
+
- lib/pindo/command/appstore/adhocbuild.rb
|
|
322
|
+
- lib/pindo/command/appstore/autoresign.rb
|
|
320
323
|
- lib/pindo/command/appstore/iap.rb
|
|
324
|
+
- lib/pindo/command/appstore/import.rb
|
|
321
325
|
- lib/pindo/command/appstore/itcapp.rb
|
|
322
326
|
- lib/pindo/command/appstore/metadata.rb
|
|
323
327
|
- lib/pindo/command/appstore/screenshots.rb
|
|
@@ -346,20 +350,14 @@ files:
|
|
|
346
350
|
- lib/pindo/command/deploy/tag.rb
|
|
347
351
|
- lib/pindo/command/deploy/updateconfig.rb
|
|
348
352
|
- lib/pindo/command/deploy/uploadipa.rb
|
|
349
|
-
- lib/pindo/command/dev.rb
|
|
350
353
|
- lib/pindo/command/dev/autobuild.rb
|
|
351
354
|
- lib/pindo/command/dev/build.rb
|
|
352
355
|
- lib/pindo/command/dev/debug.rb
|
|
353
|
-
- lib/pindo/command/dev/feishu.rb
|
|
354
|
-
- lib/pindo/command/dev/repoinit.rb
|
|
355
|
-
- lib/pindo/command/dev/tag.rb
|
|
356
356
|
- lib/pindo/command/env.rb
|
|
357
357
|
- lib/pindo/command/env/dreamstudio.rb
|
|
358
358
|
- lib/pindo/command/env/quarkenv.rb
|
|
359
359
|
- lib/pindo/command/env/swarkenv.rb
|
|
360
360
|
- lib/pindo/command/env/workhard.rb
|
|
361
|
-
- lib/pindo/command/feishu.rb
|
|
362
|
-
- lib/pindo/command/feishu/send_message.rb
|
|
363
361
|
- lib/pindo/command/gplay.rb
|
|
364
362
|
- lib/pindo/command/gplay/iap.rb
|
|
365
363
|
- lib/pindo/command/gplay/itcapp.rb
|
|
@@ -368,16 +366,14 @@ files:
|
|
|
368
366
|
- lib/pindo/command/gplay/screenshots.rb
|
|
369
367
|
- lib/pindo/command/gplay/upload.rb
|
|
370
368
|
- lib/pindo/command/ios.rb
|
|
371
|
-
- lib/pindo/command/ios/adhoc.rb
|
|
372
369
|
- lib/pindo/command/ios/applovin.rb
|
|
373
370
|
- lib/pindo/command/ios/autobuild.rb
|
|
374
371
|
- lib/pindo/command/ios/autoresign.rb
|
|
375
372
|
- lib/pindo/command/ios/build.rb
|
|
376
|
-
- lib/pindo/command/ios/
|
|
377
|
-
- lib/pindo/command/
|
|
378
|
-
- lib/pindo/command/
|
|
379
|
-
- lib/pindo/command/
|
|
380
|
-
- lib/pindo/command/ipa/output.rb
|
|
373
|
+
- lib/pindo/command/ios/cert.rb
|
|
374
|
+
- lib/pindo/command/ios/podlint.rb
|
|
375
|
+
- lib/pindo/command/ios/podpush.rb
|
|
376
|
+
- lib/pindo/command/ios/podupdate.rb
|
|
381
377
|
- lib/pindo/command/jps.rb
|
|
382
378
|
- lib/pindo/command/jps/apptest.rb
|
|
383
379
|
- lib/pindo/command/jps/bind.rb
|
|
@@ -386,11 +382,6 @@ files:
|
|
|
386
382
|
- lib/pindo/command/jps/login.rb
|
|
387
383
|
- lib/pindo/command/jps/resign.rb
|
|
388
384
|
- lib/pindo/command/jps/upload.rb
|
|
389
|
-
- lib/pindo/command/lib.rb
|
|
390
|
-
- lib/pindo/command/lib/forcepush.rb
|
|
391
|
-
- lib/pindo/command/lib/lint.rb
|
|
392
|
-
- lib/pindo/command/lib/push.rb
|
|
393
|
-
- lib/pindo/command/lib/update.rb
|
|
394
385
|
- lib/pindo/command/repo.rb
|
|
395
386
|
- lib/pindo/command/repo/clone.rb
|
|
396
387
|
- lib/pindo/command/repo/create.rb
|
|
@@ -400,18 +391,21 @@ files:
|
|
|
400
391
|
- lib/pindo/command/unity.rb
|
|
401
392
|
- lib/pindo/command/unity/apk.rb
|
|
402
393
|
- lib/pindo/command/unity/autobuild.rb
|
|
403
|
-
- lib/pindo/command/unity/initpack.rb
|
|
404
394
|
- lib/pindo/command/unity/ipa.rb
|
|
405
|
-
- lib/pindo/command/unity/
|
|
406
|
-
- lib/pindo/command/unity/
|
|
395
|
+
- lib/pindo/command/unity/packbuild.rb
|
|
396
|
+
- lib/pindo/command/unity/packinit.rb
|
|
397
|
+
- lib/pindo/command/unity/packpush.rb
|
|
407
398
|
- lib/pindo/command/unity/web.rb
|
|
408
399
|
- lib/pindo/command/utils.rb
|
|
409
400
|
- lib/pindo/command/utils/boss.rb
|
|
410
401
|
- lib/pindo/command/utils/clearcert.rb
|
|
411
402
|
- lib/pindo/command/utils/device.rb
|
|
403
|
+
- lib/pindo/command/utils/feishu.rb
|
|
412
404
|
- lib/pindo/command/utils/icon.rb
|
|
413
405
|
- lib/pindo/command/utils/renewcert.rb
|
|
414
406
|
- lib/pindo/command/utils/renewproj.rb
|
|
407
|
+
- lib/pindo/command/utils/repoinit.rb
|
|
408
|
+
- lib/pindo/command/utils/tag.rb
|
|
415
409
|
- lib/pindo/command/utils/tgate.rb
|
|
416
410
|
- lib/pindo/command/utils/xcassets.rb
|
|
417
411
|
- lib/pindo/command/utils/xcassets.sh
|
data/lib/pindo/command/dev.rb
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# require 'pindo/command/dev/create'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
require 'pindo/command/dev/tag'
|
|
5
|
-
require 'pindo/command/dev/debug'
|
|
6
|
-
require 'pindo/command/dev/autobuild'
|
|
7
|
-
require 'pindo/command/dev/build'
|
|
8
|
-
require 'pindo/command/dev/repoinit'
|
|
9
|
-
require 'pindo/command/dev/feishu'
|
|
10
|
-
|
|
11
|
-
module Pindo
|
|
12
|
-
class Command
|
|
13
|
-
|
|
14
|
-
class Dev < Command
|
|
15
|
-
self.abstract_command = true
|
|
16
|
-
self.summary = '开发阶段使用的相关命令'
|
|
17
|
-
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require 'json'
|
|
4
|
-
require 'net/http'
|
|
5
|
-
require 'uri'
|
|
6
|
-
require 'pindo/client/httpclient'
|
|
7
|
-
|
|
8
|
-
module Pindo
|
|
9
|
-
module Command
|
|
10
|
-
module Feishu
|
|
11
|
-
class SendMessage
|
|
12
|
-
def self.run(options)
|
|
13
|
-
new(options).run
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def initialize(options)
|
|
17
|
-
@options = options
|
|
18
|
-
@webhook_url = options[:webhook_url]
|
|
19
|
-
@message = options[:message]
|
|
20
|
-
@title = options[:title] || "通知"
|
|
21
|
-
@at_all = options[:at_all] || false
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def run
|
|
25
|
-
unless @webhook_url
|
|
26
|
-
puts "错误:未提供飞书 webhook URL"
|
|
27
|
-
return false
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
unless @message
|
|
31
|
-
puts "错误:未提供消息内容"
|
|
32
|
-
return false
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
send_message
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
private
|
|
39
|
-
|
|
40
|
-
def send_message
|
|
41
|
-
uri = URI(@webhook_url)
|
|
42
|
-
|
|
43
|
-
# 构建消息内容
|
|
44
|
-
content = {
|
|
45
|
-
"msg_type": "post",
|
|
46
|
-
"content": {
|
|
47
|
-
"post": {
|
|
48
|
-
"zh_cn": {
|
|
49
|
-
"title": @title,
|
|
50
|
-
"content": [
|
|
51
|
-
[
|
|
52
|
-
{
|
|
53
|
-
"tag": "text",
|
|
54
|
-
"text": @message
|
|
55
|
-
}
|
|
56
|
-
]
|
|
57
|
-
]
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
# 如果需要@所有人
|
|
64
|
-
if @at_all
|
|
65
|
-
content[:content][:post][:zh_cn][:content][0].unshift(
|
|
66
|
-
{
|
|
67
|
-
"tag": "at",
|
|
68
|
-
"user_id": "all"
|
|
69
|
-
}
|
|
70
|
-
)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
# 发送请求
|
|
74
|
-
begin
|
|
75
|
-
con = HttpClient.create_instance_with_proxy
|
|
76
|
-
res = con.post do |req|
|
|
77
|
-
req.url uri
|
|
78
|
-
req.headers['Content-Type'] = 'application/json'
|
|
79
|
-
req.body = content.to_json
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
if res.status == 200
|
|
83
|
-
result = JSON.parse(res.body)
|
|
84
|
-
if result['code'] == 0
|
|
85
|
-
puts "消息发送成功!"
|
|
86
|
-
return true
|
|
87
|
-
else
|
|
88
|
-
puts "消息发送失败:#{result['msg']}"
|
|
89
|
-
return false
|
|
90
|
-
end
|
|
91
|
-
else
|
|
92
|
-
puts "消息发送失败:HTTP #{res.status}"
|
|
93
|
-
return false
|
|
94
|
-
end
|
|
95
|
-
rescue => e
|
|
96
|
-
puts "发送消息时出错:#{e.message}"
|
|
97
|
-
return false
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
end
|
data/lib/pindo/command/feishu.rb
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require 'claide'
|
|
4
|
-
require 'pindo/command/feishu/send_message'
|
|
5
|
-
|
|
6
|
-
module Pindo
|
|
7
|
-
module Command
|
|
8
|
-
class Feishu < CLAide::Command
|
|
9
|
-
self.description = '飞书相关命令'
|
|
10
|
-
self.command = 'feishu'
|
|
11
|
-
self.abstract_command = true
|
|
12
|
-
|
|
13
|
-
def self.options
|
|
14
|
-
[
|
|
15
|
-
['--webhook-url=URL', '飞书 webhook URL'],
|
|
16
|
-
['--message=MESSAGE', '要发送的消息内容'],
|
|
17
|
-
['--title=TITLE', '消息标题(可选)'],
|
|
18
|
-
['--at-all', '是否@所有人(可选)']
|
|
19
|
-
]
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def initialize(argv)
|
|
23
|
-
super
|
|
24
|
-
@webhook_url = argv.option('webhook-url')
|
|
25
|
-
@message = argv.option('message')
|
|
26
|
-
@title = argv.option('title')
|
|
27
|
-
@at_all = argv.flag?('at-all')
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def validate!
|
|
31
|
-
super
|
|
32
|
-
unless @webhook_url
|
|
33
|
-
help! '必须提供 webhook URL'
|
|
34
|
-
end
|
|
35
|
-
unless @message
|
|
36
|
-
help! '必须提供消息内容'
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def run
|
|
41
|
-
Pindo::Command::Feishu::SendMessage.run(
|
|
42
|
-
webhook_url: @webhook_url,
|
|
43
|
-
message: @message,
|
|
44
|
-
title: @title,
|
|
45
|
-
at_all: @at_all
|
|
46
|
-
)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|