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": "PublicR",
        "head": "https://efchat.melon.fish/imgs/ava.png", // 可选,为空使用默认头像
        "token": "",
        "ignore_self": true // 默认忽略自身消息
    }
]
'
  • 配置项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.4.tar.gz (14.6 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.4-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_adapter_efchat-0.1.4.tar.gz.

File metadata

  • Download URL: nonebot_adapter_efchat-0.1.4.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.5 Linux/6.11.0-1015-azure

File hashes

Hashes for nonebot_adapter_efchat-0.1.4.tar.gz
Algorithm Hash digest
SHA256 2527cd8c7a953b95dafbe465357f21d8a3e44397ef9b10fecb617a266b8c0ad1
MD5 bdaced77f19591b5366594ed1625abe3
BLAKE2b-256 3f261ed8ab204ab417feda550ef1390a9f5b404ef2ebc59fcdceb1ff45296c59

See more details on using hashes here.

File details

Details for the file nonebot_adapter_efchat-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_adapter_efchat-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 91155f97aaf6375532aaec57f1fe8e6030afa356bfed6fc2d9ae4a013ae2850f
MD5 c7204a8ab8d7a3705c3dc9828f5901e1
BLAKE2b-256 dbba847f9425f435ec2b4334a67a4404c4afe8c9326962acfb016c3c07fff846

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