当前位置: 首页>>代码示例>>Python>>正文


Python dataIO.load_json方法代码示例

本文整理汇总了Python中cogs.utils.dataIO.dataIO.load_json方法的典型用法代码示例。如果您正苦于以下问题:Python dataIO.load_json方法的具体用法?Python dataIO.load_json怎么用?Python dataIO.load_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cogs.utils.dataIO.dataIO的用法示例。


在下文中一共展示了dataIO.load_json方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from cogs.utils.dataIO import dataIO [as 别名]
# 或者: from cogs.utils.dataIO.dataIO import load_json [as 别名]
def __init__(self, bot):
        self.bot = bot
        self.settings = dataIO.load_json('data/repl/settings.json')
        self.output_file = "data/repl/temp_output.txt"
        self.sessions = set()

        # backwards compat in case menu was used by other cogs
        # this is global now so might cause problems if other ppl
        # are instantiating their own REPLs (which they shouldn't be)
        self.reaction_remove_events = _reaction_remove_events
        self.interactive_results = self.pagify_interactive_results

        old_methods = ['display_page', 'remove_reactions',
                       'wait_for_interaction', 'wait_for_reaction_remove']
        for m in old_methods:
            # don't do this at home kids
            lm = (lambda mn: 
                    lambda *agrs, **kwargs: locals()[mn](self.bot, *agrs, **kwargs)
                 )(m)
            setattr(self, m, lm) 
开发者ID:irdumbs,项目名称:Dumb-Cogs,代码行数:22,代码来源:repl.py

示例2: check_files

# 需要导入模块: from cogs.utils.dataIO import dataIO [as 别名]
# 或者: from cogs.utils.dataIO.dataIO import load_json [as 别名]
def check_files():
    default = {"OUTPUT_REDIRECT": "pages", "OPEN_CMD": None,
               "MULTI_MSG_PAGING": False, "PM_PAGES": 20,
               "PAGES_LENGTH": 1500, "REPL_PREFIX": ['`']}
    settings_path = "data/repl/settings.json"

    if not os.path.isfile(settings_path):
        print("Creating default repl settings.json...")
        dataIO.save_json(settings_path, default)
    else:  # consistency check
        current = dataIO.load_json(settings_path)
        if current.keys() != default.keys():
            for key in default.keys():
                if key not in current.keys():
                    current[key] = default[key]
                    print(
                        "Adding " + str(key) + " field to repl settings.json")
            dataIO.save_json(settings_path, current) 
开发者ID:irdumbs,项目名称:Dumb-Cogs,代码行数:20,代码来源:repl.py

示例3: time

# 需要导入模块: from cogs.utils.dataIO import dataIO [as 别名]
# 或者: from cogs.utils.dataIO.dataIO import load_json [as 别名]
def time(self, ctx):
        """Show current time"""
        opt = dataIO.load_json('settings/optional_config.json')
        thebool = True
        try:
            if opt['24hours'] == "true":
                thebool = True
            else:
                thebool = False
        except IndexError:
            # No 24 hour bool given so default to true
            pass
        await ctx.message.delete()
        dandt, tzerror = self.get_datetime()
        if thebool:
            returnstring = '{:Time: `%H:%M:%S`}'.format(dandt)
        else:
            returnstring = '{:Time: `%I:%M:%S %p`}'.format(dandt)
        msg = returnstring
        await ctx.send(self.bot.bot_prefix + msg) 
开发者ID:appu1232,项目名称:Discord-Selfbot,代码行数:22,代码来源:utility.py

示例4: __init__

# 需要导入模块: from cogs.utils.dataIO import dataIO [as 别名]
# 或者: from cogs.utils.dataIO.dataIO import load_json [as 别名]
def __init__(self, bot):
        """Init."""
        self.bot = bot
        self.settings = nested_dict()
        self.settings.update(dataIO.load_json(JSON))
        self.badges = dataIO.load_json(BADGES)
        self._auth = None
        self.task = None

        provider = self.settings.get('provider')
        if provider is None:
            provider = 'cr-api'

        # add auto tasks
        loop = asyncio.get_event_loop()
        self.task = loop.create_task(self.auto_tasks())


        self._session = None 
开发者ID:smlbiobot,项目名称:SML-Cogs,代码行数:21,代码来源:clans.py

示例5: __init__

# 需要导入模块: from cogs.utils.dataIO import dataIO [as 别名]
# 或者: from cogs.utils.dataIO.dataIO import load_json [as 别名]
def __init__(self, bot):
        """Voice channel utilities."""
        self.bot = bot
        self.settings = dataIO.load_json(JSON)
        # self.task = self.bot.loop.create_task(self.loop_task())

    # async def loop_task(self):
    #     """Check for empty VCs and remove text chat."""
    #     await self.bot.wait_until_ready()
    #     await asyncio.sleep(LOOP_INTERVAL)

    #     if self is self.bot.get_cog("VCUtil"):
    #         self.task = self.loop.create_task(self.bot.loop_task())
    #         await self.monitor_vc_chat()

    # async def monitor_vc_chat(self):
    #     """Remove self-generated text chat if VC is empty."""
    #     for server_id in self.settings:
    #         pass 
开发者ID:smlbiobot,项目名称:SML-Cogs,代码行数:21,代码来源:vcutil.py

示例6: __init__

# 需要导入模块: from cogs.utils.dataIO import dataIO [as 别名]
# 或者: from cogs.utils.dataIO.dataIO import load_json [as 别名]
def __init__(self, bot):
        """Init."""
        self.bot = bot
        self.settings = dataIO.load_json(JSON)
        self._clan_roles = None

        players_path = PLAYERS

        if not os.path.exists(players_path):
            players_path = os.path.join(PATH, "player_db_bak.json")

        self._players = dataIO.load_json(players_path)
        dataIO.save_json(PLAYERS, self._players)

        with open('data/racf_audit/family_config.yaml') as f:
            self.config = yaml.load(f, Loader=yaml.FullLoader)

        loop = asyncio.get_event_loop()
        self.task = loop.create_task(self.loop_task()) 
开发者ID:smlbiobot,项目名称:SML-Cogs,代码行数:21,代码来源:racf_audit.py

示例7: __init__

# 需要导入模块: from cogs.utils.dataIO import dataIO [as 别名]
# 或者: from cogs.utils.dataIO.dataIO import load_json [as 别名]
def __init__(self, bot):
        self.bot = bot
        self.location = 'data/punish/settings.json'
        self.json = dataIO.load_json(self.location)
        self.min = ['m', 'min', 'mins', 'minutes', 'minute']
        self.hour = ['h', 'hour', 'hours']
        self.day = ['d', 'day', 'days']
        self.task = bot.loop.create_task(self.check_time()) 
开发者ID:Kowlin,项目名称:refactored-cogs,代码行数:10,代码来源:punish.py

示例8: __init__

# 需要导入模块: from cogs.utils.dataIO import dataIO [as 别名]
# 或者: from cogs.utils.dataIO.dataIO import load_json [as 别名]
def __init__(self, bot):
        self.bot = bot
        self.settings = dataIO.load_json('data/githubcards/settings.json')
        if 'Mod' not in bot.cogs:
            log.info('GithubCards: Mod not loaded, will not ignore channels')
            self.ignore = False
        else:
            self.ignore = True
        self.colour = {
            'open': 0x6cc644,
            'closed': 0xbd2c00,
            'merged': 0x6e5494
        } 
开发者ID:Kowlin,项目名称:refactored-cogs,代码行数:15,代码来源:githubcards.py

示例9: __init__

# 需要导入模块: from cogs.utils.dataIO import dataIO [as 别名]
# 或者: from cogs.utils.dataIO.dataIO import load_json [as 别名]
def __init__(self, bot):
        self.bot = bot
        self.settings_loc = 'data/buyrole/settings.json'
        self.settings_dict = dataIO.load_json(self.settings_loc) 
开发者ID:Kowlin,项目名称:refactored-cogs,代码行数:6,代码来源:buyrole.py

示例10: __init__

# 需要导入模块: from cogs.utils.dataIO import dataIO [as 别名]
# 或者: from cogs.utils.dataIO.dataIO import load_json [as 别名]
def __init__(self, bot):
        self.bot = bot
        self.settings = dataIO.load_json('data/dynamicvoice/settings.json')
        self.namelist = open('data/dynamicvoice/names.txt', 'rt')
        self.namelist = self.namelist.readlines() 
开发者ID:Kowlin,项目名称:refactored-cogs,代码行数:7,代码来源:dynamicvoice.py

示例11: __init__

# 需要导入模块: from cogs.utils.dataIO import dataIO [as 别名]
# 或者: from cogs.utils.dataIO.dataIO import load_json [as 别名]
def __init__(self, bot):
        self.bot = bot
        self.location = 'data/antilink/settings.json'
        self.json = dataIO.load_json(self.location)
        self.regex = re.compile(r"<?(https?:\/\/)?(www\.)?(discord\.gg|discordapp\.com\/invite)\b([-a-zA-Z0-9/]*)>?")
        self.regex_discordme = re.compile(r"<?(https?:\/\/)?(www\.)?(discord\.me\/)\b([-a-zA-Z0-9/]*)>?")
        self.regex_url = re.compile(r'(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))')
        self.emoji_string = "https://cdn.discordapp.com/emojis" 
开发者ID:Kowlin,项目名称:refactored-cogs,代码行数:10,代码来源:antilink.py

示例12: user_post

# 需要导入模块: from cogs.utils.dataIO import dataIO [as 别名]
# 或者: from cogs.utils.dataIO.dataIO import load_json [as 别名]
def user_post(key_users, user):
    if time.time() - float(key_users[user][0]) < float(key_users[user][1]):
        return False, [time.time(), key_users[user][1]]
    else:
        log = dataIO.load_json("settings/log.json")
        now = time.time()
        log["keyusers"][user] = [now, key_users[user][1]]
        dataIO.save_json("settings/log.json", log)
        return True, [now, key_users[user][1]] 
开发者ID:appu1232,项目名称:Discord-Selfbot,代码行数:11,代码来源:checks.py

示例13: fc

# 需要导入模块: from cogs.utils.dataIO import dataIO [as 别名]
# 或者: from cogs.utils.dataIO.dataIO import load_json [as 别名]
def fc(self, ctx, friend_code="all"):
        """List friend codes. Do [p]help fc for more information.
        [p]fc - List all of your friend codes.
        [p]fc <friend_code> - Show one of your friend codes.
        Friend codes are stored in the settings/fc.json file and look similar to this:
        {
            "3DS": "435-233",
            "Wii U": "545262",
            "Steam": "lickinlemons"
        }
        Friend code names are case-insensitive and can contain any characters you want.
        The friend code values can also be anything you want.
        """
        await ctx.message.delete()
        fc = CaseInsensitiveDict(dataIO.load_json("settings/fc.json"))
        if friend_code == "all":
            if not fc:
                return await ctx.send(self.bot.bot_prefix + "You have no friend codes to show!")
            if embed_perms(ctx.message):
                embed = discord.Embed()
                for code in fc:
                    embed.add_field(name=code, value=fc[code], inline=False)
                return await ctx.send("", embed=embed)
            else:
                message = ""
                for code in fc:
                    message += "**{}**\n{}\n".format(code, fc[code])
                return await ctx.send(message)
        else:
            if not friend_code in fc:
                return await ctx.send(self.bot.bot_prefix + "You don't have a value set for that friend code!")
            if embed_perms(ctx.message):
                embed = discord.Embed()
                embed.add_field(name=friend_code, value=fc[friend_code])
                await ctx.send("", embed=embed)
            else:
                await ctx.send("**{}**\n{}".format(friend_code, fc[friend_code])) 
开发者ID:appu1232,项目名称:Discord-Selfbot,代码行数:39,代码来源:fc.py

示例14: __init__

# 需要导入模块: from cogs.utils.dataIO import dataIO [as 别名]
# 或者: from cogs.utils.dataIO.dataIO import load_json [as 别名]
def __init__(self, bot):
        self.bot = bot
        self.replacement_dict = dataIO.load_json("settings/replacements.json") 
开发者ID:appu1232,项目名称:Discord-Selfbot,代码行数:5,代码来源:replacements.py

示例15: password

# 需要导入模块: from cogs.utils.dataIO import dataIO [as 别名]
# 或者: from cogs.utils.dataIO.dataIO import load_json [as 别名]
def password(self, ctx, *, msg):
        """Set your discord acc password to rotate avatars. See wiki for more info."""
        avi_config = dataIO.load_json('settings/avatars.json')
        avi_config['password'] = msg.strip().strip('"').lstrip('<').rstrip('>')
        dataIO.save_json('settings/avatars.json', avi_config)
        opt = dataIO.load_json('settings/optional_config.json')
        opt['password'] = avi_config['password']
        dataIO.save_json('settings/optional_config.json', opt)
        await ctx.message.delete()
        return await ctx.send(self.bot.bot_prefix + 'Password set. Do ``>avatar`` to toggle cycling avatars.') 
开发者ID:appu1232,项目名称:Discord-Selfbot,代码行数:12,代码来源:misc.py


注:本文中的cogs.utils.dataIO.dataIO.load_json方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。