Skip to main content

nonebot

NoneBot-Adapter-EFChat

✨ NoneBot2 EFChat 协议适配 / EFChat Protocol Adapter for NoneBot2 ✨

EFChat适配器简述

EFChat Adapter 是一个适用于 EFChat聊天室 的 NoneBot 适配器,可以轻松地在 EFChat 聊天室中开发机器人,并使用 NoneBot 生态来构建聊天机器人。

[!IMPORTANT]

为了避免造成不必要的麻烦,本适配器不会支持以下功能:

  1. 其他有可能危害聊天室安全的功能

🚀 特性

  • 🔌 NoneBot 适配,可直接集成到 NoneBot 插件系统,实现灵活的机器人开发
  • 📡 自动处理 EFChat 事件,支持房间消息、私聊、系统通知等
  • ✨ 支持多Bot, 支持同时运行并管理多个bot

📦 安装

pip install nonebot-adapter-efchat

🔧 配置

在 bot.py 中启用 EFChat 适配器:

from nonebot import get_driver
from nonebot.adapters.efchat import Adapter

driver = get_driver()
driver.register_adapter(Adapter)

在 .env 文件中添加:

DRIVER=~websockets+~httpx

EFCHAT_BOTS = '
[
    {
        "nick": "EFChatBot",
        "password": "", // 可选配置
        "channel": "NewPR",
        "head": "https://efchat.irin-wakako.uk/imgs/ava.png", // 可选,为空使用默认头像
        "token": "",
        "ignore_self": true // 默认忽略自身消息
    }
]
'
  • 配置项token是必填项;获取TOKEN
  • 如果Bot将会拥有管理员权限,请提供password字段以确保账号安全
  • nick是bot账号,同时也是在聊天室里显示的昵称
  • channel是Bot活跃的房间名称
  • head是Bot的头像url地址

⚠️ 暂不支持一个bot同时连接多个房间


📖 API 参考


💬 使用示例

消息回显

在 plugins/echo.py 中创建一个简单的回显插件:

from nonebot import on_message
from nonebot.adapters.efchat import MessageEvent

echo = on_message()

@echo.handle()
async def handle_echo(event: MessageEvent):
    await echo.send(f"你发送的消息是: {event.get_message()}")

机器人发送的消息默认不保存到聊天记录,如果需要保存,请在发送消息时传入show=True

例如

await matcher.send("xxx", show=True)

🔨 开发与贡献

欢迎贡献代码!请遵循以下流程:

  1. Fork 本仓库 并克隆代码。
  2. 提交 Pull Request,描述你的改动。

📜 许可证

本项目基于 MIT 许可证 开源,你可以自由使用和修改。

Metadata

Release files for nonebot-adapter-efchat 0.1.9.post2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nonebot-adapter-efchat 0.1.9.post2
File Size Uploaded
nonebot_adapter_efchat-0.1.9.post2.tar.gz 15.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nonebot-adapter-efchat 0.1.9.post2
File Interpreter ABI Platform
nonebot_adapter_efchat-0.1.9.post2-py3-none-any.whl Python 3 none any Details

Total release size: 32.9 kB

Release files / nonebot_adapter_efchat-0.1.9.post2.tar.gz

Download URL nonebot_adapter_efchat-0.1.9.post2.tar.gz
Size 15.1 kB
Tags Source
SHA-256 checksum
How to use checksums
34828288d70d8ca656e1af7e9f3773e09718bccc276118ac81b9f283df06954d
BLAKE2b-256 checksum
How to use checksums
1c89d3a7ddf1c22f71490188cb1624633dc9a97a121e564881b3ff5daa362f12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.13.7 Linux/6.11.0-1018-azure

Release files / nonebot_adapter_efchat-0.1.9.post2-py3-none-any.whl

Download URL nonebot_adapter_efchat-0.1.9.post2-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d73bfeb4aa5a3dbb3c7f965065c479c388ecec6a63e2276fc5a20ec83d046978
BLAKE2b-256 checksum
How to use checksums
65a2bd0b2ad62a42dfed3ba351001f2bb4bf63af947d3d12c76f6f1b5b8a4a3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.13.7 Linux/6.11.0-1018-azure
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page