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.2.2.tar.gz (21.5 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.2.2.tar.gz.

File metadata

File hashes

Hashes for chatgpt_mirai_qq_bot_onebot_adapter-0.2.2.tar.gz
Algorithm Hash digest
SHA256 169744783fefe3bec96bdb9eba432818fc849f68f746b5183abd85a42fd17017
MD5 d2ad0291947d078915b087c58adc0682
BLAKE2b-256 d636731456dd2e3a6865c0ef5f083bfcd9ebaaef0772626af2d3200c62257519

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatgpt_mirai_qq_bot_onebot_adapter-0.2.2.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.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for chatgpt_mirai_qq_bot_onebot_adapter-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 05060472075e539a244f0100775d6a71acda2056c746f156f00360e6fd7ae666
MD5 1a4889db6a3037b3f8cb88b413c7a653
BLAKE2b-256 f70155f5211fffd699b022ce08bc8b1025377cc6a88d04438647ef96e9800efc

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatgpt_mirai_qq_bot_onebot_adapter-0.2.2-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