Esempio n. 1
0
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
Esempio n. 2
0
async def no_mom(bot, ctx, match):
    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"]}')
    msg = random.choice(open('/home/ubuntu/HoshinoBot/res/img/nmsl.txt').readlines())#这里填写你喷词文本的绝对路径
    await bot.send(ctx, msg)
Esempio n. 3
0
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)
    await util.silence(session.ctx, 8*60*60)
Esempio n. 4
0
def init():
	logger.info(f'Initializing Database...')
	if TESTING_MODE:
		logger.warning("PAY ATTENTION!NOW UNDER TESTING MODE!")
	for db in BaseDatabase.__subclasses__():
		try:
			db_name = db.__name__
			db.bind(database(db_name))
			if skip_database_initialize:
				continue
			database(db_name).connect()
			if not db.table_exists():
				database(db_name).create_tables([db])
				logger.info(f'Table <{db_name}> not exists, will be created in database <{get_database(db_name)}>.')
			database(db_name).close()
		except Exception as e:
			traceback.print_exc()
			logger.critical(f'Error <{e}> encountered while initializing database <{get_database(db_name)}>.')