Sha256: 5a662350eb0e8cd67a2067752edfd75d9ed62400bc349eb3ff1fa46e0dc48586
Contents?: true
Size: 1010 Bytes
Versions: 36
Compression:
Stored size: 1010 Bytes
Contents
require 'lhj/helper/dingtalk_config' require 'json' module Lhj # pgyer upload class Dingtalk def self.post_message(title, message) robot_url = Lhj::DingTalkConfig.dingtalk_robot http_body = { 'msgtype' => 'markdown', 'markdown' => { 'title' => title, 'text' => message } }.to_json http_post(robot_url, http_body) post_branch_message(http_body) end def self.post_branch_message(http_body) branch_name = fetch_branch branch_map = Lhj::DingTalkConfig.git_branch branch_robot_key = branch_map[branch_name] if branch_map && branch_name branch_robot_url = Lhj::DingTalkConfig.config[branch_robot_key] if branch_robot_key http_post(branch_robot_url, http_body) if branch_robot_url end def self.http_post(robot_url, http_body) Net::HTTP.post(URI(robot_url), http_body, 'Content-Type' => 'application/json') end def self.fetch_branch name = Lhj::Actions.git_branch || '' name.split('/').last end end end
Version data entries
36 entries across 36 versions & 1 rubygems