From dc9d81d0e8be4c4e54b922a0ca05aa094e3e7dcb Mon Sep 17 00:00:00 2001 From: Tyler Hawkins <3319104+tyzbit@users.noreply.github.com> Date: Sun, 21 Jul 2024 00:17:20 -0400 Subject: [PATCH] feat(core): start sending notices of deprecation of emoji functionality --- README.md | 4 ++-- bot/discord_handlers.go | 22 +++++++++++++++++++--- bot/responses.go | 4 +++- globals/globals.go | 21 ++++++++++----------- main.go | 2 +- 5 files changed, 35 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 09bafc4..7391758 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ https://discord.gg/kvE2bbfYu3 Set some environment variables before launching, or add a `.env` file. -If database environment variables are provided, the bot will save stats to an external database. -Otherwise, it will save stats to a local sqlite database at `/var/go-discord-archiver/local.db` +If database environment variables are provided, the bot will save configuration to an external database. +Otherwise, it will save configuration to a local sqlite database at `/var/go-discord-archiver/local.db` | Variable | Value(s) | | :---------------- | :------------------------------------------------------------------------------------- | diff --git a/bot/discord_handlers.go b/bot/discord_handlers.go index 5f8a77d..b4b4088 100644 --- a/bot/discord_handlers.go +++ b/bot/discord_handlers.go @@ -159,6 +159,21 @@ func (bot *ArchiverBot) MessageReactionAddHandler(s *discordgo.Session, r *disco log.Errorf("problem sending message: %v", err) } } + + bot.DG.ChannelMessageSendComplex(r.ChannelID, &discordgo.MessageSend{ + Embeds: []*discordgo.MessageEmbed{{ + Title: "NOTICE!!!!", + Color: globals.BrightRed, + Description: "The emoji reaction feature is being removed on " + + "September 1, 2024 due to llimitations Discord has " + + "imposed. Instead, use the context menus (right-click or " + + "long press a message). They offer more functionality " + + "than the emoji as well. You can also use the `/archive` " + + "command. Use `/help` for more info. You can provide " + + "feedback on this change on the [issue tracker]" + + "(https://github.com/tyzbit/go-discord-archiver/issues/38).", + }}, + }) } } @@ -188,8 +203,9 @@ func (bot *ArchiverBot) InteractionHandler(s *discordgo.Session, i *discordgo.In } }, // bot.archiveInteraction can handle both the archive slash command and the app menu function - globals.Archive: func(s *discordgo.Session, i *discordgo.InteractionCreate) { bot.archiveInteraction(i, false, true) }, - globals.ArchiveMessage: func(s *discordgo.Session, i *discordgo.InteractionCreate) { bot.archiveInteraction(i, false, true) }, + globals.Archive: func(s *discordgo.Session, i *discordgo.InteractionCreate) { bot.archiveInteraction(i, false, false) }, + globals.ArchiveMessage: func(s *discordgo.Session, i *discordgo.InteractionCreate) { bot.archiveInteraction(i, false, false) }, + globals.ArchiveMessagePrivate: func(s *discordgo.Session, i *discordgo.InteractionCreate) { bot.archiveInteraction(i, false, true) }, globals.ArchiveMessageNewSnapshot: func(s *discordgo.Session, i *discordgo.InteractionCreate) { bot.archiveInteraction(i, true, true) }, globals.Settings: func(s *discordgo.Session, i *discordgo.InteractionCreate) { log.Debug("handling settings request") @@ -348,7 +364,7 @@ func (bot *ArchiverBot) InteractionHandler(s *discordgo.Session, i *discordgo.In } } -// archiveInteraction is called by using /archive and using the "Get snapshots" app function. +// archiveInteraction is called by using /archive and using the "Get archived snapshots" app function. func (bot *ArchiverBot) archiveInteraction(i *discordgo.InteractionCreate, newSnapshot bool, ephemeral bool) { log.Debug("handling archive command request") var flags discordgo.MessageFlags diff --git a/bot/responses.go b/bot/responses.go index 079c6ea..1be88ca 100644 --- a/bot/responses.go +++ b/bot/responses.go @@ -455,7 +455,9 @@ func (bot *ArchiverBot) buildArchiveReply(archivedLinks []string, messageUrls [] } } embed.Footer = &discordgo.MessageEmbedFooter{ - Text: "⚙️ Customize this message with /settings", + Text: "⚙️ Customize this message with /settings\n" + + "NOTICE: Reacting with 🏛️ being deprecated September 1, 2024," + + " run `/help` for more.", } embed.URL = originalUrl diff --git a/globals/globals.go b/globals/globals.go index cb1e848..144d5f5 100644 --- a/globals/globals.go +++ b/globals/globals.go @@ -9,12 +9,11 @@ const ( Retry = "retry" // Commands - Stats = "stats" Settings = "settings" Archive = "archive" - ArchiveMessage = "Get snapshot" - ArchiveMessagePrivate = "Get snapshot (private)" - ArchiveMessageNewSnapshot = "Take snapshot" + ArchiveMessage = "Get saved snapshots" + ArchiveMessagePrivate = "Get saved snapshots (private)" + ArchiveMessageNewSnapshot = "Take new snapshot" Help = "help" // Command options @@ -36,15 +35,19 @@ const ( // Colors FrenchGray = 13424349 + BrightRed = 16711680 // Archive.org URL timestamp layout ArchiveOrgTimestampLayout = "20060102150405" // Shown to the user when `/help` is called BotHelpText = `**Usage** - React to a message that has links with 🏛 (The "classical building" emoji) and the bot will respond in the channel with an archive.org link for the link(s). It saves the page to archive.org if needed. - -- You can also right-click (or long press) a message and use "Get snapshot" to get a message with snapshots that only you can see- You can also right-click (or long press) a message and use "Get snapshot" to get a message with snapshots that only you can see or select "Take snapshot" to take a snapshot of the live page. + - Right-click (or long press) a message and use "Get snapshot" to post a message with snapshots for the links in the message. + - Use the private option for a message only you can see. +- Select "Take snapshot" to take a new snapshot of the live page. + +⚠️ Being deprecated Dec 1, 2024⚠️ +- React to a message that has links with 🏛 (The "classical building" emoji) and the bot will respond in the channel with an archive.org link for the link(s). It saves the page to archive.org if needed. **This is a pretty good way to get around paywalls to read articles for free.** @@ -117,10 +120,6 @@ var ( Name: ArchiveMessageNewSnapshot, Type: discordgo.MessageApplicationCommand, }, - { - Name: Stats, - Description: "Show bot stats", - }, { Name: Settings, Description: "Change settings", diff --git a/main.go b/main.go index 72be97c..64e333e 100644 --- a/main.go +++ b/main.go @@ -141,7 +141,7 @@ func main() { // We have to be explicit about what we want to receive. In addition, // some intents require additional permissions, which must be granted // to the bot when it's added or after the fact by a guild admin - discordIntents := discordgo.IntentsGuildMessages | discordgo.IntentsGuilds | + discordIntents := discordgo.IntentsGuilds | discordgo.IntentsDirectMessages | discordgo.IntentsDirectMessageReactions | discordgo.IntentsGuildMessageReactions dg.Identify.Intents = discordIntents