Example #1
0
 def mkdir(self, path):
     """
     mkdir
     """
     slog.info("ShareFs=>mkdir" + str("mkdir"))
     os.mkdir(path)
     return 0
Example #2
0
 def readdir(self, path, offset):
     """
     Read directory
     """
     slog.info("ShareFS=>readdir" + str(path))
     for e in '.', '..', '/':
         yield fuse.Direntry(e)
Example #3
0
    def chown(self, path, uid, gid):
        """
        chown
        """

        slog.info("ShareFS=>chown"+str(path))
        return -errno.ENOENT
Example #4
0
    async def fix_roles(self, ctx: commands.Context):
        if not self.bot.permission_gate(ctx.author, PermissionLevel.ADMIN):
            return

        mem_role = ctx.guild.get_role(self.bot.member_role_id)
        user: discord.Member

        to_role = []

        for user in ctx.guild.members:
            # Note: This is >1 not >0 because @everyone is always in the role list.
            if len(user.roles) > 1 and mem_role not in user.roles:
                to_role.append(user.id)

        if len(to_role) == 0:
            await ctx.channel.send("There's nobody to give the role to!")
            return

        await ctx.reply(
            f"Granting member role to {len(to_role)} {'people' if len(to_role) != 1 else 'person'}..."
        )

        granted = 0

        for user in to_role:
            member: discord.Member = ctx.guild.get_member(user)
            await member.add_roles(mem_role)
            slog.info(
                f"Fixing roles for {member.display_name}... {granted}/{len(to_role)} ({round(granted/len(to_role) * 100, 2)}%)"
            )

        slog.info("Done fixing roles!")
        await ctx.channel.send("Done! x3")
Example #5
0
 def open(self, path, flags):
     """
     Read all files in working directory.
     """
     slog.info("ShareFS=>open"+str(path))
     # Only support for 'READ ONLY' flag
     os.open(path, flags)
     return 0
Example #6
0
async def gate_check(bot, message: discord.Message):
    if bot.gate_password == "":
        return

    text = message.content

    if text.lower() == bot.gate_password.lower():
        member_role = message.guild.get_role(bot.member_role_id)
        await message.author.add_roles(member_role)
        slog.info("User {0} passed the gate!".format(
            message.author.display_name))
Example #7
0
 def __init__(self, *args, **kw):
     """
     Call fuse.Fuse constructor with given
     arguments
     """
     slog.info("ShareFS=>init")
     fuse.Fuse.__init__(self, *args, **kw)
     self.directories = {}
     self.files = {}
     self.time_accessed = {}
     self.codec = 'utf-8'
Example #8
0
 def getattr(self, path):
     """
     Getattr for filesystem
     return stat for given path
     """
     slog.info("ShareFS=>getattr" + str(path))
     if os.path.exists(path):
         return os.lstat(path)
     else:
         return -errno.ENOENT
     st = ShareStat()
     temp = path.split('/')
     if len(temp):
         st.set_dir_attr()
     elif path:
         st.set_file_attr()
     else:
         return -errno.ENOENT
     return st
Example #9
0
    def create_default_settings(self):
        default_settings = {
            SilphyBot.TOKEN_KEY: "PUT TOKEN HERE",
            SilphyBot.SERVER_KEY: 0,
            SilphyBot.GATE_CHANNEL_KEY: 0,
            SilphyBot.STAFF_CHANNEL_KEY: [],
            SilphyBot.GATE_PASSWORD_KEY: "toy pianos",
            SilphyBot.ADMIN_LIST_KEY: [],
            SilphyBot.STAFF_ROLE_KEY: 0,
            SilphyBot.TRAINER_MOD_ROLE_KEY: 0,
            SilphyBot.MEMBER_ROLE_KEY: 0,
            SilphyBot.DATABASE_NAME_KEY: "DATABASE NAME",
            SilphyBot.DATABASE_USER_KEY: "LOGIN USER",
            SilphyBot.DATABASE_PASS_KEY: "PUT PASSWORD HERE",
            SilphyBot.DATABASE_PORT_KEY: "5432",
            SilphyBot.DATABASE_HOST_KEY: "localhost"
        }

        self.settings = default_settings
        self.save_settings()

        slog.info("Default settings file created, please update it.")
        input("Press enter to continue.")
        sys.exit(0)
Example #10
0
 def unlink(self, path):
     """
     unlink
     """
     slog.info("ShareFS=> unlink" + str(path))
     return -errno.ENOENT
Example #11
0
 def chmod(self, path, mode):
     """
     chmod
     """
     slog.info("ShareFs=>chmod"+ str(path))
     return -errno.ENOENT
Example #12
0
 def rmdir(self, path):
     """
     rmdir
     """
     slog.info("ShareFS=>rmdir" + str(path))
     return -errno.ENOENT
Example #13
0
 def fsinit(self):
     """
     fsinit
     """
     slog.info("ShareFS=>fsinit")
     return 0
Example #14
0
 def release(self, path, fh):
     """
     release
     """
     slog.info("ShareFS=>release" + str(path))
     return -errno.ENOENT
Example #15
0
 def trucate(self, path, len, fh):
     """
     trucate
     """
     slog.info("ShareFs=>trucate" + str(path))
     return -errno.ENOENT
Example #16
0
 def rename(self, old, new):
     """
     rename
     """
     slog.info("ShareFS=>rename" + str(old) +str(new))
     return -errno.ENOENT
Example #17
0
 def mknod(self, path, mode, dev):
     """
     Mknod
     """
     slog.info("ShareFS => mknod " + str(path))
     return -errno.ENOENT
Example #18
0
 def read(self, path, length, offset):
     """
     Read all files in working directory.
     """
     slog.info("ShareFS => read"+str(path))
     return 'This is just interface'
Example #19
0
 def write(self, path, length, offset):
     """
     Write call to write some content in file
     """
     slog.info("ShareFS=>write"+str(path))
     return -errno.ENOENT
Example #20
0
 def create(self, path, flags=None, mode=None):
     """
     Create call when we have to create new file
     """
     slog.info("ShareFS=>create"+str(path))
     return -errno.ENOENTx