def check_items(self, values, message): '''Raises an error if the user is asking too much of the bot.''' # TODO: this could stand to be smarter/more oriented to the type of operation you're trying to do, or something, maybe...? # meditate on this... MAXCHARS = 10000 chars = sum(len(i) for i in values) if chars > MAXCHARS and not permissions.has(message.author.id, permissions.owner): raise PipelineError(f'Attempted to process a flow of {chars} total characters at once, try staying under {MAXCHARS}.')
async def kill(self, ctx): '''Kill someone''' subject = util.strip_command(ctx) if subject.lower() in ["yourself", "self", "myself", "rezbot"]: if permissions.has(ctx.author.id, permissions.owner): await ctx.send('killing self.') await self._die() else: await ctx.send('no') else: await ctx.send('killed {0}'.format(ctx.author.name if ( subject == "me") else subject))
async def delete_file(self, ctx, filename): ''' Delete an uploaded file. Can only be done by owners of the bot or the file. ''' if filename not in uploads: await ctx.send('No file by name `%s` found!' % filename) return file = uploads[filename] if permissions.has( ctx.author.id, permissions.owner) or ctx.author.id == file.info.author_id: uploads.delete_file(filename) await ctx.send('File `%s` successfully deleted.' % file.info.name) else: await ctx.send( 'Files can only be deleted by bot owners or the owner of the file.' )
def authorised(self, user): '''Test whether or not the given user is authorised to modify this macro.''' return permissions.has(user.id, permissions.owner) or user.id == int( self.authorId)