Noise科学虫洞

Popclip扩展-文本发送至企业微信

我使用的代码采用硬编码的形式,你只需要选中所有,popclip会自动识别,点击安装启用即可

需要注意的是代码中11行webhookUrl地址改为自己的企业微信bot webhook地址,完成后再安装

// #popclip extension for sending selected text to Enterprise WeChat webhook
// name: Send to WeChat
// icon: iconify:mdi:wechat
// language: javascript
// module: true
// entitlements: [network]

async function sendToEnterpriseWeChat(input) {
  const axios = require("axios");

  const webhookUrl = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_KEY";

  try {
    await axios.post(webhookUrl, {
      msgtype: "text",
      text: {
        content: input.text,
      },
    });

    return "Text sent to Enterprise WeChat successfully!";
  } catch (error) {
    console.error("Failed to send text to Enterprise WeChat:", error);
    return "Failed to send text to Enterprise WeChat";
  }
}

exports.actions = [
  {
    title: "Send to WeChat",
    icon: "iconify:mdi:wechat",
    after: "copy",
    code: async (input, options) => sendToEnterpriseWeChat(input),
  },
];

Thoughts? Leave a comment