• 异步 QQ 机器人框架_NoneBot


    一、NoneBot使用

    1) #监控发送的消息"群发"的事件
    @on_command('send_msg', aliases=('群发',))
    async def send_msg(session: CommandSession):
    print("发送消息")
    message_type=session.ctx['message_type']
    user_id=session.ctx['user_id']
    #判断发送的消息是私聊的,并且发送的qq号码是448113545
    if message_type=='private' and user_id==448113545:
    #获取qq群的信息
    group_list = await session.bot.get_group_list()
    for group in group_list:
    #对某个qq群进行发送信息
    await session.bot.send_group_msg(group_id=group['group_id'],message='要群发的消息')
    2)session.ctx
    {'font': 6395088, 'message': [{'type': 'text', 'data': {'text': '33'}}], 'message_id': 36, 'message_type': 'private', 'post_type': 'message', 'raw_message': '33', 'self_id': 12345678, 'sender': {'age': 29, 'nickname': '美好', 'sex': 'unknown', 'user_id': 446789001}, 'sub_type': 'friend', 'time': 1578536478, 'user_id':446789001, 'to_me': True}
    3.bot的使用
    bot = nonebot.get_bot()
    info = await bot.get_group_member_info(group_id=62234565, user_id=448112234)
    await bot.send_group_msg(group_id=6227422, message='大家好~') # 发送群消息
    # 监听消息
    bot = nonebot.get_bot()
    # @bot.on_message('group') #监听群组消息
    @bot.on_message() #监听所有消息
    async def handle_group_message(ctx):
    print("group ctx>>",ctx)
     


  • 相关阅读:
    微信小程序分列显示数据
    微信小程序open-data获取用户的信息样式设置
    微信小程序-获取当前城市位置
    EXCEL按照指定的格式递增到指定的行
    在Linux合并文件
    在Linux切割文件
    解锁oracle用户的方法
    oracle/MySQL构造数据的存储过程
    在PL/SQL登录时报system用户表空间不足
    删除oracle数据库用户
  • 原文地址:https://www.cnblogs.com/jiguanghover/p/12169959.html
Copyright © 2020-2023  润新知