Skip to main content

A NoneBot adapter for EFChat

Project description

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 许可证 开源,你可以自由使用和修改。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonebot_adapter_efchat-0.1.9.post2.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_adapter_efchat-0.1.9.post2-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_adapter_efchat-0.1.9.post2.tar.gz.

File metadata

  • Download URL: nonebot_adapter_efchat-0.1.9.post2.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.7 Linux/6.11.0-1018-azure

File hashes

Hashes for nonebot_adapter_efchat-0.1.9.post2.tar.gz
Algorithm Hash digest
SHA256 34828288d70d8ca656e1af7e9f3773e09718bccc276118ac81b9f283df06954d
MD5 a0b43d7c87f21e587175957ff1d446cf
BLAKE2b-256 1c89d3a7ddf1c22f71490188cb1624633dc9a97a121e564881b3ff5daa362f12

See more details on using hashes here.

File details

Details for the file nonebot_adapter_efchat-0.1.9.post2-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_adapter_efchat-0.1.9.post2-py3-none-any.whl
Algorithm Hash digest
SHA256 d73bfeb4aa5a3dbb3c7f965065c479c388ecec6a63e2276fc5a20ec83d046978
MD5 f2a7c2f9017ccefacc87a667599d68e6
BLAKE2b-256 65a2bd0b2ad62a42dfed3ba351001f2bb4bf63af947d3d12c76f6f1b5b8a4a3a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page