Gewechat一款微信机器人开源框架

前言:

在数字化时代,自动化工具对提升效率和节省时间至关重要。Gewechat是一个开源项目,帮助开发者通过编程与微信进行互动,自动处理微信消息,创建聊天机器人。使用这个框架,你可以开发各种创新应用,例如企业客服、个人助手,甚至是有趣的社交实验。

项目概况

Gewechat 是 WeChat微信聊天机器人框架的一个插件,主要用于在 云平台上提供微信 API 接口服务。WeChaty 是一个流行的微信开发库,使用 Java 和 GO 编写,专注于通过安全稳定的云平台来实现微信的RPA自动化操作。

可用于以下业务:

  • 团队协作:将机器人集成到现有的工作流程中,用于自动发送通知、提醒或收集信息。

  • 个人效率:设置定时提醒,自动处理日常事务,如安排日程、支付账单等。

  • 数据分析:监控特定话题,收集和分析大量微信数据,用于市场研究或舆情分析。

  • 娱乐应用:开发有趣的游戏或挑战,增加互动体验。

项目特点

  • 稳定性高:利用 Gewechat 云服务,避免本地客户端的稳定性问题,确保长期可靠运行。

  • 快速更新:活跃的社区支持,持续进行优化和更新,确保兼容最新的微信功能。

  • 灵活扩展:容易与其他系统集成,可通过插件扩展功能。

  • 文档齐全:提供详细的文档和示例代码,帮助开发者快速上手。

  • 开源社区:开放源码,鼓励社区贡献,共同推进项目发展。

代码示例:

package api.base;

import com.alibaba.fastjson2.JSONObject;
import util.OkhttpUtil;

/**
 * 消息模块
 */
public class MessageApi {

    /**
     * 发送文字消息
     */
    public static JSONObject postText(String appId, String toWxid, String content, String ats) {
        JSONObject param = new JSONObject();
        param.put("appId", appId);
        param.put("toWxid", toWxid);
        param.put("content", content);
        param.put("ats", ats);
        return OkhttpUtil.postJSON("/message/postText", param);
    }

    /**
     * 发送文件消息
     */
    public static JSONObject postFile(String appId, String toWxid, String fileUrl, String fileName) {
        JSONObject param = new JSONObject();
        param.put("appId", appId);
        param.put("toWxid", toWxid);
        param.put("fileUrl", fileUrl);
        param.put("fileName", fileName);
        return OkhttpUtil.postJSON("/message/postFile", param);
    }

    /**
     * 发送图片消息
     */
    public static JSONObject postImage(String appId, String toWxid, String imgUrl) {
        JSONObject param = new JSONObject();
        param.put("appId", appId);
        param.put("toWxid", toWxid);
        param.put("imgUrl", imgUrl);
        return OkhttpUtil.postJSON("/message/postImage", param);
    }

    /**
     * 发送语音消息
     */
    public static JSONObject postVoice(String appId, String toWxid, String voiceUrl, Integer voiceDuration) {
        JSONObject param = new JSONObject();
        param.put("appId", appId);
        param.put("toWxid", toWxid);
        param.put("voiceUrl", voiceUrl);
        param.put("voiceDuration", voiceDuration);
        return OkhttpUtil.postJSON("/message/postVoice", param);
    }

    /**
     * 发送视频消息
     */
    public static JSONObject postVideo(String appId, String toWxid, String videoUrl, String thumbUrl,Integer videoDuration) {
        JSONObject param = new JSONObject();
        param.put("appId", appId);
        param.put("toWxid", toWxid);
        param.put("videoUrl", videoUrl);
        param.put("thumbUrl", thumbUrl);
        param.put("videoDuration", videoDuration);
        return OkhttpUtil.postJSON("/message/postVideo", param);
    }

    /**
     * 发送链接消息
     */
    public static JSONObject postLink(String appId, String toWxid, String title, String desc, String linkUrl, String thumbUrl) {
        JSONObject param = new JSONObject();
        param.put("appId", appId);
        param.put("toWxid", toWxid);
        param.put("title", title);
        param.put("desc", desc);
        param.put("linkUrl", linkUrl);
        param.put("thumbUrl", thumbUrl);
        return OkhttpUtil.postJSON("/message/postLink", param);
    }

    /**
     * 发送名片消息
     */
    public static JSONObject postNameCard(String appId, String toWxid, String nickName, String nameCardWxid) {
        JSONObject param = new JSONObject();
        param.put("appId", appId);
        param.put("toWxid", toWxid);
        param.put("nickName", nickName);
        param.put("nameCardWxid", nameCardWxid);
        return OkhttpUtil.postJSON("/message/postNameCard", param);
    }

    /**
     * 发送emoji消息
     */
    public static JSONObject postEmoji(String appId, String toWxid, String emojiMd5, String emojiSize) {
        JSONObject param = new JSONObject();
        param.put("appId", appId);
        param.put("toWxid", toWxid);
        param.put("emojiMd5", emojiMd5);
        param.put("emojiSize", emojiSize);
        return OkhttpUtil.postJSON("/message/postEmoji", param);
    }

    /**
     * 发送appmsg消息
     */
    public static JSONObject postAppMsg(String appId, String toWxid, String appmsg) {
        JSONObject param = new JSONObject();
        param.put("appId", appId);
        param.put("toWxid", toWxid);
        param.put("appmsg", appmsg);
        return OkhttpUtil.postJSON("/message/postAppMsg", param);
    }

    /**
     * 发送小程序消息
     */
    public static JSONObject postMiniApp(String appId, String toWxid, String miniAppId, String displayName, String pagePath, String coverImgUrl, String title, String userName) {
        JSONObject param = new JSONObject();
        param.put("appId", appId);
        param.put("toWxid", toWxid);
        param.put("miniAppId", miniAppId);
        param.put("displayName", displayName);
        param.put("pagePath", pagePath);
        param.put("coverImgUrl", coverImgUrl);
        param.put("title", title);
        param.put("userName", userName);
        return OkhttpUtil.postJSON("/message/postMiniApp", param);
    }

    /**
     * 转发文件
     */
    public static JSONObject forwardFile(String appId, String toWxid, String xml) {
        JSONObject param = new JSONObject();
        param.put("appId", appId);
        param.put("toWxid", toWxid);
        param.put("xml", xml);
        return OkhttpUtil.postJSON("/message/forwardFile", param);
    }

    /**
     * 转发图片
     */
    public static JSONObject forwardImage(String appId, String toWxid, String xml) {
        JSONObject param = new JSONObject();
        param.put("appId", appId);
        param.put("toWxid", toWxid);
        param.put("xml", xml);
        return OkhttpUtil.postJSON("/message/forwardImage", param);
    }

    /**
     * 转发视频
     */
    public static JSONObject forwardVideo(String appId, String toWxid, String xml) {
        JSONObject param = new JSONObject();
        param.put("appId", appId);
        param.put("toWxid", toWxid);
        param.put("xml", xml);
        return OkhttpUtil.postJSON("/message/forwardVideo", param);
    }

    /**
     * 转发链接
     */
    public static JSONObject forwardUrl(String appId, String toWxid, String xml) {
        JSONObject param = new JSONObject();
        param.put("appId", appId);
        param.put("toWxid", toWxid);
        param.put("xml", xml);
        return OkhttpUtil.postJSON("/message/forwardUrl", param);
    }

    /**
     * 转发小程序
     */
    public static JSONObject forwardMiniApp(String appId, String toWxid, String xml, String coverImgUrl) {
        JSONObject param = new JSONObject();
        param.put("appId", appId);
        param.put("toWxid", toWxid);
        param.put("xml", xml);
        param.put("coverImgUrl", coverImgUrl);
        return OkhttpUtil.postJSON("/message/forwardMiniApp", param);
    }

    /**
     * 撤回消息
     */
    public static JSONObject revokeMsg(String appId, String toWxid, String msgId, String newMsgId,String createTime) {
        JSONObject param = new JSONObject();
        param.put("appId", appId);
        param.put("toWxid", toWxid);
        param.put("msgId", msgId);
        param.put("newMsgId", newMsgId);
        param.put("createTime", createTime);
        return OkhttpUtil.postJSON("/message/revokeMsg", param);
    }

}

总的来说,Gewechat是一个功能强大且易于上手的微信机器人开发工具。无论你是企业还是个人开发者,都能找到适合的应用场景。赶快加入我们,发掘微信自动化的无限潜力吧!

开源地址:https://github.com/Devo919/Gewechat

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值