async def tag(self, ctx): print(cutHead(ctx.message.content, "tag").split(" ")[1:]) if ctx.invoked_subcommand is None: if cutHead(ctx.message.content, "tag") != "": await self.read_core(ctx, arg="tag", params=cutHead(ctx.message.content, "tag").split(" ")[1:], content=cutHead(ctx.message.content, "tag").split(" ")[0]) else: await ctx.send(prefix+"tag create|raw|update|delete|(tagname) for read")
async def post(self, ctx): if ctx.invoked_subcommand is None: if cutHead(ctx.message.content, "post") != "": await self.read_core(ctx, arg="post") else: await ctx.send(prefix + "post create|update|delete|(postname) for read")
async def delete(self, ctx): """delete tag""" name = cutHead(ctx.message.content, "tag delete") if not db.getTagByName(name): await ctx.send("tag does not exists") return db.deleteTag(name) await ctx.send("message deleted!") return
async def read_core(self, ctx, arg="post read"): name = cutHead(ctx.message.content, arg) res = db.getPostByName(name) if not res: await ctx.send("post does not exists") return author = self.bot.get_user(int(res[1])) embed = Embed(title=res[0], description=res[2], color=0x93faff) embed.set_footer(text=f"{author} 작성") await ctx.send("", embed=embed) return
async def delete(self, ctx): """delete post""" name = cutHead(ctx.message.content, "post delete") if not db.getPostByName(name): await ctx.send("post does not exists") return db.deletePost(name) await ctx.send("message deleted!") return
async def read_core(self, ctx, arg="tag read", params=(), content="", eval=True): name = cutHead(ctx.message.content, arg) if content: name = content res = db.getTagByName(name) if not res: await ctx.send("tag does not exists") return if eval: await ctx.send(PackageTag.eval(res[2], params)) else: await ctx.send(res[2]) return
async def create(self, ctx): """create tag""" name = cutHead(ctx.message.content, "tag create") if db.getTagByName(name): await ctx.send("tag already exists") return await ctx.send(name) msg = await self.waitForMessage(ctx) db.appendTag(name, str(ctx.author.id), msg.content) await self.read_core(ctx, arg="tag create") return
async def create(self, ctx): """create post""" name = cutHead(ctx.message.content, "post create") if db.getPostByName(name): await ctx.send("post already exists") return await ctx.send(name) msg = await self.waitForMessage(ctx) db.appendPost(name, str(ctx.author.id), msg.content) await self.read_core(ctx, arg="post create") return
async def update(self, ctx): """update tag""" name = cutHead(ctx.message.content, "tag update") find = db.getTagByName(name) if not find: await ctx.send("message does not exists") return if ctx.author.id != int(find[1]): await ctx.send("message writer and tag writer is not same") return await self.read_core(ctx, arg="tag update", eval=False) msg = await self.waitForMessage(ctx) db.updateTag(name, msg.content) await self.read_core(ctx, arg="tag update", eval=False) return
async def update(self, ctx): """update post""" name = cutHead(ctx.message.content, "post update") find = db.getPostByName(name) if not find: await ctx.send("message does not exists") return if ctx.author.id != int(find[1]): await ctx.send("message writer and post writer is not same") return await self.read_core(ctx, arg="post update") msg = await self.waitForMessage(ctx) db.updatePost(name, msg.content) await self.read_core(ctx, arg="post update") return
async def raw(self, ctx): """show raw tag""" name = cutHead(ctx.message.content, "tag raw") await self.read_core(ctx, "tag raw", eval=False) return
async def sayd(self, ctx): """say something to bot and remove message.""" await ctx.send(cutHead(ctx.message.content, "sayd")) await ctx.message.delete() return
async def say(self, ctx): """say something to bot.""" await ctx.send(cutHead(ctx.message.content, "say")) return