begin work on ircrobots
This commit is contained in:
parent
34991fa269
commit
71d6966ce8
|
@ -0,0 +1,7 @@
|
|||
namespace Robots
|
||||
{
|
||||
public class Client
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
namespace Robots
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,32 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRCRobots
|
||||
{
|
||||
public class Bot : IBot
|
||||
{
|
||||
public IServer CreateServer(string name)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<bool> Disconnected(IServer server)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task Disconnect(IServer server)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<IServer> AddServer(string name, ConnectionParams connectionParams)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task Run()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace IRCRobots
|
||||
{
|
||||
public class Capability : ICapability
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string DraftName { get; set; }
|
||||
public string Alias { get; }
|
||||
public IEnumerable<string> DependsOn { get; set; }
|
||||
private IEnumerable<string> Caps { get; }
|
||||
|
||||
public Capability()
|
||||
{
|
||||
Alias ??= Name;
|
||||
Caps = new List<string> {Name, DraftName};
|
||||
}
|
||||
|
||||
public string? Available(IEnumerable<string> capabilities)
|
||||
{
|
||||
return Caps.FirstOrDefault(cap => cap != null && capabilities.Contains(cap));
|
||||
}
|
||||
|
||||
public bool Match(string capability)
|
||||
{
|
||||
return Caps.Contains(capability);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
#nullable enable
|
||||
namespace IRCRobots
|
||||
{
|
||||
public class ConnectionParams
|
||||
{
|
||||
public string Nickname { get; set; }
|
||||
public string Host { get; set; }
|
||||
public int Port { get; set; }
|
||||
public bool UseTLS { get; set; }
|
||||
public string? Username { get; set; } = null;
|
||||
public string? Realname { get; set; } = null;
|
||||
public string? Bindhost { get; set; } = null;
|
||||
public string? Password { get; set; } = null;
|
||||
public bool VerifyTLS { get; set; } = true;
|
||||
public SASLParams? SASL { get; set; } = null;
|
||||
public STSPolicy? STS { get; set; } = null;
|
||||
public ResumePolicy? Resume { get; set; } = null;
|
||||
public int Reconnect { get; set; } = 10; // seconds
|
||||
public IEnumerable<string> AltNicknames { get; set; } = new List<string>();
|
||||
public IEnumerable<string> Autojoin { get; set; } = new List<string>();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRCRobots
|
||||
{
|
||||
public interface IBot
|
||||
{
|
||||
public IServer CreateServer(string name);
|
||||
public Task<bool> Disconnected(IServer server);
|
||||
public Task Disconnect(IServer server);
|
||||
public Task<IServer> AddServer(string name, ConnectionParams connectionParams);
|
||||
public Task Run();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IRCRobots
|
||||
{
|
||||
public interface ICapability
|
||||
{
|
||||
public string? Available(IEnumerable<string> capabilities);
|
||||
public bool Match(string capability);
|
||||
public string Copy() => "ICapability";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\IRCStates\IRCStates.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,34 @@
|
|||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using IRCTokens;
|
||||
|
||||
namespace IRCRobots
|
||||
{
|
||||
public interface IServer
|
||||
{
|
||||
public IEnumerable<SentLine> SendRaw(string line, SendPriority sendPriority = SendPriority.Default);
|
||||
public IEnumerable<SentLine> Send(Line line, SendPriority sendPriority = SendPriority.Default);
|
||||
public void SetThrottle(int rate, float time);
|
||||
public (string address, int port) ServerAddress();
|
||||
public Task Connect(ITCPTransport transport, ConnectionParams connectionParams);
|
||||
public Task Disconnect();
|
||||
public void LinePreread(Line line);
|
||||
public void LinePresend(Line line);
|
||||
public Task LineRead(Line line);
|
||||
public Task LineSend(Line line);
|
||||
public Task STSPolicy(STSPolicy stsPolicy);
|
||||
public Task ResumePolicy(ResumePolicy resumePolicy);
|
||||
public bool CapAgreed(ICapability capability);
|
||||
public string? CapAvailable(ICapability capability);
|
||||
public Task<bool> SASLAuth(SASLParams saslParams);
|
||||
}
|
||||
|
||||
public enum SendPriority
|
||||
{
|
||||
High = 0,
|
||||
Medium = 10,
|
||||
Low = 20,
|
||||
Default = Medium
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
#nullable enable
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRCRobots
|
||||
{
|
||||
public interface ITCPTransport
|
||||
{
|
||||
public Task Connect(string hostname, int port, bool useTLS, bool verifyTLS = true, string? bindhost = null);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace IRCRobots
|
||||
{
|
||||
public class MessageTag
|
||||
{
|
||||
public MessageTag()
|
||||
{
|
||||
Tags = new[] {Name, DraftName};
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public string DraftName { get; set; }
|
||||
public IEnumerable<string> Tags { get; }
|
||||
|
||||
public string? Available(IEnumerable<string> tags)
|
||||
{
|
||||
return Tags.FirstOrDefault(tag => tag != null && tags.Contains(tag));
|
||||
}
|
||||
|
||||
public string? Get(Dictionary<string, string> tags)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
namespace IRCRobots
|
||||
{
|
||||
public class ResumePolicy
|
||||
{
|
||||
public string Address { get; set; }
|
||||
public string Token { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace IRCRobots
|
||||
{
|
||||
public class SASLParams
|
||||
{
|
||||
public string Mechanism { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
namespace IRCRobots
|
||||
{
|
||||
public class STSPolicy
|
||||
{
|
||||
public int Created { get; set; }
|
||||
public int Port { get; set; }
|
||||
public int Duration { get; set; }
|
||||
public bool Preload { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using IRCTokens;
|
||||
|
||||
namespace IRCRobots
|
||||
{
|
||||
public class SentLine
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public SendPriority Priority { get; set; }
|
||||
public Line Line { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using IRCStates;
|
||||
using IRCTokens;
|
||||
|
||||
namespace IRCRobots
|
||||
{
|
||||
public class Server : IServer
|
||||
{
|
||||
private int SentCount { get; set; }
|
||||
|
||||
public IEnumerable<SentLine> SendRaw(string line, SendPriority sendPriority = SendPriority.Default)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<SentLine> Send(Line line, SendPriority sendPriority = SendPriority.Default)
|
||||
{
|
||||
LinePresend(line);
|
||||
var sentLine = new SentLine {Id = SentCount, Priority = sendPriority, Line = line};
|
||||
SentCount++;
|
||||
return new[] {sentLine};
|
||||
}
|
||||
|
||||
public void SetThrottle(int rate, float time)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public (string address, int port) ServerAddress()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task Connect(ITCPTransport transport, ConnectionParams connectionParams)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task Disconnect()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public void LinePreread(Line line)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public void LinePresend(Line line)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task LineRead(Line line)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task LineSend(Line line)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task STSPolicy(STSPolicy stsPolicy)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task ResumePolicy(ResumePolicy resumePolicy)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public bool CapAgreed(ICapability capability)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public string? CapAvailable(ICapability capability)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<bool> SASLAuth(SASLParams saslParams)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace IRCSharp.Tests.Robots
|
||||
{
|
||||
[TestClass]
|
||||
public class Glob
|
||||
{
|
||||
[TestMethod]
|
||||
public void GlobCollapse()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
13
IRCSharp.sln
13
IRCSharp.sln
|
@ -20,6 +20,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IRCSharp.Tests", "IRCSharp.
|
|||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{4260E03C-6E28-4519-8943-5B477841A75A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IRCRobots", "IRCRobots\IRCRobots.csproj", "{BACE834E-B190-46F1-8687-E994316FF768}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robots", "Examples\Robots\Robots.csproj", "{932066DD-A44A-47EA-94F5-D7847CAA8EC7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -46,6 +50,14 @@ Global
|
|||
{B420F0F3-1ED0-4FD3-9E91-2E7F96F9FF7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B420F0F3-1ED0-4FD3-9E91-2E7F96F9FF7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B420F0F3-1ED0-4FD3-9E91-2E7F96F9FF7F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BACE834E-B190-46F1-8687-E994316FF768}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BACE834E-B190-46F1-8687-E994316FF768}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BACE834E-B190-46F1-8687-E994316FF768}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BACE834E-B190-46F1-8687-E994316FF768}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{932066DD-A44A-47EA-94F5-D7847CAA8EC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{932066DD-A44A-47EA-94F5-D7847CAA8EC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{932066DD-A44A-47EA-94F5-D7847CAA8EC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{932066DD-A44A-47EA-94F5-D7847CAA8EC7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -53,6 +65,7 @@ Global
|
|||
GlobalSection(NestedProjects) = preSolution
|
||||
{A45DA39B-6B47-4713-8049-3B36E0235B67} = {4260E03C-6E28-4519-8943-5B477841A75A}
|
||||
{BC9F6696-9D83-4F7A-9E15-CE4D3626C1AF} = {4260E03C-6E28-4519-8943-5B477841A75A}
|
||||
{932066DD-A44A-47EA-94F5-D7847CAA8EC7} = {4260E03C-6E28-4519-8943-5B477841A75A}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {0B91F0EA-8564-4318-8EEC-ED0640475141}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SASL/@EntryIndexedValue">SASL</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=STS/@EntryIndexedValue">STS</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TLS/@EntryIndexedValue">TLS</s:String>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Autojoin/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Bindhost/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Realname/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
Loading…
Reference in New Issue