Chatroom Cliente em Python
Publicado por henrique (última atualização em 21/05/2022)
[ Hits: 2.102 ]
Homepage: naotem.com
Cliente do chatroom em python
#!/bin/python3 import socket import threading from sys import argv red = "\033[1;31m" blue = "\033[1;34m" cyan = "\033[1;36m" green = "\033[0;32m" reset = "\033[0;0m" bold = "\033[;1m" reverse = "\033[;7m" white = "\033[37m" gray = "\033[0;37m" def usage(): print('-' * 90 + green + ''' █████████ █████ █████ █████████ ███████████ ███████████ █████ █████ ███░░░░░███░░███ ░░███ ███░░░░░███ ░█░░░███░░░█ ░░███░░░░░███░░███ ░░███ ███ ░░░ ░███ ░███ ░███ ░███ ░ ░███ ░ ░███ ░███ ░░███ ███ ░███ ░███████████ ░███████████ ░███ ░██████████ ░░█████ ░███ ░███░░░░░███ ░███░░░░░███ ░███ ░███░░░░░░ ░░███ ░░███ ███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░░█████████ █████ █████ █████ █████ █████ ██ █████ █████ ░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░ ░░░░░ ░░░░░ exemplo: ./chatc.py <ip> <port> '''.title() + reset + '-' * 90) try: host = argv[1] port = int(argv[2]) except: usage() exit() client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client.connect((host, port)) nickname = input(red + "Escolha um nome: ") def receive(): while True: try: message = client.recv(1024).decode('ascii') if message == 'Usuario:': client.send(nickname.encode('ascii')) else: print(message) print() except: print(reset+ "Um erro aconteceu!") client.close() break def write(): while True: message = f'{nickname}: {input("")}' client.send(message.encode('ascii')) receive_thread = threading.Thread(target=receive) receive_thread.start() write_thread = threading.Thread(target=write) write_thread.start()
auth_ig.py: Script para autenticação do IG
Ligando máquina pela rede usando Python
Descritores de Arquivos e Swappiness
tux-gpt - Assistente de IA para o Terminal
Instalação e configuração do Chrony
Programa IRPF - Guia de Instalação e Resolução de alguns Problemas
Como instalar no Linux Jogos da Steam só para Windows
Instalando o Team Viewer no Debian Trixie - problema no Policykit
O Que Fazer Após Instalar Ubuntu 25.04
Graduação e certificação Eng. de redes e Eng. Linux[DUVIDA] (0)
Controle do PS5 no Linux Mint funciona? (3)
Autenticação necessária. um aplicativo quer acesso ao chaveiro "c... (1)