Esempio n. 1
0
def modify_file():
    clear_screen()
    print("select the section to modify")
    section = get_sections()
    selected_section = create_menu(section)
    retval = print_section(selected_section)
    clear_screen()
    actions = ['add', 'edit', 'remove']
    action = create_menu(actions, "Select the action to perform:")
    clear_screen()

    def get_option():
        clear_screen()
        option = create_menu(retval)
        return option

    if action == "add":
        new_key = input("Enter name of the key to add: ")
        new_value = input("Enter path of the directory or file to add: ")
        configparser.set(selected_section, new_key, new_value)
    elif action == "remove":
        option = get_option()
        print("removing value " + option[0])
        configparser.remove_option(selected_section, option[0])
    elif action == "edit":
        option = get_option()
        new_val = input('What is the new value: ')
        configparser.set(selected_section, option[0], new_val)
    with open(configfile, 'w') as cf:
        configparser.write(cf)
    exit()
Esempio n. 2
0
def create_conf(configparser, bool):
    if bool == False:
        configparser["bot"] = {'prefix': '!', 'token': '{AddBotTokenHere}'}
        configparser.write(open('config.ini', 'w'))
    else:
        local_prefix = configparser.get('bot', 'prefix')
        local_token = configparser.get('bot', 'token')
        configparser["bot"] = {'prefix': local_prefix, 'token': local_token}
        configparser.write(open('config.ini', 'w'))
Esempio n. 3
0
def _create_default_config(configparser, filename):
    configparser.add_section("spotify_api")
    configparser.set("spotify_api", "user_name", "*your spotify username*")
    configparser.set(
        "spotify_api",
        "; register an application here: https://developer.spotify.com/dashboard/login",
    )
    configparser.set("spotify_api", "client_id", "*your application ID*")
    configparser.set("spotify_api", "client_secret",
                     "*your application secret*")
    configparser.set("spotify_api", "redirect_uri",
                     "http://localhost:8888/auth")

    configparser.add_section("other")
    configparser.set("other", "config_version", "1")

    configparser.write(open(filename, "w"))
Esempio n. 4
0
def _create_default_config(configparser, filename):
    configparser.add_section('telegram_api')
    configparser.set(
        'telegram_api',
        '; obtain api keys here: https://core.telegram.org/api/obtaining_api_id'
    )
    configparser.set(
        'telegram_api',
        '; only api_id and api_hash are needed for the application to work')
    configparser.set('telegram_api', 'api_id', '*api_id here*')
    configparser.set('telegram_api', 'api_hash', '*api_hash here*')
    configparser.set('telegram_api',
                     '; number of thread to receive data from tg api')
    configparser.set('telegram_api', 'workers', '3')
    configparser.set('telegram_api',
                     '; you can use few accounts, change session name')
    configparser.set('telegram_api', 'session_name', 'user')

    configparser.add_section('app')
    configparser.set('app', 'name', 'TelegramTUI v0.1.1')
    configparser.set('app', 'message_dialog_len', '50')

    configparser.add_section('proxy')
    configparser.set('proxy', 'type', '*[SOCKS4|SOCKS5|HTTP]*')
    configparser.set('proxy', 'addr', '*ip add here*')
    configparser.set('proxy', 'port', '*port here*')
    configparser.set('proxy', '; set username and password (only for SOCKS)')
    configparser.set('proxy', 'username', 'None')
    configparser.set('proxy', 'password', 'None')

    configparser.add_section('other')
    configparser.set('other', 'timezone', '+0')
    configparser.set('other', 'emoji', 'False')
    configparser.set('other', 'emoji', 'False')
    configparser.set('other', '; ASCII image art')
    configparser.set('other', 'aalib', 'False')
    configparser.set('other', 'config_version', '1')

    configparser.write(open(filename, 'w'))