Removed module projects because it can't work like that atm. Commented out package commands.
This commit is contained in:
		| @@ -0,0 +1,11 @@ | ||||
| using System; | ||||
|  | ||||
| namespace NadekoBot.Modules.Utility.Common.Exceptions | ||||
| { | ||||
|     public class StreamRoleNotFoundException : Exception | ||||
|     { | ||||
|         public StreamRoleNotFoundException() : base("Stream role wasn't found.") | ||||
|         { | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,11 @@ | ||||
| using System; | ||||
|  | ||||
| namespace NadekoBot.Modules.Utility.Common.Exceptions | ||||
| { | ||||
|     public class StreamRolePermissionException : Exception | ||||
|     { | ||||
|         public StreamRolePermissionException() : base("Stream role was unable to be applied.") | ||||
|         { | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										23
									
								
								NadekoBot.Core/Modules/Utility/Common/Patreon/PatreonData.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								NadekoBot.Core/Modules/Utility/Common/Patreon/PatreonData.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| using Newtonsoft.Json.Linq; | ||||
|  | ||||
| namespace NadekoBot.Modules.Utility.Common.Patreon | ||||
| { | ||||
|     public class PatreonData | ||||
|     { | ||||
|         public JObject[] Included { get; set; } | ||||
|         public JObject[] Data { get; set; } | ||||
|         public PatreonDataLinks Links { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class PatreonDataLinks | ||||
|     { | ||||
|         public string first { get; set; } | ||||
|         public string next { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class PatreonUserAndReward | ||||
|     { | ||||
|         public PatreonUser User { get; set; } | ||||
|         public PatreonPledge Reward { get; set; } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,62 @@ | ||||
| namespace NadekoBot.Modules.Utility.Common.Patreon | ||||
| { | ||||
|     public class Attributes | ||||
|     { | ||||
|         public int amount_cents { get; set; } | ||||
|         public string created_at { get; set; } | ||||
|         public object declined_since { get; set; } | ||||
|         public bool is_twitch_pledge { get; set; } | ||||
|         public bool patron_pays_fees { get; set; } | ||||
|         public int pledge_cap_cents { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class Address | ||||
|     { | ||||
|         public object data { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class Data | ||||
|     { | ||||
|         public string id { get; set; } | ||||
|         public string type { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class Links | ||||
|     { | ||||
|         public string related { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class Creator | ||||
|     { | ||||
|         public Data data { get; set; } | ||||
|         public Links links { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class Patron | ||||
|     { | ||||
|         public Data data { get; set; } | ||||
|         public Links links { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class Reward | ||||
|     { | ||||
|         public Data data { get; set; } | ||||
|         public Links links { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class Relationships | ||||
|     { | ||||
|         public Address address { get; set; } | ||||
|         public Creator creator { get; set; } | ||||
|         public Patron patron { get; set; } | ||||
|         public Reward reward { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class PatreonPledge | ||||
|     { | ||||
|         public Attributes attributes { get; set; } | ||||
|         public string id { get; set; } | ||||
|         public Relationships relationships { get; set; } | ||||
|         public string type { get; set; } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										64
									
								
								NadekoBot.Core/Modules/Utility/Common/Patreon/PatreonUser.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								NadekoBot.Core/Modules/Utility/Common/Patreon/PatreonUser.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,64 @@ | ||||
| namespace NadekoBot.Modules.Utility.Common.Patreon | ||||
| { | ||||
|     public class DiscordConnection | ||||
|     { | ||||
|         public string user_id { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class SocialConnections | ||||
|     { | ||||
|         public object deviantart { get; set; } | ||||
|         public DiscordConnection discord { get; set; } | ||||
|         public object facebook { get; set; } | ||||
|         public object spotify { get; set; } | ||||
|         public object twitch { get; set; } | ||||
|         public object twitter { get; set; } | ||||
|         public object youtube { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class UserAttributes | ||||
|     { | ||||
|         public string about { get; set; } | ||||
|         public string created { get; set; } | ||||
|         public object discord_id { get; set; } | ||||
|         public string email { get; set; } | ||||
|         public object facebook { get; set; } | ||||
|         public object facebook_id { get; set; } | ||||
|         public string first_name { get; set; } | ||||
|         public string full_name { get; set; } | ||||
|         public int gender { get; set; } | ||||
|         public bool has_password { get; set; } | ||||
|         public string image_url { get; set; } | ||||
|         public bool is_deleted { get; set; } | ||||
|         public bool is_nuked { get; set; } | ||||
|         public bool is_suspended { get; set; } | ||||
|         public string last_name { get; set; } | ||||
|         public SocialConnections social_connections { get; set; } | ||||
|         public int status { get; set; } | ||||
|         public string thumb_url { get; set; } | ||||
|         public object twitch { get; set; } | ||||
|         public string twitter { get; set; } | ||||
|         public string url { get; set; } | ||||
|         public string vanity { get; set; } | ||||
|         public object youtube { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class Campaign | ||||
|     { | ||||
|         public Data data { get; set; } | ||||
|         public Links links { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class UserRelationships | ||||
|     { | ||||
|         public Campaign campaign { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class PatreonUser | ||||
|     { | ||||
|         public UserAttributes attributes { get; set; } | ||||
|         public string id { get; set; } | ||||
|         public UserRelationships relationships { get; set; } | ||||
|         public string type { get; set; } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										107
									
								
								NadekoBot.Core/Modules/Utility/Common/RepeatRunner.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										107
									
								
								NadekoBot.Core/Modules/Utility/Common/RepeatRunner.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,107 @@ | ||||
| using System; | ||||
| using System.Threading; | ||||
| using System.Threading.Tasks; | ||||
| using Discord; | ||||
| using Discord.Net; | ||||
| using Discord.WebSocket; | ||||
| using NadekoBot.Extensions; | ||||
| using NadekoBot.Core.Services.Database.Models; | ||||
| using NLog; | ||||
|  | ||||
| namespace NadekoBot.Modules.Utility.Common | ||||
| { | ||||
|     public class RepeatRunner | ||||
|     { | ||||
|         private readonly Logger _log; | ||||
|  | ||||
|         public Repeater Repeater { get; } | ||||
|         public SocketGuild Guild { get; } | ||||
|         public ITextChannel Channel { get; private set; } | ||||
|         public TimeSpan InitialInterval { get; private set; } | ||||
|  | ||||
|         private IUserMessage oldMsg = null; | ||||
|         private Timer _t; | ||||
|  | ||||
|         public RepeatRunner(DiscordSocketClient client, SocketGuild guild, Repeater repeater) | ||||
|         { | ||||
|             _log = LogManager.GetCurrentClassLogger(); | ||||
|             Repeater = repeater; | ||||
|             Guild = guild; | ||||
|  | ||||
|             InitialInterval = Repeater.Interval; | ||||
|  | ||||
|             Run(); | ||||
|         } | ||||
|  | ||||
|         private void Run() | ||||
|         { | ||||
|             if (Repeater.StartTimeOfDay != null) | ||||
|             { | ||||
|                 if ((InitialInterval = Repeater.StartTimeOfDay.Value - DateTime.UtcNow.TimeOfDay) < TimeSpan.Zero) | ||||
|                     InitialInterval += TimeSpan.FromDays(1); | ||||
|             } | ||||
|  | ||||
|             _t = new Timer(async (_) => { | ||||
|  | ||||
|                 try { await Trigger().ConfigureAwait(false); } catch { } | ||||
|  | ||||
|             }, null, InitialInterval, Repeater.Interval); | ||||
|         } | ||||
|  | ||||
|         public async Task Trigger() | ||||
|         { | ||||
|             var toSend = "🔄 " + Repeater.Message; | ||||
|             //var lastMsgInChannel = (await Channel.GetMessagesAsync(2)).FirstOrDefault(); | ||||
|             // if (lastMsgInChannel.Id == oldMsg?.Id) //don't send if it's the same message in the channel | ||||
|             //     continue; | ||||
|  | ||||
|             if (oldMsg != null) | ||||
|                 try | ||||
|                 { | ||||
|                     await oldMsg.DeleteAsync(); | ||||
|                 } | ||||
|                 catch | ||||
|                 { | ||||
|                     // ignored | ||||
|                 } | ||||
|             try | ||||
|             { | ||||
|                 if (Channel == null) | ||||
|                     Channel = Guild.GetTextChannel(Repeater.ChannelId); | ||||
|  | ||||
|                 if (Channel != null) | ||||
|                     oldMsg = await Channel.SendMessageAsync(toSend.SanitizeMentions()).ConfigureAwait(false); | ||||
|             } | ||||
|             catch (HttpException ex) when (ex.HttpCode == System.Net.HttpStatusCode.Forbidden) | ||||
|             { | ||||
|                 _log.Warn("Missing permissions. Repeater stopped. ChannelId : {0}", Channel?.Id); | ||||
|                 return; | ||||
|             } | ||||
|             catch (HttpException ex) when (ex.HttpCode == System.Net.HttpStatusCode.NotFound) | ||||
|             { | ||||
|                 _log.Warn("Channel not found. Repeater stopped. ChannelId : {0}", Channel?.Id); | ||||
|                 return; | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 _log.Warn(ex); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public void Reset() | ||||
|         { | ||||
|             Stop(); | ||||
|             Run(); | ||||
|         } | ||||
|  | ||||
|         public void Stop() | ||||
|         { | ||||
|             _t.Change(Timeout.Infinite, Timeout.Infinite); | ||||
|         } | ||||
|  | ||||
|         public override string ToString() => | ||||
|             $"{Channel?.Mention ?? $"⚠<#{Repeater.ChannelId}>" } " + | ||||
|             $"| {(int)Repeater.Interval.TotalHours}:{Repeater.Interval:mm} " + | ||||
|             $"| {Repeater.Message.TrimTo(33)}"; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,8 @@ | ||||
| namespace NadekoBot.Modules.Utility.Common | ||||
| { | ||||
|     public enum StreamRoleListType | ||||
|     { | ||||
|         Whitelist, | ||||
|         Blacklist, | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user