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.6.tar.gz (21.2 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.6.tar.gz.

File metadata

File hashes

Hashes for chatgpt_mirai_qq_bot_onebot_adapter-0.1.6.tar.gz
Algorithm Hash digest
SHA256 ed2f17aa7b34923be3ba432a980400994b43faf599e888ff0242f166e0665ee5
MD5 e8b07247f9cff0a3f50d156b8d9cc248
BLAKE2b-256 7b2ec91dfcf7c3eeec122a67cf2f3875b5680dd0bda96d87e184eb49e08b181e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for chatgpt_mirai_qq_bot_onebot_adapter-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ae7d8921541f77153760e536457ea1adc38f4e1d40ffe1526e64cef57822eac8
MD5 c801ad5a2682d24d3a511371e4fed7dd
BLAKE2b-256 6f972f435a06f51c6fc4bf41a67955248dfabe983da8b7cf52d417e143749fbc

See more details on using hashes here.

Provenance

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