diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 391c1e0..075de10 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -16,7 +16,9 @@ ```json { "discord": "YOUR DISCORD BOT TOKEN", - "coc": "YOUR COC KEY, IT IS IP SENSITIVE" + "coc": "YOUR COC KEY, IT IS IP SENSITIVE", + ... + // Please refer to the variable 'definition' in Secrets.cs for all the required data } ``` @@ -31,14 +33,14 @@ * `Discord.cs`: Module for interacting with Discord API * `Sql/`: Interacts with the database -The sole purpose of Program.cs is to fire `InitTask()` in Coc.cs and Discord.cs, then wait forever. +The sole purpose of Program.cs is to fire `InitAsync()` in Coc.cs, Sql/Db.cs and Discord.cs, then wait forever. Discord.cs requires some time to be 'ready'. When it's ready, it calls `Coc.BotReadyAsync`, which is an endless loop that processes Coc.cs tasks every 5 seconds. ## Coc.cs When Discord bot is ready, Coc.cs fetches the first copy of clan data. `PollAsync` is called every 5s. -For each call, it fetches the latest Clan data and compares it with the previous one. The result is stored in a `ClanUtil` and is used to dispatch other tasks within Coc.cs. When all the tasks are done, it will replace the previous clan data with the current one. +For each PollAsync call, it fetches the latest Clan data and compares it with the previous one. The result is stored in a `ClanUtil` and is used to dispatch other tasks within Coc.cs. When all the tasks are done, it will replace the previous clan data with the current one. For each task run, if it needs to interact with Discord, it will call the appropriate methods in `Discord.cs`. @@ -46,7 +48,7 @@ For each task run, if it needs to interact with Discord, it will call the approp # Coding Guidelines 1. No variables should be shared between `Discord.cs`, `Coc.cs` and `Db.cs`. If you need functionalities in another module, expose a public method and call it instead. -2. Access modifiers: If a var/func shouldn't be shared, make it private. If a var/func should be shared, make it public. +2. Access modifiers: Make things as restrictive as possible. If a var/func shouldn't be shared, make it private. 3. SQL: All SQL statements should be executed only in `Sql/`. Same logic as above 4. How to order things in a class: ```cs @@ -91,5 +93,4 @@ private List FindFactors(uint number) { } private async Task ReportToCIA() { } public uint ComputeFactorial(uint number) { } public async Task ProcessPayment() { } -``` -5. Make things as restrictive as possible. \ No newline at end of file +``` \ No newline at end of file diff --git a/Bot/Coc.cs b/Bot/Coc.cs index 38cbae6..80b616a 100644 --- a/Bot/Coc.cs +++ b/Bot/Coc.cs @@ -5,7 +5,7 @@ namespace Hyperstellar; -internal sealed class Coc +internal static class Coc { private sealed class ClanUtil { diff --git a/Bot/Secrets.cs b/Bot/Secrets.cs index 0b8ca94..a3122a4 100644 --- a/Bot/Secrets.cs +++ b/Bot/Secrets.cs @@ -2,9 +2,9 @@ internal sealed class Secrets { - internal static readonly string s_discord; - internal static readonly string s_coc; - internal static readonly ulong s_botLogId; + internal static readonly string s_discord; // Your Discord bot token + internal static readonly string s_coc; // Your coc token + internal static readonly ulong s_botLogId; // Discord TextChannel ID for the bot to send events to internal static readonly string s_cocId; // Your coc id, for debugging only static Secrets()