132 lines
4.9 KiB
C#
132 lines
4.9 KiB
C#
using Api.Framework;
|
|
using Api.Framework.SDK;
|
|
using Weixin.CircleTools.Properties;
|
|
using Api.Framework.Tools;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Weixin.CircleTools.Entitys;
|
|
using Weixin.CircleTools;
|
|
using Api.Framework.Enums;
|
|
using Api.Framework.Model;
|
|
|
|
namespace CircleFriendsTools
|
|
{
|
|
public class Class1 : Plugin
|
|
{
|
|
|
|
public Class1()
|
|
{
|
|
this.Logo = Resources.朋友圈工具;
|
|
this.Name = Resources.PluginName;
|
|
this.Note = Resources.PluginNote;
|
|
}
|
|
|
|
#region 自定义变量
|
|
public static Config Config = null;
|
|
private MainForm mainForm = null;
|
|
public static StringBuilder strb = new StringBuilder();
|
|
#endregion
|
|
|
|
public override void Start()
|
|
{
|
|
try
|
|
{
|
|
var session = ApiClient.GetSession();
|
|
if (!session.TableExist<fl_plugin_circletools_taskinfos>()) session.CreateTable<fl_plugin_circletools_taskinfos>();
|
|
else
|
|
{
|
|
if (!session.ColumnExist("fl_plugin_circletools_taskinfos", "task_comment"))
|
|
{
|
|
session.AddColumn("fl_plugin_circletools_taskinfos", "task_comment", "text");
|
|
}
|
|
|
|
if (!session.ColumnExist("fl_plugin_circletools_taskinfos", "robotnames"))
|
|
{
|
|
session.AddColumn("fl_plugin_circletools_taskinfos", "robotnames", "text");
|
|
session.ExcuteSQL("update fl_plugin_circletools_taskinfos set robotnames = '" + string.Join(",", session.FindRobots().Select(f => f.name)) + "'");
|
|
}
|
|
}
|
|
if (session.TableExist<fl_plugin_circletools_tgw>())
|
|
{
|
|
var tbtgws = session.Find<fl_plugin_circletools_tgw>("select * from fl_plugin_circletools_tgw").ToList();
|
|
if (tbtgws != null)
|
|
{
|
|
foreach (var item in tbtgws)
|
|
{
|
|
session.Insertable(new fl_adzone_info()
|
|
{
|
|
adzone_name = item.pid_name, //推广位名称
|
|
adzone_pid = item.pid, //推广位pid
|
|
adzone_pid_cps_name = item.pid_cps_name, //推广位cps名称
|
|
alliance_id = (int)CpsType.阿里妈妈, //联盟id
|
|
robot_id = item.robot_id, //机器人id
|
|
group_id = string.Empty, //群id
|
|
is_download = false, //不下载
|
|
member_id = 0, //私人id
|
|
onoff = item.onoff, //不禁用
|
|
custom_type = Resources.SoftwareType //自定义类型
|
|
}).ExecuteCommand();
|
|
}
|
|
}
|
|
session.DropTable<fl_plugin_circletools_tgw>();
|
|
}
|
|
|
|
Config = this.ReadConfig<Config>();
|
|
var thread = TimerTask.NewTimer<MonitorThread>(1) as MonitorThread; //创建线程 - 监听好友朋友圈和接口的线程 1秒
|
|
thread.Init();
|
|
thread.plugin = this;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
this.OnLog(ex.Message);
|
|
}
|
|
}
|
|
|
|
public override void ShowForm()
|
|
{
|
|
try
|
|
{
|
|
if (Config.transpond_send_usernames == null)
|
|
{
|
|
Config.transpond_send_usernames = new List<string>();
|
|
Config.transpond_send_usernames = Chat.Framework.ChatClient.WXClient.Values.ToList().Select(f => f.WeixinHao.Trim()).ToList();
|
|
}
|
|
|
|
if (mainForm == null || mainForm.IsDisposed)
|
|
{
|
|
mainForm = new MainForm();
|
|
mainForm.Show();
|
|
}
|
|
mainForm.TopMost = true;
|
|
mainForm.TopMost = false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
this.OnLog(ex.Message);
|
|
}
|
|
}
|
|
|
|
public override void Stop()
|
|
{
|
|
try
|
|
{
|
|
TimerTask.Close<MonitorThread>();
|
|
SessionExt.Clear();
|
|
if (mainForm != null)
|
|
{
|
|
mainForm.CloseForm();
|
|
mainForm = null;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
this.OnLog(ex.Message);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|