Ejemplo n.º 1
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)
Ejemplo n.º 2
0
def admin_plugins(flag, content, fromId):
    content = content.lstrip('.')
    if content.split(' ', 1)[0] == 'plugins':
        commands = content.split(' ')

        plugins = PluginControl()

        # open命令
        if len(commands) == 3 and commands[1] == "open":

            if commands[2] in plugins.keywords:
                res = plugins.add(commands[2], fromId)
                return action_in_type(fromId, res["content"], flag,
                                      res["result"])
            elif commands[2] == "all":
                false_set = plugins.add_all(fromId)
                if false_set == []:
                    return action_in_type(fromId, "插件全部开启成功", flag, True)
                else:
                    content = "插件 "
                    for plugin in false_set:
                        content += plugin + " , "
                    content += "开启失败"
                    return action_in_type(fromId, content, flag, False)
            else:
                return action_in_type(fromId, commands[2] + "不是可开启的插件", flag,
                                      False)

        # close命令
        elif len(commands) == 3 and commands[1] == "close":

            if commands[2] == "all":
                false_set = plugins.delete_all(fromId)
                if false_set == []:
                    return action_in_type(fromId, "插件全部关闭成功", flag, True)
                else:
                    content = "插件 "
                    for plugin in false_set:
                        content += plugin + " , "
                    content += "关闭失败"
                    return action_in_type(fromId, content, flag, False)
            else:
                res = plugins.delete(commands[2], fromId)
                return action_in_type(fromId, res["content"], flag,
                                      res["result"])

        # list命令
        elif len(commands) == 2 and commands[1] == "list":

            results = plugins.find_all(fromId)

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

            return action_in_type(fromId, content, flag, False)