def mkdir(self, path): """ mkdir """ slog.info("ShareFs=>mkdir" + str("mkdir")) os.mkdir(path) return 0
def readdir(self, path, offset): """ Read directory """ slog.info("ShareFS=>readdir" + str(path)) for e in '.', '..', '/': yield fuse.Direntry(e)
def chown(self, path, uid, gid): """ chown """ slog.info("ShareFS=>chown"+str(path)) return -errno.ENOENT
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")
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
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))
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'
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
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)
def unlink(self, path): """ unlink """ slog.info("ShareFS=> unlink" + str(path)) return -errno.ENOENT
def chmod(self, path, mode): """ chmod """ slog.info("ShareFs=>chmod"+ str(path)) return -errno.ENOENT
def rmdir(self, path): """ rmdir """ slog.info("ShareFS=>rmdir" + str(path)) return -errno.ENOENT
def fsinit(self): """ fsinit """ slog.info("ShareFS=>fsinit") return 0
def release(self, path, fh): """ release """ slog.info("ShareFS=>release" + str(path)) return -errno.ENOENT
def trucate(self, path, len, fh): """ trucate """ slog.info("ShareFs=>trucate" + str(path)) return -errno.ENOENT
def rename(self, old, new): """ rename """ slog.info("ShareFS=>rename" + str(old) +str(new)) return -errno.ENOENT
def mknod(self, path, mode, dev): """ Mknod """ slog.info("ShareFS => mknod " + str(path)) return -errno.ENOENT
def read(self, path, length, offset): """ Read all files in working directory. """ slog.info("ShareFS => read"+str(path)) return 'This is just interface'
def write(self, path, length, offset): """ Write call to write some content in file """ slog.info("ShareFS=>write"+str(path)) return -errno.ENOENT
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