-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathServerSpecificFeatures.cs
More file actions
121 lines (105 loc) · 5.05 KB
/
ServerSpecificFeatures.cs
File metadata and controls
121 lines (105 loc) · 5.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
namespace MechanicalMilkshake;
internal static class ServerSpecificFeatures
{
internal static class EventChecks
{
internal static async Task MessageCreateChecks(MessageCreatedEventArgs e)
{
// ignore dms
if (e.Channel.IsPrivate)
return;
#region my server
if (e.Guild.Id == 799644062973427743)
{
#region &caption -> #captions
if (e.Message.Author.Id == 1031968180974927903 &&
(e.Message.ReferencedMessage is not null && e.Message.ReferencedMessage.Content.Contains("caption")
|| (await e.Message.Channel.GetMessagesBeforeAsync(e.Message.Id, 1).ToListAsync())[0].Content.Contains("caption")))
{
await e.Message.ForwardAsync(1048242806486999092);
}
#endregion &caption -> #captions
}
#endregion my server
#region Patch Tuesday announcements
#if DEBUG
if (e.Guild.Id == 799644062973427743) // my server
{
await PatchTuesdayAnnouncementCheck(e, 455432936339144705, 1409289579139305573);
}
#else
if (e.Guild.Id == 438781053675634713) // not my server
{
await PatchTuesdayAnnouncementCheck(e, 696333378990899301, 1251028070488477716);
}
#endif
#endregion Patch Tuesday announcements
}
private static async Task PatchTuesdayAnnouncementCheck(MessageCreatedEventArgs e, ulong authorId, ulong channelId)
{
// Patch Tuesday automatic message generation
var insiderRedditUrlPattern = @"https:\/\/.*reddit.com\/r\/Windows[0-9]{1,}.*cumulative_updates.*";
// Filter to messages by approved author & channel IDs, and that match the pattern
if (e.Message.Author.Id != authorId || e.Channel.Id != channelId || !Regex.IsMatch(e.Message.Content, insiderRedditUrlPattern))
return;
// List of users to ping with message
var usersToPing = new List<ulong>
{
228574821590499329,
455432936339144705
};
// Get message before current message; if authors do not match or message is not a Cumulative Updates post, ignore
var previousMessage = (await e.Message.Channel.GetMessagesBeforeAsync(e.Message.Id, 1).ToListAsync())[0];
if (previousMessage.Author.Id != e.Message.Author.Id || !Regex.IsMatch(previousMessage.Content, insiderRedditUrlPattern))
return;
// Get URLs from both messages
var thisUrl = Regex.Match(e.Message.Content, insiderRedditUrlPattern).Value;
var previousUrl = Regex.Match(previousMessage.Content, insiderRedditUrlPattern).Value;
// Figure out which URL is Windows 10 and which is Windows 11
var windows10Url = thisUrl.Contains("Windows10") ? thisUrl : previousUrl;
var windows11Url = thisUrl.Contains("Windows11") ? thisUrl : previousUrl;
// Assemble message
var msg = "";
foreach (var user in usersToPing)
{
msg += $"<@{user}> ";
}
msg += $"```\nIt's <@&445773142233710594>! Update discussion threads & changelist links are here: {windows10Url} (Windows 10 Extended Security Updates) and {windows11Url} (Windows 11)\n```";
// Send message
await e.Message.Channel.SendMessageAsync(msg);
}
}
internal static class Commands
{
internal static class MessageCommands
{
// This command has no attributes to restrict where it can be used, because it is only registered to a single server anyway
[Command("poop")]
[Description("immaturity is key")]
[TextAlias("shit", "defecate")]
[AllowedProcessors(typeof(TextCommandProcessor))]
public static async Task Poop(CommandContext ctx, [RemainingText] string much = "")
{
try
{
DiscordChannel chan;
DiscordMessage msg;
#if DEBUG
chan = await Setup.State.Discord.Client.GetChannelAsync(893654247709741088);
msg = await chan.GetMessageAsync(1282187612844589168);
#else
chan = await Setup.State.Discord.Client.GetChannelAsync(892978015309557870);
msg = much == "MUCH" ? await chan.GetMessageAsync(1294869494648279071) : await chan.GetMessageAsync(1085253151155830895);
#endif
var phrases = msg.Content.Split("\n");
var content = phrases[new Random().Next(0, phrases.Length)].Replace("{user}", ctx.Member.DisplayName);
await ctx.Channel.SendMessageAsync(content);
}
catch (Exception)
{
await ctx.Channel.SendMessageAsync("sorry, i had an accident. please tell milkshake for me.");
}
}
}
}
}