本文整理匯總了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)
示例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)
示例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)
示例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
示例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
示例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())
示例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())
示例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
}
示例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)
示例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()
示例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"
示例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]]
示例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]))
示例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")
示例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.')