Untitled
unknown
python
2 years ago
2.6 kB
1
Indexable
Never
def do_something(message): command = message['message'] user = message['display-name'] user_id_command = message['user-id'] user_type = message['user-type'] prefix_volume = '!volume' prefix_skip = '!skip' prefix_sr = '!sr' prefix_atual = '!atual' command_volume = command.startswith(prefix_volume) command_skip = command.startswith(prefix_skip) command_sr = command.startswith(prefix_sr) command_atual = command.startswith(prefix_atual) if user_type == 'mod' or user_id_command == USERID: if command_volume: volume_value_command = command.split(prefix_volume,1)[1] volume_value_int = int(volume_value_command) if volume_value_int in range(0, 101): vlc_player.volume_command(volume_value_command) message_response = user +' --> O volume foi alterado para ' + volume_value_command send_message(message_response) else: message_response = user +' --> O volume deve ser um valor entre 0 e 100' send_message(message_response) elif command_skip: vlc_player.stop() message_response = user +' --> A musica foi pulada ' send_message(message_response) elif command_sr: user_input = command.split(prefix_sr,1)[1] if user_input == '': message_response = user + ' --> Você deve fornecer um nome ou link de musica válido' send_message(message_response) else: if validators.url(user_input): append_new_line('src/queue.txt', 'MUSICA: ( ' + user_input + ' ) USUÁRIO:' + user) else: simbols = [['[', ']'], ['(', ')'], ['"', '"']] rep_input = removestring(user_input, simbols) append_new_line('src/queue.txt', 'MUSICA: ( ' + rep_input + ' ) USUÁRIO:' + user) elif command_atual: f = open('src/currentsong.txt', 'r+') musica_atual = f.read() message_response = user + ' --> A musica atual é : ' + musica_atual send_message(message_response) else: if command_atual: f = open('src/currentsong.txt', 'r+') musica_atual = f.read() message_response = user + ' --> A musica atual é :' + musica_atual send_message(message_response) connection.listen(USERNAME,on_message=do_something)