{"id":28711963,"url":"https://github.com/thierryxing/dingtalk-bot","last_synced_at":"2025-07-17T13:33:48.900Z","repository":{"id":47192496,"uuid":"94679904","full_name":"thierryxing/dingtalk-bot","owner":"thierryxing","description":"钉钉自定义机器人Ruby SDK","archived":false,"fork":false,"pushed_at":"2021-09-09T03:16:04.000Z","size":46,"stargazers_count":39,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-14T22:44:18.659Z","etag":null,"topics":["dingding","dingtalk","robot","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thierryxing.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-18T10:21:10.000Z","updated_at":"2023-03-01T06:12:10.000Z","dependencies_parsed_at":"2022-09-05T15:11:01.692Z","dependency_job_id":null,"html_url":"https://github.com/thierryxing/dingtalk-bot","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/thierryxing/dingtalk-bot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thierryxing%2Fdingtalk-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thierryxing%2Fdingtalk-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thierryxing%2Fdingtalk-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thierryxing%2Fdingtalk-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thierryxing","download_url":"https://codeload.github.com/thierryxing/dingtalk-bot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thierryxing%2Fdingtalk-bot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265611336,"owners_count":23797864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dingding","dingtalk","robot","ruby"],"created_at":"2025-06-14T22:34:33.830Z","updated_at":"2025-07-17T13:33:48.889Z","avatar_url":"https://github.com/thierryxing.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DingTalk Bot\n[![Build Status](https://travis-ci.org/thierryxing/dingtalk-bot.svg?branch=master)](https://travis-ci.org/thierryxing/dingtalk-bot)\n[![Gem Version](https://badge.fury.io/rb/dingbot.svg)](https://rubygems.org/gems/dingbot)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/thierryxing/dingtalk-bot/master/LICENSE.txt)\n\nDingTalk Bot是阿里钉钉自定义机器人的Ruby库  \n官方文档：[阿里钉钉自定义机器人](https://developers.dingtalk.com/document/robots/robot-overview). \n\n\n## 安装\n从rubygems中安装:\n\n```sh\ngem install dingbot\n```\n\n添加到Gemfile中:\n\n```ruby\ngem 'dingbot'\n```\n\n## 用法\n\n初始化客户端:\n\n```ruby\n# 全局配置方式\nDingBot.configure do |config|\n  config.endpoint = 'https://oapi.dingtalk.com/robot/send' # API endpoint URL, default: ENV['DINGTALK_API_ENDPOINT'] or https://oapi.dingtalk.com/robot/send\n  config.access_token = 'your access token' # access token, default: ENV['DINGTALK_ACCESS_TOKEN']\n  config.secret = \"your sign secret\" # sign secret\nend\n\n# 局部配置方式\n DingBot.endpoint='https://oapi.dingtalk.com/robot/send'\n DingBot.access_token = 'your access token'\n DingBot.secret = \"your sign secret\" # sign secret\n```\n\n发送消息\n```ruby\n# 快速发送一套只包含文本的Text消息（不需要构造Message对象）\ndef send_simple_text\n  DingBot.send_text('我就是我, 是不一样的烟火')\nend\n\n# 发送复杂Text消息\ndef send_text\n  message = DingBot::Message::Text.new(\n      '我就是我, 是不一样的烟火',\n      ['1371xxxx117'],\n      false\n  )\n  DingBot.send_msg(message)\nend\n\n# 发送Link消息\ndef send_link\n  message = DingBot::Message::Link.new(\n      '我就是我, 是不一样的烟火',\n      '这个即将发布的新版本，创始人陈航（花名“无招”）称它为“红树林”。',\n      'https://www.dingtalk.com/',\n      'https://avatars1.githubusercontent.com/u/64818'\n  )\n  DingBot.send_msg(message)\nend\n\n# 发送Markdown消息\ndef send_markdown\n  DingBot.send_markdown('我就是我, 是不一样的烟火', '### 我就是我, 是不一样的烟火')\nend\n\n# 发送整体跳转ActionCard消息\ndef send_whole_action_card\n  message = DingBot::Message::WholeActionCard.new(\n      '乔布斯 20 年前想打造一间苹果咖啡厅，而它正是 Apple Store 的前身',\n      '![screenshot](@lADOpwk3K80C0M0FoA) ### 乔布斯 20 年前想打造的苹果咖啡厅',\n      '阅读全文',\n      'https://www.dingtalk.com/'\n  )\n  DingBot.send_msg(message)\nend\n\n# 发送独立跳转ActionCard类型消息\ndef send_independent_action_card\n  message = DingBot::Message::IndependentActionCard.new(\n      '乔布斯 20 年前想打造一间苹果咖啡厅，而它正是 Apple Store 的前身',\n      '![screenshot](@lADOpwk3K80C0M0FoA) ### 乔布斯 20 年前想打造的苹果咖啡厅',\n      [\n          DingBot::Message::ActionBtn.new('内容不错', 'https://www.dingtalk.com/'),\n          DingBot::Message::ActionBtn.new('不感兴趣', 'https://www.dingtalk.com/')\n      ]\n  )\n  DingBot.send_msg(message)\nend\n\n# 发送FeedCard类型\ndef send_feed_card\n  message = DingBot::Message::FeedCard.new(\n      [\n          DingBot::Message::FeedCardLink.new(\n              '时代的火车向前开',\n              'https://avatars1.githubusercontent.com/u/64818',\n              'https://www.dingtalk.com/'\n          ),\n          DingBot::Message::FeedCardLink.new(\n              '时代的火车向前开',\n              'https://avatars1.githubusercontent.com/u/64818',\n              'https://www.dingtalk.com/'\n          )\n      ]\n  )\n  DingBot.send_msg(message)\nend                            \n```\n更为详细的用法请见此链接：[https://github.com/thierryxing/dingtalk-bot/blob/master/test/dingbot_test.rb](https://github.com/thierryxing/dingtalk-bot/blob/master/test/dingbot_test.rb)\n\n## License\nReleased under the MIT license. See LICENSE.txt for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthierryxing%2Fdingtalk-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthierryxing%2Fdingtalk-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthierryxing%2Fdingtalk-bot/lists"}