#irc #bot #bots #internet-relay-chat #internet-relay-chat

bin+lib irc-bot

A library for writing Internet Relay Chat (IRC) bots in Rust

3 unstable releases

Uses old Rust 2015

0.2.1 Jun 19, 2018
0.2.0 Mar 19, 2018
0.1.0 May 5, 2017

#2 in #irc-bot

27 downloads per month

Apache-2.0

105KB
2.5K SLoC

irc-bot.rs Docs.rs Crates.io

A library for writing Internet Relay Chat (IRC) bots in the programming language Rust, additionally providing a pre-configured bot for immediate use.

What documentation there is should be available on Docs.rs.

Quick-start

To use this library without writing one's own bot with it, run the provided program src/bin/egbot.rs:

$ # For most people:
$ cargo run
$ # For NixOS users:
$ make run

The name egbot is derived from "e.g.", which means "for example", and is also a pun on the name of Eggdrop, an old IRC bot.

The bot can be configured by editing the YAML file config.yaml. One should at least put one's IRC nick in the admins field — e.g., if one's nick is "Ferris":

admins:
  - nick: Ferris

Configuration fields currently supported are as follows (with values given for example only):

# A string to be used as the bot's IRC nickname. This field is required.
nickname: egbot

# A string to be used as the bot's IRC username (which has little effect
# in most cases). Defaults to the nickname.
username: egbot

# A string to be used as the bot's IRC "realname" or "GECOS string", which
# has still less effect and is often used to display information about a
# bot's software. Defaults to displaying information about the bot's
# software.
realname: 'Built with `irc-bot.rs`.'

# A list of servers to which the bot should connect on start-up.
# Currently, only the first server will be used, and the bot will crash if
# no servers are listed; both of these issues should be fixed at some
# future point.
servers:
  - host: irc.mozilla.org
    port: 6697
    # Whether to use Transport Layer Security. Defaults to `true`.
    tls: true
    # A list of channels that the bot should join after connecting. Note
    # that each channel should be wrapped in quotation marks or otherwise
    # escaped so that the '#' is not taken as the start of a comment.
    channels:
      - '#rust-irc'

# A list of IRC users who will be authorized to direct the bot to run
# certain priviledged commands. For each listed user, the fields `nick`,
# `user`, and `host` may be specified; for each of which that is
# specified, a user will need to have a matching nickname, username, or
# hostname (respectively) to be authorized. All the specified fields must
# match for a user to be authorized.
admins:
  # To be authorized as an administrator of the bot, this user will need
  # to have the nickname "Ferris", the username "~crab", and the hostname
  # "rustacean.net":
  - nick: Ferris
    user: '~crab'
    host: rustacean.net
  # To be authorized as an administrator of the bot, this user will only
  # need have the nickname "c74d":
  - nick: c74d

Building

For most users, it should suffice simply to use Cargo:

$ cargo build

Users of the Linux distribution NixOS may prefer to use the provided Makefile, which wraps the tool nix-shell:

$ make build

Dependencies

~18–32MB
~453K SLoC