def reload_jobs(bot, update, job_queue, chat_data):
    if str(update.message.chat_id) in dict_settings['allowed_id']:
        jobs_list = utils.return_elements(database, owner=str(update.message.chat_id), entity="job")
        for singlejob in jobs_list:
            chat_data['tmpjob'] = singlejob
            chat_data['tmpjob']['job_name'] = chat_data['tmpjob']['name'] 
            persistend_job(bot, job_queue, chat_data, days=chat_data['tmpjob']['days'], chat_id=update.message.chat_id, db_persist=False)
    else:
        message = 'You have not the permission to use this bot.\nFor more details visit [Telegram-InstaPy-Scheduling](https://github.com/Tkd-Alex/Telegram-InstaPy-Scheduling)'
        update.message.reply_text(message, parse_mode='Markdown')
def set_job(bot, update, args, job_queue, chat_data):
    if str(update.message.chat_id) in dict_settings['allowed_id']:
        try:
            usernames = [ a['username'].lower() for a in users ]
            if not args[0].lower() in usernames:
                update.message.reply_text("Sorry, username <b>{}</b> is not saved.".format(args[0]), parse_mode='HTML')
                return

            jobs_list = utils.return_elements(database, owner=str(update.message.chat_id), entity="job")
            if args[1] in chat_data or args[1] in jobs_list or args[1] in process_array:
                update.message.reply_text("Sorry, job named <b>{}</b> is already used.".format(args[1]), parse_mode='HTML')
                return
            
            if not args[2] in scripts:
                update.message.reply_text("Sorry, script named <b>{}</b> is not in your scripts file.".format(args[2]), parse_mode='HTML')
                return

            data = {
                'username': args[0], 
                'job_name': args[1], 
                'script_name': args[2], 
                'scheduled': args[3], 
                'days': []
            }
            chat_data['tmpjob'] = data
            
            keyboard = [[InlineKeyboardButton("Sunday", callback_data='6'),
                         InlineKeyboardButton("Monday", callback_data='0'),
                         InlineKeyboardButton("Tuesday", callback_data='1'),
                         InlineKeyboardButton("Wednesday", callback_data='2')],
                         [InlineKeyboardButton("Thursday", callback_data='3'),
                         InlineKeyboardButton("Friday", callback_data='4'),
                         InlineKeyboardButton("Saturday", callback_data='5')],
                        [InlineKeyboardButton("Everyday", callback_data='-1')]]
        
            update.message.reply_text('Choose a day: ', reply_markup=InlineKeyboardMarkup(keyboard))  
        except (IndexError, ValueError):
            update.message.reply_text('Usage: /set <username> <job_name> <script_name> <hh:mm:ss>') 

    else:
        message = 'You have not the permission to use this bot.\nFor more details visit [Telegram-InstaPy-Scheduling](https://github.com/Tkd-Alex/Telegram-InstaPy-Scheduling)'
        update.message.reply_text(message, parse_mode='Markdown')