Skip to content

Commit

Permalink
Slackord 2.4.1
Browse files Browse the repository at this point in the history
CHANGE - Upgrade from .NET6 to .NET7.
CHANGE - All multi-line strings to new raw string literals.
  • Loading branch information
thomasloupe committed Nov 10, 2022
1 parent 8e2b7fe commit c115bc6
Show file tree
Hide file tree
Showing 18 changed files with 1,182 additions and 85 deletions.
Binary file modified Slackord_Mac_Linux/.vs/ProjectEvaluation/slackord.metadata.v5.1
Binary file not shown.
Binary file modified Slackord_Mac_Linux/.vs/ProjectEvaluation/slackord.projects.v5.1
Binary file not shown.
Binary file modified Slackord_Mac_Linux/.vs/Slackord/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file modified Slackord_Mac_Linux/.vs/Slackord/v17/.futdcache.v2
Binary file not shown.
Binary file modified Slackord_Mac_Linux/.vs/Slackord/v17/.suo
Binary file not shown.
94 changes: 54 additions & 40 deletions Slackord_Mac_Linux/Slackord/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
using Microsoft.Extensions.DependencyInjection;
using Discord.Net;
using Octokit;
using System.Threading;

namespace Slackord
{
internal class Slackord : InteractionModuleBase<SocketInteractionContext>
{
private const string CurrentVersion = "v2.4";
private const string CurrentVersion = "v2.4.1";
private DiscordSocketClient _discordClient;
private string _discordToken;
private bool _isFileParsed;
Expand All @@ -39,9 +38,9 @@ public Slackord()

public async void Start()
{
AboutSlackord();
CheckForExistingBotToken();
CheckForFilesFolder();
await AboutSlackord();
await CheckForExistingBotToken();
await CheckForFilesFolder();
}

private static Task CheckForFilesFolder()
Expand All @@ -55,15 +54,19 @@ private static Task CheckForFilesFolder()

public static async Task AboutSlackord()
{
Console.WriteLine("Slackord " + CurrentVersion + ".\n" +
"Created by Thomas Loupe." + "\n" +
"Github: https://github.com/thomasloupe" + "\n" +
"Twitter: https://twitter.com/acid_rain" + "\n" +
"Website: https://thomasloupe.com" + "\n");
Console.WriteLine($"""
Slackord {CurrentVersion}
Created by Thomas Loupe.
Github: https://github.com/thomasloupe
Twitter: https://twitter.com/acid_rain
Website: https://thomasloupe.com
""");

Console.WriteLine("Slackord will always be free!\n"
+ "If you'd like to buy me a beer anyway, I won't tell you not to!\n"
+ "You can donate at https://www.paypal.me/thomasloupe\n" + "\n"); ;
Console.WriteLine("""
Slackord will always be free!
If you'd like to buy me a beer anyway, I won't tell you not to!
"You can donate at https://www.paypal.me/thomasloupe
""");
await CheckForUpdates();
}

Expand All @@ -78,14 +81,16 @@ private static async Task CheckForUpdates()
}
else if (CurrentVersion != latest.TagName)
{
Console.WriteLine("A new version of Slackord is available!\n"
+ "Current version: " + CurrentVersion + "\n"
+ "Latest version: " + latest.TagName + "\n"
+ "You can get the latest version from the GitHub repository at https://github.com/thomasloupe/Slackord2");
Console.WriteLine($"""
A new version of Slackord is available!
Current version: {CurrentVersion}
Latest version: {latest.TagName}
You can get the latest version from the GitHub repository at https://github.com/thomasloupe/Slackord2
""");
}
}

private void CheckForExistingBotToken()
private async Task CheckForExistingBotToken()
{
if (File.Exists("Token.txt"))
{
Expand All @@ -96,11 +101,11 @@ private void CheckForExistingBotToken()
Console.WriteLine("No bot token found. Please enter your bot token: ");
_discordToken = Console.ReadLine();
File.WriteAllText("Token.txt", _discordToken);
CheckForExistingBotToken();
await CheckForExistingBotToken();
}
else
{
ParseJsonFiles();
await ParseJsonFiles();
}
}
else
Expand All @@ -109,7 +114,7 @@ private void CheckForExistingBotToken()
_discordToken = Console.ReadLine();
if (_discordToken == null)
{
CheckForExistingBotToken();
await CheckForExistingBotToken();
}
else
{
Expand All @@ -128,12 +133,14 @@ private async Task ParseJsonFiles()
var files = Directory.GetFiles("Files");
if (files.Length == 0)
{
Console.WriteLine("You haven't placed any JSON files in the Files folder.\n" +
"Please place your JSON files in the Files folder then press ENTER to continue.");
Console.WriteLine("""
You haven't placed any JSON files in the Files folder.
"Please place your JSON files in the Files folder then press ENTER to continue.
""");
ConsoleKeyInfo keyPressed = Console.ReadKey(true);
if (keyPressed.Key != ConsoleKey.Enter)
{
ParseJsonFiles();
await ParseJsonFiles();
}
}
else
Expand All @@ -151,8 +158,10 @@ private async Task ParseJsonFiles()
{
var json = File.ReadAllText(file);
parsed = JArray.Parse(json);
Console.WriteLine("Begin parsing JSON data..." + "\n");
Console.WriteLine("-----------------------------------------" + "\n");
Console.WriteLine("""
Begin parsing JSON data...);
-----------------------------------------
""");
string debugResponse;
foreach (JObject pair in parsed.Cast<JObject>())
{
Expand Down Expand Up @@ -257,8 +266,10 @@ private async Task ParseJsonFiles()
debugResponse = newDateTime + " - " + slackUserName + ": " + slackMessage;
if (debugResponse.Length >= 2000)
{
Console.WriteLine("The following parse is over 2000 characters. Discord does not allow messages over 2000 characters. This message " +
"will be split into multiple posts. The message that will be split is:\n" + debugResponse);
Console.WriteLine($"""
The following parse is over 2000 characters. Discord does not allow messages over 2000 characters.
This message will be split into multiple posts. The message that will be split is: {debugResponse}
""");
}
else
{
Expand All @@ -269,11 +280,11 @@ private async Task ParseJsonFiles()
Console.WriteLine(debugResponse + "\n");
}
}
Console.WriteLine("\n");
Console.WriteLine("-----------------------------------------" + "\n");
Console.WriteLine("Parsing of " + file + " completed successfully!" + "\n");
Console.WriteLine("-----------------------------------------" + "\n");
Console.WriteLine("\n");
Console.WriteLine("""
-----------------------------------------
Parsing of {{file}} completed successfully!
-----------------------------------------
""");
if (_discordClient != null)
{
await _discordClient.SetActivityAsync(new Game("awaiting command to import messages...", ActivityType.Watching));
Expand All @@ -284,7 +295,7 @@ private async Task ParseJsonFiles()
{
Console.WriteLine(ex.Message);
Console.WriteLine("An error occured while parsing the JSON file. Please try again.");
ParseJsonFiles();
await ParseJsonFiles();
}
}
}
Expand All @@ -308,9 +319,10 @@ private async Task PostMessages(SocketChannel channel, ulong guildID)
// await DeferAsync();
if (_isFileParsed)
{
Console.WriteLine("\n");
Console.WriteLine("Beginning transfer of Slack messages to Discord..." + "\n" +
"-----------------------------------------" + "\n");
Console.WriteLine("""
Beginning transfer of Slack messages to Discord...
-----------------------------------------
""");

SocketThreadChannel threadID = null;
foreach (string message in Responses)
Expand Down Expand Up @@ -398,8 +410,10 @@ private async Task PostMessages(SocketChannel channel, ulong guildID)
}
}
}
Console.WriteLine("-----------------------------------------" + "\n" +
"All messages sent to Discord successfully!" + "\n");
Console.WriteLine("""
-----------------------------------------
All messages sent to Discord successfully!
""");
// TODO: Fix Application did not respond in time error.
// await FollowupAsync("All messages sent to Discord successfully!", ephemeral: true);
await _discordClient.SetActivityAsync(new Game("awaiting parsing of messages.", ActivityType.Watching));
Expand Down Expand Up @@ -481,7 +495,7 @@ private static DateTime ConvertFromUnixTimestampToHumanReadableTime(double times

private async Task DiscordClient_Log(LogMessage arg)
{
Console.WriteLine(arg.ToString() + "\n");
Console.WriteLine(arg.ToString() + ".\n");
await Task.CompletedTask;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PublishDir>C:\Users\acid_rain\Desktop\Slackord2_Linux_x64</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>false</PublishSingleFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2022-11-06T00:39:04.5008785Z;True|2022-10-30T20:06:32.6012063-05:00;True|2022-10-30T20:04:43.0621902-05:00;True|2022-10-30T19:41:03.5899839-05:00;True|2022-10-30T19:37:19.2506588-05:00;True|2022-10-30T19:30:30.2405827-05:00;True|2022-10-30T19:15:57.0231425-05:00;True|2022-09-28T09:53:23.2405195-05:00;True|2022-09-09T11:20:37.8936142-05:00;True|2022-09-07T09:21:44.8560331-05:00;True|2022-09-06T20:03:26.8708312-05:00;True|2022-09-06T18:04:01.1476860-05:00;True|2022-09-06T17:57:43.7189984-05:00;True|2022-09-04T18:13:17.0640993-05:00;True|2022-09-04T15:13:24.9245143-05:00;True|2022-09-03T12:11:25.9090446-05:00;True|2022-09-02T06:34:34.9234318-05:00;True|2022-09-01T18:21:11.7930268-05:00;True|2022-08-28T06:37:02.2882076-05:00;</History>
<History>True|2022-11-10T15:26:03.7269070Z;True|2022-11-05T19:39:04.5008785-05:00;True|2022-10-30T20:06:32.6012063-05:00;True|2022-10-30T20:04:43.0621902-05:00;True|2022-10-30T19:41:03.5899839-05:00;True|2022-10-30T19:37:19.2506588-05:00;True|2022-10-30T19:30:30.2405827-05:00;True|2022-10-30T19:15:57.0231425-05:00;True|2022-09-28T09:53:23.2405195-05:00;True|2022-09-09T11:20:37.8936142-05:00;True|2022-09-07T09:21:44.8560331-05:00;True|2022-09-06T20:03:26.8708312-05:00;True|2022-09-06T18:04:01.1476860-05:00;True|2022-09-06T17:57:43.7189984-05:00;True|2022-09-04T18:13:17.0640993-05:00;True|2022-09-04T15:13:24.9245143-05:00;True|2022-09-03T12:11:25.9090446-05:00;True|2022-09-02T06:34:34.9234318-05:00;True|2022-09-01T18:21:11.7930268-05:00;True|2022-08-28T06:37:02.2882076-05:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PublishDir>C:\Users\acid_rain\Desktop\Slackord2_Mac_x64</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<RuntimeIdentifier>osx-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>false</PublishSingleFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2022-11-06T00:39:09.4552032Z;True|2022-10-30T20:06:28.5452059-05:00;True|2022-10-30T20:05:19.4211898-05:00;True|2022-09-28T09:53:13.5191668-05:00;True|2022-09-09T11:20:43.9506630-05:00;True|2022-09-07T09:20:31.8437641-05:00;True|2022-09-06T20:03:31.7927375-05:00;True|2022-09-06T18:03:54.5007647-05:00;True|2022-09-06T17:57:52.4538451-05:00;True|2022-09-04T18:13:10.9335352-05:00;True|2022-09-04T15:13:30.2220771-05:00;True|2022-09-03T12:11:20.8350468-05:00;True|2022-09-02T06:34:28.4239943-05:00;True|2022-09-01T18:21:37.3336024-05:00;True|2022-08-29T13:50:52.3720125-05:00;False|2022-08-29T13:41:04.3514375-05:00;False|2022-08-29T13:40:55.1297764-05:00;True|2022-08-28T06:34:09.4345835-05:00;</History>
<History>True|2022-11-10T15:26:16.3436624Z;True|2022-11-05T19:39:09.4552032-05:00;True|2022-10-30T20:06:28.5452059-05:00;True|2022-10-30T20:05:19.4211898-05:00;True|2022-09-28T09:53:13.5191668-05:00;True|2022-09-09T11:20:43.9506630-05:00;True|2022-09-07T09:20:31.8437641-05:00;True|2022-09-06T20:03:31.7927375-05:00;True|2022-09-06T18:03:54.5007647-05:00;True|2022-09-06T17:57:52.4538451-05:00;True|2022-09-04T18:13:10.9335352-05:00;True|2022-09-04T15:13:30.2220771-05:00;True|2022-09-03T12:11:20.8350468-05:00;True|2022-09-02T06:34:28.4239943-05:00;True|2022-09-01T18:21:37.3336024-05:00;True|2022-08-29T13:50:52.3720125-05:00;False|2022-08-29T13:41:04.3514375-05:00;False|2022-08-29T13:40:55.1297764-05:00;True|2022-08-28T06:34:09.4345835-05:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions Slackord_Mac_Linux/Slackord/Slackord.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<StartupObject>Slackord.Slackord</StartupObject>
Expand All @@ -17,7 +17,7 @@
<PackageReference Include="Discord.Net.Core" Version="3.8.1" />
<PackageReference Include="Discord.Net.Interactions" Version="3.8.1" />
<PackageReference Include="Discord.Net.WebSocket" Version="3.8.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Octokit" Version="4.0.1" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion Slackord_Mac_Linux/Slackord/Slackord.csproj.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_LastSelectedProfileId>Z:\Development\Git Repositories\Slackord2\Slackord_Mac_Linux\Slackord\Properties\PublishProfiles\Linux x64.pubxml</_LastSelectedProfileId>
<_LastSelectedProfileId>Z:\Development\Git Repositories\Slackord2\Slackord_Mac_Linux\Slackord\Properties\PublishProfiles\Mac OSx x64.pubxml</_LastSelectedProfileId>
</PropertyGroup>
</Project>
111 changes: 111 additions & 0 deletions Slackord_Win/AnalysisReport.sarif
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"$schema": "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.5.json",
"version": "2.1.0",
"runs": [
{
"tool": {
"driver": {
"name": "Dependency Analysis",
"semanticVersion": "0.4.336902",
"informationUri": "https://docs.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-overview",
"rules": [
{
"id": "UA105",
"name": "PackageToBeDeleted",
"fullDescription": {
"text": "Packages that need to be deleted in order to upgrade the project to chosen TFM"
},
"helpUri": "https://docs.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-overview"
},
{
"id": "UA106",
"name": "PackageToBeAdded",
"fullDescription": {
"text": "Packages that need to be added in order to upgrade the project to chosen TFM"
},
"helpUri": "https://docs.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-overview"
}
]
}
},
"results": [
{
"ruleId": "UA105",
"message": {
"text": "Package Discord.Net.Core needs to be removed as its a transitive dependency that is not required"
},
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"uri": "file:///Z:/Development/Git%20Repositories/Slackord2/Slackord_Win/Slackord/Slackord.csproj"
},
"region": {}
}
}
]
},
{
"ruleId": "UA105",
"message": {
"text": "Package Discord.Net.WebSocket, Version=3.8.1 needs to be deleted."
},
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"uri": "file:///Z:/Development/Git%20Repositories/Slackord2/Slackord_Win/Slackord/Slackord.csproj"
},
"region": {}
}
}
]
},
{
"ruleId": "UA106",
"message": {
"text": "Package Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers, Version=0.4.355802 needs to be added."
},
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"uri": "file:///Z:/Development/Git%20Repositories/Slackord2/Slackord_Win/Slackord/Slackord.csproj"
},
"region": {}
}
}
]
},
{
"ruleId": "UA106",
"message": {
"text": "Package Microsoft.Windows.Compatibility, Version=7.0.0 needs to be added."
},
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"uri": "file:///Z:/Development/Git%20Repositories/Slackord2/Slackord_Win/Slackord/Slackord.csproj"
},
"region": {}
}
}
]
}
],
"columnKind": "utf16CodeUnits"
},
{
"tool": {
"driver": {
"name": "API Upgradability",
"semanticVersion": "0.4.336902",
"informationUri": "https://docs.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-overview"
}
},
"results": [],
"columnKind": "utf16CodeUnits"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PublishDir>C:\Users\acid_rain\Desktop\Slackord2_Win_x64</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net7.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
Expand Down
Loading

0 comments on commit c115bc6

Please sign in to comment.