Skip to main content

OneBot adapter for lss233/chatgpt-mirai-qq-bot

Project description

OneBot-adapter for ChatGPT-Mirai-QQ-Bot

本项目是 ChatGPT-Mirai-QQ-Bot 的一个插件,用于将OneBot协议的消息转换为ChatGPT-Mirai-QQ-Bot的消息格式。

安装

pip install chatgpt-mirai-qq-bot-onebot-adapter

使用

config.yaml 中的 ims 中添加以下内容:

ims:
  enable:
    onebot: ['onebot']
    ... # 其他IM配置
  configs:
    onebot:
      host: '0.0.0.0'             # OneBot服务器地址
      port: '5545'                # OneBot服务器端口
      access_token: ''            # OneBot服务器访问令牌
      heartbeat_interval: '15'    # 心跳间隔(秒)
    ... # 其他IM配置

项目工作原理

sequenceDiagram
    participant Client as OneBot Client
    participant Adapter as OneBotAdapter
    participant Dispatcher as WorkflowDispatcher
    participant Memory as MemorySystem
    participant LLM as LLMService

    Client->>Adapter: WebSocket消息
    Note over Adapter: 心跳检测
    
    alt 元事件
        Adapter->>Adapter: _handle_meta
        Note over Adapter: 更新连接状态
    else 消息事件
        Adapter->>Adapter: _handle_msg
        Adapter->>Adapter: convert_to_message
        Note over Adapter: 转换为IMMessage格式
        
        Adapter->>Dispatcher: dispatch
        
        alt 工作流匹配
            Dispatcher->>Memory: 查询历史记录
            Memory-->>Dispatcher: 返回对话历史
            Dispatcher->>LLM: 请求响应
            LLM-->>Dispatcher: 返回AI回复
            Dispatcher-->>Adapter: 返回处理结果
            
            Adapter->>Adapter: convert_to_message_segment
            Note over Adapter: 转换为OneBot消息段
            
            loop 每个消息段
                Note over Adapter: 添加随机延时
                alt 群消息
                    Adapter->>Client: send_group_msg
                else 私聊消息
                    Adapter->>Client: send_private_msg
                end
            end
            
        else 无匹配工作流
            Note over Dispatcher: 跳过处理
        end
    end

    Client-->>Adapter: 消息处理完成

开源协议

本项目基于 ChatGPT-Mirai-QQ-Bot 开发,遵循其 开源协议

感谢

感谢 ChatGPT-Mirai-QQ-Bot 的作者 lss233 提供框架支持

感谢 AIOCQHTTP 的作者 nonebot 提供CQHTTP协议支持

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

chatgpt_mirai_qq_bot_onebot_adapter-0.1.7.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file chatgpt_mirai_qq_bot_onebot_adapter-0.1.7.tar.gz.

File metadata

File hashes

Hashes for chatgpt_mirai_qq_bot_onebot_adapter-0.1.7.tar.gz
Algorithm Hash digest
SHA256 73efd4da4a0b5e3d5fff79c0aceb5250c0cdc3c8fee54ca4ae0abcf931197b40
MD5 3e8aec95d6a38573d2295cce0abf0e69
BLAKE2b-256 f16f1b5e0abeb8168eff7d4e241667a95220b8e7ef60d48a29dab9322851bf0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatgpt_mirai_qq_bot_onebot_adapter-0.1.7.tar.gz:

Publisher: publish.yml on Cloxl/chatgpt-mirai-qq-bot-onebot-adapter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chatgpt_mirai_qq_bot_onebot_adapter-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for chatgpt_mirai_qq_bot_onebot_adapter-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 437f5137b847f478a15bb88e81c3c0c901e8ad2da9cb7b8ab651b0009b41b34b
MD5 f66eee69c0bc674b49e6ce79d75bbb39
BLAKE2b-256 ae015e2c558c41aa4754fdd6b779fdc4dbb48d5811de517405f25bf2161da62e

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatgpt_mirai_qq_bot_onebot_adapter-0.1.7-py3-none-any.whl:

Publisher: publish.yml on Cloxl/chatgpt-mirai-qq-bot-onebot-adapter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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