Skip to content

Commit b653b99

Browse files
updated conditions for collected posts plus minor other stuff
1 parent e4e8ff9 commit b653b99

4 files changed

Lines changed: 20 additions & 13 deletions

File tree

help_channel_mirror.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
</Content>
2525

2626
<PackageReference Include="Discord.Net" Version="3.16.0" />
27+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.6" />
28+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.6" />
2729
<PackageReference Include="Octokit" Version="14.0.0" />
2830

2931
</ItemGroup>

src/Program.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Threading.Tasks;
44
using Discord;
55
using Discord.WebSocket;
6+
using Microsoft.EntityFrameworkCore;
67

78
public class Program
89
{
@@ -26,6 +27,12 @@ private Program(
2627

2728
public static async Task Main(string[] args)
2829
{
30+
var dbOptions = new DbContextOptionsBuilder<DphContext>().UseSqlite($"Data Source={System.IO.Path.Join(AppContext.BaseDirectory, "data_storage.db")}").Options;
31+
using (var db = new DphContext(dbOptions))
32+
{
33+
db.Database.EnsureCreated();
34+
}
35+
2936
string token = null;
3037
bool auto = false;
3138

@@ -98,6 +105,8 @@ private async Task RunAsync()
98105

99106
private async Task ConsoleLoopAsync()
100107
{
108+
ConsoleCommand cmd = new();
109+
101110
while (true)
102111
{
103112
#region Experimental Console
@@ -111,7 +120,7 @@ private async Task ConsoleLoopAsync()
111120
// case ConsoleKey.Enter:
112121
// goto break_input_loop;
113122
// break;
114-
123+
115124
// case ConsoleKey.Backspace:
116125
// if (input.Length < 1) break;
117126
// input = input[0..^1];
@@ -135,7 +144,7 @@ private async Task ConsoleLoopAsync()
135144

136145
var input = Console.ReadLine();
137146

138-
if(await EvaluateInputAsync(input)) break;
147+
if (await EvaluateInputAsync(cmd, input)) break;
139148
}
140149

141150
_ = Logger.Log("Bot shutting down.", LogSeverity.Info);
@@ -147,12 +156,12 @@ private async Task ConsoleLoopAsync()
147156
/// </summary>
148157
/// <param name="input"></param>
149158
/// <returns>Should exit console loop</returns>
150-
private async Task<bool> EvaluateInputAsync(string input)
159+
private async Task<bool> EvaluateInputAsync(ConsoleCommand cmd, string input)
151160
{
152-
ConsoleCommand cmd = new();
153161
string[] processedInput = input.Split(' ');
154162
bool shouldConsoleLoopExit = false;
155163

164+
// TODO Put the switch in the ConsoleCommand class
156165
switch (processedInput[0])
157166
{
158167
case "help":
@@ -179,7 +188,7 @@ private async Task<bool> EvaluateInputAsync(string input)
179188
_ = Logger.Log("Too many arguments for this command!", LogSeverity.Error);
180189
break;
181190
}
182-
shouldConsoleLoopExit = await cmd.Exit( client);
191+
shouldConsoleLoopExit = await cmd.Exit(client);
183192
break;
184193

185194
case "reload-config":
@@ -196,8 +205,8 @@ private async Task<bool> EvaluateInputAsync(string input)
196205
{
197206
_ = Logger.Log("Too many arguments for this command!", LogSeverity.Error);
198207
break;
199-
}
200-
else if(processedInput.Length < 2)
208+
}
209+
else if (processedInput.Length < 2)
201210
{
202211
_ = Logger.Log("Too many arguments for this command!", LogSeverity.Error);
203212
break;
@@ -257,7 +266,7 @@ private async Task<bool> EvaluateInputAsync(string input)
257266
break;
258267

259268
default:
260-
invalid_input:
269+
invalid_input:
261270
Console.Write($"\x1b[1F\x1b[K\x1b[31m'{input}' is not a valid command.\x1b[0m\n");
262271
break;
263272
}

src/Utillity/DataProcessor.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,7 @@ private async Task<IEnumerable<IThreadChannel>> GetAllForumPosts(IForumChannel c
135135

136136
var allThreads = await channel.GetPublicArchivedThreadsAsync(before: before);
137137
if (allThreads.Count == 0) break;
138-
var threads = allThreads.Where(t =>
139-
t.AppliedTags.Intersect(AppConfig.Data.ResolvedTagIds).Any() &&
140-
!t.Name.StartsWith("!n")
141-
);
138+
var threads = allThreads.Where(t => !t.Name.StartsWith("!n"));
142139
if (threads.Count() == 0) break;
143140

144141
before = threads.Last().ArchiveTimestamp.DateTime;

src/Utillity/Github.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.IO;
3-
using System.Linq;
43
using System.Threading.Tasks;
54
using Discord;
65
using Octokit;

0 commit comments

Comments
 (0)