cleanup, better logging for shared nadeko

This commit is contained in:
Kwoth 2016-08-04 22:07:42 +02:00
parent 337110ca29
commit 7e059a63a0
6 changed files with 82 additions and 82 deletions

View File

@ -7,7 +7,6 @@ using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Reflection; using System.Reflection;
@ -227,6 +226,7 @@ namespace NadekoBot
DateTime dt; DateTime dt;
if (!commandTracker.TryGetValue(e.Message.Id, out dt)) if (!commandTracker.TryGetValue(e.Message.Id, out dt))
return; return;
#if NADEKO_RELEASE
try try
{ {
if (e is CommandErrorEventArgs) if (e is CommandErrorEventArgs)
@ -248,6 +248,7 @@ namespace NadekoBot
} }
} }
catch { } catch { }
#endif
} }
private async void StatsCollector_RanCommand(object sender, CommandEventArgs e) private async void StatsCollector_RanCommand(object sender, CommandEventArgs e)

Binary file not shown.

View File

@ -7,37 +7,32 @@ using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Timers;
namespace NadekoBot.Modules.Searches.Commands namespace NadekoBot.Modules.Searches.Commands
{ {
internal class StreamNotifications : DiscordCommand internal class StreamNotifications : DiscordCommand
{ {
private readonly Timer checkTimer = new Timer
{
Interval = new TimeSpan(0, 0, 15).TotalMilliseconds,
};
private ConcurrentDictionary<string, Tuple<bool, string>> cachedStatuses = new ConcurrentDictionary<string, Tuple<bool, string>>(); private ConcurrentDictionary<string, Tuple<bool, string>> cachedStatuses = new ConcurrentDictionary<string, Tuple<bool, string>>();
private bool FirstPass { get; set; } = true; private bool FirstPass { get; set; } = true;
public StreamNotifications(DiscordModule module) : base(module) public StreamNotifications(DiscordModule module) : base(module)
{ {
//start checking only after ready, because we need all servers to be initialized
checkTimer.Elapsed += (s, e) => Task.Run(async () => NadekoBot.OnReady += () => Task.Run(async () =>
{
while (true)
{ {
cachedStatuses.Clear(); cachedStatuses.Clear();
try try
{ {
var streams = SpecificConfigurations.Default.AllConfigs.SelectMany(c => c.ObservingStreams); var streams = SpecificConfigurations.Default.AllConfigs.SelectMany(c => c.ObservingStreams);
if (!streams.Any()) return; if (!streams.Any()) return;
#if NADEKO_RELEASE
var clr = Console.ForegroundColor; var clr = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Blue; Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine($"Getting {streams.Count()} streams."); Console.WriteLine($"Getting {streams.Count()} streams.");
Console.ForegroundColor = clr; Console.ForegroundColor = clr;
#endif
foreach (var stream in streams) foreach (var stream in streams)
{ {
Tuple<bool, string> data; Tuple<bool, string> data;
@ -75,16 +70,20 @@ namespace NadekoBot.Modules.Searches.Commands
} }
} }
FirstPass = false; FirstPass = false;
#if NADEKO_RELEASE
clr = Console.ForegroundColor; clr = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Blue; Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine($"Getting {streams.Count()} streams."); Console.WriteLine($"Done getting streams.");
Console.ForegroundColor = clr; Console.ForegroundColor = clr;
#endif
} }
catch { } catch { }
finally
{
await Task.Delay(TimeSpan.FromSeconds(15));
}
}
}); });
//start checking only after ready, because we need all servers to be initialized
NadekoBot.OnReady += checkTimer.Start;
} }
private async Task<Tuple<bool, string>> GetStreamStatus(StreamNotificationConfig stream, bool checkCache = true) private async Task<Tuple<bool, string>> GetStreamStatus(StreamNotificationConfig stream, bool checkCache = true)

View File

@ -231,7 +231,7 @@ namespace NadekoBot
#if NADEKO_RELEASE #if NADEKO_RELEASE
Client.ClientAPI.SentRequest += (s, e) => Client.ClientAPI.SentRequest += (s, e) =>
{ {
Console.WriteLine($"[Request sent in {e.Milliseconds}]"); Console.WriteLine($"[Request of type {e.Request.GetType()} sent in {e.Milliseconds}]");
}; };
#endif #endif
PermissionsHandler.Initialize(); PermissionsHandler.Initialize();

View File

@ -13,6 +13,9 @@
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<IsWebBootstrapper>false</IsWebBootstrapper> <IsWebBootstrapper>false</IsWebBootstrapper>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
<PublishUrl>C:\Users\Master\Desktop\NadekoBot\</PublishUrl> <PublishUrl>C:\Users\Master\Desktop\NadekoBot\</PublishUrl>
<Install>true</Install> <Install>true</Install>
<InstallFrom>Disk</InstallFrom> <InstallFrom>Disk</InstallFrom>
@ -30,9 +33,6 @@
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted> <PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -161,6 +161,9 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>lib\ScaredFingers.UnitsConversion.dll</HintPath> <HintPath>lib\ScaredFingers.UnitsConversion.dll</HintPath>
</Reference> </Reference>
<Reference Include="sqlite3">
<HintPath>Classes\lib\sqlite3.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Net" /> <Reference Include="System.Net" />
@ -299,8 +302,12 @@
<Compile Include="Classes\NadekoStats.cs" /> <Compile Include="Classes\NadekoStats.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config">
<None Include="packages.config" /> <SubType>Designer</SubType>
</None>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2"> <BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
@ -553,9 +560,7 @@
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\packages\SQLitePCL.native.sqlite3.v110_xp.0.9.2\build\SQLitePCL.native.sqlite3.v110_xp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\SQLitePCL.native.sqlite3.v110_xp.0.9.2\build\SQLitePCL.native.sqlite3.v110_xp.targets'))" />
</Target> </Target>
<Import Project="..\packages\SQLitePCL.native.sqlite3.v110_xp.0.9.2\build\SQLitePCL.native.sqlite3.v110_xp.targets" Condition="Exists('..\packages\SQLitePCL.native.sqlite3.v110_xp.0.9.2\build\SQLitePCL.native.sqlite3.v110_xp.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">

View File

@ -11,11 +11,6 @@
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net46" /> <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net46" />
<package id="RestSharp" version="105.2.3" targetFramework="net452" /> <package id="RestSharp" version="105.2.3" targetFramework="net452" />
<package id="sqlite-net" version="1.0.8" targetFramework="net452" /> <package id="sqlite-net" version="1.0.8" targetFramework="net452" />
<package id="SQLitePCL.bundle_green" version="0.9.2" targetFramework="net452" />
<package id="SQLitePCL.native.sqlite3.v110_xp" version="0.9.2" targetFramework="net452" />
<package id="SQLitePCL.plugin.sqlite3.net45" version="0.9.2" targetFramework="net452" />
<package id="SQLitePCL.raw" version="0.9.2" targetFramework="net452" />
<package id="System.Data.SQLite" version="1.0.102.0" targetFramework="net452" />
<package id="taglib" version="2.1.0.0" targetFramework="net452" /> <package id="taglib" version="2.1.0.0" targetFramework="net452" />
<package id="VideoLibrary" version="1.3.3" targetFramework="net452" /> <package id="VideoLibrary" version="1.3.3" targetFramework="net452" />
</packages> </packages>