Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A bot command to fork a thread #34

Closed
jkomoros opened this issue May 16, 2021 · 2 comments
Closed

A bot command to fork a thread #34

jkomoros opened this issue May 16, 2021 · 2 comments

Comments

@jkomoros
Copy link
Owner

jkomoros commented May 16, 2021

If someone replies to any message in any channel and uses the magic command, then the bot should create a new thread starting with the message that it's in reply to.

At the beginning, it will be a slash command reply that is in reply to the message that should be the new OP.

The thread OP should be a copy/paste of the message, with a link back to the original (using a channel reference, an actual link, and an @mention of the user).

In the future (once #35) is supported, when we can rename threads by tfidf words, then it should be possible to fork a thread merely by hitting the 🍴 emoji reaction on a post and have it auto named based on the contents of the OP.

Originally captured in #19

@jkomoros
Copy link
Owner Author

jkomoros commented May 16, 2021

  • Switch to using a version of discordgo that supports slash commands
  • Fix the slash command permissions error
  • Figure out how to get the slash command to show up when composing a a reply to another message in the UI (is this not possible?)
  • Fix Have a command to have the bot rename a thread based on distinctive words #35 (so threads created will automatically have reasonable names)
  • When seeing a 🧵 emoji, create a fork automatically in a fixed channel ID
  • The channel fork cache has to keep channelD + messageID for both sides (you can't fetch a message via just a messageID)
  • Save out forked message caches when they're updated
  • The IDF cache indexes forked messages when it sees them and keeps track of the originalMessageID --> forkedID
  • The IDF cache should be persisted in memory (especially if we need to look into it for forks, and it's not huge memory) and periodically rebuilt.
  • Bug: the forked message is not persited anymore, so if you kill the bot and restart and the cache is recent enough, it won't contain the forked messages that happened since last rebuild. One option is to delete the IDF cache when it needs to be rebuilt. Another option is to have the timestamp be IN the file, not literal metadata in filesystem, so we can distinguish when an IDF needs to be regenerated, while still persisting fork information just fine.
  • When a message that is forked is edited, update the content in the forked version
  • Handle read outs of emojis that are not built-in in forked messages
  • When a message that is forked is deleted, delete the forks (or not?)
  • When a message that is a fork of another is deleted, forget about it
  • When seeing the fork emoji don't fork if it's already been forked
  • After forking, undo the thread and needle
  • BUG: AutoTopWords last line can panic if there aren't that many words total
  • When an emoji reaction comes in on a message that is forked, update the emoji reactions for each
  • When a forked message is created, reply back to the last message in the fork chain with a link to the new forked thing
  • When hitting the thread emoji, reply to that message and ask what the thread title should be and then fork it to that thread.
  • Do the clippings for normal emoji reactions (when they lose the emoji they need to be a clipping, delete the clipping, and every additional emoji copy over the emojis)
  • The fork reply should mention that you can use a :needle to fork multiple items if only one was provided
  • When a 🧵 emoji reaction comes, fork just that item
  • Also start at a :sewing-needle and copy down to he thread. (remind people in the "thread created" response that the can do that) (look upwards only until you get to a sewing needle or the thread so you don't copy too much) (ignore messages that aren't normal or replies)
  • When deploying to production also allow the applications.command oauth scope (following instructions in readme)
  • newBot should return a bot and an err, not panic
  • Once tehre's a new release of discordgo that supports slash commands, switch to that and off of the specific commit import

jkomoros added a commit that referenced this issue May 16, 2021
…s, since there's not a tagged release yet that does. Part of #34.
jkomoros added a commit that referenced this issue May 16, 2021
Because it's a global command, not a guild command, it might take up to an hour for it to actually show up for use in guilds. I THINK it worked but can't tell yet because of that.

This will require re-authing the bot on your channel as it also requires application.command oauth scope.

Part of #34.
jkomoros added a commit that referenced this issue May 16, 2021
… or env var `DEBUG_GUILD_ID`.

This reveals that the command was failing to register with a permissions error in the last commit. (But I guess it doesn't show the error because it wasn't clear that ANY guild actually wanted it).

Part of #34.
jkomoros added a commit that referenced this issue May 16, 2021
jkomoros added a commit that referenced this issue May 16, 2021
It's currently just a no-op ACK but at least now there isn't an error show in the discord chat client to the invoking user.

Part of #34.
@jkomoros
Copy link
Owner Author

jkomoros commented May 16, 2021

Well darn it, looks like slash commands are not legal to issue in the UI when responding to a message, and there's no type of field in a slash command for a given message ID. So we'll need to figure out a different interaction pattern than replying to a message you want to use as an OP with the '/fork' command.

This machinery with slash commands is useful, so I don't want to get rid of. Maybe have an /archive command to start, which just archives a thread?

jkomoros added a commit that referenced this issue May 16, 2021
* fork-thread-command:
  Make the main interaction be an /archive action. Part of #34. Fixes #36.
  Define getThreadGroupInfoForThread and reimplement isThread in terms of it. Part of #34.
  The bot does an interaction response (as required) for the command fork.
  Fix the permissions error for the slash command bot.
  Allow setting a specific guild ID to debug with via `-debug-guild-id` or env var `DEBUG_GUILD_ID`.
  Make a stub 'fork' command that doesn't actually do anything yet.
  Use a specific version of discordgo module that supports SlashCommands, since there's not a tagged release yet that does. Part of #34.
jkomoros added a commit that referenced this issue Jun 14, 2021
… do antyhing, but will help disable this feature in production in the future if desired. Part of #34.
jkomoros added a commit that referenced this issue Jun 14, 2021
…s if disableEmojiFork is true. Part of #34.

Currently just outputs an ACK message.
jkomoros added a commit that referenced this issue Jun 14, 2021
jkomoros added a commit that referenced this issue Jun 14, 2021
jkomoros added a commit that referenced this issue Jun 14, 2021
…en forked from which other ones (backward references).

We also keep track of those changes live as they happen, although those are currently not saved out regularly. Part of #34.
jkomoros added a commit that referenced this issue Jun 14, 2021
…annelID + messageID to be able to fetch them.

Introduce notion of packedMessageReference which is a simple string that puts `channelID+messageID` and can be unpacked for storing in JSON.

Part of #34.
jkomoros added a commit that referenced this issue Jun 14, 2021
jkomoros added a commit that referenced this issue Jun 14, 2021
…e IDF cache is modified and immediately persisted. Part of #34.
jkomoros added a commit that referenced this issue Jun 14, 2021
jkomoros added a commit that referenced this issue Jun 14, 2021
jkomoros added a commit that referenced this issue Jun 14, 2021
jkomoros added a commit that referenced this issue Jun 15, 2021
… we don't persist the in-memory IDF.

In-memory IDFs might get kind of wonky (e.g. message edits, etc). The canonical way to generate them is to rebuild from scratch, which still happens on a timer.

We'll need the IDFs to be around and convienent to check on message reaction if there's a forked message to update.

Part of #34.
jkomoros added a commit that referenced this issue Jun 15, 2021
…rnal timestamp to figure out if it needs to be regenerated.

This will allow forked indexes to be persisted without messing with the logic for when a full regeneration is necessary. Part of #34.
jkomoros added a commit that referenced this issue Jun 15, 2021
…ile.

This allows noted forked messages to be peristed, otherwise until the rebuild of the IDF happened after a bot shutdown the forked messages would be forgotten about.

Part of #34.
jkomoros added a commit that referenced this issue Jun 15, 2021
…e within 5 minutes, but reqpeated calls will still only have one.

Part of #34.
jkomoros added a commit that referenced this issue Jun 15, 2021
Before, if a forked message came in after an IDF cache was created, and the bot was killed and restarted, then the bot wouldn't know about the forked message until the IDF cache was rebuilt.

Now it should be way less likely for the IDF Cache to not include MOST forked messages (although you could still have one come in in the moment the bot was down, which wouldn't be noticed until the next reindexing).

Part of #34.
jkomoros added a commit that referenced this issue Jun 15, 2021
jkomoros added a commit that referenced this issue Jun 15, 2021
…i reactions on the forked versions, too. Part of #34.
jkomoros added a commit that referenced this issue Jun 15, 2021
…link to the channel it was forked to. Part of #34.
jkomoros added a commit that referenced this issue Jun 15, 2021
…use guildID wasn't passed. No idea why session.ChannelMessage isn't returning the guildID.

Part of #34.
jkomoros added a commit that referenced this issue Jun 15, 2021
…turned message, and document why it exists. Part of #34.
jkomoros added a commit that referenced this issue Jun 15, 2021
… with that message.

The thread is created in the wrong category right now. Part of #34.
jkomoros added a commit that referenced this issue Jun 15, 2021
…ween them, inclusive, up to 100 messages, will be forked too.

Part of #34.
jkomoros added a commit that referenced this issue Jun 15, 2021
…sages before thread.

Now it only copies the one unless there is a needle above it. Part of #34.
jkomoros added a commit that referenced this issue Jun 15, 2021
…wer total words seen then were asked for. Part of #34.
jkomoros added a commit that referenced this issue Jun 16, 2021
…d at some point. Introduce restErrorCode. Part of #34.
jkomoros added a commit that referenced this issue Jun 16, 2021
…eleted, so we don't try to update them when they don't exist.

Not TOTALLY necessary since we handle that problem smoothly in updatedForkedMessages now, but better hygiene.

Part of #34.
jkomoros added a commit that referenced this issue Jun 16, 2021
…nd informs the user they could have forked multiple messages if they used the needle emoji.

Part of #34.
jkomoros added a commit that referenced this issue Jun 17, 2021
…the first time a message gets a fork (or rather, when it passes from 0 to 1, which could theoretically happen multiple times.)

Part of #34.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant