2017-08-24 05:57:31 +00:00
using FluentValidation ;
2016-09-24 19:22:57 +00:00
using NzbDrone.Core.Annotations ;
using NzbDrone.Core.ThingiProvider ;
using NzbDrone.Core.Validation ;
namespace NzbDrone.Core.Notifications.Telegram
{
public class TelegramSettingsValidator : AbstractValidator < TelegramSettings >
{
public TelegramSettingsValidator ( )
{
RuleFor ( c = > c . BotToken ) . NotEmpty ( ) ;
RuleFor ( c = > c . ChatId ) . NotEmpty ( ) ;
}
}
public class TelegramSettings : IProviderConfig
{
private static readonly TelegramSettingsValidator Validator = new TelegramSettingsValidator ( ) ;
[FieldDefinition(0, Label = "Bot Token", HelpLink = "https://core.telegram.org/bots")]
public string BotToken { get ; set ; }
2017-08-24 05:57:31 +00:00
[FieldDefinition(1, Label = "Chat ID", HelpLink = "http://stackoverflow.com/a/37396871/882971", HelpText = "You must start a conversation with the bot or add it to your group to receive messages")]
2016-09-24 19:22:57 +00:00
public string ChatId { get ; set ; }
2016-12-09 06:54:15 +00:00
public bool IsValid = > ! string . IsNullOrWhiteSpace ( ChatId ) & & ! string . IsNullOrWhiteSpace ( BotToken ) ;
2016-09-24 19:22:57 +00:00
public NzbDroneValidationResult Validate ( )
{
return new NzbDroneValidationResult ( Validator . Validate ( this ) ) ;
}
}
}