Ejemplo n.º 1
0
def receive_events(ctx: dict):
	if ctx['CurrentPacket']['Data']['EventName'] == 'ON_EVENT_GROUP_REVOKE' and \
			ctx['CurrentPacket']['Data']['EventData']['UserID'] != configuration.qq:

		# check
		plugin = PluginControl()
		if not plugin.check("防撤回", ctx['CurrentPacket']['Data']['EventData']['UserID'],
							ctx['CurrentPacket']['Data']['EventData']['GroupID']):
			return

		action = Action(configuration.qq)
		msg_set = ctx['CurrentPacket']['Data']['EventData']
		msg_seq = msg_set['MsgSeq']
		msg_group_id = msg_set['GroupID']
		msg_revoke = find_group_msg_by_msg_seq(msg_seq, msg_group_id)
		if msg_revoke is None:
			logger.error('db.find returns null result')
			return
		if msg_revoke["msg_type"] == 'TextMsg':
			msg = "爷发现 " + msg_revoke["from_nickname"] + " 撤回了消息:\n\n"
			action.send_group_text_msg(msg_revoke["from_group_id"], msg + msg_revoke["content"])
		if msg_revoke["msg_type"] == 'PicMsg':
			msg = "爷发现 " + msg_revoke["from_nickname"] + " 撤回了图片:\n\n"
			msg_content = msg_revoke["content"] if msg_revoke["content"] is not None else ""
			action.send_group_text_msg(msg_revoke["from_group_id"], msg + msg_content)
			pics = msg_revoke["pics"]
			for pic_id in pics:
				pic_content = find_img_by_id(pic_id)
				action.send_group_pic_msg(
					msg_revoke["from_group_id"],
					fileMd5=pic_content['FileMd5'],
					picBase64Buf=pic_content['ForwordBuf']
				)
Ejemplo n.º 2
0
def receive_group_msg(ctx: GroupMsg):
    # check
    plugin = PluginControl()
    if not plugin.check("reply", ctx.FromUserId, ctx.FromGroupId):
        return

    # param
    param = plugin.find_one("reply", ctx.FromGroupId)["param"]
    p = float(param["p"])
    q = float(param["q"])
    delay_time = float(param["delay_time"])

    if random.random() < p and ctx.FromUserId != configuration.qq:
        time.sleep(random.random() * delay_time)
        action = Action(configuration.qq)
        if ctx.MsgType == 'TextMsg' and not plugin.is_command(
                ctx.Content.split(' ', 1)[0], ctx.FromGroupId):
            action.send_group_text_msg(ctx.FromGroupId,
                                       replace_text_msg(ctx.Content, q))
        elif ctx.MsgType == 'PicMsg':
            pic_msg = json.loads(ctx.Content)
            for pic_content in pic_msg['GroupPic']:
                action.send_group_pic_msg(
                    ctx.FromGroupId,
                    fileMd5=pic_content['FileMd5'],
                    picBase64Buf=pic_content['ForwordBuf'])
Ejemplo n.º 3
0
def receive_group_msg(ctx: GroupMsg):
    if ctx.FromUserId != configuration.qq:

        # check
        plugin = PluginControl()
        if not plugin.check("setu", ctx.FromUserId, ctx.FromGroupId):
            return

        action = Action(configuration.qq)
        if ctx.MsgType == 'TextMsg':
            command = ctx.Content.split(' ')
            if command[0] == "setu":

                if len(command) == 2:
                    execute = command[1]
                else:

                    # param
                    param = plugin.find_one("setu", ctx.FromGroupId)["param"]
                    execute = param["default"]

                id_url = "http://jinfans.top/setu/latest/view/random?type=" + execute
                id_image = get_html_text(id_url)
                id_json = json.loads(id_image)
                url = "http://jinfans.top/setu/latest/view/direct/" + id_json["_id"]
                action.send_group_pic_msg(ctx.FromGroupId, content=execute, picUrl=url)
Ejemplo n.º 4
0
def receive_group_msg(ctx: GroupMsg):
    if ctx.FromUserId != configuration.qq:

        # check
        plugin = PluginControl()
        if not plugin.check("latex", ctx.FromUserId, ctx.FromGroupId):
            return

        action = Action(configuration.qq)
        if ctx.MsgType == 'TextMsg':

            command = ctx.Content.split(' ', 1)
            if command[0] == "latex" and len(command) > 1:
                latex_content = command[1]
                url = 'https://quicklatex.com/latex3.f'

                # param
                param = plugin.find_one("latex", ctx.FromGroupId)["param"]
                fsize = str(param["fsize"])

                data = {"formula": transfer_spacing(latex_content), "fcolor": "000000", "fsize": fsize, "mode": "0", "out": "1", "remhost": "quicklatex.com"}
                response = post(url, data)
                content = response.text.split("\r\n")
                if content[0] == "0":
                    pic_url = content[1].split(' ')[0]
                    print(pic_url)
                    action.send_group_pic_msg(ctx.FromGroupId, picUrl=pic_url, timeout=20)
                else:
                    action.send_group_text_msg(ctx.FromGroupId, "无法识别公式!")
Ejemplo n.º 5
0
def admin_test(flag, content, fromId):
    content = content.lstrip('.')

    if content == 'test':

        if flag == 1:
            action = Action(configuration.qq)
            action.send_group_pic_msg(fromId, 'https://t.cn/A6Am7xYO')
        elif flag == 2:
            action = Action(configuration.qq)
            action.send_friend_pic_msg(fromId, 'https://t.cn/A6Am7xYO')
        else:
            return 'https://t.cn/A6Am7xYO'
Ejemplo n.º 6
0
def receive_group_msg(ctx: GroupMsg):
    if ctx.Content.startswith('ph '):
        args = [i.strip() for i in ctx.Content.split(' ') if i.strip()]
        if len(args) >= 3:
            left = args[1]
            right = args[2]
            f = combine_img_horizontal
            if len(args) >= 4:
                if args[3] == '1':
                    f = combine_img_vertical
            bot = Action(qq_or_bot=ctx.CurrentQQ, queue=True, queue_delay=0.5)

            bot.send_group_pic_msg(
                ctx.FromGroupId,
                picBase64Buf=f(left, right),
            )