How to use the nonebot.on_request function in nonebot

To help you get started, we’ve selected a few nonebot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Joenothing-lst / kkl-Android-2.0 / kkl_bot / kkl / plugins / notices.py View on Github external
@on_request('group')
async def bot_request(session: RequestSession):
    global request_flag
    f_group= session.ctx['group_id']
    f_user= session.ctx['user_id']
    if session.ctx['sub_type']=='invite':
        if request_flag == False:
            await session.bot.send_private_msg(user_id=f_user,message=f'想邀请可可萝入群嘛?请先点击这里联系作者:\nhttps://wpa.qq.com/msgrd?v=3&uin={master}&site=qq&menu=yes')
            await session.bot.send_private_msg(user_id=master,message=f'有新的群邀请:\n群:{f_group}\n邀请人:{f_user}\n已忽略')
        else :
            try:
                await session.approve()
            except ActionFailed as e:
                print(e.retcode)
            await session.bot.send_private_msg(user_id=master,message=f'有新的群邀请:\n群:{f_group}\n邀请人:{f_user}\n已同意')
            request_flag=False

nonebot

An asynchronous QQ bot framework based on CoolQ.

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis