-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.py
101 lines (68 loc) · 2.08 KB
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import socket
import threading
import sys
from termcolor import cprint,colored
import platform
import os
import time
if platform.system() == "Windows":
clear = lambda:os.system("cls")
if platform.system() == "Linux":
clear = lambda:os.system("clear")
cprint("[!] Enter your Profile name: ","green",end="")
name = input()
cprint("[!] Enter your Friend's Local IP: ","green",end="")
hisip = input()
cprint("\n[*] Connecting Hold On","white","on_green")
s = socket.socket()
s.connect((hisip,80))
time.sleep(2)
clear()
cprint("Connection Established\n","white","on_cyan",["blink"])
cprint("Chat Program Activated ! Profile name %s\n"%(name),"white","on_yellow",["bold"])
cprint('[NOTE] Type "Bye" or "Exit" to quit Chat Program\n\n',"green")
partner = s.recv(1024).decode("utf-8")
s.send(name.encode())
outing = partner+" ---> Bye"
cprint("Emoji's You Like","white")
print("""
😀 😁 😂 🤣 😃 😄 😅 😆 😉 😊 😋 😎 😍 😘 🥰 😗
😙 😚 ☺️ 🙂 🤗 🥴 🤩 🤔 🤨 😐 😑 😶 🙄 😏 😣 😥
😮 🤐 😯 😪 😫 😴 😌 😛 😜 😝 😒 🤭 🥵 🥶 😳 🤪
😵 😡 😠 🤬 😷 🤒 🤕 🤢 🤮 🤧 😇 🤠 🤡 🥳 😓 😔
🥴 🤪 😕 🙃 🤑 😲 ☹️ 🙁 😖 😞 😟 😤 😢 😭 😦 😧
😨 😩 🤯 😬 😰 😱 🥳 😵 😈 👹 👺 💀 👻 👽 🤖 💩
""")
def sending():
try:
while True:
#sending
msg = input()
if msg == "Exit" or msg == "exit" or msg == "bye" or msg == "Bye":
msg = name+" ---> Bye"
s.send(msg.encode())
cprint("\nConnection Closed","white","on_red",["blink"])
s.close()
break
msg = "[+] "+name+" --> "+msg
s.send(msg.encode())
msg = ''
except:
sys.exit()
def receving():
try:
while True:
#recving
text = s.recv(1024).decode("utf-8")
if outing == text:
print(text)
cprint("\nConnection Closed","white","on_red",["blink"])
s.close()
break
cprint(text,"green")
except:
sys.exit()
t1 = threading.Thread(target=sending)
t2 = threading.Thread(target=receving)
t1.start()
t2.start()