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

bin+lib irc-bot

Rust 编程语言中编写 Internet Relay Chat (IRC) 机器人的库

3 个不稳定版本

使用旧的 Rust 2015

0.2.1 2018 年 6 月 19 日
0.2.0 2018 年 3 月 19 日
0.1.0 2017 年 5 月 5 日

#bots 中排名 #8

Apache-2.0

105KB
2.5K SLoC

irc-bot.rs Docs.rs Crates.io

一个用于在编程语言 Rust 中编写 Internet Relay Chat (IRC) 机器人 的库,另外还提供预配置的机器人以便立即使用。

现有的文档应可在 Docs.rs 上找到。

快速入门

要使用此库而无需编写自己的机器人,请运行提供的程序 src/bin/egbot.rs

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

名称 egbot 来自于 "e.g.",意为“例如”,同时也是对古老的 IRC 机器人 Eggdrop 的双关语。

可以通过编辑 YAML 文件 config.yaml 来配置机器人。至少应该在 admins 字段中放入自己的 IRC 昵称——例如,如果昵称是 "Ferris"

admins:
  - nick: Ferris

目前支持的配置字段如下(以下示例仅供参考)

# 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

构建

对于大多数用户来说,只需使用 Cargo 即可

$ cargo build

NixOS 分发的用户可能更喜欢使用提供的 Makefile,它封装了 nix-shell 工具

$ make build

依赖项

~19–32MB
~469K SLoC