using NadekoBot.Db.Models; namespace NadekoBot.Modules.Searches.Common.StreamNotifications.Providers; /// /// Abstract class implemented by providers of all supported platforms /// public abstract class Provider { /// /// Type of the platform. /// public abstract FollowedStream.FType Platform { get; } /// /// Gets the stream usernames which fail to execute due to an error, and when they started throwing errors. /// This can happen if stream name is invalid, or if the stream doesn't exist anymore. /// Override to provide a custom implementation /// public virtual IReadOnlyDictionary FailingStreams => _failingStreams; /// /// When was the first time the stream continually had errors while being retrieved /// protected readonly ConcurrentDictionary _failingStreams = new(); /// /// Checks whether the specified url is a valid stream url for this platform. /// /// Url to check /// True if valid, otherwise false public abstract Task IsValidUrl(string url); /// /// Gets stream data of the stream on the specified url on this /// /// Url of the stream /// of the specified stream. Null if none found public abstract Task GetStreamDataByUrlAsync(string url); /// /// Gets stream data of the specified id/username on this /// /// Name (or id where applicable) of the user on the platform /// of the user. Null if none found public abstract Task GetStreamDataAsync(string login); /// /// Gets stream data of all specified ids/usernames on this /// /// List of ids/usernames /// of all users, in the same order. Null for every id/user not found. public abstract Task> GetStreamDataAsync(List usernames); /// /// Unmark the stream as errored. You should override this method /// if you've overridden the property. /// /// public virtual void ClearErrorsFor(string login) => _failingStreams.Clear(); }