<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Tgstation.Server.Api.Models
{
	/// <inheritdoc />
	public sealed class ChatBot : Internal.ChatBot
	{
		/// <summary>
		/// Channels the Discord bot should listen/announce in
		/// </summary>
		public List<ChatChannel> Channels { get; set; }

		/// <summary>
		/// Validates <see cref="Channels"/> are correct for the <see cref="Internal.ChatBot.Provider"/>
		/// </summary>
		/// <returns></returns>
		public bool ValidateProviderChannelTypes()
		{
			switch (Provider)
			{
				case ChatProvider.Discord:
					return Channels.Select(x => x.DiscordChannelId.HasValue && x.IrcChannel == null).All(x => x);
				case ChatProvider.Irc:
					return Channels.Select(x => !x.DiscordChannelId.HasValue && x.IrcChannel != null).All(x => x);
				default:
					throw new InvalidOperationException("Invalid provider type!");
			}
		}
	}
}<commit_msg>Fix NullReferenceException in ValidateProviderChannelTypes()<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Tgstation.Server.Api.Models
{
	/// <inheritdoc />
	public sealed class ChatBot : Internal.ChatBot
	{
		/// <summary>
		/// Channels the Discord bot should listen/announce in
		/// </summary>
		public List<ChatChannel> Channels { get; set; }

		/// <summary>
		/// Validates <see cref="Channels"/> are correct for the <see cref="Internal.ChatBot.Provider"/>
		/// </summary>
		/// <returns></returns>
		public bool ValidateProviderChannelTypes()
		{
			switch (Provider)
			{
				case ChatProvider.Discord:
					return Channels?.Select(x => x.DiscordChannelId.HasValue && x.IrcChannel == null).All(x => x) ?? true;
				case ChatProvider.Irc:
					return Channels?.Select(x => !x.DiscordChannelId.HasValue && x.IrcChannel != null).All(x => x) ?? true;
				default:
					throw new InvalidOperationException("Invalid provider type!");
			}
		}
	}
}
{'fraction_non_alphanumeric': 0.1472265422498704, 'fraction_numerical': 0.0, 'mean_word_length': 3.5093457943925235, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2000409', 'n_tokens_mistral': 668, 'n_tokens_neox': 591, 'n_words': 139}