zoukankan      html  css  js  c++  java
  • QQ机器人教程

    机器人框架:Graia Framework

    1.安装Java运行时(版本必须 >= 11)

    2.下载MCL

    3.双击运行mcl.cmd

    4.配置自动登录信息config/Console/AutoLogin.yml:

     5.安装辅助登录插件

    mcl --update-package net.mamoe:mirai-login-solver-selenium --channel nightly --type plugin

    运行mcl.cmd,拖动滑块验证登录

    6.安装mirai-api-http

    mcl --update-package net.mamoe:mirai-api-http --channel stable --type plugin

    运行mcl.cmd,记录config/net.mamoe.mirai-api-http/setting.yml的authKey

     7.编写机器人业务代码

    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", # 填入 httpapi 服务运行的地址
            authKey="graia-mirai-api-http-authkey", # 填入 authKey
            account=5234120587, # 你的机器人的 qq 号
            websocket=True # Graia 已经可以根据所配置的消息接收的方式来保证消息接收部分的正常运作.
        )
    )
    
    @bcc.receiver("FriendMessage")
    async def friend_message_listener(app: GraiaMiraiApplication, friend: Friend):
        await app.sendFriendMessage(friend, MessageChain.create([
            Plain("Hello, World!")
        ]))
    
    app.launch_blocking()
  • 相关阅读:
    HDU 1850 Being a Good Boy in Spring Festival
    UESTC 1080 空心矩阵
    HDU 2491 Priest John's Busiest Day
    UVALive 6181
    ZOJ 2674 Strange Limit
    UVA 12532 Interval Product
    UESTC 1237 质因子分解
    UESTC 1014 Shot
    xe5 android listbox的 TMetropolisUIListBoxItem
    xe5 android tts(Text To Speech)
  • 原文地址:https://www.cnblogs.com/viewts/p/14505745.html
Copyright © 2011-2022 走看看