Reference resources : Development mirai QQ Robot start tutorial _ Sigh -CSDN Blog _mirai python

This article refers to the above blog , The invalid content and version matching are supplemented and modified , The actual measurement can run successfully . See this blog for a screenshot of some steps , Please refer to each other .

0. To configure jdk, Version must be OpenJDK>=11

OracleJDK Untested , Normal operation is not guaranteed

1. download mirai-console-loader(mcl), Version must be 1.2.2

iTXTech/mirai-console-loader: modularization 、 Lightweight and fully customizable mirai loader . (github.com)

mcl See the following document for the command usage :mirai-console-loader/README.md at master · iTXTech/mirai-console-loader (github.com)

2. add to mirai-api-http(mah) plug-in unit , Version must be 1.12.0

project-mirai/mirai-api-http at 9628ab1767f088822f713c166eb127840a69de81 (github.com)

cd ./mcl-1.2.2
sh ./mcl --update-package net.mamoe:mirai-api-http --channel stable --type plugin --version 1.12.0
sh ./mcl --dry-run

If the automatic download appears corrupt Report errors , You can download it manually mirai-api-http-v1.12.0.mirai.jar, And put it in mcl-1.2.2/plugins In the folder

3. Ban mcl Of updater Script , Prevent automatic upgrades

sh ./mcl --disable-script updater

4. Check the version correspondence

here , Pay attention to inspection mcl-1.2.2/config.json The contents of the document shall be the same as the following , Special attention required :mirai-console、mirai-console-terminal、mirai-core-all The version is 2.7.*,mirai-api-http The version is 1.12.0,"disabled_scripts": ["updater"] !!

{
"js_optimization_level": -1,
"mirai_repo": "https://gitee.com/peratx/mirai-repo/raw/master",
"maven_repo": [
"https://maven.aliyun.com/repository/public"
],
"packages": [
{
"id": "org.bouncycastle:bcprov-jdk15on",
"channel": "stable",
"version": "1.64",
"type": "libs",
"versionLocked": false
},
{
"id": "org.itxtech:mcl-addon",
"channel": "c122",
"version": "1.2.2",
"type": "plugins",
"versionLocked": false
},
{
"id": "net.mamoe:mirai-console",
"channel": "stable",
"version": "2.7.0",
"type": "libs",
"versionLocked": false
},
{
"id": "net.mamoe:mirai-console-terminal",
"channel": "stable",
"version": "2.7.0",
"type": "libs",
"versionLocked": false
},
{
"id": "net.mamoe:mirai-core-all",
"channel": "stable",
"version": "2.7.0",
"type": "libs",
"versionLocked": false
},
{
"id": "net.mamoe:mirai-api-http",
"channel": "stable",
"version": "1.12.0",
"type": "plugins",
"versionLocked": false
}
],
"disabled_scripts": [
"updater"
],
"proxy": "",
"log_level": 1,
"script_props": {}
}

Check mcl-1.2.2/libs and mcl-1.2.2/plugins Medium jar The package exists and matches the version in the above file !!

Reference resources :mirai Update to 2.7M1 after mirai-api-http Plug in not available | MiraiForum (mamoe.net)

5. To configure mah, Must follow 1.x Configure the document

project-mirai/mirai-api-http at 9628ab1767f088822f713c166eb127840a69de81 (github.com)

modify mcl-1.2.2/config/net.mamoe.mirai-api-http/setting.yml file , The following configurations can be copied directly

## This configuration is global , For all Session It works
# Optional , The default value is 0.0.0.0
host: '0.0.0.0' # Optional , The default value is 8080
port: 8080 # Optional , By default, it is randomly generated when the plug-in is first started , It is recommended to specify
authKey: 1234567890 # Optional , Cache size , Default 4096. Too small cache will cause reference reply and recall messages to fail
cacheSize: 4096 # Optional , Open or not websocket, Off by default , Recommended by Session Configuration settings for the scope
enableWebsocket: true # Optional , To configure CORS Cross domain , The default is *, That is, all domain names are allowed
cors:
- '*' ## Report the news
report:
# Function master switch
enable: false
# Group message reporting
groupMessage:
report: false
# Friend message reporting
friendMessage:
report: false
# Temporary message reporting
tempMessage:
report: false
# Report the incident
eventMessage:
report: false
# Report URL
destinations: []
# Additional when reporting Header
extraHeaders: {} ## heartbeat
heartbeat:
# Function master switch
enable: false
# Start delay
delay: 1000
# Heartbeat interval
period: 15000
# Heartbeat report URL
destinations: []
# Additional information when reporting
extraBody: {}
# The extra amount at the time of reporting
extraHeaders: {}

6. install MiraiAndroid

mirai-login-solver-selenium and TxCaptchaHelper Can't work properly (2021.9.9)!

Reference resources : Unable to log in temporary processing scheme | MiraiForum (mamoe.net)

github:mzdluo123/MiraiAndroid: QQ robot /( experimental ) stay Android Up operation Mirai-console, Support plug-ins (github.com)

download :https://install.appcenter.ms/users/mzdluo123/apps/miraiandroid/distribution_groups/release

Environmental preparation before use :

stay mirai Add... To the runtime JVM attribute mirai.slider.captcha.supported ( Add parameter -Dmirai.slider.captcha.supported) To confirm that the sliding verification is completed manually

It doesn't matter if you don't understand the above , Look directly at the following steps : about mirai-console-loader, open mcl(Linux) or mcl.bat(Windows), stay java ..... -jar .... In the command -jar Add parameters before -Dmirai.slider.captcha.supported,Linux The revised result is as follows :

#!/usr/bin/env sh
export JAVA_BINARY=java
$JAVA_BINARY -Dmirai.slider.captcha.supported -jar mcl.jar $*
  • If it runs on mirai-console, Need to be in plugins Delete inside mirai-login-solver-selenium plug-in unit
  • If it's based directly on mirai-core Development , You need to remove mirai-login-solver-selenium rely on

Usage method :

Download and install it on your phone , And finish logging in ; The login method is set in the automatic login in the upper right corner of the main screen , Verification is required during login. Please click notification in the notification column to complete verification .

After successful login, go to the left menu to find advanced functions ( Tools ), Choose your account ( Select a bot) Then export the device file (device.json) Send to PC , And overwrite the computer version of the file (Linux The next path is mcl-1.2.2/bots/qq Number /device.json).

Run again mcl Script

cd ./mcl-1.2.2
sh ./mcl

wait for mcl After opening, enter the following command to successfully log in :

> login qq Number qq password 

7. install graia-application-mirai, Note that you need to downgrade the version to work properly

Reference configuration : Install and configure the development environment | Graia Document (graia-document.vercel.app)

GraiaProject/Application: An exquisitely designed , The protocol implements complete , be based on mirai-api-http Automation framework of instant chat software . (github.com)

cannot import name 'BaseDispatcher' · Issue #161 · GraiaProject/Application (github.com)

pip install graia-application-mirai==0.18.4

establish bot.py file , modify bot.py Medium host、authKey And mirai-api-http The configuration of is the same , modify account,websocket Change it to true

from graia.broadcast import Broadcast
from graia.application import GraiaMiraiApplication, Session
from graia.application.message.chain import MessageChain
import asyncio from graia.application.message.elements.internal import Plain
from graia.application.friend import Friend loop = asyncio.get_event_loop() bcc = Broadcast(loop=loop)
app = GraiaMiraiApplication(
broadcast=bcc,
connect_info=Session(
host="http://localhost:8080", # fill httpapi The address where the service runs
authKey="graia-mirai-api-http-authkey", # fill authKey
account=****, # Your robot qq Number
websocket=True # Graia The normal operation of the message receiving part can be guaranteed according to the configured message receiving mode .
)
) @bcc.receiver("FriendMessage")
async def friend_message_listener(app: GraiaMiraiApplication, friend: Friend):
await app.sendFriendMessage(friend, MessageChain.create([
Plain("Hello, World!")
])) app.launch_blocking()

function bot.py

python bot.py

Then tell your QQ robot , Just send a message , If it replies to you Hello, World!, Is a success

Python+mirai Development QQ Robot start tutorial (2021.9.9 The test works ) More articles about

  1. Mirai frame qq Robot Tutorial new edition

    Mirai frame qq Robot Tutorial new edition Preface Information list 1. Get ready i. To configure java Environmental Science ii. To configure IDE iii. download mirai-console-loader(mcl) As a starter 2. establish mirai ...

  2. Mirai frame qq Robot Tutorial

    Mirai frame qq Robot Tutorial 0. Preface 1. install Java 2. install Mirai starter 3. download IDEA Or other compilers 4. establish mirai-console Plug-in project 4.1 adopt git establish 4.2 Through plug-ins ...

  3. cool Q robot ,QQ Robot Tutorial

    The software is introduced : cool Q, Software cool Q Robot is based on webqq Development of an automatic receiving . Handle qq Message software . The program is written in easy language , Simplify a lot of unnecessary code , Reduced software volume , Optimize program speed , Make it cool Q It's lighter and easier to use . In message processing ...

  4. Use cool Q SDK Development QQ robot

    cool Q SDK Download address :https://github.com/CoolQ/cqsdk-vc Open the project , edit appmain.cpp take “ A private chat ” Code at Change to CQEVENT(int32_t, __e ...

  5. 【 turn 】windows and linux Build in python Integrated development environment IDE

    This series is divided into two parts : 1.[ turn ]windows and linux Build in python Integrated development environment IDE 2.[ turn ]linux and windows Lower installation python Integrated development environment and its python package 3.windows and l ...

  6. windows and linux In architecture python Integrated development environment IDE

    http://blog.csdn.net/pipisorry/article/details/39854707 System and software used Ubuntu / windows Python 2.7 / pytho ...

  7. 【Python Development 】python Integrated development environment IDE build

    http://blog.csdn.net/pipisorry/article/details/39854707 System and software used Ubuntu / windows Python 2.7 / pytho ...

  8. Western Qin Dynasty ACE-Python course One 、Python Local development environment deployment

    Western Qin Dynasty ACE-Python course One .Python Local development environment deployment       Western qin Level :  Forum moderator Post 1357 Cloud coin 2782 Pay more attention to Write private letters   Just look at the landlord   More operations    Published in : 10-10 ...

  9. python Realization qq robot qqbot

    title: python Realization qq robot qqbot tags: python date: 2018-6-1 10:19:00 --- The following is reprint One . Introduce qqbot It's a use. python Realization ...

  10. be based on go-cqhttp Realization QQ robot

    This article records that I am writing QQ Some of the problems encountered by robots and the realization of core functions . QQ robot RabbitBot use python To write , Because it's personal learning to use , Therefore, we will not open source the complete code at present , Only the core code will be released for learning reference . ...

Random recommendation

  1. linux intermediate -JAVA Enterprise application TOMCAT actual combat

    1. Tomcat brief introduction Tomcat yes Apache Software foundation (Apache Software Foundation) Of Jakarta A core project in a project , from Apache.Sun With other companies and individuals ...

  2. A+B Again( Find a number greater than m The least divisor of )

    A+B Again Accepted : 15   Submit : 243 Time Limit : 1000 MS   Memory Limit : 65536 KB  Title Description Xiaoming's in the last fun contest ...

  3. [Angular2 Form] Style Validation in Angular 2 Forms

    Inputs using Angular 2’s ngModel automatically apply style classes of .ng-validand .ng-invalid each ...

  4. Asp.NET MVC Technical references :http://kb.cnblogs.com/zt/mvc/

    Asp.NET MVC Technical references :http://kb.cnblogs.com/zt/mvc/

  5. cocos2dx vs2010 Open the print window

    vs2010 In the trial run , Sometimes you need a print window . stay main.cpp The beginning of the function , Join in AllocConsole(); freopen("CONIN$", "r" ...

  6. 【 turn 】 Image cache memory cache technology LruCache、 Soft citation Compare

    Whenever you come across some big pictures , If we don't process the pictures, we will report OOM abnormal , This problem used to annoy me , It was finally solved , Now let me share it with you . The picture caching mechanism in this blog post , I've been exposed to two clocks , One ...

  7. The first 45 piece js Operation open local program

    Original address :http://blog.laofu.online/2017/06/10/how-js-controlApp/ background Suppose there is such a product , One web And a winform client , In the customer in web Of ...

  8. Random data generation and matching 【c++ edition , Conscience explanation 】

    10.7 to update : See bottom leave NOIP2018 There's not much time left , I suddenly found out that I can't even do the opposite , So I rushed to the Internet to find information , After searching for a long time, I found a particularly wonderful program , use c++ Written ! But let's talk about random data generation first . It's simple , Just write a ...

  9. scp Copy tips its a directory error

    scp Copy tips its a directory error scene Use scp The format is scp my_file user@ip:/home/directory It's been used like this before , Nothing wrong , Without rhyme or reason Cause orientation ...

  10. php Open the compressed gzip

    php Open compression of services , Save bandwidth See if the compressed website is turned on http://www.cnblogs.com/GaZeon/p/5421906.html find php.ini, Modify the following , restart php-fpm z ...