fix args
This commit is contained in:
parent
a2274e3961
commit
d5a20fdf33
1 changed files with 4 additions and 5 deletions
|
@ -194,13 +194,12 @@ class MSCGetter(niobot.Module):
|
||||||
|
|
||||||
@niobot.command("msc.cache")
|
@niobot.command("msc.cache")
|
||||||
@niobot.is_owner()
|
@niobot.is_owner()
|
||||||
async def msc_cache_manager(self, ctx: niobot.Context, *args):
|
async def msc_cache_manager(self, ctx: niobot.Context, operation: str, arg1: str = None):
|
||||||
"""
|
"""
|
||||||
MSC Cache manager
|
MSC Cache manager
|
||||||
|
|
||||||
Available commands: get, download, remove, clear, list
|
Available commands: get, download, remove, clear, list
|
||||||
"""
|
"""
|
||||||
operation, *args = args
|
|
||||||
if operation == "list":
|
if operation == "list":
|
||||||
known = []
|
known = []
|
||||||
total_size = 0
|
total_size = 0
|
||||||
|
@ -226,7 +225,7 @@ class MSCGetter(niobot.Module):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif operation in ["get", "view"]:
|
elif operation in ["get", "view"]:
|
||||||
file = self.msc_cache / ("{:0>4}.json".format(int(args[0])))
|
file = self.msc_cache / ("{:0>4}.json".format(int(arg1)))
|
||||||
if file.exists():
|
if file.exists():
|
||||||
data = json.loads(file.read_text())
|
data = json.loads(file.read_text())
|
||||||
out = json.dumps(data, indent=4)
|
out = json.dumps(data, indent=4)
|
||||||
|
@ -235,12 +234,12 @@ class MSCGetter(niobot.Module):
|
||||||
)
|
)
|
||||||
return await ctx.respond("%s does not exist." % file.name)
|
return await ctx.respond("%s does not exist." % file.name)
|
||||||
elif operation in ["download", "dl", "fetch"]:
|
elif operation in ["download", "dl", "fetch"]:
|
||||||
x = await self.get_msc_with_cache(int(args[0]))
|
x = await self.get_msc_with_cache(int(arg1))
|
||||||
return await ctx.respond(
|
return await ctx.respond(
|
||||||
"```json\n%s\n```" % json.dumps(x, indent=4)
|
"```json\n%s\n```" % json.dumps(x, indent=4)
|
||||||
)
|
)
|
||||||
elif operation in ["delete", "remove", "rm", "del"]:
|
elif operation in ["delete", "remove", "rm", "del"]:
|
||||||
file = self.msc_cache / ("{:0>4}.json".format(int(args[0])))
|
file = self.msc_cache / ("{:0>4}.json".format(int(arg1)))
|
||||||
if file.exists():
|
if file.exists():
|
||||||
file.remove()
|
file.remove()
|
||||||
return await ctx.respond("Removed cached file %s." % file.name)
|
return await ctx.respond("Removed cached file %s." % file.name)
|
||||||
|
|
Loading…
Reference in a new issue