Sha256: dd458aa69b147830dc6db36057400d584828041e4531ac99ccebcb3a003403af

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

module DingBot
  module Message

    # markdown类型
    # {
    #     "msgtype": "markdown",
    #     "markdown": {
    #         "title":"杭州天气",
    #         "text": "#### 杭州天气\n" +
    #             "> 9度,西北风1级,空气良89,相对温度73%\n\n" +
    #             "> ![screenshot](http://image.jpg)\n"  +
    #             "> ###### 10点20分发布 [天气](http://www.thinkpage.cn/) \n"
    #     },
    #     "at": {
    #       "atMobiles": [
    #       "1825718XXXX"
    #       ], 
    #     "isAtAll": false
    #     }
    # }
    class Markdown < Base
      attr_accessor :title, :text, :at_mobiles, :is_at_all

      def initialize(title='', text='', at_mobiles=[], is_at_all=false)
        @title = title
        @text = text
        @at_mobiles = at_mobiles
        @is_at_all = is_at_all
      end

      def msg_type
        TYPE::MARKDOWN
      end

      def body_params
        super.merge({
            markdown: {
                text: @text,
                title: @title,
            },
            at: {
                    atMobiles: @at_mobiles,
                    isAtAll: @is_at_all
                }
            }
        )
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dingbot-0.2.5 lib/dingbot/message/markdown.rb
dingbot-0.2.3 lib/dingbot/message/markdown.rb