old_flsystem/应用/提取xml连接/Class1.cs

101 lines
2.8 KiB
C#
Raw Permalink Normal View History

2022-09-20 03:10:29 +00:00
using Api.Framework.SDK;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using xml连接.Properties;
namespace xml连接
{
public class Class1 : Plugin
{
public Class1()
{
this.Logo = Resources.Lark20210414_110119;
this.Name = "xml提取地址";
this.Note = "xml提取地址";
}
#region
public static Config Config;
private MainForm mainForm = null;
#endregion
public override void Start()
{
Config = this.ReadConfig<Config>();
SDK.ReciveIMEvent += SDK_ReciveIMEvent;
}
#region
private void SDK_ReciveIMEvent(object sender, ReciveIMEvent e)
{
try
{
if (e.Message.Trim().Contains("<appmsg"))
{
var url = string.Empty;
var reg = Regex.Match(e.Message, @"((?:<pagepath>(?<链接>[\w\W]+?)</pagepath>)|(?:<url>(?<链接>[\w\W]+?)</url>))", RegexOptions.IgnoreCase | RegexOptions.Multiline);
if (reg.Success)
{
var strb = new StringBuilder();
strb.AppendLine($"用户:{e.NickName}({e.Username})");
strb.AppendLine($"提取:{reg.Groups[""].Value.Replace("<![CDATA[", "").Replace("]]>", "")}");
strb.AppendLine($"时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
if (Config.usernames.Contains(e.Username))
{
e.SendMessage(strb.ToString());
}
else
this.OnLog(strb.ToString());
}
}
}
catch (Exception ex)
{
this.OnLog(ex.Message);
}
}
#endregion
public override void ShowForm()
{
try
{
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
{
if (mainForm != null)
{
mainForm.CloseForm();
mainForm = null;
}
}
catch (Exception ex)
{
this.OnLog(ex.Message);
}
}
}
}