async def hb_handler(ctx): self_id = ctx['self_id'] user_id = ctx['user_id'] group_id = ctx['group_id'] first_msg_seg = ctx['message'][0] if first_msg_seg.type == 'hb': title = first_msg_seg['data']['title'] if _check_hbtitle_is_cmd(ctx, title): Service.set_block_group(group_id, timedelta(hours=1)) Service.set_block_user(user_id, timedelta(days=30)) util.silence(ctx, 7 * 24 * 60 * 60) msg_from = f"{ctx['user_id']}@[群:{ctx['group_id']}]" logger.critical( f'Self: {ctx["self_id"]}, Message {ctx["message_id"]} from {msg_from} detected as abuse: {ctx["message"]}' ) await bot.send(ctx, "检测到滥用行为,您的操作已被记录并加入黑名单。\nbot拒绝响应本群消息1小时", at_sender=True) try: await bot.set_group_kick(self_id=self_id, group_id=group_id, user_id=user_id, reject_add_request=True) logger.critical(f"已将{user_id}移出群{group_id}") except: pass
async def setblock(session): ctx=session.ctx try: timelen=5 if not session.current_arg_text else int(session.current_arg_text) except: return count=0 for m in ctx['message']: if m.type == 'at' and m.data['qq'] != 'all' : uid = int(m.data['qq']) Service.set_block_user(uid,timedelta(minutes=timelen)) count+=1 session.finish(f'已拉黑{count}人{timelen}分钟,嘿嘿嘿~')
async def ban_word(session): ctx = session.ctx user_id = ctx['user_id'] msg_from = str(user_id) if ctx['message_type'] == 'group': msg_from += f'@[群:{ctx["group_id"]}]' elif ctx['message_type'] == 'discuss': msg_from += f'@[讨论组:{ctx["discuss_id"]}]' logger.critical( f'Self: {ctx["self_id"]}, Message {ctx["message_id"]} from {msg_from}: {ctx["message"]}' ) # await session.send(random.choice(BANNED_WORD)) Service.set_block_user(user_id, timedelta(hours=8)) pic = R.img(f"chieri{random.randint(1, 4)}.jpg").cqcode await session.send(f"不理你啦!バーカー\n{pic}", at_sender=True)
async def ban_word(session): ctx = session.ctx user_id = ctx['user_id'] msg_from = str(user_id) if ctx['message_type'] == 'group': msg_from += f'@[群:{ctx["group_id"]}]' elif ctx['message_type'] == 'discuss': msg_from += f'@[讨论组:{ctx["discuss_id"]}]' logger.critical(f'Self: {ctx["self_id"]}, Message {ctx["message_id"]} from {msg_from}: {ctx["message"]}') # await session.send(random.choice(BANNED_WORD)) Service.set_block_user(user_id, timedelta(hours=8)) pic_index = random.randint(1, 3); pic = R.img(f"chieri{pic_index}.jpg").cqcode msg = '' if pic_index == 1: msg = '不理你啦!' elif pic_index == 2: msg = '不理你啦!口亨!' elif pic_index == 3: msg = '信不信我把你变成布丁?' else: msg = '不理你啦!バーカー' await session.send(f"{msg}\n{pic}", at_sender=True) await util.silence(session.ctx, 8*60*60)