Skip to content

lc-cn/dingtalk-bot

Repository files navigation

dingtalk-bot

  • 钉钉机器人开发SDK

prepare

  1. 前往钉钉开放平台创建应用
  2. 点击创建好的应用,为其添加机器人能力img.png
  3. 点击凭证与基础信息,获取clientIdclientSecretimg_2.png
  4. 填写机器人信息,并指定消息接收模式为Stream模式img_1.png
  5. 发布机器人

install

npm install node-dd-bot

usage

const {Bot}=require('node-dd-bot')
const bot=new Bot({
	clientId:'',
	clientSecret:''
})
bot.on('message.group',(e)=>{
	e.reply('hello world')
})
bot.on('message.private',(e)=>{
	e.reply('hi world')
})
bot.sendPrivateMsg('user_id',[
	'你好呀',
	{
		type:'image',
		url:'https://foo.bar/img.jpg'
	}
])

bot.sendGroupMsg('converationId',[
	'你好呀',
	{
		type:'image',
		url:'https://foo.bar/img.jpg'
	}
])
bot.start()