public void ProcessRequest(HttpContext context) { using (var sr = new StreamReader(context.Request.InputStream)) { var json = sr.ReadToEnd(); var body = JsonConvert.DeserializeObject <Dictionary <string, string> >(json); if (body != null && body.TryGetValue("TypeCode", out var typeCode) && typeCode == "ProcessPrivateMessage" && body.TryGetValue("Platform", out var platform) && int.TryParse(platform, out var intPlatform) && intPlatform == 0 && body.TryGetValue("FromQQ", out var qq) && body.TryGetValue("Msg", out var msg) ) { var cqpApi = new CqpApi("http://127.0.0.1:36524"); cqpApi.Apiv1CqpCQSendPrivateMsg(new CqpCQSendPrivateMsgHttpInput { Msg = msg, Qqid = Convert.ToInt64(qq) } ); } } }
public MahuaHttpModule() : base("/api") { Post["/ReceiveMahuaOutput"] = parameters => { var body = this.Bind <BodyModel>(); if (body != null && body.TypeCode == "ProcessPrivateMessage" && body.Platform == 0 ) { var cqpApi = new CqpApi("http://127.0.0.1:36524"); cqpApi.Apiv1CqpCQSendPrivateMsg(new CqpCQSendPrivateMsgHttpInput { Msg = body.Msg, Qqid = body.FromQQ } ); return("ok"); } return("nothing"); }; }
public ActionResult Reveive( [FromBody] IReadOnlyDictionary <string, string> body) { if (body != null && body.TryGetValue("TypeCode", out var typeCode) && typeCode == "ProcessPrivateMessage" && body.TryGetValue("Platform", out var platform) && int.TryParse(platform, out var intPlatform) && intPlatform == 0 && body.TryGetValue("FromQQ", out var qq) && body.TryGetValue("Msg", out var msg) ) { var cqpApi = new CqpApi("http://127.0.0.1:36524"); cqpApi.Apiv1CqpCQSendPrivateMsg(new CqpCQSendPrivateMsgHttpInput { Msg = msg, Qqid = Convert.ToInt64(qq) } ); } return(Ok()); }