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.3.0.tar.gz (22.1 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.3.0.tar.gz.

File metadata

File hashes

Hashes for chatgpt_mirai_qq_bot_onebot_adapter-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e1e7558998f1d967be8cd76bafea3a05cd29aefedf4d8b218679dea38be0c077
MD5 4e17dc683d879bfdbb3c7a577e90be99
BLAKE2b-256 d84c5ff1ba5515cc514f340d04f9b14856b1bc61b4d3b3520abdfc2fba1f27f6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for chatgpt_mirai_qq_bot_onebot_adapter-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cb5d50627ddf022da2d1ef7ecb7fb0ef5882d322a818d39e5aacb1ecd0af020e
MD5 e748d990c35e0853ef466f5585a2cb0a
BLAKE2b-256 7d5b23c03076f862f72118bb5fbc06c2b1447f54adef3df2c4c33226744593ae

See more details on using hashes here.

Provenance

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