lib/dingtalk/robot.rb in dingtalk-robot-0.2.0 vs lib/dingtalk/robot.rb in dingtalk-robot-0.2.1
- old
+ new
@@ -4,10 +4,12 @@
require 'net/http'
require 'dingtalk/robot/configurable'
require 'dingtalk/robot/errors'
require 'dingtalk/robot/strategies/text_strategy'
require 'dingtalk/robot/strategies/markdown_strategy'
+require 'dingtalk/robot/strategies/action_card_strategy'
+require 'dingtalk/robot/strategies/feed_card_strategy'
module Dingtalk
# DingTalk Group Robot
# @see https://open-doc.dingtalk.com/microapp/serverapi2/qf2nxq
class Robot
@@ -42,10 +44,10 @@
template_paths = Dir["#{config.template_dir}/#{channel}.*.erb"]
if template_paths.empty?
raise ArgumentError, "Undefined channel template, channel: #{channel}, template_dir: #{config.template_dir}"
end
types = template_paths.map do |template_path|
- template_path[%r{#{config.template_dir}/#{channel}.([a-zA-Z]+).erb}, 1].to_sym
+ template_path[%r{#{config.template_dir}/#{channel}.([a-z_]+).erb}, 1].to_sym
end
types.include?(config.message_type) ? config.message_type : types.first
end
valid = VALID_MESSAGE_TYPES.include?(@message_type)
raise ConfigurationError.new(:message_type, @message_type, VALID_MESSAGE_TYPES) unless valid