二叉树树

二叉树树

瞎几吧写

Build your QQBot using NoneBot2!

Install NapCat (Win)#

Used for logging into QQ to send and receive messages

  1. Go to Release NapCat V4.1.12 · NapNeko/NapCatQQ · GitHub and download NapCat.Shell.zip

  2. Extract it to a separate folder, then open the command line and run launcher.bat <BOT QQ number>

  3. After running, log in by scanning the QR code with your phone

  4. It will print the local console address information, such as: [NapCat] [WebUi] WebUi Local Panel Url: http://127.0.0.1:6099/webui?token=4xldg5fqb1

  5. Go directly to it and configure as shown in the image (the port number can be modified, but it must match the port that NoneBot2 listens to below. Here it is 9090)
    bb1e230077d5d678c689bef29aaa8315

Install NoneBot2#

Used to implement logic and control NapCat to send and receive messages

  1. First, you need to install Python. Windows users can use https://scoop.sh/

  2. Tsinghua pypi source: pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

  3. Install pipx: pip install pipx. You can also use scoop install pipx

  4. Set pipx global variable: pipx ensurepath

  5. Install nb-cli: pipx install nb-cli

  6. If the nb command cannot be found: For root users, you can edit /root/.bashrc or /root/.profile (if you are using Bash): nano /root/.bashrc and add the following line: export PATH="$HOME/.local/bin:$PATH" Save and reload the configuration: source /root/.bashrc

  7. Install nb bootstrap: nb self install nb-cli-plugin-bootstrap

  8. Create a new project, choose a folder you like, then: nb bs (just press enter if you don't understand)

Example:

C:\afbot>nb bs
Loading adapter list...
Please enter the project name
[?] Please enter > onanibot
[?] Please select the adapter you want to use OneBot V11 (OneBot V11 protocol)
Please enter the Bot superuser, the superuser has the highest authority over the Bot (just fill in the QQ number for QQ integration) (press enter to finish input)
[?] Item 1 >
Please enter the Bot nickname, messages starting with the Bot nickname can replace mentions (press enter to finish input)
[?] Item 1 >
Please enter the Bot command prefix, messages starting with the prefix will be recognized as commands,
If there is a command for querying, when this configuration item has "/", it will only be triggered by "/query",
Leaving it blank will use the default value ['', '/', '#'] (press enter to finish input)
[?] Item 1 >
Please enter the Bot command separator, generally used for secondary commands,
Leaving it blank will use the default value ['.', ' '] (press enter to finish input)
[?] Item 1 >
Please enter the NoneBot2 listening address, if you want to open it to the public, change it to 0.0.0.0
[?] Please enter > 127.0.0.1
Please enter the NoneBot2 listening port, range 1 ~ 65535, please ensure that this port number is the same as the connection port configuration or related to port mapping configuration
[?] Please enter > 8080
[?] Do you want to release a shortcut startup script in the project directory? Yes
[?] Do you want to redirect the storage path of the localstore plugin to the project path for easier subsequent migration of the Bot? Yes
[?] Do you want to use the superuser Ping command reply plugin? Yes
[?] Do you want to install the logpile plugin to provide logging to file functionality? Yes
[?] Do you want to use the webui plugin to start the project in the startup script to manage NoneBot via the web? (This plugin is still under development and not recommended for production environments) No
Successfully created project onanibot
[?] Do you want to create a virtual environment? Yes
Creating virtual environment in C:\afbot\onanibot\.venv
Virtual environment created successfully
[?] Do you need to modify or clear the pip PyPI mirror source configuration? No
[?] Do you want to immediately install project dependencies? Yes
Installing project dependencies
Dependencies installed successfully
[?] Please select the built-in plugins you want to enable
Project configuration completed, let's get started!
  1. After the project is created, start it: nb run

  2. When you see: [INFO] nonebot | OneBot V11 | Bot XXXXXXXXXX connected, you have successfully connected to NapCat

  3. Test by sending a /ping to see if you get a Pong~

  4. If you want to debug NoneBot2, please first use nb shell to enter the virtual environment. Then use pip install <package name>

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.