tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
ChatBotSettings.cs
Go to the documentation of this file.
1using System;
2using System.ComponentModel.DataAnnotations;
3
5{
9 public abstract class ChatBotSettings : NamedEntity
10 {
14 public bool? Enabled { get; set; }
15
19 [Required]
20 [Range(1, UInt32.MaxValue)]
21 public uint? ReconnectionInterval { get; set; }
22
26 [Required]
27 public ushort? ChannelLimit { get; set; }
28
32 [Required]
33 [RequestOptions(FieldPresence.Required, PutOnly = true)]
34 [EnumDataType(typeof(ChatProvider))]
35 public ChatProvider? Provider { get; set; }
36
40 [Required]
41 [RequestOptions(FieldPresence.Required, PutOnly = true)]
42 [ResponseOptions]
43 [StringLength(Limits.MaximumStringLength)]
44 public string? ConnectionString { get; set; }
45
51 {
52 if (ConnectionString == null)
53 return null;
54 return Provider switch
55 {
56 ChatProvider.Discord => new DiscordConnectionStringBuilder(ConnectionString),
57 ChatProvider.Irc => new IrcConnectionStringBuilder(ConnectionString),
58 _ => throw new InvalidOperationException("Invalid Provider!"),
59 };
60 }
61
67 {
68 ConnectionString = stringBuilder?.ToString() ?? throw new ArgumentNullException(nameof(stringBuilder));
69 }
70 }
71}
ChatConnectionStringBuilder for ChatProvider.Discord.
ushort? ChannelLimit
The maximum number of ChatChannels the ChatBotSettings may contain.
string? ConnectionString
The information used to connect to the Provider.
ChatProvider? Provider
The ChatProvider used for the connection.
uint? ReconnectionInterval
The time interval in minutes the chat bot attempts to reconnect if Enabled and disconnected....
void SetConnectionStringBuilder(ChatConnectionStringBuilder stringBuilder)
Set the ChatConnectionStringBuilder for the ChatBotSettings. Also updates the ConnectionString.
ChatConnectionStringBuilder? CreateConnectionStringBuilder()
Get the ChatConnectionStringBuilder which maps to the ConnectionString.
Helper for building ChatBotSettings.ConnectionStrings.
override string ToString()
Gets the ChatBotSettings.ConnectionString associated with the ChatConnectionStringBuilder.
ChatConnectionStringBuilder for ChatProvider.Irc.
Sanity limits to prevent users from overloading.
Definition Limits.cs:9
const int MaximumStringLength
Length limit for strings in fields.
Definition Limits.cs:13
Base class for named entities.
Definition NamedEntity.cs:9
FieldPresence
Indicates whether a request field is Required or Ignored.
ChatProvider
Represents a chat service provider.
@ Required
DMAPI validation must suceed for the deployment to succeed.