public object ConvertType(string value, BotCommandPropertyType type)
 {
     return(type switch
     {
         BotCommandPropertyType.Time => ToTimeSpan(value),
         BotCommandPropertyType.Number => int.Parse(value),//TODO add more types
         _ => value
     });
 public object ConvertType(string value, BotCommandPropertyType type)
 {
     return(type switch
     {
         BotCommandPropertyType.Time => this.ToTimeSpan(value),
         BotCommandPropertyType.Number => int.Parse(value),
         BotCommandPropertyType.Bool => bool.Parse(value),
         BotCommandPropertyType.UserMention => ulong.Parse(_exMention.Match(value).Value),
         BotCommandPropertyType.ChannelMention => ulong.Parse(_exMention.Match(value).Value),
         _ => value
     });
 private bool IsMatchedPropertyType(string value, BotCommandPropertyType type)
 {
     if (type == BotCommandPropertyType.Number && !int.TryParse(value, out _))
     {
         return false;
     }
     if (type == BotCommandPropertyType.Time && !this._exTime.IsMatch(value))
     {
         return false;
     }
     if (type == BotCommandPropertyType.UserMention || type == BotCommandPropertyType.ChannelMention && !this._exMention.IsMatch(value))
     {
         return false;
     }
     if (type == BotCommandPropertyType.SingleWord && value.Contains(' '))
     {
         return false;
     }
     return true;
 }
Пример #4
0
 public BotCommandProperty(string name, BotCommandPropertyType type, bool isOptional)
 {
     this.Name       = name;
     this.Type       = type;
     this.IsOptional = isOptional;
 }
Пример #5
0
 public BotCommandProperty(string name, BotCommandPropertyType type, bool isOptional)
 {
     Name       = name;
     Type       = type;
     IsOptional = isOptional;
 }