This article has two purposes: one is to serve as a study note for easy review during the next deployment. The second is to be an immature tutorial, but the overall process is learned from others.
Actually, I was just bored at home and looking for something to do.
Only showing situations where no errors were encountered.
If you encounter an error, please first search for the situation and error text using a search engine.
Or check the official website for common problems and the official channel.
First of all, I am also a beginner. I like to tinker with things that interest me, so please correct me if I make any mistakes. I completed the deployment based on the official documentation and the tutorial by Initial-heart. However, the tutorial by the expert is for deployment on Windows, while the idea is the same; this article is for deployment on a Linux system.
Before we start, let me introduce my deployment environment and the tools used.
I am using Alibaba Cloud server for deployment, operating system: Ubuntu 20.04.
I will use the open-source SSH tool Tabby, download link: Official website
And the FTP tool FlashFXP Official website which is a paid software but can be trialed, or: Baidu Cloud (Extraction code: wya6) Lanzou Cloud (Password: hfly)
Sliding verification assistant (install on your phone or emulator) Github link
Tabby usage: After opening the software, select Settings - Configuration and Connection, click New Configuration, choose SSH connection, and enter the server's public IP and username/password (Note: In this software, please do not use Ctrl+C to copy text; instead, select the text with the left mouse button and right-click to copy. Similarly, to paste text, just right-click. Additionally, when you need to enter a file name, simply type the first one or more letters of the file name and press the Tab key to autocomplete.)
FlashFXP usage: In the menu bar, go to Session - Quick Connect, enter the server's public IP and username/password.
Now let's officially begin.
{mtitle title="Deploying mirai"/}
Open mirai-Release, select the latest version, and find the file you need.
Right-click - Copy link address
Next, go to Tabby and enter the following command, press Enter to run, and create a folder named mirai.
mkdir mirai
Execute the following command to view all files in the current directory.
ls
You can see that it has been created.
Execute the following command to enter the mirai directory, which can be understood as double-clicking to open the folder (cd ..
is to return to the previous level).
cd mirai
Execute the following command to download mirai, with the URL being the link you just copied.
wget URL
Wait for the download to complete.
Execute the ls
command again to see the downloaded file.
Execute the following command to set file permissions.
chmod 777 filename
After setting, the color of the filename will change.
Execute the following command to run the file and start the download.
./filename
During the installation process, there will be several options to choose from:
Whether to install Java: choose y to install.
Java version: choose the highest version.
JRE & JDK: choose JDK.
Binary Architecture: choose x64.
Later, it will also ask whether to download MCL, choose y to download.
Seeing this means the installation is complete; press any key to exit.
You can see the installed files with ls
.
Execute the following command to start MCL. The first time you start it, it needs to initialize and download the runtime library and plugins.
After completion, you will see this message.
Initialization is complete; now you can press Ctrl+C to end the process.
Next, go to FlashFXP, find this file along the path, right-click - Edit.
Fill in your QQ number in account, and the password in value; for protocol, it is recommended to fill in IPAD.
Note: There must be a space between the colon and the value!
Note: There must be a space between the colon and the value!
Note: There must be a space between the colon and the value!
After filling it out, save and close.
./mcl
Run mcl again.
You will see this; select the last piece of information, right-click to copy, and send it to your phone.
Open the sliding verification assistant, paste this string, and click next.
Complete the verification.
Copy the given Ticket and return to the computer.
Right-click to paste, and press Enter.
Next, SMS verification is needed; enter yes and press Enter.
Enter the SMS verification code, and login successfully.
Finally, this prompt appears, indicating that MCL has started successfully.
Ctrl+C to close.
{mtitle title="Installing mah"/}
Open mah-Release, select the latest version, and find the file you need.
Download it to your computer. Next, use another method to install mah.
Of course, you can continue using the previously introduced method, moving to the mirai/plugins directory using the cd
command and installing with wget URL
.
In FlashFXP, the left side is your local computer files, and the right side is the server.
Drag the file from the left to the right.
Run ./mcl
again to start mcl, wait for initialization to complete, then Ctrl+C to close.
Go to this directory, right-click in the blank space to refresh.
Enter the newly appeared folder.
Right-click to edit and open setting.yml.
Delete the original content and paste the content below, changing the value of verifyKey.
## Enabled adapters, built-in http, ws, reverse-ws, webhook
adapters:
- http
- ws
## Whether to enable the authentication process; if true, verification is required when establishing a connection with verifyKey
## It is recommended to enable when connecting to the public network
enableVerify: true
verifyKey: 1234567890
## Enable some debugging information
debug: false
## Whether to enable single session mode; if true, a session will be automatically created bound to the bot logged in the console
## After enabling, any sessionKey in the interface does not need to pass parameters
## If there are multiple bots logged in the console, the behavior is undefined
## Ensure that only one bot is logged in the console when enabled
singleMode: false
## Cache size for historical messages
## At the same time, this is also the message queue capacity of the http adapter
cacheSize: 4096
## Separate configuration for the adapter, key names are the same as the adapters item configuration
adapterSettings:
## See the http adapter usage instructions for configuration details
http:
host: localhost
port: 8080
cors: ["*"]
unreadQueueMaxSize: 100
## See the websocket adapter usage instructions for configuration details
ws:
host: localhost
port: 8060
reservedSyncId: -1
{mtitle title="Deploying AmiyaBot"/}
Click on Configuration and Connection above; it will display the connection history. Click to create a new window.
Right-click to rename them for easier control of starting mirai and AmiyaBot.
First step, install git.
First method (there may be cases where git cannot be recognized in subsequent steps):
Click to download and use FlashFXP to place it in the root directory, or download using the wget
command.
chmod 777 filename
to give permissions.
tar -xzvf filename
to extract.
Second method:
Execute apt-get update -y
and apt-get upgrade -y
to update the apt tool.
apt install git
to install git.
git --version
to check the installed git version; if you can query it, it means the installation is successful.
Next, clone the repository.
git clone https://github.com/AmiyaBot/Amiya-Bot.git
cd Amiya-Bot
pip install -r requirements.txt
to install dependencies.
playwright install --with-deps chromium
to install Chromium.
Go to this directory and right-click to edit.
Change host to 0.0.0.0; the authKey password can be left blank, but it is recommended to fill it in for security.
Finally,
python3 amiya.py
to run.
In the mirai window: cd mirai
, ./mcl
. In the AmiyaBot window: cd Amiya-Bot
, python3 amiya.py
.
After both sides start successfully, proceed to the next step, connecting to the console.
{mtitle title="Connecting to the Console"/}
First, go to the server console (taking Alibaba Cloud as an example), select the instance to enter the details.
Security group - Configure rules.
Click to manually add, set the port range to 8088/8088, and set the authorized object to 0.0.0.0/0, then save.
For safety, also open port 8088 locally; the specific operation is to open the control panel and select the firewall.
Advanced settings.
Inbound rules - New rule.
Select port.
Select TCP, fill in 8088 below, and confirm to save.
Open the browser and go to console http://console.amiyabot.com.
The service address is http://server public IP:8088, and the key is the authKey filled in server.yaml.
Select instance management.
Configure according to the image below (the controllable instance can be filled in or not; the content is your group number).
After completion, it looks like this.
Next, you can go to the plugin store to install the required plugins; each plugin will have instructions on how to configure and use it.
Now you can interact with the rabbit in the group or privately.
Although it is already running normally, if you close Tabby, the process will also close. So, you can't keep the computer on and run Tabby all the time. The solution is what I will introduce next—screen.
{mtitle title="Screen Keep Alive"/}
If you find that the following commands cannot be executed, it may be because the system has not installed screen. For Ubuntu systems, execute the following command to install.
apt-get install screen
First, execute the following command to create a session named mirai.
screen -S mirai
After executing, it seems that nothing has changed, but in fact, screen is already running.
Next, execute ./mcl
to start mcl. After it starts, press Ctrl+A+D; at this point, the session will be temporarily interrupted, but the commands executed in the session will not be interrupted.
Similarly, use the cd
command to move to the AmiyaBot directory, create a session named AmiyaBot, and execute python3 amiya.py
to start amiya.py, then press Ctrl+A+D again to interrupt the session. Now, you can close Tabby at any time, and the program will continue to run.
Now that you know how to interrupt a session, how do you recover a session?
First, use screen -ls
to check the session list, then screen -r session name
or screen -r id
to recover the session.
To close a session: exit
Remaining content (most likely not to be written):
- Nginx reverse proxy encryption connection, refer to (this tutorial)
- Video version
- Configuration of public recruitment and ChatGPT in plugins
Much of the content comes from the internet and my own tinkering; I do not guarantee 100% accuracy. If there are errors or omissions, please point them out.
PS: It may be because I also installed the Baota panel, but accessing the console always prompts that the interface request failed. I don't really want to continue fiddling with it, so let's leave it at that; this article probably won't be updated again.