| @@ -7,7 +7,9 @@ using System; | ||||
| using System.Collections.Concurrent; | ||||
| using System.Collections.Generic; | ||||
| using System.Diagnostics; | ||||
| #if NADEKO_RELEASE | ||||
| using System.IO; | ||||
| #endif | ||||
| using System.Linq; | ||||
| using System.Net.Http; | ||||
| using System.Reflection; | ||||
| @@ -227,6 +229,7 @@ namespace NadekoBot | ||||
|             DateTime dt; | ||||
|             if (!commandTracker.TryGetValue(e.Message.Id, out dt)) | ||||
|                 return; | ||||
| #if NADEKO_RELEASE | ||||
|             try | ||||
|             { | ||||
|                 if (e is CommandErrorEventArgs) | ||||
| @@ -248,6 +251,7 @@ namespace NadekoBot | ||||
|                 } | ||||
|             } | ||||
|             catch { } | ||||
| #endif | ||||
|         } | ||||
|  | ||||
|         private async void StatsCollector_RanCommand(object sender, CommandEventArgs e) | ||||
|   | ||||
| @@ -61,10 +61,31 @@ namespace NadekoBot.Classes | ||||
|             IEnumerable<KeyValuePair<string, string>> headers = null, | ||||
|             RequestHttpMethod method = RequestHttpMethod.Get) | ||||
|         { | ||||
|  | ||||
|             using (var streamReader = new StreamReader(await GetResponseStreamAsync(url, headers, method).ConfigureAwait(false))) | ||||
|             if (string.IsNullOrWhiteSpace(url)) | ||||
|                 throw new ArgumentNullException(nameof(url)); | ||||
|             var cl = new HttpClient(); | ||||
|             cl.DefaultRequestHeaders.Clear(); | ||||
|             switch (method) | ||||
|             { | ||||
|                 return await streamReader.ReadToEndAsync().ConfigureAwait(false); | ||||
|                 case RequestHttpMethod.Get: | ||||
|                     if (headers != null) | ||||
|                     { | ||||
|                         foreach (var header in headers) | ||||
|                         { | ||||
|                             cl.DefaultRequestHeaders.TryAddWithoutValidation(header.Key, header.Value); | ||||
|                         } | ||||
|                     } | ||||
|                     return await cl.GetStringAsync(url).ConfigureAwait(false); | ||||
|                 case RequestHttpMethod.Post: | ||||
|                     FormUrlEncodedContent formContent = null; | ||||
|                     if (headers != null) | ||||
|                     { | ||||
|                         formContent = new FormUrlEncodedContent(headers); | ||||
|                     } | ||||
|                     var message = await cl.PostAsync(url, formContent).ConfigureAwait(false); | ||||
|                     return await message.Content.ReadAsStringAsync().ConfigureAwait(false); | ||||
|                 default: | ||||
|                     throw new NotImplementedException("That type of request is unsupported."); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								NadekoBot/Classes/lib/sqlite3.dll
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								NadekoBot/Classes/lib/sqlite3.dll
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -7,31 +7,32 @@ using System; | ||||
| using System.Collections.Concurrent; | ||||
| using System.Linq; | ||||
| using System.Threading.Tasks; | ||||
| using System.Timers; | ||||
|  | ||||
| namespace NadekoBot.Modules.Searches.Commands | ||||
| { | ||||
|     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 bool FirstPass { get; set; } = true; | ||||
|  | ||||
|         public StreamNotifications(DiscordModule module) : base(module) | ||||
|         { | ||||
|  | ||||
|             checkTimer.Elapsed += async (s, e) => | ||||
|             //start checking only after ready, because we need all servers to be initialized | ||||
|             NadekoBot.OnReady += () => Task.Run(async () => | ||||
|             { | ||||
|                 while (true) | ||||
|                 { | ||||
|                     cachedStatuses.Clear(); | ||||
|                     try | ||||
|                     { | ||||
|                         var streams = SpecificConfigurations.Default.AllConfigs.SelectMany(c => c.ObservingStreams); | ||||
|                         if (!streams.Any()) return; | ||||
|  | ||||
| #if NADEKO_RELEASE | ||||
|                         var clr = Console.ForegroundColor; | ||||
|                         Console.ForegroundColor = ConsoleColor.Blue; | ||||
|                         Console.WriteLine($"Getting {streams.Count()} streams."); | ||||
|                         Console.ForegroundColor = clr; | ||||
| #endif | ||||
|                         foreach (var stream in streams) | ||||
|                         { | ||||
|                             Tuple<bool, string> data; | ||||
| @@ -47,6 +48,8 @@ namespace NadekoBot.Modules.Searches.Commands | ||||
|                             if (data.Item1 != stream.LastStatus) | ||||
|                             { | ||||
|                                 stream.LastStatus = data.Item1; | ||||
|                                 if (FirstPass) | ||||
|                                     continue; | ||||
|                                 var server = NadekoBot.Client.GetServer(stream.ServerId); | ||||
|                                 var channel = server?.GetChannel(stream.ChannelId); | ||||
|                                 if (channel == null) | ||||
| @@ -66,12 +69,21 @@ namespace NadekoBot.Modules.Searches.Commands | ||||
|                                 await channel.SendMessage(msg).ConfigureAwait(false); | ||||
|                             } | ||||
|                         } | ||||
|                         FirstPass = false; | ||||
| #if NADEKO_RELEASE | ||||
|                         clr = Console.ForegroundColor; | ||||
|                         Console.ForegroundColor = ConsoleColor.Blue; | ||||
|                         Console.WriteLine($"Done getting streams."); | ||||
|                         Console.ForegroundColor = clr; | ||||
| #endif | ||||
|                     } | ||||
|                     catch { } | ||||
|                 await ConfigHandler.SaveConfig().ConfigureAwait(false); | ||||
|             }; | ||||
|             //start checking only after ready, because we need all servers to be initialized | ||||
|             NadekoBot.OnReady += checkTimer.Start; | ||||
|                     finally | ||||
|                     { | ||||
|                         await Task.Delay(TimeSpan.FromSeconds(15)); | ||||
|                     } | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         private async Task<Tuple<bool, string>> GetStreamStatus(StreamNotificationConfig stream, bool checkCache = true) | ||||
|   | ||||
| @@ -300,10 +300,11 @@ $@"🌍 **Weather for** 【{obj["target"]}】 | ||||
|                       { | ||||
|                           var items = JObject.Parse(res); | ||||
|                           var sb = new System.Text.StringBuilder(); | ||||
|                           sb.AppendLine($"`Term:` {items["list"][0]["word"].ToString()}"); | ||||
|                           sb.AppendLine($"`Definition:` {items["list"][0]["definition"].ToString()}"); | ||||
|                           sb.Append($"`Link:` <{await items["list"][0]["permalink"].ToString().ShortenUrl().ConfigureAwait(false)}>"); | ||||
|                           await e.Channel.SendMessage(sb.ToString()); | ||||
|                           var item = items["list"][0]; | ||||
|                           sb.AppendLine($"`Term:` {item["word"].ToString()}"); | ||||
|                           sb.AppendLine($"`Definition:` {item["definition"].ToString()}"); | ||||
|                           sb.Append($"`Link:` <{item["permalink"].ToString()}>"); | ||||
|                           await e.Channel.SendMessage(sb.ToString()).ConfigureAwait(false); | ||||
|                       } | ||||
|                       catch | ||||
|                       { | ||||
|   | ||||
| @@ -117,7 +117,7 @@ namespace NadekoBot | ||||
|             Client = new DiscordClient(new DiscordConfigBuilder() | ||||
|             { | ||||
|                 MessageCacheSize = 10, | ||||
|                 ConnectionTimeout = 180000, | ||||
|                 ConnectionTimeout = 200000, | ||||
|                 LogLevel = LogSeverity.Warning, | ||||
|                 LogHandler = (s, e) => | ||||
|                     Console.WriteLine($"Severity: {e.Severity}" + | ||||
| @@ -197,7 +197,7 @@ namespace NadekoBot | ||||
|                     return; | ||||
|                 } | ||||
| #if NADEKO_RELEASE | ||||
|                 await Task.Delay(150000).ConfigureAwait(false); | ||||
|                 await Task.Delay(180000).ConfigureAwait(false); | ||||
| #else | ||||
|                 await Task.Delay(1000).ConfigureAwait(false); | ||||
| #endif | ||||
| @@ -228,6 +228,12 @@ namespace NadekoBot | ||||
|                     if (string.IsNullOrWhiteSpace(request.Content)) | ||||
|                         e.Cancel = true; | ||||
|                 }; | ||||
| #if NADEKO_RELEASE | ||||
|                 Client.ClientAPI.SentRequest += (s, e) => | ||||
|                 { | ||||
|                     Console.WriteLine($"[Request of type {e.Request.GetType()} sent in {e.Milliseconds}]"); | ||||
|                 }; | ||||
| #endif | ||||
|                 PermissionsHandler.Initialize(); | ||||
|                 NadekoBot.Ready = true; | ||||
|                 NadekoBot.OnReady(); | ||||
|   | ||||
| @@ -13,6 +13,9 @@ | ||||
|     <FileAlignment>512</FileAlignment> | ||||
|     <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||||
|     <IsWebBootstrapper>false</IsWebBootstrapper> | ||||
|     <NuGetPackageImportStamp> | ||||
|     </NuGetPackageImportStamp> | ||||
|     <TargetFrameworkProfile /> | ||||
|     <PublishUrl>C:\Users\Master\Desktop\NadekoBot\</PublishUrl> | ||||
|     <Install>true</Install> | ||||
|     <InstallFrom>Disk</InstallFrom> | ||||
| @@ -30,9 +33,6 @@ | ||||
|     <UseApplicationTrust>false</UseApplicationTrust> | ||||
|     <PublishWizardCompleted>true</PublishWizardCompleted> | ||||
|     <BootstrapperEnabled>true</BootstrapperEnabled> | ||||
|     <NuGetPackageImportStamp> | ||||
|     </NuGetPackageImportStamp> | ||||
|     <TargetFrameworkProfile /> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||||
|     <PlatformTarget>AnyCPU</PlatformTarget> | ||||
| @@ -161,6 +161,9 @@ | ||||
|       <SpecificVersion>False</SpecificVersion> | ||||
|       <HintPath>lib\ScaredFingers.UnitsConversion.dll</HintPath> | ||||
|     </Reference> | ||||
|     <Reference Include="sqlite3"> | ||||
|       <HintPath>Classes\lib\sqlite3.dll</HintPath> | ||||
|     </Reference> | ||||
|     <Reference Include="System" /> | ||||
|     <Reference Include="System.Drawing" /> | ||||
|     <Reference Include="System.Net" /> | ||||
| @@ -299,8 +302,12 @@ | ||||
|     <Compile Include="Classes\NadekoStats.cs" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <None Include="App.config" /> | ||||
|     <None Include="packages.config" /> | ||||
|     <None Include="App.config"> | ||||
|       <SubType>Designer</SubType> | ||||
|     </None> | ||||
|     <None Include="packages.config"> | ||||
|       <SubType>Designer</SubType> | ||||
|     </None> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <BootstrapperPackage Include=".NETFramework,Version=v4.5.2"> | ||||
| @@ -553,9 +560,7 @@ | ||||
|     <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> | ||||
|     </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> | ||||
|   <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.  | ||||
|        Other similar extension points exist, see Microsoft.Common.targets. | ||||
|   <Target Name="BeforeBuild"> | ||||
|   | ||||
| @@ -11,11 +11,6 @@ | ||||
|   <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net46" /> | ||||
|   <package id="RestSharp" version="105.2.3" 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="VideoLibrary" version="1.3.3" targetFramework="net452" /> | ||||
| </packages> | ||||
 Submodule discord.net updated: e3fd2b99a4...f90cf4ae5c
									
								
							
		Reference in New Issue
	
	Block a user