| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- using dodohold.core;
- namespace molilian.core
- {
- public class ReplacementRule
- {
- public class Rule
- {
- public class Condition
- {
- public string Value { get; set; }
- public string Operator { get; set; } = "equals";
- public bool Evaluate(string input)
- {
- return Operator switch
- {
- "equals" => input == Value,
- "contains" => input.Contains(Value),
- "startsWith" => input.StartsWith(Value),
- "endsWith" => input.EndsWith(Value),
- _ => false
- };
- }
- }
- public Condition When { get; set; }
- public string Then { get; set; }
- }
- public string Name { get; set; }
- public List<Rule> Rules { get; set; }
- public string Default { get; set; }
- internal object FirstOrDefault(Func<object, bool> value)
- {
- throw new NotImplementedException();
- }
- }
- public enum UrlAction
- {
- None = 0,
- Redirect = 1,
- Body = 2,
- JsonBody = 3,
- }
- public class DeeplinkParseRule
- {
- public UrlAction url_action { get; set; } = UrlAction.None;
- public string body_pattern { get; set; } = string.Empty;
- public string url_pattern { get; set; } = string.Empty;
- public string pattern { get; set; } = string.Empty;
- public string plugin { get; set; } = string.Empty;
- public List<string[]> replace { get; set; } = new();
- public string deeplink_template { get; set; } = string.Empty;
- public string prompt_text { get; set; } = string.Empty;
- public bool enable { get; set; } = true;
- public List<DeeplinkParseRule> childs { get; set; } = new();
- public List<DeeplinkResources> resources { get; set; } = new();
- public List<ReplacementRule> replacements { get; set; } = new();
- }
- /// <summary>
- /// "resources": [
- /// {
- /// "name": "info",
- /// "url_pattern": "https://api.my.tv.sohu.com/forward/api/h5/getForwardInfo?callback=jsonpx1730973492613_41_1&forward_id={1}",
- /// "url_action": 2,
- /// "pattern": [
- /// "{\"commentDigg\":{\"id\":\"(\\d+)\"",
- /// "\"comment_id\":\"(\\d+)\""
- /// ]
- /// }
- /// ]
- /// </summary>
- public class DeeplinkResources
- {
- public string name { get; set; } = string.Empty;
- public string url_pattern { get; set; } = string.Empty;
- public UrlAction url_action { get; set; } = UrlAction.None;
- public List<string> pattern { get; set; } = [];
- public bool enable { get; set; } = true;
- }
- [Table("deeplink_parse_rule")]
- public class DeeplinkParseRuleDTO
- {
- [Key]
- public int id { get; set; }
- public int channel_id { get; set; } = 0;
- public int push_channel_id { get; set; } = 0;
- public string channel_name { get; set; } = string.Empty;
- public string name { get; set; } = string.Empty;
- public string logo { get; set; } = string.Empty;
- public string rules { get; set; } = string.Empty;
- public string IgnorePercentageCity { get; set; } = string.Empty;
- public bool status { get; set; } = false;
- public DateTime create_time { get; set; } = DateTime.Now;
- [IgnoreUpdate]
- public DateTime last_time { get; set; } = DateTime.Now;
- }
- }
|