mirror of
https://github.com/NoiTheCat/BirthdayBot.git
synced 2024-11-21 21:54:36 +00:00
Merge pull request #21 from NoiTheCat/dev/tweaks
Various tweaks and additions
This commit is contained in:
commit
586c11d540
6 changed files with 47 additions and 21 deletions
|
@ -221,7 +221,8 @@ public class BirthdayModule : BotModuleBase {
|
|||
select new {
|
||||
UserId = (ulong)row.UserId,
|
||||
Month = row.BirthMonth,
|
||||
Day = row.BirthDay
|
||||
Day = row.BirthDay,
|
||||
Zone = row.TimeZone
|
||||
};
|
||||
|
||||
var result = new List<ListItem>();
|
||||
|
@ -234,7 +235,8 @@ public class BirthdayModule : BotModuleBase {
|
|||
BirthDay = row.Day,
|
||||
DateIndex = DateIndex(row.Month, row.Day),
|
||||
UserId = guildUser.Id,
|
||||
DisplayName = Common.FormatName(guildUser, false)
|
||||
DisplayName = Common.FormatName(guildUser, false),
|
||||
TimeZone = row.Zone
|
||||
});
|
||||
}
|
||||
return result;
|
||||
|
@ -254,6 +256,7 @@ public class BirthdayModule : BotModuleBase {
|
|||
writer.Write(item.UserId);
|
||||
writer.Write(" " + user.Username + "#" + user.Discriminator);
|
||||
if (user.Nickname != null) writer.Write(" - Nickname: " + user.Nickname);
|
||||
if (item.TimeZone != null) writer.Write(" | Time zone: " + item.TimeZone);
|
||||
writer.WriteLine();
|
||||
}
|
||||
writer.Flush();
|
||||
|
@ -267,7 +270,7 @@ public class BirthdayModule : BotModuleBase {
|
|||
var writer = new StreamWriter(result, Encoding.UTF8);
|
||||
|
||||
// Conforming to RFC 4180; with header
|
||||
writer.Write("UserId,Username,Nickname,MonthDayDisp,Month,Day");
|
||||
writer.Write("UserId,Username,Nickname,MonthDayDisp,Month,Day,TimeZone");
|
||||
writer.Write("\r\n"); // crlf line break is specified by the standard
|
||||
foreach (var item in list) {
|
||||
var user = guild.GetUser(item.UserId);
|
||||
|
@ -283,6 +286,8 @@ public class BirthdayModule : BotModuleBase {
|
|||
writer.Write(item.BirthMonth);
|
||||
writer.Write(',');
|
||||
writer.Write(item.BirthDay);
|
||||
writer.Write(',');
|
||||
writer.Write(item.TimeZone);
|
||||
writer.Write("\r\n");
|
||||
}
|
||||
writer.Flush();
|
||||
|
@ -325,6 +330,7 @@ public class BirthdayModule : BotModuleBase {
|
|||
public int BirthDay;
|
||||
public ulong UserId;
|
||||
public string DisplayName;
|
||||
public string? TimeZone;
|
||||
}
|
||||
#endregion
|
||||
}
|
|
@ -193,7 +193,7 @@ public class ConfigModule : BotModuleBase {
|
|||
var result = new StringBuilder();
|
||||
|
||||
result.AppendLine($"Server ID: `{guild.Id}` | Bot shard ID: `{Shard.ShardId:00}`");
|
||||
result.AppendLine($"Number of registered birthdays: `{ guildconf.UserEntries.Count() }`");
|
||||
result.AppendLine($"Number of registered birthdays: `{ guildconf.UserEntries.Count }`");
|
||||
result.AppendLine($"Server time zone: `{ (guildconf.TimeZone ?? "Not set - using UTC") }`");
|
||||
result.AppendLine();
|
||||
|
||||
|
|
|
@ -132,9 +132,10 @@ class BirthdayRoleUpdate : BackgroundService {
|
|||
if (!toApply.Contains(user.Id)) removals.Add(user);
|
||||
else no_ops.Add(user.Id);
|
||||
}
|
||||
int removalAllowance = 15; // Limit removals per run, to not get continuously stuck on rate limits in misconfigured servers
|
||||
foreach (var user in removals) {
|
||||
// TODO this gets hit with rate limits sometimes. figure something out.
|
||||
await user.RemoveRoleAsync(r);
|
||||
if (--removalAllowance == 0) break;
|
||||
}
|
||||
|
||||
foreach (var target in toApply) {
|
||||
|
@ -146,7 +147,7 @@ class BirthdayRoleUpdate : BackgroundService {
|
|||
}
|
||||
} catch (Discord.Net.HttpException ex)
|
||||
when (ex.DiscordCode is DiscordErrorCode.MissingPermissions or DiscordErrorCode.InsufficientPermissions) {
|
||||
// Encountered access and/or permission issues despite earlier checks. Quit the loop here.
|
||||
// Encountered access and/or permission issues despite earlier checks. Quit the loop here, don't report error.
|
||||
}
|
||||
return additions;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>3.3.1</Version>
|
||||
<Version>3.4.0</Version>
|
||||
<Authors>NoiTheCat</Authors>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
|||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="NodaTime" Version="3.0.9" />
|
||||
<PackageReference Include="NodaTime" Version="3.0.10" />
|
||||
<PackageReference Include="Npgsql" Version="6.0.3" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.3" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.Design" Version="1.1.0" />
|
||||
|
|
41
Readme.md
41
Readme.md
|
@ -4,30 +4,47 @@
|
|||
|
||||
## Recognize birthdays in your Discord community!
|
||||
|
||||
Birthday Bot is a simple, single-purpose bot. It will set a role on your users for the duration of their birthdays and, if desired, can announce a message in a channel of your choosing. Server owners can further specify a default time zone, with individual users also setting their own to ensure everyone's birthdays are recognized precisely on time.
|
||||
Birthday Bot is a simple, single-purpose bot. It will set a role on your users for the duration of their birthdays and, if desired, can
|
||||
announce a message in a channel of your choosing. Server owners can further specify a default time zone, with individual users also setting
|
||||
their own to ensure everyone's birthdays are recognized precisely on time.
|
||||
|
||||
#### Getting started
|
||||
This bot requires a small amount of initial set-up before it's ready for use. To quickly get started, ensure that you:
|
||||
* Create a dedicated birthday role to be used only by the bot. Ensure the new role is placed beneath the bot's own role.
|
||||
* **Do not use an existing role!** This bot assumes exclusive control over it. Users that have the role but are not having a birthday *will* be removed from it!
|
||||
* Instruct the bot to use the role: `bb.config role (role name)`
|
||||
* **Do not use an existing role!** This bot assumes exclusive control over it. Users that have the role but are not having a birthday
|
||||
*will* be removed from it!
|
||||
* Instruct the bot to use the role: `/config role set-birthday-role`
|
||||
At this point, you may also wish to do the following optional steps:
|
||||
* Set the birthday announcement channel: `bb.config channel (channel)`
|
||||
* Set a default time zone: `bb.config zone (time zone)`
|
||||
* Use the command `bb.help-tzdata` for information on how to specify time zones.
|
||||
* Customize the announcement message: See `bb.help-message` for more information.
|
||||
* Set the birthday announcement channel: `/config announce set-channel`
|
||||
* Set a default time zone: `/config set-timezone`
|
||||
* Customize the announcement message: See `/config announce help` for more information.
|
||||
|
||||
#### Time zone support
|
||||
You may specify a time zone in order to have your birthday recognized with respect to your local time. This bot only accepts zone names
|
||||
from the IANA Time Zone Database (a.k.a. Olson Database).
|
||||
* To find your zone: https://xske.github.io/tz/
|
||||
* Interactive map: https://kevinnovak.github.io/Time-Zone-Picker/
|
||||
* Complete list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||
|
||||
#### Support the bot
|
||||
Birthday Bot is and shall remain fully free to use. I have no plans to hide any new or existing features behind pay-only, premium features. This is an independent hobby project and all costs associated with it come out of my pocket.
|
||||
Birthday Bot is and shall remain fully free to use. I have no plans to hide any new or existing features behind pay-only, premium features.
|
||||
This is an independent hobby project and all costs associated with it come out of my pocket.
|
||||
|
||||
This bot has had a far greater response than I've ever expected, and at this point I find it difficult to pay for the server it runs on as its resource needs grow. I would greatly appreciate if you consider pitching in a little bit to cover my recurring costs by checking out my Ko-fi page: https://ko-fi.com/noithecat.
|
||||
This bot has had a far greater response than I've ever expected, and at this point I find it difficult to pay for the server it runs on as
|
||||
its resource needs grow. I would greatly appreciate if you consider pitching in a little bit to cover my recurring costs by checking out my
|
||||
Ko-fi page: https://ko-fi.com/noithecat.
|
||||
|
||||
#### Support, Privacy and Security
|
||||
The support server for my bots can be accessed via the given link: https://discord.gg/JCRyFk7. Further information in setting up the bot can be found within it, as well as a small group of volunteers who are willing to answer questions.
|
||||
The support server for my bots can be accessed via the given link: https://discord.gg/JCRyFk7. Further information in setting up the bot
|
||||
can be found within it, as well as a small group of volunteers who are willing to answer questions.
|
||||
|
||||
This bot collects and stores only information necessary for its operation, including user, server, and role IDs. This data is not stored indefinitely, and is removed after an extended period of lack of use. If an individual member of a server is not seen after 360 days, their data is purged. If the bot has been removed from a server, all existing data (including of its associated users) is purged after 180 days.
|
||||
This bot collects and stores only information necessary for its operation, including user, server, and role IDs. This data is not stored
|
||||
indefinitely, but is removed after an extended period of lack of use. If an individual member of a server is not seen after 360 days, their
|
||||
data is purged. If the bot has been removed from a server, all data (including of its associated users) is purged after 180 days.
|
||||
|
||||
Birthdays are not shared between servers that this same bot may be in. This is *by design*, for those preferring to share their birthdays with only certain communities instead of automatically sharing it to all of them. Users must enter their birthday information onto every server they share with the bot for the servers they wish for it to be known in.
|
||||
Birthdays are not shared between servers that this same bot may be in. This is *by design*, for those preferring to share their birthdays
|
||||
with only certain communities instead of automatically sharing it to all of them. Users must enter their birthday information onto every
|
||||
server they share with the bot for the servers they wish for it to be known in.
|
||||
|
||||
Any questions and concerns regarding data and security may be sent to the bot author via the support server or GitHub.
|
||||
|
||||
|
|
|
@ -34,7 +34,9 @@ internal class HelpInfoCommands : CommandsCommon {
|
|||
// Normal section
|
||||
var cmdField = new EmbedFieldBuilder() {
|
||||
Name = "Commands",
|
||||
Value = $"{cpfx}help`, `{CommandPrefix}info`, `{CommandPrefix}help-tzdata`\n"
|
||||
Value = "----\n**Notice**: Text commands will soon be __removed__. "
|
||||
+ "For a list of new commands, see this bot's `/help` command.\n----\n"
|
||||
+ $"{cpfx}help`, `{CommandPrefix}info`, `{CommandPrefix}help-tzdata`\n"
|
||||
+ $" » Help and informational messages.\n"
|
||||
+ ListingCommands.DocUpcoming.Export() + "\n"
|
||||
+ UserCommands.DocSet.Export() + "\n"
|
||||
|
|
Loading…
Reference in a new issue