README.md in dingbot-0.2.2 vs README.md in dingbot-0.2.3

- old
+ new

@@ -1,7 +1,8 @@ # DingTalk Bot -[![Gem Version](https://rubygems.org/gems/dingbot)](https://badge.fury.io/rb/dingbot.svg) +[![Build Status](https://travis-ci.org/thierryxing/dingtalk-bot.svg?branch=master)](https://travis-ci.org/thierryxing/dingtalk-bot) +[![Gem Version](https://badge.fury.io/rb/dingbot.svg)](https://rubygems.org/gems/dingbot) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/thierryxing/dingtalk-bot/master/LICENSE.txt) DingTalk Bot是阿里钉钉自定义机器人的Ruby库 官方文档:[阿里钉钉自定义机器人](https://open-doc.dingtalk.com/docs/doc.htm?spm=a219a.7629140.0.0.karFPe&treeId=257&articleId=105735&docType=1). @@ -22,14 +23,19 @@ ## 用法 初始化客户端: ```ruby +# 全局配置方式 DingBot.configure do |config| config.endpoint = 'https://oapi.dingtalk.com/robot/send' # API endpoint URL, default: ENV['DINGTALK_API_ENDPOINT'] or https://oapi.dingtalk.com/robot/send config.access_token = '3ddef428f1478056e858450e07272834c79bd538e8055a04e989573c469xxxx' # access token, default: ENV['DINGTALK_ACCESS_TOKEN'] end + +# 局部配置方式 + DingBot.endpoint='https://oapi.dingtalk.com/robot/send' + DingBot.access_token = '3ddef428f1478056e858450e07272834c79bd538e8055a04e989573c469xxxx' ``` 发送消息 ```ruby # 快速发送一套只包含文本的Text消息(不需要构造Message对象) @@ -39,22 +45,22 @@ # 发送复杂Text消息 def send_text message = DingBot::Message::Text.new( '我就是我, 是不一样的烟火', - ['13718896117'], + ['1371xxxx117'], false ) DingBot.send_msg(message) end # 发送Link消息 def send_link message = DingBot::Message::Link.new( '我就是我, 是不一样的烟火', '这个即将发布的新版本,创始人陈航(花名“无招”)称它为“红树林”。', - 'https://mp.weixin.qq.com/s?__biz=MzA4NjMwMTA2Ng==&mid=2650316842&idx=1&sn=60da3ea2b29f1dcc43a7c8e4a7c97a16&scene=2&srcid=09189AnRJEdIiWVaKltFzNTw&from=timeline&isappinstalled=0&key=&ascene=2&uin=&devicetype=android-23&version=26031933&nettype=WIFI', + 'https://www.dingtalk.com/', 'https://avatars1.githubusercontent.com/u/64818' ) DingBot.send_msg(message) end @@ -107,6 +113,6 @@ end ``` 更为详细的用法请见此链接:[https://github.com/thierryxing/dingtalk-bot/blob/master/test/dingbot_test.rb](https://github.com/thierryxing/dingtalk-bot/blob/master/test/dingbot_test.rb) ## License -Released under the MIT license. See LICENSE.txt for details. \ No newline at end of file +Released under the MIT license. See LICENSE.txt for details.