當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。