Skip to content
SharpMUSHPublic

About

Sharpie, the helpful, albeit smug, SharpMUSH assistant

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Sharpie, looking smug

Sharpie

"I read every page of the docs so you don't have to. You're welcome."

The SharpMUSH help bot for Discord.


Sharpie answers SharpMUSH questions in Discord. They read only the public documentation: the sharpmush.com docs (including the in-game help), SharpMUSH.Guide and the SharpMUSH.Packages READMEs. Every answer ends with the pages they used and the in-game help topic. When the docs do not cover a question, Sharpie tags the post and pings the Helper role instead of guessing.

How it works

  • Each question is a post in the #sharpie-help forum. /ask, or a mention of Sharpie in another channel, opens a post for you.
  • Every answer has two buttons. Solved (the asker or a Helper) tags the post Answered. Get a person tags it Needs a person and pings the Helper role. A 👎 on an answer does the same.
  • Ask Sharpie to correct something in their answer and they edit it in place, then reply "Edited my answer" with a link and a line on what changed.
  • Once a Helper replies in a post, Sharpie stays out of it unless mentioned.
  • Limits: 5 questions an hour and 20 a day per member, raised automatically when answers cost less than planned (see below), and $15 a day and $150 a month of API spend. Past the spend limit Sharpie hands every new post to the Helpers.
  • Questions and answers are kept 30 days for review, then deleted. Spend totals are kept a year.

What Sharpie remembers

  • Helper notes. A Helper right-clicks a message in a help post and picks Apps › Save as Sharpie note. A form opens with the post's question and the message, to trim before saving. Sharpie's search finds notes beside the docs, the docs win when the two disagree, and an answer that uses one lists "Helper note 12" under Sources. Only Helpers can save notes, so nothing a member writes becomes one.
  • The list of notes is what the docs are missing. /sharpie-notes shows it to a Helper, and with Sharpie__NotesChannelId set it is posted there once a week. Once the docs cover a note, /sharpie-notes retire:12 takes it out of use.
  • Member facts. When a member says something lasting about their own game, such as the version they run, Sharpie keeps it in a few words and uses it only on that member's later questions. A fact is dropped 30 days after it was last said, and a member keeps at most 10. /forget-me deletes a member's facts at once.
  • Both live in memory.db in the data folder, apart from the docs index and the 30-day log.

Moods

Sharpie shows what they are doing with reactions on the question, and puts a sticker on the messages they post.

Reading the docs Still reading Answered Marked Solved
Handed to a Helper An answer got a 👎 Resting Too many questions

Personality

Sharpie's character and voice are in Personality.md: a smug coder, they/them, played big like an anime rival, with no cat mannerisms and a list of phrases they never use. The rules for answering follow it in SharpiePrompt.cs. Both are sent with every question, word for word as they are here.

Cost and caching

Every request starts with the same prefix: Sharpie's instructions, the whole softcode guide, and a map of every docs page (title, address, help topic), about 40,000 tokens. The guide and the map come from the local copy of the docs, so they change only when the index is rebuilt. The prefix carries a one-hour cache marker, so a question within the hour reads it at $0.20 per million tokens instead of $4. When nobody has asked for 55 minutes, Sharpie sends a request that only reads the cache, which keeps it warm for under a cent; writing it again would cost about 32 cents. Within one question, the pages Sharpie reads are cached for five minutes between its steps.

Whatever that saves goes back to members. Each question asked, Sharpie divides the last 7 days' spend (keeping the cache warm included) by the questions answered or handed over, once there are at least 10. When that is under the 15 cents the limits were planned for, the per-member limits grow by the same ratio, up to three times: at 10 cents a question, members get 7 an hour and 30 a day. The spend limits still apply.

Setting it up

  1. Discord application. At https://discord.com/developers/applications create an application named Sharpie. Use assets/branding/sharpie/approved/png/sharpie-primary-badge.png from the SharpMUSH repository as the bot's avatar. Under Bot, turn on the Message Content intent and copy the token.

  2. Invite them. Open this URL with your application id: https://discord.com/oauth2/authorize?client_id=<APP_ID>&scope=bot+applications.commands&permissions=309237992512 That grants View Channels, Send Messages, Send Messages in Threads, Create Public Threads, Embed Links, Read Message History, Add Reactions and Use External Emojis. In #sharpie-help's permissions, give their role Manage Posts (Discord's name for Manage Threads in a forum), so they can set tags on members' posts. Turn on "Allow anyone to @mention this role" for the Helper role, or a hand-over pings nobody.

  3. Emoji. Upload the files in assets/branding/sharpie/discord/png-128 from the SharpMUSH repository as server emoji, keeping their names (sharpie_thinking, sharpie_sweat, …). Sharpie uses thinking, sweat, smug, sparkle, confused, sad, sleepy and annoyed. The minimal pack in discord-minimal/png-128 (sharpie_min_…) works too; Sharpie uses the main pack's emoji where both are uploaded. With neither, they use plain emoji. Reactions can only be emoji, but the server's Sharpie stickers go on the messages they post: an answer (sharpie_smug), the hand-over (sharpie_confused, sharpie_sad or sharpie_sleepy) and the too-many-questions reply (sharpie_annoyed). A sticker is matched by name, ignoring case, spaces and underscores, and the mood may come first, so Sharpie Sleepy and Sleepy Sharpie work too.

  4. Forum and role. Create a forum channel #sharpie-help with the tags Answered, Needs a person, Softcode, Setup and Import. Create a Helper role for the people who take over hand-offs.

  5. API key. In the Claude Console create a workspace for Sharpie, set its monthly spend limit to $150, and create a key in it.

  6. Run it. On the server:

    mkdir -p /opt/sharpie/secrets && cd /opt/sharpie
    curl -fsSLO https://raw.githubusercontent.com/SharpMUSH/Sharpie/main/deploy/compose.yaml
    curl -fsSL -o .env https://raw.githubusercontent.com/SharpMUSH/Sharpie/main/deploy/.env.example
    # fill in the server, forum and Helper role ids in .env
    read -rsp 'Bot token: ' t && printf '%s' "$t" > secrets/discord_token; unset t; echo
    read -rsp 'API key: ' t && printf '%s' "$t" > secrets/anthropic_api_key; unset t; echo
    chown 1654:1654 secrets/* && chmod 400 secrets/* && chmod 700 secrets
    docker compose up -d

    read -s keeps the secrets off the screen and out of the shell history. Uid 1654 is the container's user, so only Sharpie can read the files; a root-owned file stops Sharpie at startup with "Access to the path is denied".

    They open no ports. They dial out to Discord, the Claude API and GitHub (to fetch the docs, refreshed every 6 hours).

The ids come from Discord with Developer Mode on: right-click the server, the forum or the role and choose Copy ID.

Secrets

Sharpie has two: the Discord bot token and the Claude API key.

  • They live only in /opt/sharpie/secrets on the server, mounted into the container by Compose at /run/secrets. They are never in this repository, the image, .env, an environment variable or the log.
  • The API key belongs to a Console workspace of its own with a $150 monthly limit, so a leaked key can spend no more than that, and it can be revoked without touching anything else.
  • The container runs as a non-root user with a read-only filesystem, no Linux capabilities and no privilege escalation. It writes only to its /data volume and /tmp.
  • To replace a secret, write the new file the same way and run docker compose up -d --force-recreate. Revoke the old one in the Discord developer portal or the Claude Console.

Settings

Every setting lives under Sharpie__ in .env:

Setting Default
GuildId, HelpForumId, HelperRoleId none Required
Model, Effort claude-opus-5-5, medium
MonthlyLimitUsd, DailyLimitUsd 150, 15 Checked before each question
QuestionsPerHour, QuestionsPerDay 5, 20 Per member
Concurrency 3 Questions answered at once
Stickers true Add the mood's sticker to answers, hand-overs and limit messages
KeepCacheWarm true Renew the one-hour cache while the forum is quiet
ReferenceCostUsd, MaxQuestionBoost 0.15, 3 Cost per question the limits assume, and how far savings may raise them
NotesChannelId 0 Channel for the weekly list of Helper notes; 0 posts none
LogRetentionDays 30
IndexRefreshHours 6

The two secrets are read from /run/secrets/discord_token and /run/secrets/anthropic_api_key. For a local run, the DISCORD_TOKEN and ANTHROPIC_API_KEY environment variables work instead; don't use them on the server, where docker inspect shows a container's environment.

Building

Needs the .NET SDK pinned in global.json.

dotnet build
dotnet run --project tests/Sharpie.Tests

Licence

Apache 2.0.

About

Sharpie, the helpful, albeit smug, SharpMUSH assistant

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages