Skip to content

Add !advice command with custom Markov chain text generation#41

Open
Copilot wants to merge 8 commits into
mainfrom
copilot/add-advice-command-markov-chain
Open

Add !advice command with custom Markov chain text generation#41
Copilot wants to merge 8 commits into
mainfrom
copilot/add-advice-command-markov-chain

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 18, 2026

  • Understand the current backfill code — it fetches ALL messages with no limit
  • Add a @default_max_messages constant (default 5,000) to DiscordBackfill
  • Add run/2 that accepts an optional max message limit
  • Update fetch_page to stop when the limit is reached
  • Update !backfill command handler to mention the default limit
  • Run validation

Copilot AI and others added 2 commits April 18, 2026 22:27
- Load model from markov_model.txt on init (if it exists)
- Save periodically every 5 minutes via Process.send_after
- Save on graceful shutdown via terminate/2 with trap_exit
- Add save/0 client API for manual saves from IEx
- Tab-separated text format: chain entries then starts, separated by blank line
- Configurable path via MARKOV_MODEL_PATH env var
- Add markov_model.txt to .gitignore

Agent-Logs-Url: https://github.com/datafruits/fruitbot/sessions/ae78124d-42bc-4a5e-88de-c0e13b34ed23

Co-authored-by: mcfiredrill <66243+mcfiredrill@users.noreply.github.com>
Copilot AI and others added 2 commits April 18, 2026 22:40
Add Fruitbot.DiscordBackfill module that paginates through a Discord
channel's history using Nostrum.Api.get_channel_messages/3, filters
out bot messages and commands, and trains the Markov chain on each
message. Runs async via Task.start to avoid blocking.

Add MarkovChain.backfill/1 convenience function and !backfill chat
command.

Agent-Logs-Url: https://github.com/datafruits/fruitbot/sessions/4a3e72c9-18d6-4a10-b14c-8dcfdac4eacc

Co-authored-by: mcfiredrill <66243+mcfiredrill@users.noreply.github.com>
Nostrum.Api.get_channel_messages/3 crashes when passed an empty map
as the locator argument. Use the 2-argument form for the initial
page fetch (no before_id), and only pass %{before: id} for
subsequent pages.

Agent-Logs-Url: https://github.com/datafruits/fruitbot/sessions/58bcf38f-8671-47ac-bf5f-5fc63ac523d3

Co-authored-by: mcfiredrill <66243+mcfiredrill@users.noreply.github.com>
Nostrum.Api.Channel.messages_call/3 expects the locator as a tuple
(e.g. {:before, message_id}) or {} for no locator. Passing a map
%{before: id} caused it to be placed directly into the query params
list as [{:limit, 100}, %{before => id}], crashing the HTTP state
machine on the second page fetch.

Agent-Logs-Url: https://github.com/datafruits/fruitbot/sessions/c687df36-526d-4013-9e53-9c6a3874f9bb

Co-authored-by: mcfiredrill <66243+mcfiredrill@users.noreply.github.com>
Agent-Logs-Url: https://github.com/datafruits/fruitbot/sessions/453fb770-483d-4408-8eb8-44e1d384ad87

Co-authored-by: mcfiredrill <66243+mcfiredrill@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

2 participants