Пример #1
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)
Пример #2
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)
Пример #3
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": "不要乱发指令啊喂"}
Пример #4
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": '插件已刷新'}
Пример #5
0
def receive_friend_msg(ctx: FriendMsg):
    action = Action(configuration.qq)
    if ctx.MsgType == 'TextMsg':

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

            data = {"formula": transfer_spacing(latex_content), "fcolor": "000000", "fsize": "70px", "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_friend_pic_msg(ctx.FromUin, picUrl=pic_url, timeout=20)
            else:
                action.send_friend_text_msg(ctx.FromUin, "无法识别公式!")
Пример #6
0
def receive_friend_msg(ctx: FriendMsg):
    setu_allow = False
    if ctx.FromUin != configuration.qq:
        action = Action(configuration.qq)
        if ctx.MsgType == 'TextMsg':
            command = ctx.Content.split(' ')
            if command[0] == "setu":
                if setu_allow:
                    if len(command) == 2:
                        execute = command[1]
                    else:
                        execute = "drawings"

                    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_friend_pic_msg(ctx.FromUin, content=execute, picUrl=url)
                else:
                    action.send_friend_text_msg(ctx.FromUin, content='ф╜ахЬицГ│ЁЯНС')
Пример #7
0
def receive_friend_msg(ctx: FriendMsg):
    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_friend_text_msg(ctx.FromUin, content="文件名非法")
                return

            res = runpy(command[1])
            action.send_friend_text_msg(ctx.FromUin, 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'

        print(char_r, char_n, char_r < char_n or char_n == -1, char)

        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_friend_text_msg(ctx.FromUin, content="文件名非法")
                return

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

            res = newpy(command[1], pycontent)
            if res:
                action.send_friend_text_msg(ctx.FromUin,
                                            content=command[1] + " 创建成功")
            else:
                action.send_friend_text_msg(ctx.FromUin, content="文件创建失败")
Пример #8
0
def receive_friend_msg(ctx: FriendMsg):
    action = Action(configuration.qq)
    if ctx.MsgType == 'TextMsg':

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

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

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

            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_friend_text_msg(ctx.FromUin,
                                                "爷发现你输入了非法参数:\n设定时间已过!")
                else:
                    action.send_friend_text_msg(ctx.FromUin, "爷设好闹钟啦!")
                    time.sleep(sleep_time)
                    msg = " 闹钟 " + f"""{command[0]}""" + " 到时间啦!"
                    action.send_friend_text_msg(ctx.FromUin, content=msg)
            else:
                action.send_friend_text_msg(ctx.FromUin,
                                            "爷发现你输入了非法参数:\n非法时间格式!")
Пример #9
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) >= 2:

            text = command[1]
            voiceId = "geyou"
            speed = "1.5"
            volume = "100"
            audioType = "wav"
            for i in range(len(command) - 2):
                if command[i + 2][:8] == 'voiceId=':
                    voiceId = command[i + 2].lstrip('voice=Id')
                elif command[i + 2][:6] == 'speed=':
                    speed = command[i + 2].lstrip('speed=')
                elif command[i + 2][:7] == 'volume=':
                    volume = command[i + 2].lstrip('volume=')
                elif command[i + 2][:10] == 'audioType=':
                    audioType = command[i + 2].lstrip('audioType=')

            url = "https://dds.dui.ai/runtime/v1/synthesize?voiceId=" + voiceId + "&speed=" + speed + \
               "&volume=" + volume + "&audioType=" + audioType + "&text=" + text

            action.send_friend_voice_msg(ctx.FromUin, url)

        elif command[0] == "对话" and len(command) >= 2:

            ask = command[1]
            voiceId = "geyou"
            speed = "1.5"
            volume = "100"
            audioType = "wav"
            for i in range(len(command) - 2):
                if command[i + 2][:8] == 'voiceId=':
                    voiceId = command[i + 2].lstrip('voice=Id')
                elif command[i + 2][:6] == 'speed=':
                    speed = command[i + 2].lstrip('speed=')
                elif command[i + 2][:7] == 'volume=':
                    volume = command[i + 2].lstrip('volume=')
                elif command[i + 2][:10] == 'audioType=':
                    audioType = command[i + 2].lstrip('audioType=')

            res_url = "https://api.ownthink.com/bot?appid=xiaosi&spoken=" + ask

            res = json.loads(get_html_text(res_url))

            print(res)
            if res["message"] == "error":
                action.send_friend_text_msg(ctx.FromUin, "对话请求错误!")
                return
            elif not res["data"]["type"] == 5000:
                action.send_friend_text_msg(ctx.FromUin, "对话返回错误!")
                return
            else:
                text = res["data"]["info"]["text"]

            url = "https://dds.dui.ai/runtime/v1/synthesize?voiceId=" + voiceId + "&speed=" + speed + \
               "&volume=" + volume + "&audioType=" + audioType + "&text=" + text

            action.send_friend_voice_msg(ctx.FromUin, url)
Пример #10
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, "爷发现你输入了非法参数!")