Sha256: 5e4691ac9189d0e925a3a9aa71d87db2565784d946699f15caae6994be8456d8

Contents?: true

Size: 1.7 KB

Versions: 14

Compression:

Stored size: 1.7 KB

Contents

require 'cocoapods'
require 'pathname'
require 'pp'
require 'tmpdir'
require 'json'

require 'rainbow'
require 'yaml'
require 'git'
require 'yk_command/analyze/dependency_result'
require 'wechat_work_webhook'
require 'thor'
module YkCommand
  class WxBot < Thor



    no_commands do

      def initialize(config)

        webhook_url = config[:webhook_url]
        @project_url = config[:project_url]
        @project_cover_image_url = config[:project_cover_image_url]

        @wechat = WechatWorkWebhook.new(webhook_url)
      end

      def send_result_to_group(success_list, failed_list)
        time = Time.new
        time_s = "#{time.year}-#{time.month}-#{time.day} "
        @wechat.markdown("## #{time_s} 分析结果\n### 成功 #{success_list.length} 个 #{result_item_list_string(success_list, 'success')}\n### 失败 #{failed_list.length} 个 #{result_item_list_string(failed_list, 'failed')}")

      end

      def send_news_to_group
        require 'wechat_work_webhook'


        time = Time.new
        time_s = "#{time.year}-#{time.month}-#{time.day} "

        @wechat.news([{
                        "title" => "#{time_s}  依赖分析已完成",
                        "description" => "点击进入组件管理平台",
                        "url" => @project_url,
                        "picurl" => @project_cover_image_url
                      }])
      end

      def result_item_list_string(list, level)
        result = ''
        list.each do |name|
          if level == 'success'
            result += "\n- <font color=\"#0099ff\">#{name}</font> "
          else
            result += "\n- <font color=\"#DC143C\">#{name}</font> "
          end
        end
        result
      end
    end

  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
yk_command-0.6.5 lib/yk_command/bot/wx_bot.rb
yk_command-0.6.4 lib/yk_command/bot/wx_bot.rb
yk_command-0.6.2 lib/yk_command/bot/wx_bot.rb
yk_command-0.6.1 lib/yk_command/bot/wx_bot.rb
yk_command-0.6.0 lib/yk_command/bot/wx_bot.rb
yk_command-0.5.91 lib/yk_command/bot/wx_bot.rb
yk_command-0.5.9 lib/yk_command/bot/wx_bot.rb
yk_command-0.5.8 lib/yk_command/bot/wx_bot.rb
yk_command-0.5.7 lib/yk_command/bot/wx_bot.rb
yk_command-0.5.6 lib/yk_command/bot/wx_bot.rb
yk_command-0.5.5 lib/yk_command/bot/wx_bot.rb
yk_command-0.5.4 lib/yk_command/bot/wx_bot.rb
yk_command-0.5.3 lib/yk_command/bot/wx_bot.rb
yk_command-0.5.2 lib/yk_command/bot/wx_bot.rb