群机器人

在使用之前,请确认你已经配置过了企业内部群聊机器人,并且获得了webhookurl里面的key参数。

消息发送

文本类型 (TODO)

  1. key := "693axxx6-7aoc-4bc4-97a0-0ec2sifa5aaa"
  2. msg := &request.GroupRobotMsgText{
  3. Content: "广州今日天气:29度,大部分多云,降雨概率:60%",
  4. MentionedList: []string{"wangqing", "@all"},
  5. MentionedMobileList: []string{"13800001111", "@all"},
  6. }
  7. WeComApp.GroupRobot.SendText(key, msg)

微信官方文档

Markdown类型 (TODO)

  1. key := "693axxx6-7aoc-4bc4-97a0-0ec2sifa5aaa"
  2. msg := &request.GroupRobotMsgMarkdown{
  3. Content: `实时新增用户反馈<font color=\"warning\">132例</font>,请相关同事注意。\n
  4. >类型:<font color=\"comment\">用户反馈</font>
  5. >普通用户反馈:<font color=\"comment\">117例</font>
  6. >VIP用户反馈:<font color=\"comment\">15例</font>`,
  7. }
  8. WeComApp.GroupRobot.SendMarkdown(ctx,key, msg)

微信官方文档

图片类型 (TODO)

  1. key := "693axxx6-7aoc-4bc4-97a0-0ec2sifa5aaa"
  2. msg := &request.GroupRobotMsgImage{
  3. Base64: "DATA",
  4. Md5: "MD5",
  5. }
  6. WeComApp.GroupRobot.SendImage(ctx,key, msg)

微信官方文档

图文类型 (TODO)

  1. key := "693axxx6-7aoc-4bc4-97a0-0ec2sifa5aaa"
  2. msg := []*request.GroupRobotMsgNewsArticles{
  3. {
  4. Title: "中秋节礼品领取",
  5. Description: "今年中秋节公司有豪礼相送",
  6. Url: "www.qq.com",
  7. PicUrl: "https://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png",
  8. },
  9. }
  10. WeComApp.GroupRobot.SendNewsArticles(ctx,key, msg)

微信官方文档

文件类型 (TODO)

  1. key := "693axxx6-7aoc-4bc4-97a0-0ec2sifa5aaa"
  2. msg := &request.GroupRobotMsgFile{
  3. MediaID: "3a8asd892asd8asd",
  4. }
  5. WeComApp.GroupRobot.SendFile(ctx,key, msg)

微信官方文档

模版卡片类型 (TODO)

  1. key := "693axxx6-7aoc-4bc4-97a0-0ec2sifa5aaa"
  2. msg := &request.GroupRobotMsgTemplateCard{
  3. CardType: "text_notice",
  4. Source: request.TemplateCardSource{
  5. IconUrl: "https://wework.qpic.cn/wwpic/252813_jOfDHtcISzuodLa_1629280209/0",
  6. Desc: "企业微信",
  7. },
  8. MainTitle: request.TemplateCardMainTitle{
  9. Title: "欢迎使用企业微信",
  10. Desc: "您的好友正在邀请您加入企业微信",
  11. },
  12. EmphasisContent: request.TemplateCardEmphasisContent{
  13. Title: "100",
  14. Desc: "数据含义",
  15. },
  16. SubTitleText: "下载企业微信还能抢红包!",
  17. HorizontalContentList: []request.TemplateCardHorizontalContentListItem{
  18. {
  19. KeyName: "邀请人",
  20. Value: "张三",
  21. },
  22. {
  23. KeyName: "企微官网",
  24. Value: "点击访问",
  25. Type: 1,
  26. Url: "https://work.weixin.qq.com/?from=openApi",
  27. },
  28. {
  29. KeyName: "企微下载",
  30. Value: "企业微信.apk",
  31. Type: 2,
  32. MediaID: "MEDIAID",
  33. },
  34. },
  35. JumpList: []request.TemplateCardJumpListItem{
  36. {
  37. Type: 1,
  38. Url: "https://work.weixin.qq.com/?from=openApi",
  39. Title: "企业微信官网",
  40. },
  41. {
  42. Type: 2,
  43. AppID: "APPID",
  44. PagePath: "PAGEPATH",
  45. Title: "跳转小程序",
  46. },
  47. },
  48. CardAction: request.TemplateCardCardAction{
  49. Type: 1,
  50. Url: "https://work.weixin.qq.com/?from=openApi",
  51. AppID: "APPID",
  52. PagePath: "PAGEPATH",
  53. },
  54. }
  55. WeComApp.GroupRobot.SendTemplateCard(ctx,key, msg)

微信官方文档

WARNING

每个机器人发送的消息不能超过20条/分钟。

文件上传接口(TODO)

功能还未做

素材上传得到media_id,该media_id仅三天内有效 media_id只能是对应上传文件的机器人可以使用

使用示例

参考:PowerWechatTutorial