------ #### V1.0.2404.1201 - 新增支持手动运行规则。 - 规则播放时间间隔不再针对全局声效,而只针对当前规则声效。 - 修复规则中播放文件夹可能导致无法执行的BUG。 - 修复规则不勾选礼物和点赞,则无法执行的BUG。
183 lines
6.4 KiB
C#
183 lines
6.4 KiB
C#
using ryCommon;
|
|
using ryCommonDb;
|
|
using rySafe;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Net.NetworkInformation;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LiveTools
|
|
{
|
|
public class Config
|
|
{
|
|
public static bool InitCef { get; set; } = false;
|
|
public static int isAutoLogin = 0;
|
|
public static UserInfo UserInfo { get; set; } = new UserInfo();
|
|
public static string Api_Url = "http://reg.itjs.top/API/";
|
|
public static string SoftId = "LiveTools";
|
|
public static bool MustUpdate = false;
|
|
public static string NewVerUrl = "";
|
|
public static RyPostGet ry_api = new RyPostGet();
|
|
/// <summary>
|
|
/// 默认礼物特效
|
|
/// </summary>
|
|
public static bool GiftTrigger { get; set; } = true;
|
|
public static bool PlaySound { get; set; } = true;
|
|
/// <summary>
|
|
/// 是否允许多个声音同时播放
|
|
/// </summary>
|
|
public static bool MultiPlaySound { get; set; } = true;
|
|
public static int PicSize { get; set; } = 70;
|
|
public static int PicCount { get; set; } = 10;
|
|
/// <summary>
|
|
/// 礼物缓存
|
|
/// </summary>
|
|
public static Hashtable GiftCache { get; set; } = new Hashtable();
|
|
public static UsingLock<object> GiftLock { get; set; } = new UsingLock<object>();
|
|
public static void LoadSetting()
|
|
{
|
|
Json json = new Json(RyFiles.ReadAllText(Config.UserDbFolder + "\\Setting.json"));
|
|
GiftTrigger = json.GetJsonValue("GiftTrigger", true);
|
|
PlaySound = json.GetJsonValue("PlaySound", true);
|
|
MultiPlaySound = json.GetJsonValue("MultiPlaySound", true);
|
|
PicSize = json.GetJsonValue("PicSize", 70);
|
|
PicCount = json.GetJsonValue("PicCount", 10);
|
|
}
|
|
/// <summary>
|
|
/// 数据库完整路径
|
|
/// </summary>
|
|
public static string DbFullPath
|
|
{
|
|
get
|
|
{
|
|
return UserDbFolder + "\\MyDb.dat";
|
|
}
|
|
}
|
|
public static string GetCurrentFolder
|
|
{
|
|
get
|
|
{
|
|
return System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule?.FileName??"").TrimEnd('\\') ??"";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 系统数据文件夹
|
|
/// </summary>
|
|
public static string SysDbFolder
|
|
{
|
|
get
|
|
{
|
|
return GetCurrentFolder + "\\SysDb";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 所有用户数据文件夹
|
|
/// </summary>
|
|
public static string AllUserDbFolder
|
|
{
|
|
get
|
|
{
|
|
return GetCurrentFolder + "\\UserDb";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 用户数据文件夹
|
|
/// </summary>
|
|
public static string UserDbFolder
|
|
{
|
|
get
|
|
{
|
|
if(UserInfo.UserId.Length>0)
|
|
{
|
|
return GetCurrentFolder + "\\UserDb\\"+ UserInfo.UserId;
|
|
}
|
|
return GetCurrentFolder + "\\UserDb";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 创建数据库
|
|
/// </summary>
|
|
public static void CreateDb()
|
|
{
|
|
IDbInterface db = new SQLiteDataProvider();
|
|
if (db.ConnDb(DbFullPath) == 1)
|
|
{
|
|
#region 规则表
|
|
RyQuickSQL mySQL = new("Rules");
|
|
mySQL.AddField("RuleName", "");
|
|
mySQL.AddField("SortIndex", 0d);
|
|
mySQL.AddField("RuleJson", "");
|
|
mySQL.AddField("AddTime", 0L);
|
|
mySQL.AddField("EditTime", 0L);
|
|
db.CreateDb(mySQL);
|
|
#endregion
|
|
#region 直播表
|
|
mySQL.Clear();
|
|
mySQL.TableName = "Direct";
|
|
mySQL.AddField("Name", "");
|
|
mySQL.AddField("Platform", "");
|
|
mySQL.AddField("DirectId", "");
|
|
mySQL.AddField("DirectJson", "");
|
|
mySQL.AddField("AddTime", 0L);
|
|
mySQL.AddField("EditTime", 0L);
|
|
db.CreateDb(mySQL);
|
|
#endregion
|
|
//
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 为1表示登录
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static int IsLogin()
|
|
{
|
|
if (UserInfo.UserId.Length == 0)
|
|
{
|
|
return 0;
|
|
}
|
|
if (UserInfo.UserId.Length>0 && UserInfo.OutTime>=DateTime.Now.ToInt64())
|
|
{
|
|
return 1;
|
|
}
|
|
return -1;
|
|
}
|
|
public static string GetMac()
|
|
{
|
|
IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties();
|
|
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
|
|
// HostName = computerProperties.HostName;
|
|
Console.WriteLine("Interface information for {0}.{1} ",
|
|
computerProperties.HostName, computerProperties.DomainName);
|
|
if (nics == null || nics.Length < 1)
|
|
{
|
|
return "";
|
|
}
|
|
foreach (NetworkInterface adapter in nics)
|
|
{
|
|
IPInterfaceProperties properties = adapter.GetIPProperties(); // .GetIPInterfaceProperties();
|
|
string Description = adapter.Description;//接口的描述
|
|
string NetworkInterfaceType = adapter.NetworkInterfaceType.ToString();//获取接口类型
|
|
PhysicalAddress address = adapter.GetPhysicalAddress();//返回MAC地址
|
|
if (NetworkInterfaceType != "Loopback" && NetworkInterfaceType == "Ethernet")
|
|
|
|
return adapter.GetPhysicalAddress().ToString();
|
|
//byte[] bytes = address.GetAddressBytes();
|
|
//for (int i = 0; i < bytes.Length; i++)
|
|
//{
|
|
// //.ToString("X2") 将byte数组转换成字符串
|
|
// Console.Write("{0}", bytes[i].ToString("X2"));
|
|
// if (i != bytes.Length - 1)
|
|
// {
|
|
// Console.Write("-");
|
|
// }
|
|
//}
|
|
}
|
|
return "";
|
|
}
|
|
}
|
|
}
|