Esempio n. 1
0
async def trackdel(ctx, *, username):
    if botutils.is_admin(ctx.message.author.id):
        if len(username) > 0:
            if not os.path.exists('data/tracking/%s' %
                                  (str(ctx.message.channel.id))):
                await ctx.message.channel.send(
                    '`Tracking is not enabled in this channel`')
            else:
                await ctx.message.channel.send(
                    '`Checking if user \'%s\' exists`' % (username))
                if botutils.check_user_del(username,
                                           ctx.message.channel.id) == 1:
                    await ctx.message.channel.send(
                        '`User \'%s\' found, deleting...`' % (username))
                    if botutils.del_user(username,
                                         ctx.message.channel.id) == 1:
                        await ctx.message.channel.send(
                            '`User successfuly deleted`')
                    else:
                        await ctx.message.channel.send(
                            '`Error while deleting, this sucks...\nDumping file content to stdout...`'
                        )
                else:
                    await ctx.message.channel.send('`User \'%s\' not found`' %
                                                   (username))
        else:
            await ctx.message.channel.send(
                '`Check your syntax with ,help ,trackdel`')
    else:
        await ctx.message.channel.send(embed=await adminnotice())
Esempio n. 2
0
async def restart(ctx):
    if botutils.is_admin(ctx.message.author.id):
        await ctx.message.channel.send("Restarting")
        quit()
        #exit()
    else:
        await ctx.message.channel.send(embed=await adminnotice())
Esempio n. 3
0
async def gitpull(ctx):
    if botutils.is_admin(ctx.message.author.id):
        await ctx.message.channel.send("Updating")
        os.system('git pull')
        quit()
        #exit()
    else:
        await ctx.message.channel.send(embed=await adminnotice())
Esempio n. 4
0
async def disable(ctx):
    if botutils.is_admin(ctx.message.author.id):
        #if os.path.exists('data/tracking/'+str(ctx.message.channel.id)):
        #	shutil.rmtree('data/tracking/'+str(ctx.message.channel.id))
        await ctx.message.channel.send(
            '`This function is disabled because its buggy`')
    else:
        await ctx.message.channel.send(embed=await adminnotice())
Esempio n. 5
0
async def enable(ctx):
    if botutils.is_admin(ctx.message.author.id):
        if not os.path.exists('data/tracking/%s' %
                              (str(ctx.message.channel.id))):
            os.makedirs('data/tracking/%s' % (str(ctx.message.channel.id)))
            os.makedirs('data/tracking/%s/data/' %
                        (str(ctx.message.channel.id)))
            tracklistfile = open(
                'data/tracking/%s/tracklist.txt' %
                (str(ctx.message.channel.id)), 'wb')
            tracklistfile.write(bytes("", 'ascii'))
            tracklistfile.close()
        await ctx.message.channel.send(
            '`Tracking is now enabled in this channel`')
    else:
        await ctx.message.channel.send(embed=await adminnotice())
Esempio n. 6
0
async def track(ctx, *, username):
    if botutils.is_admin(ctx.message.author.id):
        if len(username) > 0:
            if not os.path.exists('data/tracking/%s' %
                                  (str(ctx.message.channel.id))):
                await ctx.message.channel.send(
                    '`Tracking is not enabled in this channel`')
            else:
                await ctx.message.channel.send(
                    '`Checking if user \'%s\' exists`' % (username))
                if botutils.check_user_del(username,
                                           ctx.message.channel.id) == 0:
                    if await osu.check_user(username) == 1:
                        await ctx.message.channel.send(
                            '`User \'%s\' exists, adding it to tracking`' %
                            (username))
                        try:
                            with open(
                                    'data/tracking/%s/tracklist.txt' %
                                (str(ctx.message.channel.id)), "a") as myfile:
                                myfile.write(username + '\n')
                            with open(
                                    'data/tracking/%s/data/%s.json' %
                                (str(ctx.message.channel.id), username),
                                    'a') as nf:
                                nf.write('[]')
                            await ctx.message.channel.send(
                                '`User \'%s\' Succesfuly added to tracking`' %
                                (username))
                        except Exception as e:
                            print('[!ERROR!] In Adduser tracking')
                            print(e)
                    elif await osu.check_user(username) == -1:
                        await ctx.message.channel.send(
                            '`osu servers are laggy atm, try again later`')
                    else:
                        await ctx.message.channel.send(
                            '`User \'%s\' not found`' % (username))
                else:
                    await ctx.message.channel.send(
                        '`User \'%s\' already in tracking file`' % (username))
        else:
            await ctx.message.channel.send(
                '`Check your syntax with ,help ,track`')
    else:
        await ctx.message.channel.send(embed=await adminnotice())