Exemplo n.º 1
0
def menu_de_inicio() -> None:
    """
    Imprime por pantalla el menu de inicio
    """
    global tutorial_activo
    terminal('clear')
    salto_de_linea(10)
    tab(5)
    print(
        '                     🧟  Bienvenido, pulsa enter para empezar  🧟     ')
    intro = reproducir_efecto(1, loops=inf)
    while True:
        tecla_de_entrada, _ = getch()
        if tecla_de_entrada == '\n':
            # en este caso, la funcion 'reproducir_cancion no habra retornado None'
            if volumen_actual != 0:
                intro.stop()
            reproducir_efecto(3)
            break
    menu_de_seleccion_de_formas()
    menu_de_seleccion_de_dificultad()
    menu = ['Tutorial (recomendado para noobs)', 'Empezar la partida', 'Salir']
    eleccion = print_menu(menu)
    if eleccion == 3:
        terminal('clear')
        quit()
    else:
        reproducir_efecto(3)
        tutorial_activo = True if eleccion == 1 else False
Exemplo n.º 2
0
def menu_de_derrota() -> None:
    '''
    Menu interactivo para el caso de que el
    jugador sea derrotado
    '''
    global tutorial_activo
    terminal('clear')
    salto_de_linea(10)
    tab(6)
    print('👎 Has sido derrotad@, pulsa enter para continuar 👎')
    reproducir_efecto(6)
    while True:
        tecla_entrada, _ = getch()
        if tecla_entrada == '\n':
            reproducir_efecto(3)
            break
    menu = ['Volver a jugar', 'Ir al tutorial', 'Salir']
    eleccion = print_menu(menu)
    if eleccion != 3:
        reproducir_efecto(3)
        if eleccion == 2:
            tutorial_activo = True
    else:
        terminal('clear')
        quit()
Exemplo n.º 3
0
def play(file_name, temp_dir):
	"""Plays a random audio sample of the file with the provided name"""
	audio = Audio(file_name)
	start = randint(0, floor(audio.duration - DURATION))
	file_path = path.join(temp_dir, str(time()) + '.mp3')
	audio.subclip(start, start + DURATION).write_audiofile(file_path, verbose=False, progress_bar=False)
	terminal(file_path)
Exemplo n.º 4
0
def say(tts, speak_type=2):
    check_connection = internet_on()
    print(tts)
    if check_connection == True and speak_type == 1:
    	gtts_speak(tts)
    elif check_connection == False and speak_type == 2:
    	speaking_executable = path.join(marvin_path,'executables','speaking.py')
    	terminal(f'{python_path} {speaking_executable} {tts}')
Exemplo n.º 5
0
def print_help():
    terminal(CMD_CLEAR_TERM)
    print(Fore.LIGHTGREEN_EX +
          'PROX v0.2 - Utility for checking proxy in terminal')
    print(Fore.LIGHTGREEN_EX +
          'Authors: Hasanov Abdurahmon & Ilyosiddin Kalandar')
    print(Fore.LIGHTCYAN_EX)
    print('Usage -> prox -f <filename> - Check file with proxies')
    print('prox -p <proxy> - check only one proxy')
    print('prox --help - show this menu')
Exemplo n.º 6
0
def unmute_system_audio():
	if OS == 'Darwin':
		os_command = 'osascript -e \'set volume output muted false\''
	elif OS == 'Linux':
		os_command = 'amixer set Master unmute'
	else:
		os_command = None
		print('No support for your Operating System. (No Windows yet)')

	if os_command != None:
		terminal(os_command)
Exemplo n.º 7
0
def fetch_repo(download=True):
    """
    This function is called on `!triple fetch` and `!triple fetch reboot`.
    It downloads repository updates, and updates the command list, the help menu and the database.
    """
    # Get new files from GitHub if download is True
    if download:
        terminal("cd " + PYPATH + " && git fetch && git pull")

    # Update commands, help menu and database
    update_cmd_list()
    update_help_menu()
    update_db_cmds()
Exemplo n.º 8
0
 def imprimir_calibrador_de_volumen():
     nonlocal iterador
     iterador = 0
     terminal('clear')
     manual_de_control_de_volumen(frecuencia_actual)
     salto_de_linea(4)
     tab(9)
     for frecuencia in frecuencias_de_volumen:
         print(frecuencia, end='')
         if iterador == frecuencia_actual:
             print(caracter_de_frecuencia_actual, end='')
         iterador += 1
     print(frecuencia)
Exemplo n.º 9
0
def imprimir(personaje_1: personaje, bala_1: bala,
             enemigos_1: enemigos) -> None:
    """
    Imprime los elementos en pantalla (enemigos, personajes, balas) ...
    """
    terminal('clear')
    for y in range(limite_y + 1):
        for x in range(limite_x + 1):
            if (x, y) == personaje_1.posicion_actual:
                print(personaje_1.forma_neutro, end='')
            elif (x, y) == bala_1.posicion_actual:
                print(bala_1.forma, end='')
            elif (x, y) in bala_1.posiciones_de_paquetes:
                print(bala_1.paquete_de_municiones_forma, end='')
            elif (x, y) == personaje_1.posicion_de_arma:
                if bala_1.cantidad_de_balas != 0:
                    print(
                        formas_de_disparo[personaje_1.orientacion_de_disparo],
                        end='')
                else:
                    print(forma_de_ataque_para_sin_balas, end='')

            elif (x, y) in enemigos_1.diccionario_de_posiciones_enemigos[
                    'normales'] and enemigos_habilitados:
                print(enemigos_1.forma_de_enemigo_normal, end='')
            # en caso de que la posicion del enemigo este en una lista, querra decir que esta eliminado
            elif [
                    x, y
            ] in enemigos_1.diccionario_de_posiciones_enemigos['normales']:
                print(enemigos_1.forma_de_enemigo_normal_eliminado, end='')
                enemigos_1.diccionario_de_posiciones_enemigos[
                    'normales'].remove([x, y])
            elif (
                    x, y
            ) in enemigos_1.diccionario_de_posiciones_enemigos['mayores']:
                print(enemigos_1.forma_enemigo_mayor, end='')
            elif [
                    x, y
            ] in enemigos_1.diccionario_de_posiciones_enemigos['mayores']:
                print(enemigos_1.forma_de_enemigo_mayor_eliminado, end='')
                enemigos_1.diccionario_de_posiciones_enemigos[
                    'mayores'].remove([x, y])

            else:
                print(' ', end='')
        print()
    if tutorial_activo:
        manual_de_tutorial()
    else:
        status_de_partida(personaje_1, enemigos_1, bala_1)
Exemplo n.º 10
0
def main():
    Popen(['python', 'compile_readme.py']).wait()
    Popen(['git', 'add', '-A']).wait()
    Popen(['git', 'status']).wait()
    try:
        message = input('OK? Commit message: ')
        message = message or 'auto commit'
        Popen(['git', 'commit', '-m', message]).wait()
        Popen(['git', 'push']).wait()
        input('Enter...')
    except (EOFError, KeyboardInterrupt):
        print('Did not commit. ')
        from os import system as terminal
        terminal('cmd')
def print_help():
    terminal(CMD_CLEAR_TERM)
    print(Fore.LIGHTGREEN_EX + 'PROX v1.1 - Utility for checking proxy in terminal')
    print(Fore.LIGHTGREEN_EX + 'Author: @Pritam Raj \n')
    #print(Fore.LIGHTCYAN_EX)
    print(Fore.LIGHTCYAN_EX +'Usage -> python proxy_checker  -f <filename> - Check file with proxies')
    print(Fore.LIGHTGREEN_EX + '''EX:- python proxy_checker.py -f C:\\Users\dashc\Desktop\proxy3.csv\n''')
    print(Fore.LIGHTRED_EX +'please keep your csv formet is similar as:')
    print(Fore.LIGHTGREEN_EX + '''
             proxy
             104.42.216.178:80
             52.179.231.206:80
             207.244.244.163:80\n''')       
    print(Fore.LIGHTGREEN_EX +'proxy_checker -p <proxy> - check only one proxy Ex:- 85.209.150.238:8085\n')
    print(Fore.LIGHTRED_EX +'prox_checker --help - show this menu')
    print(Fore.LIGHTCYAN_EX)
Exemplo n.º 12
0
def menu_de_pausa() -> None:
    '''
    Menu de accion en caso de que el jugador pulse la tecla de pausa ...
    '''
    while True:
        terminal('clear')
        menu = ['Continuar', 'Configurar Volumen', 'Salir']
        eleccion = print_menu(menu, indice_de_comienzo=0)
        if eleccion == 1 or eleccion == 2:
            reproducir_efecto(3)
            if eleccion == 1:
                break
            else:
                menu_de_configuracion_de_volumen()
        elif eleccion == 3:
            terminal('clear')
            quit()
def mapplot():
    """
    plot google map based on given latitude and longitude
    """
    from os import system as terminal
    import os
    try:
        import gmplot
        print(
            "Enter latitude and longitude to print html Or Press Enter to use default"
        )
        lat = input("latitude:")
        longitude = input("longitude:")
        if len(lat) == 0 and len(longitude) == 0:
            # Passing the center latitude and longitude
            gmap = gmplot.GoogleMapPlotter(13.0826802, 80.2707184, 13)
        else:
            gmap = gmplot.GoogleMapPlotter(float(lat), float(longitude), 13)
        #save file in html formet
        filename = "plottedlocation.html"
        completename = os.path.join(os.path.expanduser('~'), 'Desktop',
                                    filename)
        gmap.draw(completename)
        print("your file saved on desktop named as 'plottedlocation.html'")
    except ImportError:
        terminal("pip install gmplot")
        import gmplot
        print(
            "Enter latitude and longitude to print html Or Press Enter to use default"
        )
        lat = input("latitude:")
        longitude = input("longitude:")
        if len(lat) and len(longitude) == 0:
            # Passing the center latitude and longitude
            gmap = gmplot.GoogleMapPlotter(13.0826802, 80.2707184, 13)
        else:
            gmap = gmplot.GoogleMapPlotter(float(lat), float(longitude), 13)
        #save file in html formet
        filename = "plottedlocation.html"
        completename = os.path.join(os.path.expanduser('~'), 'Desktop',
                                    filename)
        gmap.draw(completename)
        print("your file saved on desktop named as 'plottedlocation.html'")
    except Exception as err_msg:
        print("something went wrong:", err_msg)
Exemplo n.º 14
0
def play_song(search_query):
    # Play youtube song from seach term
    if not path.isfile('songcache/' + search_query): # If song is not cached
        url = get_youtube_link(search_query) # Get video url from get_youtube_link()
        cur_time = str(timestamp()) # Get current time and set it to cur_time
        ydl_opts = {
            'format': 'bestaudio/best',
            'outtmpl': search_query
        } # Set youtube_dl options
        with youtube_dl.YoutubeDL(ydl_opts) as ydl: # With youtube_dl instance as ydl
            say("Downloading song") # Say "Downloading song"
            chdir('songcache') # Change directory to songcache
            ydl.download([url]) # Download mp3
    else: # If song does exist
        chdir('songcache') # Change directory to songcache
    say("Playing song") # Say playing song
    terminal("cvlc --play-and-exit --vout none '" + search_query + "'") # Play song using vlc
    chdir('..') # Change directory back
Exemplo n.º 15
0
def main():
    os.chdir(path.dirname(path.abspath(__file__)))
    print(os.getcwd())
    os.chdir('../frontend/build')
    if not DEV_SERVER:
        frontendProcess = Popen(
            ['python', '-m', 'http.server',
             str(PORT_FRONT)])
    os.chdir('../..')
    if not DEV_SERVER:
        terminal(f'explorer http://localhost:{PORT_FRONT}')
    os.chdir('backend')
    backendProcess = Popen(['node', 'main.js', str(PORT_BACK)])
    backendProcess.wait()
    if DEV_SERVER:
        os.kill(frontendProcess.pid, 2)
    else:
        os.kill(frontendProcess.pid, 2)
Exemplo n.º 16
0
def clearAndShowHeader(style: Dict[str, str]) -> NoReturn:
    from random import randint
    from os import system as terminal

    terminal('clear')
    banners: List[str] = [
        f'''
    {style['blue']}
     w                w      db               8 w                  
    w8ww .d88b Yb dP w8ww   dPYb   8d8b. .d88 8 w d88b Yb  dP d88b 
     8   8.dP'  `8.   8    dPwwYb  8P Y8 8  8 8 8 `Yb.  YbdP  `Yb. 
     Y8P `Y88P dP Yb  Y8P dP    Yb 8   8 `Y88 8 8 Y88P   dP   Y88P 
                                                        dP         
        ''', f'''
        {style['red']}
                                             _ _                 
     _               _      /\              | (_)                
    | |_  ____ _   _| |_   /  \  ____   ____| |_  ___ _   _  ___ 
    |  _)/ _  | \ / )  _) / /\ \|  _ \ / _  | | |/___) | | |/___)
    | |_( (/ / ) X (| |__| |__| | | | ( ( | | | |___ | |_| |___ |
     \___)____|_/ \_)\___)______|_| |_|\_||_|_|_(___/ \__  (___/ 
                                                     (____/      
        ''', f'''
        {style['liteGreen']}                                                                         
         _                 _     _____                 __   _                    
    (_)_  ____        (_)_  (_____)  _            (__) (_) ____         ____ 
    (___)(____) _   _ (___)(_)___(_)(_)__    ____  (_)  _ (____) _   _ (____)
    (_) (_)_(_)(_)_(_)(_)  (_______)(____)  (____) (_) (_)(_)__ (_) (_)(_)__ 
    (_)_(__)__   (_)  (_)_ (_)   (_)(_) (_)( )_( ) (_) (_) _(__)(_)_(_) _(__)
     (__)(____)(_) (_) (__)(_)   (_)(_) (_) (__)_)(___)(_)(____) (____)(____)
                                                                  __(_)      
                                                                 (___)       
        ''', f'''
        {style['liteYellow']}
     dMMMMMMP dMMMMMP dMP dMP dMMMMMMP .aMMMb  dMMMMb  .aMMMb  dMP     dMP .dMMMb  dMP dMP .dMMMb 
       dMP   dMP     dMK.dMP    dMP   dMP"dMP dMP dMP dMP"dMP dMP     amr dMP" VP dMP.dMP dMP" VP 
      dMP   dMMMP   .dMMMK"    dMP   dMMMMMP dMP dMP dMMMMMP dMP     dMP  VMMMb   VMMMMP  VMMMb   
     dMP   dMP     dMP"AMF    dMP   dMP dMP dMP dMP dMP dMP dMP     dMP dP .dMP dA .dMP dP .dMP   
    dMP   dMMMMMP dMP dMP    dMP   dMP dMP dMP dMP dMP dMP dMMMMMP dMP  VMMMP"  VMMMP"  VMMMP"                                                                                                  
        '''
    ]
    print(f'{banners[randint(0,3)]}{style["reset"]}\n')
Exemplo n.º 17
0
def change_file_byte_number(BYTE_NUMBER):
	terminal("sed -i \"1s/.*/#define BYTE_NUMBER		"+str(BYTE_NUMBER)+"/\" pci-driver.c")
	return
             207.244.244.163:80\n''')       
    print(Fore.LIGHTGREEN_EX +'proxy_checker -p <proxy> - check only one proxy Ex:- 85.209.150.238:8085\n')
    print(Fore.LIGHTRED_EX +'prox_checker --help - show this menu')
    print(Fore.LIGHTCYAN_EX)

if len(argv) > 1:
    commands = ['--help','-h','-f','-p','/?','--file','-file','--proxy','-proxy']
    if argv[1] in commands:
        if argv[1] in ('--help','-help','/?','--?'):
            print_help()
        elif argv[1] in ('-f','--file','-file'):
            try:
                file = open(argv[2])
                proxies = list(file)
                goods = 0
                terminal(CMD_CLEAR_TERM)
                print(Fore.LIGHTCYAN_EX + '===========================================')
                for proxy in proxies:
                    try:
                        if check_proxy(proxy):
                            print(Fore.LIGHTRED_EX + 'Bad proxy ' + proxy)
                        else:
                            print(Fore.LIGHTGREEN_EX + 'Good proxy ' + proxy)
                            file_with_goods = open('good.txt','a')
                            file_with_goods.write(proxy)
                            goods += 1
                        print(Fore.LIGHTCYAN_EX + '=================================================')
                    except KeyboardInterrupt:
                        print(Fore.LIGHTGREEN_EX + '\nExit.')
                        exit()
                print(Fore.LIGHTGREEN_EX + 'Total ' + str(goods) + ' good proxies found')
Exemplo n.º 19
0
#Imports
from os import path, mkdir, listdir, remove
from os import system as terminal
from json import dump
from platform import system
from shutil import rmtree, move
import sys

# Run code if file directly called and app.py, requirements.txt, and __init__.py in marvin-env exists to make many checks that setup.py called in right directory
if __name__ == '__main__' and path.isfile('app.py') and path.isfile(
        'requirements.txt') and path.isfile(
            path.join('marvin-env', 'lib', 'site-packages', '__init__.py')):

    try:
        terminal('pip install tqdm==4.28.1 -t ' +
                 path.join('marvin-env', 'lib', 'site-packages') +
                 ' --upgrade')
    except Exception as e:
        print('There was an error: ' + str(e))

    try:
        sys.path.insert(
            0, path.join('marvin-env', 'lib', 'site-packages')
        )  # make env sitepackages folder in path for pip installed libraries
        from tqdm import tqdm
    except Exception as e:
        print('There was an error: ' + str(e))

    try:
        # Make marvin-data directory to store any json and data needed to run marvin
        mkdir('marvin-data')
Exemplo n.º 20
0
    # Ler o arquivo *.js de template
    template = JSTemplate(argumentos.template)

    if not isfile(argumentos.nome):
        raise Exception("Arquivo {} não encontrado".format(argumentos.nome))

    nome = argumentos.nome.replace(
        ".sol", "")  # Transformar 'contrato.sol' em 'contrato'
    nome = nome.split('/')[-1]  # Transformar em caminho relativo

    # limpar rastros anteriores (arquivos js, abi, bin)
    for formato in ['js', 'abi', 'bin']:
        arquivo = "{}.{}".format(nome, formato)
        if isfile(arquivo):
            remove(arquivo)

    # compilar o arquivo *.sol
    terminal("solc -o . --bin --abi {}".format(argumentos.nome))

    # Ler os arquivos *.abi e *.bin
    abi = open("{}.abi".format(nome), "r").read()
    bin = open("{}.bin".format(nome), "r").read()

    template.abi = abi
    template.bin = bin

    # Salvar o novo arquivo *.js
    js = open("{}.js".format(nome), "w")
    js.write(template.compilar())
    js.close()
Exemplo n.º 21
0
def linux_has_emojione():
    return terminal('fc-list | grep -q emojione') >= 1
Exemplo n.º 22
0
def linux_install(pkg_mng, pkg):
    terminal(f"sudo {pkg_mng} -y install {pkg}")
Exemplo n.º 23
0
|||    decrypt : decryption   |||
|||    -w : words             |||
|||    -f : file              |||
|||    clean : clear screen   |||
|||    close : exit           |||
/////////////////////////////////

'''
decoration = "(aep) >> "
while True:
    choice = input(decoration)
    if choice == "help":
        print(manual)

    elif choice == "clean":
        terminal("clear")

    elif choice[:7] == "encrypt":

        if choice[8:10] == '-w':
            words = choice[11:]
            answer = encrypt(words)
            print("\n==> " + answer + "\n")

        elif choice[8:10] == '-f':
            fileName = choice[11:].split(" ")[0]
            print("\nCreate a password ")
            passw = input("-> ")
            answer = encryptFile(fileName, passw)
            print(answer)
Exemplo n.º 24
0
def readOutLoud(fileText):
    terminal("say -v Samantha '{}' ".format(fileText))
Exemplo n.º 25
0
def clear():
    terminal("clear")
Exemplo n.º 26
0
from os import system as terminal

input('You need admin access to install dependencies. Continue? ')
terminal('sudo python -m pip install cocos2d')
try:
    import cocos
    input('Success! Hit Enter to quit...')
except:
    terminal('sudo -H python -m pip install cocos2d')
    try:
        import cocos
        input('Success! Hit Enter to quit...')
    except:
        input('Fail! Hit Enter to quit...')
Exemplo n.º 27
0
	for x in a:
		x = x.strip().split()
		try:
			index = x.index(looking_key)
			# print(x[index + 1])
			output_list.append(int(x[index + 1]))
		except:
			pass
	return output_list


average_read = []

average_write = []
for i in range(POWER_OF_TWO):
	terminal("sudo dmesg -C")
	change_file_byte_number(2**i)
	terminal("make")
	terminal("make insert")
	for i in range(NUMBER_OF_ITERATIO):
		terminal("cat /dev/hesam_pci")
		terminal("echo salam > /dev/hesam_pci")
	terminal("make clean")

	a  = popen('dmesg').readlines()



	read = find_in_dmesg("READ_TIME",a)
	average_read.append(sum(read) / len(read))
Exemplo n.º 28
0
##  "exit" or "CTRL + C" for close  ##
##  -f for file                     ##
##  -w for words                    ##
######################################
'''
while True:
    usr_input = input(colored("[Black Pheonix]# ",
                              'red'))  #Printing it to look like a console
    firsts = usr_input[:7]  #Taking first seven character from user input
    seconds = usr_input[7:9]  #Taking 8-9 letter from user input
    if usr_input[:4] == "help":  #If users type help printing the help string
        print(colored(helpc, 'green'))
    elif usr_input[:4] == "exit":
        print(colored("Bye See You Again :)", 'red'))
        exit()  #If user types exit, breaking the loop

    elif usr_input == "clear":
        if (platform.system() == "Windows"):
            terminal("cls")
        else:
            terminal("clear")
    elif usr_input[:7] in [
            "encrypt", "decrypt"
    ]:  #Checking if the user input is in the list or not
        ctype = usr_input[:7]  #Filtering the type of command into ctype
        tail = usr_input[8:10]  #Taking the tail of command(file or word)
        latt = usr_input[11:]  #Taking the file name or word
        construct(ctype, tail, latt)  #Passing it all to construct function
    else:
        terminal(usr_input)
Exemplo n.º 29
0
    async def on_message(self, message):
        """
        This function is executed everytime a message is received from anyone and from any channel.
        """

        # Checks if message isn't from the bot itself and it is plain text. 
        if message.author == self.user or message.type != discord.MessageType.default or len(message.content)<2:
            return

        # As all the commands use ! at the beggining, we can forget about all the other messages.
        if message.content[0] != '!':
            return

        # Defining some temp constants
        content = message.content.lower()[1:]
        channel = message.channel
        auth_id = message.author.id
        auth_vc = message.author.voice
        guild_id = message.guild.id

        # Now that we have all the things, we can remove the message:
        # We don't remove it in code commands as we want to see them on chat.
        if content.split()[0] in COMMAND_LIST:
            await message.delete()

        # Single commands: !triple help
        if content in ['triple help', 'triple help keep']:
            await self.send_to_ch(channel, HELP_TEXT, None if 'keep' in content else 25)
            return

        # Single commands: !triple fetch (reboot is for admin only)
        if content in ["triple fetch", "triple fetch reboot"]:
            # Fetch and pull from repository
            fetch_repo()

            # Shows a message
            await self.send_to_ch(channel, 'Fetched!' + ('\nRebooting...' if 'reboot' in content else ''), 5)

            # Reboot if in linux and if requester is admin.
            if 'reboot' in content:
                if auth_id==ADMIN_ID and THISOS=="Linux":

                    await self.close() # Close the Discord connection
                    terminal("sudo reboot")

                else:
                    await self.send_to_ch(channel, 'Can\'t reboot!\nNo permmissions or bad OS.', 5)

        # Triple ranks: shows top 10 audios
        if content == "triple ranks":

            # Checking database
            db_response = db_get_most_times_played()

            # Sending response
            await self.send_to_ch(channel, '**TripleBot Ranks** - *Top 10 sounds.*' + ''.join(['\n**{0}**: has been played {1} times.'.format(command.upper(), times) for command, times in db_response]), 15)


        # Triple stop (admin only). Stops the bot
        if content == 'triple stop' and auth_id == ADMIN_ID:

            await self.send_to_ch(channel, "Stopping bot...", 2)
            await self.close() # Close the Discord connection
            return

        # Triple calla. Stops any sound and leaves voice_channels
        if content == 'triple calla':
            await self.send_to_ch(channel, "This isn't ready yet!", 5)
            # TODO

        # Triple guilds (admin only): shows all guilds the bot is in.
        if content == "triple guilds" and auth_id == ADMIN_ID:

            # Shows response
            await self.send_to_ch(channel, "**GUILDS WHERE I AM:**" + ''.join(['\n{0} - *Id: {1}*'.format(cguild.name, cguild.id) for cguild in self.guilds] ), 15)
            return

        # Triple stats [command]: shows all information of a sound
        if len(content)>13:
            if content[:13] == 'triple stats ' and content[13:] in COMMAND_LIST:

                # Checks database
                db_response = db_get_single_info(content.split()[2])

                # Sends response
                await self.send_to_ch(channel, '**TripleBot Command Stats**: *{0}*\nHas been played {1} times.\nTripleBot is keeping track of this sound since *{2}*\nLast time played: *{3}*'.format(db_response[0], db_response[1], time.ctime(int(db_response[2])), time.ctime(int(db_response[3])) if int(db_response[3]) != 0 else "Hasn't been played yet."  ), 15 )

        # Triple stats and triple stats [user]: shows all info about that person.
        if 'triple stats' in content:
            await self.send_to_ch(channel, "This isn't ready yet!", 5)
            # TODO

        # FROM NOW ON MUSIC WILL BE PLAYED

        # Sound commands
        if content in COMMAND_LIST:

            # Only play music if user is in a voice channel
            if auth_vc != None and guild_id not in self.playing_on:

                # Set playing status
                self.playing_on.append(guild_id)
                vc = await auth_vc.channel.connect()

                audiopath = PYPATH + 'sounds/' + content + '_sound.mp3'

                await self.play_sound(audiopath, vc)
                db_sound_played(content)

                # Disconnect after the player has finished
                await vc.disconnect()
                self.playing_on.remove(guild_id)

            elif guild_id in self.playing_on:
                await self.send_to_ch(channel, 'I\'m already playing a sound!', 5)

            else:
                await self.send_to_ch(channel, 'User is not in a channel.', 5)

            return

        if content == "repetir":
            if str(guild_id) in self.last_code:
                code = self.last_code[str(guild_id)]

                if auth_vc!= None and guild_id not in self.playing_on:
                    self.playing_on.append(guild_id)
                    vc = await auth_vc.channel.connect()

                    await self.play_code(code, vc)

                    await vc.disconnect()
                    self.playing_on.remove(guild_id)

                elif guild_id in self.playing_on:
                    await self.send_to_ch(channel, 'I\'m already playing a sound!', 5)

                else:
                    await self.send_to_ch(channel, 'User is not in a channel.', 5)

                return

            else:
                await self.send_to_ch(channel, 'I don\'t have anything to repeat!', 5)
                return

        if len(content.split())==2:
            if content.split()[0] in ["codi", "code"]:
                code = content.split()[1]
                self.last_code[str(guild_id)] = code

                # Only play if user is in a voice channel
                if auth_vc != None and guild_id not in self.playing_on:

                    # Set playing status
                    self.playing_on.append(guild_id)

                    # Create StreamPlayer
                    vc = await auth_vc.channel.connect()

                    await self.play_code(code, vc)

                    # Disconnect after the player has finished
                    await vc.disconnect()

                    # Set playing status
                    self.playing_on.remove(guild_id)

                elif guild_id in self.playing_on:
                    await self.send_to_ch(channel, 'I\'m already playing a sound!', 5)

                else:
                    await self.send_to_ch(channel, 'User is not in a channel.', 5)

                return

        if len(content.split())==3:
            splitted = content.split()
            if splitted[0] in ["codi", "code"]:
                code = splitted[1]
                times = splitted[2]

                if times in ["1", "2", "3", "4", "5"]:
                    timesInt = int(times)
                else:
                    await self.send_to_ch( channel, times + " is not a number between 1 and 5.", 5 )
                    return

                self.last_code[str(guild_id)] = code

                # Only play if user is in a voice channel
                if auth_vc != None and guild_id not in self.playing_on:

                    # Set playing status
                    self.playing_on.append(guild_id)

                    # Create StreamPlayer
                    vc = await auth_vc.channel.connect()

                    await self.play_code(code, vc, timesInt)

                    # Disconnect after the player has finished
                    await vc.disconnect()

                    # Set playing status
                    self.playing_on.remove(guild_id)

                elif guild_id in self.playing_on:
                    await self.send_to_ch(channel, 'I\'m already playing a sound!', 5)

                else:
                    await self.send_to_ch(channel, 'User is not in a channel.', 5)
Exemplo n.º 30
0
    try:
        if platform() == 'Darwin' and path.isfile(
                '/usr/local/Homebrew/bin/brew') == False:
            print(
                '\nMAC os detected\nHomebrew not found\nMarvin virtual assistant needs homebrew to install portaudio\n'
            )
            allow_brew_install = input(
                'Allow the setup.py to install Homebrew using Ruby and cURL? y/n? '
            ).lower()

            if allow_brew_install == 'y' or allow_brew_install == 'yes' or allow_brew_install == 'true':
                print(
                    '\n\nInstalling Homebrew from https://raw.githubusercontent.com/Homebrew/install/master/install\n\n'
                )
                terminal(
                    '/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"'
                )

                allow_portaudio_install = input(
                    'Allow the setup.py to install portaudio using Homebrew? y/n? '
                ).lower()
                if allow_portaudio_install == 'y' or allow_portaudio_install == 'yes' or allow_portaudio_install == 'true':
                    print('\n\nInstalling portaudio from Homebrew\n\n')
                    terminal('brew install portaudio')
            else:
                print(
                    'There will be an error later when installing pyaudio. Read more about port audio here: http://www.portaudio.com/'
                )

        else:
            allow_portaudio_install = input(
Exemplo n.º 31
0
""" 
Joseph Whiteaker 
3/4/2021 
I am copying and pasting chunks of my online textbook and having it read to me because I don't feel like reading it. 
"""

from os import system as terminal


def clear():
    terminal("clear")


try:
    terminal("black *.py")
except:
    print("Warning: The code couldn't be formatted\nCode will still work")
finally:
    print("\n\nCode is running now\n\n{}\n".format("Press ctrl+c to stop reading"))
    terminal("python3 readFile.py")