async def create( self, ctx, name: clean_content, tag_type: TagTypeConverter, *content: clean_content, ): """create tag content""" with self.bot.session_scope() as session: if Tag.exists(name, ctx.guild.id, session): raise NerpyException("tag already exists!") async with ctx.typing(): with self.bot.session_scope() as session: self.bot.log.info( f"creating tag {ctx.guild.name}/{name} started") _tag = Tag( Name=name, Author=str(ctx.author), Type=tag_type, CreateDate=datetime.utcnow(), Count=0, Volume=100, GuildId=ctx.guild.id, ) Tag.add(_tag, session) session.flush() self._add_tag_entries(session, _tag, content) self.bot.log.info(f"creating tag {ctx.guild.name}/{name} finished") await self.bot.sendc(ctx, f"tag {name} created!")
def action_update_tags(self, slug=None): for tag in Tag.all(): tag.delete() for entry in Entry.all().filter('entrytype =', 'post'): if entry.tags: for t in entry.tags: try: logging.info('sss:' + t) Tag.add(t) except: traceback.print_exc() self.write('"All tags for entry have been updated."')