流程为:构建事件触发,然后调用类库Api通知到本地系统,由本地的机器人系统给指定的目标微信名称的账号发送消息
地址:https://github.com/danni-cool/docker-wechatbot-webhook
部署方式按照说明即可,此机器人基于Docker制作
在Unity里面我使用了编辑器拓展的IPostprocessBuildWithReport接口,这个接口会在unity输出完成后自动被Unity调用。而我将 WxNotify.SendMsg(“目标微信昵称”, “程序输出构建完成”);写在了这个方法里面
https://github.com/zhangtianqing/WxNotify
使用Hook机制实现
https://github.com/expzhizhuo/WechatBot
string msg = $"{Application.productName}构建完成,用时:{EditorApplication.timeSinceStartup - time}s";
string timeNow = DateTime.Now.ToLongTimeStamp().ToString();
string sendMsg = "{\"para\": { \"id\": \""+ timeNow + "\", \"type\": 555, \"wxid\": \"目标微信好友的微信号\", \"roomid\": \"null\", \"content\": \""+ msg + "\", \"nickname\": \"null\", \"ext\": \"null\"}}";
WxNotify.Post("http://你的服务器访问地址/api/sendtxtmsg", sendMsg);
附:Unity编辑器拓展-构建事件通知(构建开始、构建结束)
using UnityEditor.Build.Reporting;
using UnityEditor.Build;
using UnityEngine;
using UnityEngine.SceneManagement;
using System.IO;
using Dll.Utils;
using UnityEditor;
using System;
public class BuildCompleteEventListener : IPreprocessBuildWithReport, IPostprocessBuildWithReport,IProcessSceneWithReport
{
public int callbackOrder => 0;
double time;
public void OnPreprocessBuild(BuildReport report)
{
time = EditorApplication.timeSinceStartup;
Debug.LogWarning("打包前");
}
public void OnPostprocessBuild(BuildReport report)
{
Debug.LogWarning($"打包后:{report.GetType().FullName}:{report.summary.outputPath}");
try
{
string msg = $"{Application.productName}构建完成,用时:{EditorApplication.timeSinceStartup - time}s";
string timeNow = DateTime.Now.ToLongTimeStamp().ToString();
string sendMsg = "{\"para\": { \"id\": \""+ timeNow + "\", \"type\": 555, \"wxid\": \"目标微信好友的微信号\", \"roomid\": \"null\", \"content\": \""+ msg + "\", \"nickname\": \"null\", \"ext\": \"null\"}}";
WxNotify.Post("http://你的服务器访问地址/api/sendtxtmsg", sendMsg);
}
catch (System.Exception e)
{
Debug.Log("WxNotifyError:" + e);
}
DeleteExcelOnOutput(report);
}
///
/// 打包前遍历场景列表(Scenes In Build)
///
/// Build Settings中的勾选的场景列表,不勾选的不会遍历到
///
public void OnProcessScene(Scene scene, BuildReport report)
{
Debug.LogWarning("打包前对场景操作:" + scene.name);
}
}