diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index b03b75a..505588d 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,44 +1,44 @@
-name: FosscordSharp CI
-
-on:
- push:
- branches: [ master ]
- pull_request:
- branches: [ master ]
-
-jobs:
- build:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - name: Setup .NET Core
- uses: actions/setup-dotnet@v1
- with:
- dotnet-version: '5.0.x'
- - name: Discord webhook
- run: |
- curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST --data "{\"content\": \"<:fox_wave_duckmaster:900151686616715306> New commit by $GITHUB_ACTOR: [commit]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$GITHUB_SHA), [run](<$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID?check_suite_focus=true>)\"}" ${{ secrets.DISCORD_WEBHOOK }}
- curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST --data "{\"content\": \"<:fox_wave_duckmaster:900151686616715306> New commit by $GITHUB_ACTOR: [commit]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$GITHUB_SHA), [run](<$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID?check_suite_focus=true>)\"}" ${{ secrets.DISCORD_WEBHOOK2 }}
- - name: Install dependencies
- run: dotnet restore
- - name: Build
- run: dotnet build --configuration Release --no-restore
- - name: Test
- run: dotnet test
- - name: Publish
- run: |
- rm -rf *.nupkg
- dotnet pack --nologo --version-suffix preview$GITHUB_RUN_ID.$(git rev-parse --short HEAD) -o . FosscordSharp
- dotnet nuget push $(ls *.nupkg) -k ${{ secrets.NUGET_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- if: ${{ success() }}
- - name: Publish success
- run: |
- curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST --data "{\"content\": \"<:foxSip:899416354728329217> Build, test and publish successful! ([See run](<$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID?check_suite_focus=true>))\"}" ${{ secrets.DISCORD_WEBHOOK }}
- curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST --data "{\"content\": \"<:foxSip:899416354728329217> Build, test and publish successful! ([See run](<$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID?check_suite_focus=true>))\"}" ${{ secrets.DISCORD_WEBHOOK2 }}
- if: ${{ success() }}
- - name: Publish failure
- run: |
- curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST --data "{\"content\": \"<:fox_cry_storfus:900093667405070396> Build, test or publish failed! ([See run](<$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID?check_suite_focus=true>))\"}" ${{ secrets.DISCORD_WEBHOOK }}
- curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST --data "{\"content\": \"<:fox_cry_storfus:900093667405070396> Build, test or publish failed! ([See run](<$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID?check_suite_focus=true>))\"}" ${{ secrets.DISCORD_WEBHOOK2 }}
- if: ${{ failure() }}
+name: FosscordSharp CI
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup .NET Core
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: '5.0.x'
+ - name: Discord webhook
+ run: |
+ curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST --data "{\"content\": \"<:fox_wave_duckmaster:900151686616715306> New commit by $GITHUB_ACTOR: [commit]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$GITHUB_SHA), [run](<$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID?check_suite_focus=true>)\"}" ${{ secrets.DISCORD_WEBHOOK }}
+ curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST --data "{\"content\": \"<:fox_wave_duckmaster:900151686616715306> New commit by $GITHUB_ACTOR: [commit]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$GITHUB_SHA), [run](<$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID?check_suite_focus=true>)\"}" ${{ secrets.DISCORD_WEBHOOK2 }}
+ - name: Install dependencies
+ run: dotnet restore
+ - name: Build
+ run: dotnet build --configuration Release --no-restore
+ - name: Test
+ run: dotnet test
+ - name: Publish
+ run: |
+ rm -rf *.nupkg
+ dotnet pack --nologo --version-suffix preview$GITHUB_RUN_ID.$(git rev-parse --short HEAD) -o . FosscordSharp
+ dotnet nuget push $(ls *.nupkg) -k ${{ secrets.NUGET_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
+ if: ${{ success() }}
+ - name: Publish success
+ run: |
+ curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST --data "{\"content\": \"<:foxSip:899416354728329217> Build, test and publish successful! ([See run](<$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID?check_suite_focus=true>))\"}" ${{ secrets.DISCORD_WEBHOOK }}
+ curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST --data "{\"content\": \"<:foxSip:899416354728329217> Build, test and publish successful! ([See run](<$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID?check_suite_focus=true>))\"}" ${{ secrets.DISCORD_WEBHOOK2 }}
+ if: ${{ success() }}
+ - name: Publish failure
+ run: |
+ curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST --data "{\"content\": \"<:fox_cry_storfus:900093667405070396> Build, test or publish failed! ([See run](<$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID?check_suite_focus=true>))\"}" ${{ secrets.DISCORD_WEBHOOK }}
+ curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST --data "{\"content\": \"<:fox_cry_storfus:900093667405070396> Build, test or publish failed! ([See run](<$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID?check_suite_focus=true>))\"}" ${{ secrets.DISCORD_WEBHOOK2 }}
+ if: ${{ failure() }}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 679e883..9650b34 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,3 @@
-.idea/
-obj/
-bin/
+.idea/
+obj/
+bin/
diff --git a/FosscordSharp.ExampleBot/FosscordSharp.ExampleBot.csproj b/FosscordSharp.ExampleBot/FosscordSharp.ExampleBot.csproj
index 97d415e..036b381 100644
--- a/FosscordSharp.ExampleBot/FosscordSharp.ExampleBot.csproj
+++ b/FosscordSharp.ExampleBot/FosscordSharp.ExampleBot.csproj
@@ -1,17 +1,17 @@
-
-
-
- Exe
- net5.0
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ Exe
+ net5.0
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FosscordSharp.ExampleBot/Program.cs b/FosscordSharp.ExampleBot/Program.cs
index ad66824..f2c1fdf 100644
--- a/FosscordSharp.ExampleBot/Program.cs
+++ b/FosscordSharp.ExampleBot/Program.cs
@@ -1,175 +1,183 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using FosscordSharp.Entities;
-using FosscordSharp.EventArgs;
-using Microsoft.VisualBasic;
-
-namespace FosscordSharp.ExampleBot
-{
- class Program
- {
- private static Dictionary clients = new();
- static void Main(string[] args)
- {
- if(!File.Exists("instances.txt")) File.WriteAllText("instances.txt", "https://dev.fosscord.com\nhttps://fosscord.thearcanebrony.net\n");
- foreach (var inst in File.ReadAllLines("instances.txt"))
- {
- Run(inst);
- }
- Thread.Sleep(int.MaxValue);
- }
- static async void Run(string endpoint)
- {
- FosscordClient client;
- clients.Add(endpoint, client = new FosscordClient(new()
- {
- // Email = $"FosscordSharp{Environment.TickCount64}@example.com",
- Email = $"FosscordSharpDev@example.com",
- Password = "FosscordSharp",
- // Endpoint = "https://dev.fosscord.com",
- // Endpoint = "https://fosscord.thearcanebrony.net",
- Endpoint = endpoint,
- Verbose = false,
- ShouldRegister = true,
- RegistrationOptions =
- {
- Username = "FosscordSharp Example Bot",
- DateOfBirth = "1969-01-01",
- CreateBotGuild = true
- },
- PollMessages = false
- }));
- await client.Login();
- User botUser = await client.GetCurrentUser();
- Console.WriteLine($"Logged in as {botUser.Username}#{botUser.Discriminator} ({botUser.Id})!");
- client.MessageReceived += ClientOnMessageReceived;
- Guild[] guilds = await client.GetGuilds();
- Console.WriteLine($"I am in {guilds.Length} guilds");
- try
- {
- await client.JoinGuild("qFlTsl");
- } catch { }
- guilds = await client.GetGuilds();
- Console.WriteLine($"I am in {guilds.Length} guilds*");
- foreach (var guild in guilds)
- {
- Console.WriteLine($" - {guild.Name} ({guild.Id})");
- Channel[] channels = await guild.GetChannels();
- foreach (var channel in channels)
- {
- Console.WriteLine($" - {channel.Name} ({channel.Id})");
- }
- }
- }
-
- private static async void ClientOnMessageReceived(object? sender, MessageReceivedEventArgs e)
- {
- Console.WriteLine("Message received: "+e.Message.Content);
- if (e.Message.Content.StartsWith("!"))
- {
- var guild = await e.Client.GetGuild(e.Message.GuildId);
- var channel = await guild.GetChannel(e.Message.ChannelId);
- var _ = e.Message.Content.Split(" ");
- var command = _[0][1..];
- var args = _.Skip(1).ToArray();
- switch (command)
- {
- case "help":
- await channel.SendMessage("Fosscord Example Bot command list:\n" +
- "```diff\n" +
- " - ping: Pong!\n" +
- " - avatar: Get avatar url.\n" +
- " - guildlist: Get guild + channel list.\n" +
- " - botinfo: show info about the bot and its environment.\n" +
- " - joinguild: join guild by invite on current instance.\n" +
- " - joininstance: join instance.\n" +
- "```");
- break;
- case "ping":
- await channel.SendMessage("pong!");
- break;
- case "avatar":
- await channel.SendMessage($"Your avatar url: {e.Message.Author.AvatarUrl}");
- break;
- case "guildlist":
- string msg = "Guild list:\n";
- foreach (var gui in await e.Client.GetGuilds())
- {
- msg += $"- {gui.Name}\n";
- foreach (var c in await gui.GetChannels())
- {
- msg += $" - {c.Name}: {(c.Type == 0 ? (await c.CreateInvite()).FullUrl : "")}\n";
- }
- }
-
- await channel.SendMessage(msg);
- break;
- case "globaltree":
- foreach (var client in clients)
- {
- string globaltree = "Guild list:\n";
- foreach (var gu in await client.Value.GetGuilds())
- {
- globaltree += $"- {gu.Name}\n";
- foreach (var c in await gu.GetChannels())
- {
- globaltree += $" - {c.Name}: {(c.Type == 0 ? (await c.CreateInvite()).FullUrl : "")}\n";
- }
- }
-
- await channel.SendMessage(globaltree);
- }
-
- break;
- case "botinfo":
- await channel.SendMessage($"Bot info:\n" +
- $".NET version: {Environment.Version}\n" +
- $"FosscordSharp version: {RuntimeInfo.LibVersion}\n" +
- $"Guild count: {(await e.Client.GetGuilds()).Length} (instance), {clients.Sum(x=>(x.Value.GetGuilds().Result.Length))} (bot)\n" +
- $"Instance count: {clients.Count}");
- break;
- case "joinguild":
- if (args.Length != 1)
- {
- await channel.SendMessage("This command takes one argument!");
- break;
- }
- await e.Client.JoinGuild(args[0].Split("/").Last());
- break;
- case "joininstance":
- if (args.Length != 1)
- {
- await channel.SendMessage("This command takes one argument!");
- break;
- }
- File.AppendAllText("instances.txt", args[0]+"\n");
- Run(args[0]);
- break;
- case "testguild":
- var g = await e.Client.CreateGuild("Test Guild - Delete me");
- await channel.SendMessage((await (await g.GetChannels())[0].CreateInvite()).Code);
- List categories = new();
- for (int i = 0; i < 4; i++)
- {
- categories.Add(await g.CreateChannel("Category "+i));
- }
-
- foreach (var cat in categories)
- {
- for (int i = 0; i < 10; i++)
- {
- g.CreateChannel($"channel" + i, parent: cat.Id);
- }
- }
- break;
- default: break;
- }
-
- }
- }
- }
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using FosscordSharp.Entities;
+using FosscordSharp.EventArgs;
+using Microsoft.VisualBasic;
+
+namespace FosscordSharp.ExampleBot
+{
+ class Program
+ {
+ private static Dictionary clients = new();
+ static void Main(string[] args)
+ {
+ if(!File.Exists("instances.txt")) File.WriteAllText("instances.txt", "https://dev.fosscord.com\nhttps://fosscord.thearcanebrony.net\n");
+ foreach (var inst in File.ReadAllLines("instances.txt"))
+ {
+ Run(inst);
+ }
+ Thread.Sleep(int.MaxValue);
+ }
+
+ private static Random rnd = new Random();
+ static async void Run(string endpoint)
+ {
+ FosscordClient client;
+ clients.Add(endpoint, client = new FosscordClient(new()
+ {
+ // Email = $"FosscordSharp{Environment.TickCount64}@example.com",
+ Email = $"FosscordSharpDev@example.com",
+ Password = "FosscordSharp",
+ // Endpoint = "https://dev.fosscord.com",
+ // Endpoint = "https://fosscord.thearcanebrony.net",
+ Endpoint = endpoint,
+ Verbose = false,
+ ShouldRegister = true,
+ RegistrationOptions =
+ {
+ Username = "FosscordSharp Example Bot",
+ DateOfBirth = "1969-01-01",
+ CreateBotGuild = true
+ },
+ PollMessages = true
+ }));
+ await client.Login();
+ User botUser = await client.GetCurrentUser();
+ Console.WriteLine($"Logged in as {botUser.Username}#{botUser.Discriminator} ({botUser.Id})!");
+ client.MessageReceived += ClientOnMessageReceived;
+ Guild[] guilds = await client.GetGuilds();
+ Console.WriteLine($"I am in {guilds.Length} guilds");
+ try
+ {
+ await client.JoinGuild("qFlTsl");
+ } catch { }
+ guilds = await client.GetGuilds();
+ Console.WriteLine($"I am in {guilds.Length} guilds*");
+ foreach (var guild in guilds)
+ {
+ Console.WriteLine($" - {guild.Name} ({guild.Id})");
+ Channel[] channels = await guild.GetChannels();
+ foreach (var channel in channels)
+ {
+ Console.WriteLine($" - {channel.Name} ({channel.Id})");
+ new Thread(() => {
+ while (true) {
+ channel.SendMessage("hi hello");
+ Thread.Sleep(rnd.Next(2000));
+ }
+ }).Start();
+ }
+ }
+ }
+
+ private static async void ClientOnMessageReceived(object? sender, MessageReceivedEventArgs e)
+ {
+ Console.WriteLine("Message received: "+e.Message.Content);
+ if (e.Message.Content.StartsWith("!"))
+ {
+ var guild = await e.Client.GetGuild(e.Message.GuildId);
+ var channel = await guild.GetChannel(e.Message.ChannelId);
+ var _ = e.Message.Content.Split(" ");
+ var command = _[0][1..];
+ var args = _.Skip(1).ToArray();
+ switch (command)
+ {
+ case "help":
+ await channel.SendMessage("Fosscord Example Bot command list:\n" +
+ "```diff\n" +
+ " - ping: Pong!\n" +
+ " - avatar: Get avatar url.\n" +
+ " - guildlist: Get guild + channel list.\n" +
+ " - botinfo: show info about the bot and its environment.\n" +
+ " - joinguild: join guild by invite on current instance.\n" +
+ " - joininstance: join instance.\n" +
+ "```");
+ break;
+ case "ping":
+ await channel.SendMessage("pong!");
+ break;
+ case "avatar":
+ await channel.SendMessage($"Your avatar url: {e.Message.Author.AvatarUrl}");
+ break;
+ case "guildlist":
+ string msg = "Guild list:\n";
+ foreach (var gui in await e.Client.GetGuilds())
+ {
+ msg += $"- {gui.Name}\n";
+ foreach (var c in await gui.GetChannels())
+ {
+ msg += $" - {c.Name}: {(c.Type == 0 ? (await c.CreateInvite()).FullUrl : "")}\n";
+ }
+ }
+
+ await channel.SendMessage(msg);
+ break;
+ case "globaltree":
+ foreach (var client in clients)
+ {
+ string globaltree = "Guild list:\n";
+ foreach (var gu in await client.Value.GetGuilds())
+ {
+ globaltree += $"- {gu.Name}\n";
+ foreach (var c in await gu.GetChannels())
+ {
+ globaltree += $" - {c.Name}: {(c.Type == 0 ? (await c.CreateInvite()).FullUrl : "")}\n";
+ }
+ }
+
+ await channel.SendMessage(globaltree);
+ }
+
+ break;
+ case "botinfo":
+ await channel.SendMessage($"Bot info:\n" +
+ $".NET version: {Environment.Version}\n" +
+ $"FosscordSharp version: {RuntimeInfo.LibVersion}\n" +
+ $"Guild count: {(await e.Client.GetGuilds()).Length} (instance), {clients.Sum(x=>(x.Value.GetGuilds().Result.Length))} (bot)\n" +
+ $"Instance count: {clients.Count}");
+ break;
+ case "joinguild":
+ if (args.Length != 1)
+ {
+ await channel.SendMessage("This command takes one argument!");
+ break;
+ }
+ await e.Client.JoinGuild(args[0].Split("/").Last());
+ break;
+ case "joininstance":
+ if (args.Length != 1)
+ {
+ await channel.SendMessage("This command takes one argument!");
+ break;
+ }
+ File.AppendAllText("instances.txt", args[0]+"\n");
+ Run(args[0]);
+ break;
+ case "testguild":
+ var g = await e.Client.CreateGuild("Test Guild - Delete me");
+ await channel.SendMessage((await (await g.GetChannels())[0].CreateInvite()).Code);
+ List categories = new();
+ for (int i = 0; i < 4; i++)
+ {
+ categories.Add(await g.CreateChannel("Category "+i));
+ }
+
+ foreach (var cat in categories)
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ g.CreateChannel($"channel" + i, parent: cat.Id);
+ }
+ }
+ break;
+ default: break;
+ }
+
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/FosscordSharp.InstanceTest/FosscordSharp.InstanceTest.csproj b/FosscordSharp.InstanceTest/FosscordSharp.InstanceTest.csproj
new file mode 100644
index 0000000..172aea0
--- /dev/null
+++ b/FosscordSharp.InstanceTest/FosscordSharp.InstanceTest.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/FosscordSharp.InstanceTest/Program.cs b/FosscordSharp.InstanceTest/Program.cs
new file mode 100644
index 0000000..2d6e81e
--- /dev/null
+++ b/FosscordSharp.InstanceTest/Program.cs
@@ -0,0 +1,3 @@
+// See https://aka.ms/new-console-template for more information
+
+Console.WriteLine("Hello, World!");
\ No newline at end of file
diff --git a/FosscordSharp.Test/FosscordSharp.Test.csproj b/FosscordSharp.Test/FosscordSharp.Test.csproj
index bfb1443..1e7902d 100644
--- a/FosscordSharp.Test/FosscordSharp.Test.csproj
+++ b/FosscordSharp.Test/FosscordSharp.Test.csproj
@@ -1,21 +1,21 @@
-
-
-
- Exe
- net5.0
- enable
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ Exe
+ net5.0
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FosscordSharp.Test/Program.cs b/FosscordSharp.Test/Program.cs
index 5146dcd..8d03c08 100644
--- a/FosscordSharp.Test/Program.cs
+++ b/FosscordSharp.Test/Program.cs
@@ -1,92 +1,92 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Net;
-using System.Threading;
-using System.Threading.Tasks;
-using ArcaneLibs;
-using ArcaneLibs.Logging;
-using ArcaneLibs.Logging.LogEndpoints;
-using FosscordSharp.Entities;
-using Microsoft.VisualBasic;
-using Newtonsoft.Json;
-
-namespace FosscordSharp.Test
-{
- class Program
- {
- private static LogManager stdout = new LogManager();
- private static LogManager stderr = new LogManager();
- private static LogManager stddbg = new LogManager();
- static void Main(string[] args)
- {
- Console.WriteLine("Hello World!");
- stdout.AddEndpoint(new ConsoleEndpoint());
- stdout.AddEndpoint(new FileEndpoint("out.txt", false));
- stderr.AddEndpoint(new DebugEndpoint());
- stderr.AddEndpoint(new FileEndpoint("err.txt", false));
- stderr.AddEndpoint(new DebugEndpoint());
- stderr.AddEndpoint(new FileEndpoint("dbg.txt", false));
- run();
- Thread.Sleep(int.MaxValue);
- }
-
- static async Task run()
- {
- Random rnd = new Random();
-
- FosscordClient fc = new FosscordClient(new()
- {
- Email = "FosscordSharp@test.bot",
- // Password = File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)+"/.ssh/id_rsa.pub"),
- Password = "SomePassword",
- Endpoint = "https://fosscord.thearcanebrony.net",
- // Endpoint = "http://localhost:3001",
- RegistrationOptions =
- {
- Username = "FosscordSharp Example Bot",
- DateOfBirth = "1969-01-01"
- },
- Verbose = false,
- PollMessages = true,
- ShouldRegister = true
- });
- await fc.Login();
- List invites = new();
- for (int i = 0; i < 10; i++)
- {
- FosscordClient client = new(new()
- {
- Email = $"FosscordSharp{rnd.Next()}@test.bot",
- Password = "SomePassword",
- Endpoint = "https://fosscord.thearcanebrony.net",
- RegistrationOptions =
- {
- Username = "FosscordSharp Test Bot"
- }
- });
- await client.Login();
- invites.Add((await (await (await client.CreateGuild($"FC#{i}:")).GetChannels())[0].CreateInvite(1000)).Code);
- }
-
- foreach (var invite in invites)
- {
- await fc.JoinGuild(invite);
- }
- var gs = await fc.GetGuilds();
- stddbg.Log("Got guilds!");
- foreach (var g in gs)
- {
- stdout.Log($"{g.Name}: ");
- var cs = await g.GetChannels();
- foreach (var c in await g.GetChannels())
- {
- stdout.Log($"- {c.Name}: {(await c.CreateInvite()).FullUrl} ({(await c.GetMessages()).Length} messages)");
- stddbg.Log((await c.SendMessage("Hi from FosscordSharp!")).Id+"");
- await (await c.SendMessage("Hi from FosscordSharp!")).Delete();
- }
- }
- stdout.Log(fc.GetGuilds().Result.Length + " guilds");
- }
- }
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net;
+using System.Threading;
+using System.Threading.Tasks;
+using ArcaneLibs;
+using ArcaneLibs.Logging;
+using ArcaneLibs.Logging.LogEndpoints;
+using FosscordSharp.Entities;
+using Microsoft.VisualBasic;
+using Newtonsoft.Json;
+
+namespace FosscordSharp.Test
+{
+ class Program
+ {
+ private static LogManager stdout = new LogManager();
+ private static LogManager stderr = new LogManager();
+ private static LogManager stddbg = new LogManager();
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello World!");
+ stdout.AddEndpoint(new ConsoleEndpoint());
+ stdout.AddEndpoint(new FileEndpoint("out.txt", false));
+ stderr.AddEndpoint(new DebugEndpoint());
+ stderr.AddEndpoint(new FileEndpoint("err.txt", false));
+ stderr.AddEndpoint(new DebugEndpoint());
+ stderr.AddEndpoint(new FileEndpoint("dbg.txt", false));
+ run();
+ Thread.Sleep(int.MaxValue);
+ }
+
+ static async Task run()
+ {
+ Random rnd = new Random();
+
+ FosscordClient fc = new FosscordClient(new()
+ {
+ Email = "FosscordSharp@test.bot",
+ // Password = File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)+"/.ssh/id_rsa.pub"),
+ Password = "SomePassword",
+ Endpoint = "https://fosscord.thearcanebrony.net",
+ // Endpoint = "http://localhost:3001",
+ RegistrationOptions =
+ {
+ Username = "FosscordSharp Example Bot",
+ DateOfBirth = "1969-01-01"
+ },
+ Verbose = false,
+ PollMessages = true,
+ ShouldRegister = true
+ });
+ await fc.Login();
+ List invites = new();
+ for (int i = 0; i < 10; i++)
+ {
+ FosscordClient client = new(new()
+ {
+ Email = $"FosscordSharp{rnd.Next()}@test.bot",
+ Password = "SomePassword",
+ Endpoint = "https://fosscord.thearcanebrony.net",
+ RegistrationOptions =
+ {
+ Username = "FosscordSharp Test Bot"
+ }
+ });
+ await client.Login();
+ invites.Add((await (await (await client.CreateGuild($"FC#{i}:")).GetChannels())[0].CreateInvite(1000)).Code);
+ }
+
+ foreach (var invite in invites)
+ {
+ await fc.JoinGuild(invite);
+ }
+ var gs = await fc.GetGuilds();
+ stddbg.Log("Got guilds!");
+ foreach (var g in gs)
+ {
+ stdout.Log($"{g.Name}: ");
+ var cs = await g.GetChannels();
+ foreach (var c in await g.GetChannels())
+ {
+ stdout.Log($"- {c.Name}: {(await c.CreateInvite()).FullUrl} ({(await c.GetMessages()).Length} messages)");
+ stddbg.Log((await c.SendMessage("Hi from FosscordSharp!")).Id+"");
+ await (await c.SendMessage("Hi from FosscordSharp!")).Delete();
+ }
+ }
+ stdout.Log(fc.GetGuilds().Result.Length + " guilds");
+ }
+ }
}
\ No newline at end of file
diff --git a/FosscordSharp.UnitTests/FosscordSharp.UnitTests.csproj b/FosscordSharp.UnitTests/FosscordSharp.UnitTests.csproj
index 6f3eb8b..2c10073 100644
--- a/FosscordSharp.UnitTests/FosscordSharp.UnitTests.csproj
+++ b/FosscordSharp.UnitTests/FosscordSharp.UnitTests.csproj
@@ -1,29 +1,29 @@
-
-
-
- net5.0
-
- false
-
-
-
-
-
-
-
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
-
-
-
-
-
-
+
+
+
+ net5.0
+
+ false
+
+
+
+
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
+
+
+
diff --git a/FosscordSharp.UnitTests/UnitTest1.cs b/FosscordSharp.UnitTests/UnitTest1.cs
index 908b651..cc70ade 100644
--- a/FosscordSharp.UnitTests/UnitTest1.cs
+++ b/FosscordSharp.UnitTests/UnitTest1.cs
@@ -1,55 +1,55 @@
-using System;
-using System.Threading.Tasks;
-using Xunit;
-using Xunit.Abstractions;
-
-namespace FosscordSharp.UnitTests
-{
- public class UnitTest1
- {
- private static Random rnd = new();
- int id = rnd.Next(int.MaxValue);
- private readonly ITestOutputHelper output;
-
- public UnitTest1(ITestOutputHelper output)
- {
- this.output = output;
- }
-
- public async Task GetClient()
- {
- return new FosscordClient(new()
- {
- Endpoint = "https://fosscord.thearcanebrony.net",
- Email = $"fosscordsharp.{id}@fosscord.bot",
- Password = "fosscordsharp",
- Verbose = false,
- RegistrationOptions = new()
- {
- Username = "F#Bot" + id,
- DateOfBirth = "2000-11-11"
- }
- });
- }
-
- [Fact]
- public async Task RegisterAndLogin()
- {
- (await GetClient()).Login();
- }
-
- [Fact]
- public async Task FetchGuilds()
- {
- FosscordClient cli = await GetClient();
- await cli.Login();
- var guilds = await cli.GetGuilds();
- output.WriteLine(guilds.Length+"");
- foreach (var guild in guilds)
- {
- output.WriteLine(guild.Id + "");
- Assert.Equal((await cli.GetGuild(guild.Id)).Id, guild.Id);
- }
- }
- }
+using System;
+using System.Threading.Tasks;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace FosscordSharp.UnitTests
+{
+ public class UnitTest1
+ {
+ private static Random rnd = new();
+ int id = rnd.Next(int.MaxValue);
+ private readonly ITestOutputHelper output;
+
+ public UnitTest1(ITestOutputHelper output)
+ {
+ this.output = output;
+ }
+
+ public async Task GetClient()
+ {
+ return new FosscordClient(new()
+ {
+ Endpoint = "https://fosscord.thearcanebrony.net",
+ Email = $"fosscordsharp.{id}@fosscord.bot",
+ Password = "fosscordsharp",
+ Verbose = false,
+ RegistrationOptions = new()
+ {
+ Username = "F#Bot" + id,
+ DateOfBirth = "2000-11-11"
+ }
+ });
+ }
+
+ [Fact]
+ public async Task RegisterAndLogin()
+ {
+ (await GetClient()).Login();
+ }
+
+ [Fact]
+ public async Task FetchGuilds()
+ {
+ FosscordClient cli = await GetClient();
+ await cli.Login();
+ var guilds = await cli.GetGuilds();
+ output.WriteLine(guilds.Length+"");
+ foreach (var guild in guilds)
+ {
+ output.WriteLine(guild.Id + "");
+ Assert.Equal((await cli.GetGuild(guild.Id)).Id, guild.Id);
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/FosscordSharp.sln b/FosscordSharp.sln
index 0d4bbef..dbfc350 100644
--- a/FosscordSharp.sln
+++ b/FosscordSharp.sln
@@ -1,34 +1,40 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FosscordSharp", "FosscordSharp\FosscordSharp.csproj", "{507A2104-26E2-4FA9-86D4-7915425F46E7}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FosscordSharp.Test", "FosscordSharp.Test\FosscordSharp.Test.csproj", "{71933DC6-2039-4203-927C-E8A39C56AACB}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FosscordSharp.UnitTests", "FosscordSharp.UnitTests\FosscordSharp.UnitTests.csproj", "{36EB2987-7650-4143-957D-159F79D3F7BE}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FosscordSharp.ExampleBot", "FosscordSharp.ExampleBot\FosscordSharp.ExampleBot.csproj", "{E12445E5-DAB6-4253-9659-E07406D3F8D9}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {507A2104-26E2-4FA9-86D4-7915425F46E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {507A2104-26E2-4FA9-86D4-7915425F46E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {507A2104-26E2-4FA9-86D4-7915425F46E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {507A2104-26E2-4FA9-86D4-7915425F46E7}.Release|Any CPU.Build.0 = Release|Any CPU
- {71933DC6-2039-4203-927C-E8A39C56AACB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {71933DC6-2039-4203-927C-E8A39C56AACB}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {71933DC6-2039-4203-927C-E8A39C56AACB}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {71933DC6-2039-4203-927C-E8A39C56AACB}.Release|Any CPU.Build.0 = Release|Any CPU
- {36EB2987-7650-4143-957D-159F79D3F7BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {36EB2987-7650-4143-957D-159F79D3F7BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {36EB2987-7650-4143-957D-159F79D3F7BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {36EB2987-7650-4143-957D-159F79D3F7BE}.Release|Any CPU.Build.0 = Release|Any CPU
- {E12445E5-DAB6-4253-9659-E07406D3F8D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E12445E5-DAB6-4253-9659-E07406D3F8D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E12445E5-DAB6-4253-9659-E07406D3F8D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E12445E5-DAB6-4253-9659-E07406D3F8D9}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FosscordSharp", "FosscordSharp\FosscordSharp.csproj", "{507A2104-26E2-4FA9-86D4-7915425F46E7}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FosscordSharp.Test", "FosscordSharp.Test\FosscordSharp.Test.csproj", "{71933DC6-2039-4203-927C-E8A39C56AACB}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FosscordSharp.UnitTests", "FosscordSharp.UnitTests\FosscordSharp.UnitTests.csproj", "{36EB2987-7650-4143-957D-159F79D3F7BE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FosscordSharp.ExampleBot", "FosscordSharp.ExampleBot\FosscordSharp.ExampleBot.csproj", "{E12445E5-DAB6-4253-9659-E07406D3F8D9}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FosscordSharp.InstanceTest", "FosscordSharp.InstanceTest\FosscordSharp.InstanceTest.csproj", "{D3E0CAC1-51B9-49BD-A13F-371F86E2F4EA}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {507A2104-26E2-4FA9-86D4-7915425F46E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {507A2104-26E2-4FA9-86D4-7915425F46E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {507A2104-26E2-4FA9-86D4-7915425F46E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {507A2104-26E2-4FA9-86D4-7915425F46E7}.Release|Any CPU.Build.0 = Release|Any CPU
+ {71933DC6-2039-4203-927C-E8A39C56AACB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {71933DC6-2039-4203-927C-E8A39C56AACB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {71933DC6-2039-4203-927C-E8A39C56AACB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {71933DC6-2039-4203-927C-E8A39C56AACB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {36EB2987-7650-4143-957D-159F79D3F7BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {36EB2987-7650-4143-957D-159F79D3F7BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {36EB2987-7650-4143-957D-159F79D3F7BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {36EB2987-7650-4143-957D-159F79D3F7BE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E12445E5-DAB6-4253-9659-E07406D3F8D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E12445E5-DAB6-4253-9659-E07406D3F8D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E12445E5-DAB6-4253-9659-E07406D3F8D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E12445E5-DAB6-4253-9659-E07406D3F8D9}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D3E0CAC1-51B9-49BD-A13F-371F86E2F4EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D3E0CAC1-51B9-49BD-A13F-371F86E2F4EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D3E0CAC1-51B9-49BD-A13F-371F86E2F4EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D3E0CAC1-51B9-49BD-A13F-371F86E2F4EA}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+EndGlobal
diff --git a/FosscordSharp/Core/FosscordObject.cs b/FosscordSharp/Core/FosscordObject.cs
index cbbd546..d49c7f7 100644
--- a/FosscordSharp/Core/FosscordObject.cs
+++ b/FosscordSharp/Core/FosscordObject.cs
@@ -1,7 +1,7 @@
-namespace FosscordSharp.Core
-{
- public class FosscordObject
- {
- internal FosscordClient _client;
- }
+namespace FosscordSharp.Core
+{
+ public class FosscordObject
+ {
+ internal FosscordClient _client;
+ }
}
\ No newline at end of file
diff --git a/FosscordSharp/Entities/Attachment.cs b/FosscordSharp/Entities/Attachment.cs
index e6db320..b16694a 100644
--- a/FosscordSharp/Entities/Attachment.cs
+++ b/FosscordSharp/Entities/Attachment.cs
@@ -1,17 +1,17 @@
-using System;
-using FosscordSharp.Core;
-
-namespace FosscordSharp.Entities
-{
- public partial class Attachment : FosscordObject
- {
- public string Id { get; set; }
- public string Filename { get; set; }
- public long Size { get; set; }
- public Uri Url { get; set; }
- public Uri ProxyUrl { get; set; }
- public long Width { get; set; }
- public long Height { get; set; }
- public string ContentType { get; set; }
- }
+using System;
+using FosscordSharp.Core;
+
+namespace FosscordSharp.Entities
+{
+ public partial class Attachment : FosscordObject
+ {
+ public string Id { get; set; }
+ public string Filename { get; set; }
+ public long Size { get; set; }
+ public Uri Url { get; set; }
+ public Uri ProxyUrl { get; set; }
+ public long Width { get; set; }
+ public long Height { get; set; }
+ public string ContentType { get; set; }
+ }
}
\ No newline at end of file
diff --git a/FosscordSharp/Entities/Author.cs b/FosscordSharp/Entities/Author.cs
index 783c872..0dda388 100644
--- a/FosscordSharp/Entities/Author.cs
+++ b/FosscordSharp/Entities/Author.cs
@@ -1,37 +1,37 @@
-using FosscordSharp.Core;
-using Newtonsoft.Json;
-
-namespace FosscordSharp.Entities
-{
- public class Author : FosscordObject
- {
- [JsonProperty("id")]
- public string Id { get; set; }
-
- [JsonProperty("username")]
- public string Username { get; set; }
-
- [JsonProperty("discriminator")]
- public string Discriminator { get; set; }
-
- [JsonProperty("avatar")]
- public string Avatar { get; set; }
-
- [JsonProperty("accent_color")]
- public object AccentColor { get; set; }
-
- [JsonProperty("banner")]
- public object Banner { get; set; }
-
- [JsonProperty("bot")]
- public bool Bot { get; set; }
-
- [JsonProperty("bio")]
- public string Bio { get; set; }
-
- [JsonProperty("public_flags")]
- public int PublicFlags { get; set; }
-
- public string AvatarUrl => _client._httpClient.BaseAddress + "/avatars/" + Id + "/" + Avatar + ".png?size=8192";
- }
+using FosscordSharp.Core;
+using Newtonsoft.Json;
+
+namespace FosscordSharp.Entities
+{
+ public class Author : FosscordObject
+ {
+ [JsonProperty("id")]
+ public string Id { get; set; }
+
+ [JsonProperty("username")]
+ public string Username { get; set; }
+
+ [JsonProperty("discriminator")]
+ public string Discriminator { get; set; }
+
+ [JsonProperty("avatar")]
+ public string Avatar { get; set; }
+
+ [JsonProperty("accent_color")]
+ public object AccentColor { get; set; }
+
+ [JsonProperty("banner")]
+ public object Banner { get; set; }
+
+ [JsonProperty("bot")]
+ public bool Bot { get; set; }
+
+ [JsonProperty("bio")]
+ public string Bio { get; set; }
+
+ [JsonProperty("public_flags")]
+ public int PublicFlags { get; set; }
+
+ public string AvatarUrl => _client._httpClient.BaseAddress + "/avatars/" + Id + "/" + Avatar + ".png?size=8192";
+ }
}
\ No newline at end of file
diff --git a/FosscordSharp/Entities/Channel.cs b/FosscordSharp/Entities/Channel.cs
index f2304c5..1992f03 100644
--- a/FosscordSharp/Entities/Channel.cs
+++ b/FosscordSharp/Entities/Channel.cs
@@ -1,97 +1,97 @@
-using System;
-using System.Collections.Generic;
-using System.Net.Http;
-using System.Net.Http.Json;
-using System.Threading.Tasks;
-using FosscordSharp.Core;
-using FosscordSharp.Utilities;
-using Newtonsoft.Json;
-using OneOf;
-
-namespace FosscordSharp.Entities
-{
- public class Channel : FosscordObject
- {
- [JsonProperty("id")] public ulong Id { get; set; }
-
- [JsonProperty("created_at")] public DateTime CreatedAt { get; set; }
-
- [JsonProperty("name")] public string Name { get; set; }
-
- [JsonProperty("icon")] public object Icon { get; set; }
-
- [JsonProperty("type")] public int Type { get; set; }
-
- [JsonProperty("last_message_id")] public ulong? LastMessageId { get; set; }
-
- [JsonProperty("guild_id")] public string GuildId { get; set; }
-
- [JsonProperty("parent_id")] public object ParentId { get; set; }
-
- [JsonProperty("owner_id")] public object OwnerId { get; set; }
-
- [JsonProperty("last_pin_timestamp")] public object LastPinTimestamp { get; set; }
-
- [JsonProperty("default_auto_archive_duration")]
- public object DefaultAutoArchiveDuration { get; set; }
-
- [JsonProperty("position")] public int Position { get; set; }
-
- [JsonProperty("permission_overwrites")]
- public List