Skip to content

Commit 84af47f

Browse files
Merge pull request #108 from nullinside-development-group/feat/disconnect
bug: fixing application not exiting
2 parents b738a59 + cc9409b commit 84af47f

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

src/Nullinside.Api.TwitchBot/ChatRules/StreamRise.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ namespace Nullinside.Api.TwitchBot.ChatRules;
1111
/// </summary>
1212
public class StreamRise : AChatRule {
1313
private const string SPAM = "Hello, sorry for bothering you. I want to offer promotion of your channel, " +
14-
"viewers, followers, views, chat bots, etc...The price is lower than any competitor, " +
15-
"the quality is guaranteed to be the best. Flexible and convenient order management " +
16-
"panel, chat panel, everything is in your hands, a huge number of custom settings. Go " +
17-
"to streamrise";
14+
"viewers, followers, views, chat bots, etc...The price is lower than any competitor, " +
15+
"the quality is guaranteed to be the best. Flexible and convenient order management " +
16+
"panel, chat panel, everything is in your hands, a huge number of custom settings. Go " +
17+
"to streamrise";
1818

1919
/// <inheritdoc />
2020
public override bool ShouldRun(TwitchUserConfig config) {

src/Nullinside.Api.TwitchBot/Nullinside.Api.TwitchBot.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
<ItemGroup>
2525
<PackageReference Include="FlexLabs.EntityFrameworkCore.Upsert" Version="9.0.0"/>
2626
<PackageReference Include="log4net.Ext.Json" Version="3.0.3"/>
27-
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.7" />
27+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.7"/>
2828
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.7">
2929
<PrivateAssets>all</PrivateAssets>
3030
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3131
</PackageReference>
3232
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0"/>
3333
<PackageReference Include="Nullinside.MySql.EntityFrameworkCore" Version="9.0.3"/>
34-
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.3" />
34+
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.3"/>
3535
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1"/>
3636
</ItemGroup>
3737

src/Nullinside.Api.TwitchBot/Services/MainService.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,18 @@ public MainService(IServiceScopeFactory serviceScopeFactory) {
9999
_db = _scope.ServiceProvider.GetRequiredService<INullinsideContext>();
100100
_api = _scope.ServiceProvider.GetRequiredService<ITwitchApiProxy>();
101101
_client = _scope.ServiceProvider.GetRequiredService<ITwitchClientProxy>();
102+
_client.AddDisconnectedCallback(OnTwitchClientDisconected);
102103
_chatMessageConsumer = new TwitchChatMessageMonitorConsumer(_db, _api, _receivedMessageProcessingQueue);
103104
}
104105

106+
/// <summary>
107+
/// Called when the twitch client is disconnected.
108+
/// </summary>
109+
private void OnTwitchClientDisconected() {
110+
_log.Info("Twitch Client Disconnected, exiting app");
111+
Environment.Exit(0);
112+
}
113+
105114
/// <summary>
106115
/// The execute called by the .NET runtime.
107116
/// </summary>

0 commit comments

Comments
 (0)