206 lines
9.0 KiB
C#
206 lines
9.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Xml;
|
|
using Api.Framework;
|
|
using Api.Framework.Events;
|
|
using Api.Framework.SDK;
|
|
using Api.Framework.Tools;
|
|
using Chat.Framework;
|
|
using Chat.Framework.WXSdk.Implement;
|
|
using CsharpHttpHelper;
|
|
using ProductTool.Properties;
|
|
using SqlSugar;
|
|
|
|
namespace ProductTool
|
|
{
|
|
// Token: 0x02000006 RID: 6
|
|
public class Class1 : Plugin
|
|
{
|
|
// Token: 0x06000026 RID: 38 RVA: 0x000026A1 File Offset: 0x000008A1
|
|
public Class1()
|
|
{
|
|
base.Name = "爆单-服务端";
|
|
base.Logo = Resources.爆;
|
|
base.Note = "专业的运营团队、代运营朋友圈、直播群!";
|
|
}
|
|
|
|
// Token: 0x06000027 RID: 39 RVA: 0x000026D0 File Offset: 0x000008D0
|
|
public override void Start()
|
|
{
|
|
TimerTask.NewTimer<ThreadDelete>(60, null);
|
|
SqlSugarClient session = ApiClient.GetSession(null, true);
|
|
bool flag = !SqlSugarExtend.TableExist<CircleClass>(session);
|
|
if (flag)
|
|
{
|
|
SqlSugarExtend.CreateTable<CircleClass>(session);
|
|
}
|
|
base.SDK.WebRequestEvent += this.SDK_WebRequestEvent;
|
|
base.Start();
|
|
}
|
|
|
|
// Token: 0x06000028 RID: 40 RVA: 0x00002722 File Offset: 0x00000922
|
|
public override void Stop()
|
|
{
|
|
TimerTask.Close<ThreadDelete>();
|
|
base.SDK.WebRequestEvent -= this.SDK_WebRequestEvent;
|
|
base.Stop();
|
|
}
|
|
|
|
// Token: 0x06000029 RID: 41 RVA: 0x0000274C File Offset: 0x0000094C
|
|
private string FormatXml(XmlDocument xml)
|
|
{
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
StringWriter w = new StringWriter(stringBuilder);
|
|
XmlTextWriter xmlTextWriter = null;
|
|
try
|
|
{
|
|
xmlTextWriter = new XmlTextWriter(w);
|
|
xmlTextWriter.Formatting = Formatting.Indented;
|
|
xmlTextWriter.Indentation = 1;
|
|
xmlTextWriter.IndentChar = '\t';
|
|
xml.WriteTo(xmlTextWriter);
|
|
}
|
|
finally
|
|
{
|
|
bool flag = xmlTextWriter == null;
|
|
if (flag)
|
|
{
|
|
xmlTextWriter.Close();
|
|
}
|
|
}
|
|
return stringBuilder.ToString();
|
|
}
|
|
|
|
// Token: 0x0600002A RID: 42 RVA: 0x000027C8 File Offset: 0x000009C8
|
|
private void SDK_WebRequestEvent(object sender, WebRequestEvents e)
|
|
{
|
|
try
|
|
{
|
|
string text = e.Param.ContainsKey("method") ? e.Param["method"] : string.Empty;
|
|
string a = text;
|
|
if (!(a == "getCircle"))
|
|
{
|
|
if (!(a == "addItem"))
|
|
{
|
|
if (a == "findPyq")
|
|
{
|
|
string text2 = e.Param["wxid"];
|
|
PluginExtend.OnLog(this, "获取" + text2 + "的朋友圈");
|
|
List<WeixinBase> list = (from f in ChatClient.WXClient.Values
|
|
where f.WeixinType != WeixinType.QYHook微信
|
|
select f).ToList<WeixinBase>();
|
|
foreach (WeixinBase weixinBase in list)
|
|
{
|
|
Dictionary<string, object> dictionary = weixinBase.FindCircle(text2, "", 0L).FirstOrDefault<Dictionary<string, object>>();
|
|
bool flag = dictionary != null;
|
|
if (flag)
|
|
{
|
|
PluginExtend.OnLog(this, string.Concat(new string[]
|
|
{
|
|
weixinBase.User.Nick,
|
|
"(",
|
|
weixinBase.User.Username,
|
|
")获取",
|
|
text2,
|
|
"朋友圈成功"
|
|
}));
|
|
XmlDocument xmlDocument = new XmlDocument();
|
|
xmlDocument.LoadXml(dictionary["ObjectDesc"].ToString());
|
|
object obj = this.FormatXml(xmlDocument);
|
|
e.Send(obj, 0);
|
|
}
|
|
else
|
|
{
|
|
PluginExtend.OnLog(this, string.Concat(new string[]
|
|
{
|
|
weixinBase.User.Nick,
|
|
"(",
|
|
weixinBase.User.Username,
|
|
")获取",
|
|
text2,
|
|
"朋友圈为空"
|
|
}));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string url = e.Param["itemUrl"];
|
|
SqlSugarClient session = ApiClient.GetSession(null, true);
|
|
bool flag2 = bool.Parse(e.Param["isItem"]);
|
|
string circle = HttpHelper.URLDecode(e.Param["circle"], null);
|
|
bool flag3 = string.IsNullOrEmpty(circle);
|
|
if (flag3)
|
|
{
|
|
throw new Exception("朋友圈内容,不能为空!");
|
|
}
|
|
bool flag4 = flag2;
|
|
CircleClass circleClass;
|
|
if (flag4)
|
|
{
|
|
circleClass = session.Queryable<CircleClass>().Single((CircleClass f) => f.itemUrl == url && f.sendTime > DateTime.Now.AddHours(-24.0));
|
|
}
|
|
else
|
|
{
|
|
circleClass = session.Queryable<CircleClass>().Single((CircleClass f) => f.circle == circle && f.sendTime > DateTime.Now.AddHours(-24.0));
|
|
}
|
|
bool flag5 = circleClass != null;
|
|
if (flag5)
|
|
{
|
|
throw new Exception("此宝贝已发布过!");
|
|
}
|
|
circleClass = new CircleClass();
|
|
circleClass.isItem = bool.Parse(e.Param["isItem"]);
|
|
circleClass.appendQrcode = bool.Parse(e.Param["appendQrcode"]);
|
|
circleClass.itemUrl = HttpHelper.URLDecode(e.Param["itemUrl"], null);
|
|
circleClass.quanUrl = HttpHelper.URLDecode(e.Param["quanUrl"], null);
|
|
circleClass.comment = HttpHelper.URLDecode(e.Param["comment"], null);
|
|
circleClass.circle = HttpHelper.URLDecode(e.Param["circle"], null);
|
|
circleClass.sendTime = (string.IsNullOrEmpty(e.Param["sendTime"]) ? DateTime.Now : DateTime.Parse(HttpHelper.URLDecode(e.Param["sendTime"], null)));
|
|
bool flag6 = circleClass.isItem && string.IsNullOrEmpty(circleClass.itemUrl);
|
|
if (flag6)
|
|
{
|
|
throw new Exception("宝贝无效!");
|
|
}
|
|
session.Insertable<CircleClass>(circleClass).ExecuteCommand();
|
|
e.Send("添加成功!", 0);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string b = e.Param["lastId"];
|
|
CircleClass circleClass2 = CacheTool.GetSingleObj().Get<CircleClass>("CircleClass");
|
|
bool flag7 = circleClass2 != null && circleClass2.id.ToString() != b;
|
|
if (flag7)
|
|
{
|
|
e.Send(new
|
|
{
|
|
lastId = circleClass2.id,
|
|
itemUrl = circleClass2.itemUrl,
|
|
quanUrl = circleClass2.quanUrl,
|
|
sendTime = circleClass2.sendTime.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
circle = circleClass2.circle,
|
|
comment = circleClass2.comment.Replace("¥", "").Replace("元", ""),
|
|
appendQrcode = circleClass2.appendQrcode,
|
|
isItem = circleClass2.isItem
|
|
}, 0);
|
|
}
|
|
else
|
|
{
|
|
e.Send(new Exception("无结果"), -1);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
PluginExtend.OnLog(this, ex.Message);
|
|
e.Send(ex, -1);
|
|
}
|
|
}
|
|
}
|
|
}
|