Skip to main content

闲聊QQ机器人,也就是人工智障

Project description

ELFChatBot

这是一个闲聊机器人,基于 Nonebot2
接入了腾讯和百度的闲聊 api,百度的api支持连续对话
可以实现群聊、私聊,同时随机回复群聊消息。

效果图:

image-20210114125523902

娱乐功能

  1. 随机回复群友消息
  2. 伪造转发合并消息(fake、fakes触发,具体使用看代码)

申请密钥

  1. 腾讯开放平台(推荐作为备用也申请一个)

    前往 https://ai.qq.com/console/capability/detail/8 注册并创建应用,并在能力库接入 智能闲聊,得到 app_id 以及 app_key

  2. 百度大脑平台(推荐使用!)

    https://ai.baidu.com/unit/home 注册并创建机器人,设置好机器人技能(至少包含闲聊),得到机器人id(S开头)、api_keysecret_key

    注意:默认优先使用百度

部署

注意:Python 3.7+

一 、配置 QQ 协议端

目前支持的协议有:

QQ 协议端举例:

这里以 go-cqhttp为例

  1. 下载 go-cqhttp 对应平台的 release 文件,点此前往

  2. 运行 exe 文件或者使用 ./go-cqhttp 启动

  3. 生成默认配置文件并修改默认配置

    {
     "uin": 你的QQ号,
     "password": "你的密码",
     "encrypt_password": false,
     "password_encrypted": "",
     "enable_db": true,
     "access_token": "",
     "relogin": {
       "enabled": true,
       "relogin_delay": 3,
       "max_relogin_times": 0
     },
     "_rate_limit": {
       "enabled": false,
       "frequency": 0,
       "bucket_size": 0
     },
     "ignore_invalid_cqcode": false,
     "force_fragmented": true,
     "heartbeat_interval": 0,
     "http_config": {
       "enabled": true,
       "host": "0.0.0.0",
       "port": 5700,
       "timeout": 0,
       "post_urls": {}
     },
     "ws_config": {
       "enabled": true,
       "host": "0.0.0.0",
       "port": 6700
     },
     "ws_reverse_servers": [
       {
         "enabled": true,
         "reverse_url": "ws://127.0.0.1:8080/cqhttp/ws",
         "reverse_api_url": "",
         "reverse_event_url": "",
         "reverse_reconnect_interval": 3000
       }
     ],
     "post_message_format": "string",
     "use_sso_address": false,
     "debug": false,
     "log_level": "",
     "web_ui": {
       "enabled": true,
       "host": "0.0.0.0",
       "web_ui_port": 9999,
       "web_input": false
     }
    }
    

    其中 ws://127.0.0.1:8080/cqhttp/ws 中的 127.0.0.18080 应分别对应 nonebot 配置的 HOST 和 PORT

    其中以下配置项务必按照下方样式修改!

    "ws_reverse_servers": [
        {
          "enabled": true,
          "reverse_url": "ws://127.0.0.1:8080/cqhttp/ws",
          "reverse_api_url": "",
          "reverse_event_url": "",
          "reverse_reconnect_interval": 3000
        }
      ],
    
    1. 再次运行 exe 文件或者使用 ./go-cqhttp 启动

二、部署聊天插件

第一次部署

  1. 下载代码到本地

  2. 参照 ELF_RSS 2.0的部署方式

  3. 运行 pip install -r requirements.txt

  4. 请按照 注释 修改配置文件 (文件 .env.prod

  5. 运行 nb run

  6. 收到机器人发送的启动成功消息

从 Nonebot1 到 NoneBot2

  1. 卸载 nonebot1

    pip uninstall nonebot
    
  2. 运行

    pip install -r requirements.txt
    
  3. 参照 第一次部署

已经部署过其它 Nonebot2 机器人

  1. 下载 项目文件夹 src/plugins/ELFChatBot 复制 到你部署好了的机器人 plugins 目录
  2. 下载 requirements.txt 文件,并运行 pip install -r requirements.txt
  3. 第一次部署 一样,修改配置文件
  4. 运行 nb run

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

elfchatbot-0.0.1.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

elfchatbot-0.0.1-py3-none-any.whl (30.6 kB view details)

Uploaded Python 3

File details

Details for the file elfchatbot-0.0.1.tar.gz.

File metadata

  • Download URL: elfchatbot-0.0.1.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for elfchatbot-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7b3edac7cc4999f731daf52a264ed1295b1ecf8ab59d49c6be5f2be093bd7e8a
MD5 1b78d61326a6272efd3f01a19fac455d
BLAKE2b-256 28dccb0bc5ade5e09c28b4180650939ac624bb63add1783b825ad21641429b4e

See more details on using hashes here.

File details

Details for the file elfchatbot-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: elfchatbot-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 30.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for elfchatbot-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f583f4b5592b8eed1862455e75dfebea9c87a4a41108557d1fbf6fde12fd4704
MD5 50b271d6c513e5b7c9892b519f26a5a9
BLAKE2b-256 8b0bdfd99256fbf065a4987406c3bf3450601ced105cbcf22e7295f94d1dfc35

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page