Skip to content

Instantly share code, notes, and snippets.

@Havvy
Last active October 15, 2017 04:44
Show Gist options
  • Save Havvy/5abe8b29b5810f9a2bfb8bc736ac5d79 to your computer and use it in GitHub Desktop.
Save Havvy/5abe8b29b5810f9a2bfb8bc736ac5d79 to your computer and use it in GitHub Desktop.

Rustbot is the helpful IRC bot found in many of the Rust IRC channels on irc.mozilla.org. Rustbot is maintained by Havvy and is a Tennu bot.

Using Rustbot

Rustbot only responds to intentional commands. You can say one of the following to trigger it:

  • !command args
  • rustbot: !command args
  • arbitrary text {!command args} arbitrary text
  • Private messaging rustbot is supported.

Functionality

The main utilities in Rustbot are crate lookup, github issue/PR lookup, and factoids.

Crate Lookup

For every crate on Crates.io, you can send the command !crate <crate-name> and it will give the latest version, summary description of the crate, a link to it's crates.io page and a link to it's Docs.rs page.

Github Issue and PR Lookup

The !gh <number> command will lookup the specific issue or pull request in rust-lang/rust.

For arbtirary repoes (such as your own), you can use !gh <user> <repo> <number>.

Aliases have been set up for looking up issues in the reference with !reference <number> and the RFCs repo with !rfc <number>.

Factoids

Factoids are little messages you can have Rustbot say.

You can make Rustbot say the factoid by using the command !factoid <factoid-name>. For convenience, you can also just say !<factoid-name>. Note that the !<factoid-name> form looks like a command, but is not, so things like rustbot: <factoid-name> won't work.

If you want the latest list of factoids, ask Havvy and they'll give you a copy. It's a Dirty DB so it'll be a list of JSON entries. The "key" is the factoid name. Only the last line with a specific key is valid. Maybe one day Havvy will provide a better interface for this.

You can lookup the metadata about a factoid with !factoid-metadata <factoid-name>. It'll give when and who the factoid was last edited by. If it's a factoid alias, it'll show where it points to.

Teaching Rustbot New Factoids

You can teach Rustbot new factoids, remove useless factoids, and modify factoids to be more useful. And if you find a good opportunity, you should do so.

You can teach a new factoid with !learn <factoid-name> = <factoid-description>. The factoid name can contain any characters except for = and @. To create a new alias, use !learn <alias-name> = <factoid-name>.

You can remove a factoid with !forget <factoid-name>.

There are multiple ways of modifying factoids. The simplest is to just do a wholesale replacement with !learn <factoid-name> f= <factoid-description>. The f there means force because without it, you'll get an error message saying it's already defined. You can append more information to the description by using !learn <factoid-name> += <more-description>. A space will be placed between the original description and your description. For those who know regular expressions, you can use them with !learn <factoid-name> ~= s/<find>/<replacement>/<flags>. You can use $1, $2, etc. in the replacement to match capturing groups. As Rustbot is a JS bot, we use JS regex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment