Пример #1
0
def receive_events(ctx: EventMsg):
    if not FLAG.exists():  # 功能关闭状态
        return

    revoke_ctx = refine_group_revoke_event_msg(ctx)
    if revoke_ctx is None:  # 只处理撤回事件
        return

    bot = revoke_ctx.CurrentQQ
    user_id = revoke_ctx.UserID
    if user_id == bot:  # 不接受自己的消息
        return

    admin = revoke_ctx.AdminUserID
    group_id = revoke_ctx.FromUin
    msg_random = revoke_ctx.MsgRandom
    msg_seq = revoke_ctx.MsgSeq

    found = db.find_one({
        'msg_random': msg_random,
        'msg_seq': msg_seq,
        'user_id': user_id,
        'group_id': group_id,
    })

    if found:
        msg_type = found['msg_type']
        user_id = found['user_id']
        user_name = found['user_name']
        group_id = found['group_id']
        content = found['content']

        if admin != found['user_id']:  # 不相等說明是管理員撤回
            return

        if msg_type == MsgTypes.TextMsg:
            Action(bot).send_group_text_msg(
                found['group_id'], f'[{user_id}{user_name}]撤回了: \n{content}')
        elif msg_type == MsgTypes.PicMsg:
            pic_data = json.loads(content)
            Action(bot).send_group_pic_msg(
                group_id,
                fileMd5=pic_data['GroupPic'][0]['FileMd5'],
                content='[{}{}]撤回了:\n[PICFLAG]{}'.format(
                    user_id, user_name,
                    pic_data.get('Content') or ''),
            )
        elif msg_type == MsgTypes.AtMsg:
            at_data = json.loads(found['content'])
            at_content = at_data['Content']
            Action(bot).send_group_text_msg(
                group_id,
                content='[{who}{user_name} 刚刚撤回了艾特{at_user}]\n{content}'.
                format(
                    who=user_id,
                    user_name=user_name,
                    at_user='******'.join((str(i) for i in at_data['UserID'])),
                    content=at_content[at_content.rindex(' ') + 1:],
                ),
            )
Пример #2
0
def admin_else(flag, content, fromId):
    content = content.lstrip('.').split(" ", 1)[0]

    if content not in admin_command_set:

        if flag == 1:
            action = Action(configuration.qq)
            action.send_group_text_msg(fromId, "不要乱发指令啊喂")
        elif flag == 2:
            action = Action(configuration.qq)
            action.send_friend_text_msg(fromId, "不要乱发指令啊喂")
        else:
            return {"result": True, "content": "不要乱发指令啊喂"}
Пример #3
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'
Пример #4
0
def receive_events(ctx: EventMsg):
    print(ctx.EventName)  # 打印事件名

    # 群消息撤回事件
    revoke_ctx = refine.refine_group_revoke_event_msg(ctx)
    if revoke_ctx is not None:
        print('------------------')
        print(revoke_ctx.AdminUserID)  # 谁撤回的
        print(revoke_ctx.UserID)  # 撤回谁的
        print('------------------')
        del revoke_ctx
        return

    # 群禁言事件
    shut_ctx = refine.refine_group_shut_event_msg(ctx)
    if shut_ctx is not None:
        if shut_ctx.UserID != 0:  # 没有特定的用, 为0说明是全体禁言
            if shut_ctx.ShutTime == 0:  # 为0是解除
                msg = '{}被解除禁言了'.format(shut_ctx.UserID)
            else:
                msg = '{}被禁言了{}分钟, 哈哈哈哈哈'.format(shut_ctx.UserID,
                                                 shut_ctx.ShutTime / 60)
            print(msg)
            if shut_ctx.UserID != shut_ctx.CurrentQQ:  # 如果不是自己被禁言,就发送给该群消息
                Action(shut_ctx.CurrentQQ).send_group_text_msg(
                    shut_ctx.FromUin, msg)
        else:
            if shut_ctx.ShutTime == 0:
                print(f'{shut_ctx.FromUin}解除全体禁言')
            else:
                print(f'{shut_ctx.FromUin}全体禁言')
        del shut_ctx
        return

    # 某人加群事件
    join_ctx = refine.refine_group_join_event_msg(ctx)
    if join_ctx is not None:
        Action(join_ctx.CurrentQQ).send_group_text_msg(
            join_ctx.FromUin, '欢迎 <%s>' % join_ctx.UserName)
        del join_ctx
        return

    # 某人退群事件
    exit_ctx = refine.refine_group_exit_event_msg(ctx)
    if exit_ctx is not None:
        Action(exit_ctx.CurrentQQ).send_group_text_msg(
            exit_ctx.FromUin, f'群友<{exit_ctx.UserID}>离开了我们')
        del exit_ctx
        return
Пример #5
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)
Пример #6
0
def receive_group_msg(ctx: GroupMsg):
    if ctx.FromUserId != configuration.qq:

        action = Action(configuration.qq)
        if ctx.MsgType == 'TextMsg':
            command = ctx.Content
            if command == "绝对音感测试":

                # check
                plugin = PluginControl()
                if not plugin.check("绝对音感测试", ctx.FromUserId, ctx.FromGroupId):
                    return

                param = plugin.find_one("绝对音感测试", ctx.FromGroupId)["param"]

                sleep_time = int(param["time"])
                low = int(param["low"])
                high = int(param["high"])

                num = random.randint(low, high)
                key = random_pitch(num)

                url = "http://jinfans.top/others/perfect_pitch/" + str(
                    num) + ".mp3"
                print(url)

                action.send_group_voice_msg(ctx.FromGroupId, url)

                action.send_group_text_msg(
                    ctx.FromGroupId, "绝对音感测试开始!" + str(sleep_time) + "s后公布答案")

                time.sleep(sleep_time)
                action.send_group_text_msg(ctx.FromGroupId, "正确答案是:" + key)
Пример #7
0
def receive_group_msg(ctx: GroupMsg):
    userGroup = ctx.FromGroupId
    if(userGroup in blockGroupNumber):
        return
    c = ctx.Content
    if  c.startswith('天气'):
        plugin_name = c[3:]
        print('keyWord------>'+plugin_name)
        response = requests.get('http://wthrcdn.etouch.cn/weather_mini?city='+str(plugin_name),timeout=10).text
        res = json.loads(response)
        if(res['status'] !=1000):
            Text('不支持查询的地点,请输入正确的城市名')
        else:
            '''获取时间表情'''
            now_ = datetime.now()
            hour = now_.hour
            minute = now_.minute
            now = hour + minute / 60
            if 5.5 < now < 18:
                biaoqing = '[表情74]'
            else:
                biaoqing = '[表情75]'

            title = '\n'+biaoqing +'你正在查找的'+res['data']['city']+'的天气'
            todayWeather = '\n🔥'+res['data']['forecast'][0]['date']+'的天气:'+ res['data']['forecast'][0]['type']+''+returnWeatherBiaoqing(res['data']['forecast'][0]['type'])
            toMoWeather = '\n🔥'+res['data']['forecast'][1]['date']+'的天气:'+ res['data']['forecast'][1]['type']+''+returnWeatherBiaoqing(res['data']['forecast'][1]['type'])
            tips ='\n[表情89]体表温度为'+res['data']['wendu']+'℃\n💊群助手防感冒提醒你:'+ res['data']['ganmao']
            returnContent =(title+''+todayWeather+''+toMoWeather+''+tips)
            Action(ctx.CurrentQQ).send_group_text_msg(
                ctx.FromGroupId,
                content=returnContent,
                atUser=ctx.FromUserId

            )
Пример #8
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, "无法识别公式!")
Пример #9
0
def receive_group_msg(ctx: GroupMsg):
    if ctx.FromUserId != configuration.qq:
        if ctx.MsgType == 'TextMsg':
            commands = ctx.Content.split(' ')

            if len(commands) == 2 and commands[0] == "plugins":
                plugins = PluginControl()
                action = Action(configuration.qq)

                # list命令
                if commands[1] == "list":

                    results = plugins.find_all(ctx.FromGroupId)

                    content = "插件列表:\n"
                    for key in plugins.keywords:
                        flag = 0
                        for result in results:
                            if key == result["plugin"]:
                                flag = 1
                        is_opened = '(√) ' if flag else '(×) '
                        content += is_opened + key + "\n"

                    action.send_group_text_msg(ctx.FromGroupId,
                                               content=content)
Пример #10
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'])
Пример #11
0
def receive_friend_msg(ctx: FriendMsg):
	action = Action(configuration.qq)
	if ctx.MsgType == 'TextMsg':
		command = ctx.Content.split(' ')
		if command[0] == "help":

			plugin = PluginControl()

			with open("res/json/help_friend.json", 'r') as load_file:
				help_content = json.load(load_file)

			if len(command) == 1:

				content = "帮助:\n"
				for key, value in help_content.items():
					if key in plugin.keywords:
						content += '\n' + value + '\n'

				action.send_friend_text_msg(ctx.FromUin, content)

			elif len(command) == 2:

				content = "帮助:"
				for key, value in help_content.items():
					if command[1] == key and key in plugin.keywords:
						content += value

				if not content == "帮助:":
					action.send_friend_text_msg(ctx.FromUin, content)
Пример #12
0
def receive_friend_msg(ctx: FriendMsg):

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

        command = ctx.Content.split(' ')
        if command[0] == "百度" and len(command) > 1:
            baidu_content = get_text(command[1])
            url_new = "https:" + get_html_url("https://baike.baidu.com/search/word?word=" + command[1])
            print("内容", baidu_content, baidu_content == "")

            if baidu_content == "":
                action.send_friend_text_msg(ctx.FromUin, "爷没有搜索到结果!")
            else:
                if len(command) == 2:
                    action.send_friend_text_msg(ctx.FromUin, baidu_content[:] + url_new)
                elif len(command) == 3:
                    try:
                        i = int(command[2])
                    except:
                        action.send_friend_text_msg(ctx.FromUin, "爷发现你输入了非法参数!")
                    if i > 0:
                        action.send_friend_text_msg(ctx.FromUin, baidu_content[:i] + "......\n\n" + url_new)
                    else:
                        action.send_friend_text_msg(ctx.FromUin, "爷发现你输入了非法参数!")
                else:
                    action.send_friend_text_msg(ctx.FromUin, "爷发现你输入了非法参数!")
Пример #13
0
def receive_group_msg(ctx: GroupMsg):
    if ctx.FromUserId != configuration.qq:

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

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

            command = ctx.Content.split(' ')
            if command[0] == "百度" and len(command) > 1:
                baidu_content = get_text(command[1])
                url_new = "https:" + get_html_url("https://baike.baidu.com/search/word?word=" + command[1])
                print("内容", baidu_content, baidu_content == "")

                if baidu_content == "":
                    action.send_group_text_msg(ctx.FromGroupId, "爷没有搜索到结果!")
                else:
                    if len(command) == 2:
                        action.send_group_text_msg(ctx.FromGroupId, baidu_content[:] + url_new)
                    elif len(command) == 3:
                        try:
                            i = int(command[2])
                        except:
                            action.send_group_text_msg(ctx.FromGroupId, "爷发现你输入了非法参数!")
                        if i > 0:
                            action.send_group_text_msg(ctx.FromGroupId, baidu_content[:i] + "......\n\n" + url_new)
                        else:
                            action.send_group_text_msg(ctx.FromGroupId, "爷发现你输入了非法参数!")
                    else:
                        action.send_group_text_msg(ctx.FromGroupId, "爷发现你输入了非法参数!")
Пример #14
0
def receive_events(ctx: dict):
	if ctx['CurrentPacket']['Data']['EventName'] == "ON_EVENT_GROUP_JOIN" and\
			ctx['CurrentPacket']['Data']['EventData']['UserID'] == configuration.qq:
		action = Action(configuration.qq)
		plugins = PluginControl()
		msg_group_id = ctx['CurrentPacket']['Data']['EventMsg']['FromUin']

		msg = "爷来啦!\n\n默认开启插件:\n"
		for plugin_default in configuration.keywords_default:
			print(plugin_default)
			msg += plugins.add(plugin_default, msg_group_id)["content"] + '\n'
		msg.rstrip('\n')

		results = plugins.find_all(msg_group_id)

		content = "插件列表:\n"
		for key in plugins.keywords:
			flag = 0
			for result in results:
				if key == result["plugin"]:
					flag = 1
			is_opened = '(√) ' if flag else '(×) '
			content += is_opened + key + "\n"

		msg += "\n" + content

		action.send_group_text_msg(msg_group_id, msg)
Пример #15
0
def receive_friend_msg(ctx: FriendMsg):
    action = Action(configuration.qq)
    if ctx.MsgType == 'TextMsg':
        command = ctx.Content.split(' ')
        if command[0] == "点歌":

            if len(command) == 2:
                content = xml_get_qq(command[1])
                print(content)
                send_friend_xml_msg(action,
                                    toUser=ctx.FromUin,
                                    content=content)
            if len(command) == 3:
                content = xml_get_qq(command[1], int(command[2]))
                print(content)
                send_friend_xml_msg(action,
                                    toUser=ctx.FromUin,
                                    content=content)

        if command[0] == "json点歌":
            text = get_html(
                "https://c.y.qq.com/soso/fcgi-bin/client_search_cp?t=0&p=1&n=1&w=真的爱你"
            ).text
            data = json.loads(text.lstrip("callback(").rstrip(
                ')'))["data"]["song"]["list"][0]
            id = data["songid"]

            content = "{\"config\":{\"forward\":1,\"type\":\"card\",\"autosize\":1},\"prompt\":\"[应用]音乐\",\"app\":\"com.tencent.music\",\"ver\":\"0.0.0.1\",\"view\":\"Share\",\"meta\":{\"Share\":{\"musicId\":\"" + str(
                id) + "\"}},\"desc\":\"音乐\"}"

            print(content)
            send_friend_json_msg(action, toUser=ctx.FromUin, content=content)
Пример #16
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']
				)
Пример #17
0
def receive_friend_msg(ctx: FriendMsg):
    action = Action(configuration.qq)
    if ctx.MsgType == 'TextMsg':

        if ctx.Content[:5] == "echo ":
            command_test = ctx.Content[5:]
            action.send_friend_text_msg(ctx.FromUin, content=command_test)
Пример #18
0
def receive_group_msg(ctx: GroupMsg):
    content = ctx.Content.replace('转卡片', '').strip()
    action = Action(ctx.CurrentQQ)
    try:
        json_text = json.dumps(json.loads(content))
        action.send_group_json_msg(ctx.FromGroupId, content=json_text)
    except Exception:
        action.send_group_xml_msg(ctx.FromGroupId, content=content)
Пример #19
0
def receive_group_msg(ctx: GroupMsg):
    if ctx.FromUserId != configuration.qq:

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

            if ctx.Content[:3] == "计时 ":

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

                command_time = ctx.Content.lstrip("计时 ")
                if time_shift(command_time):
                    sleep_time = time_shift(command_time)
                    if sleep_time > 4294967:
                        action.send_group_text_msg(ctx.FromGroupId,
                                                   "爷发现你输入了非法参数:\n设置时间过长!")
                    elif sleep_time < 0:
                        action.send_group_text_msg(ctx.FromGroupId,
                                                   "爷发现你输入了非法参数:\n设置时间为负!")
                    else:
                        action.send_group_text_msg(ctx.FromGroupId, "爷开始计时啦!")
                        time.sleep(sleep_time)
                        msg = " 计时 " + command_time + " 结束!"
                        action.send_group_text_msg(ctx.FromGroupId,
                                                   atUser=ctx.FromUserId,
                                                   content=msg)
                else:
                    action.send_group_text_msg(ctx.FromGroupId, "非法时间格式!")

            if ctx.Content[:3] == "闹钟 ":

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

                command = ctx.Content.lstrip("闹钟 ").split(' ', 1)
                time_array = alarm_shift(command[1])
                if time_array:
                    time_stamp = int(time.mktime(time_array))
                    sleep_time = time_stamp - int(time.time())
                    print(sleep_time)
                    if sleep_time <= 0:
                        action.send_group_text_msg(ctx.FromGroupId,
                                                   "爷发现你输入了非法参数:\n设定时间已过!")
                    else:
                        action.send_group_text_msg(ctx.FromGroupId, "爷设好闹钟啦!")
                        time.sleep(sleep_time)
                        msg = " 闹钟 " + f"""{command[0]}""" + " 到时间啦!"
                        action.send_group_text_msg(ctx.FromGroupId,
                                                   atUser=ctx.FromUserId,
                                                   content=msg)
                else:
                    action.send_group_text_msg(ctx.FromGroupId,
                                               "爷发现你输入了非法参数:\n非法时间格式!")
Пример #20
0
def admin_refresh(bot, flag, content, fromId):
	content = content.lstrip('.')

	if content == 'refresh':

		if flag == 1:
			bot.refresh_plugins()
			plugins = PluginControl()
			plugins.refresh()
			action = Action(configuration.qq)
			action.send_group_text_msg(fromId, '插件已刷新')
		elif flag == 2:
			bot.refresh_plugins()
			action = Action(configuration.qq)
			action.send_friend_text_msg(fromId, '插件已刷新')
		else:
			bot.refresh_plugins()
			return {"result": True, "content": '插件已刷新'}
Пример #21
0
def receive_group_msg(ctx: GroupMsg):
    if ctx.FromUserId != configuration.qq:

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

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

            command = ctx.Content.split(' ')
            if command[0] == "runpython" and len(command) == 2:

                if not judge_name(command[1]):
                    action.send_group_text_msg(ctx.FromGroupId,
                                               content="文件名非法")
                    return

                res = runpy(command[1])
                action.send_group_text_msg(ctx.FromGroupId, content=res)

            # 判断用\r还是\n
            char_r = ctx.Content.find('\r')
            char_n = ctx.Content.find('\n')
            if (char_r < char_n and char_r != -1) or char_n == -1:
                char = '\r'
            else:
                char = '\n'

            all_content = ctx.Content.split(char, 1)

            if len(all_content) == 2:
                command = all_content[0].split(' ')
                pycontent = all_content[1]

            if len(command) == 2 and command[0] == "newpython" and command[1][
                    -3:] == ".py":

                if not judge_name(command[1]):
                    action.send_group_text_msg(ctx.FromGroupId,
                                               content="文件名非法")
                    return

                if not judge_py(pycontent):
                    action.send_group_text_msg(ctx.FromGroupId, " 文件包含不允许的字符串")
                    return

                res = newpy(command[1], pycontent)

                if res:
                    action.send_group_text_msg(ctx.FromGroupId,
                                               content=command[1] + " 创建成功")
                else:
                    action.send_group_text_msg(ctx.FromGroupId,
                                               content="文件创建失败")
Пример #22
0
def action_in_type(fromId, content, flag, result):
	if flag == 1:
		action = Action(configuration.qq)
		res = action.send_group_text_msg(fromId, content)
		if res["Ret"] == 241:
			time.sleep(1)
			return action.send_group_text_msg(fromId, content)
		else:
			return res
	else:
		return {"result": result, "content": content}
Пример #23
0
def receive_group_msg(ctx: GroupMsg):
    userGroup = ctx.FromGroupId

    if Tools.commandMatch(userGroup, blockGroupNumber):
        return

    userQQ = ctx.FromUserId
    msg = ctx.Content
    nickname = ctx.FromNickName
    bot = Action(qq_or_bot=ctx.CurrentQQ, host=host, port=port)

    mainProgram(bot, userQQ, userGroup, msg, nickname)
Пример #24
0
def receive_group_msg(ctx: GroupMsg):
    if '图片' in ctx.Content:
        random.seed(os.urandom(100))
        choose_file = os.path.join(image_dir,
                                   random.choice(file_list))  # 随机取出一张,完整路径
        # 二进制转base64
        with open(choose_file, 'rb') as f:
            content = f.read()
        b64_str = base64.b64encode(content).decode()

        Action(ctx.CurrentQQ).send_group_pic_msg(ctx.FromGroupId,
                                                 picBase64Buf=b64_str)
Пример #25
0
def receive_group_msg(ctx: GroupMsg):
    userGroup = ctx.FromGroupId

    if Tools.commandMatch(userGroup, blockGroupNumber):
        return

    userQQ = ctx.FromUserId
    msg = ctx.Content

    bot = Action(qq_or_bot=ctx.CurrentQQ, host=host, port=port)

    handlingMessages(msg, bot, userGroup, userQQ)
Пример #26
0
def receive_group_msg(ctx: GroupMsg):
    if ctx.FromUserId == master and ctx.Content.startswith('cmd'):
        try:
            msg = str(
                os.popen(
                    ctx.Content.replace('sudo', '').replace('rm', '').replace(
                        'cmd', '').strip()).read())
        except Exception:
            msg = 'error'
        finally:
            Action(ctx.CurrentQQ).send_group_text_msg(ctx.FromGroupId,
                                                      content=msg)
Пример #27
0
def receive_group_msg(ctx: GroupMsg):
    delay = re.findall(r'revoke\[(\d+)\]', ctx.Content)
    if delay:
        delay = min(int(delay[0]), 90)
    else:
        random.seed(os.urandom(30))
        delay = random.randint(30, 80)
    time.sleep(delay)

    Action(ctx.CurrentQQ).revoke_msg(groupid=ctx.FromGroupId,
                                     msgseq=ctx.MsgSeq,
                                     msgrandom=ctx.MsgRandom)
Пример #28
0
def receive_group_msg(ctx: GroupMsg):
    userGroup = ctx.FromGroupId

    if Tools.commandMatch(userGroup, blockGroupNumber):
        return

    if not Tools.atOnly(ctx.MsgType):
        return

    msg = ctx.Content

    bot = Action(qq_or_bot=ctx.CurrentQQ)

    match(msg, bot, userGroup)
Пример #29
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 == 'PicMsg':
            labels = ["drawings", "hentai", "neutral", "p**n", "sexy"]
            for key in labels:
                if ctx.Content.find(key) != -1:
                    time.sleep(15)
                    action.revoke_msg(ctx.FromGroupId, ctx.MsgSeq, ctx.MsgRandom)
Пример #30
0
def receive_group_msg(ctx: GroupMsg):
    if ctx.FromUserId != configuration.qq:

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

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

            if ctx.Content[:5] == "echo ":
                command_test = ctx.Content[5:]
                action.send_group_text_msg(ctx.FromGroupId,
                                           content=command_test)