Skip to content

Commit 8bed1af

Browse files
committed
Private Chats are Now Live (Joinning and SKey Left to Do)
1 parent 1d03c9d commit 8bed1af

File tree

5 files changed

+84
-37
lines changed

5 files changed

+84
-37
lines changed

PrivateChats.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
from KThread import *
2+
3+
4+
def main(username, x):
5+
import pymongo
6+
import os
7+
myclient = pymongo.MongoClient(
8+
"mongodb+srv://CodingBlood:[email protected]/myFirstDatabase?retryWrites=true&w=majority")
9+
os.system('cls' if os.name == 'nt' else 'clear')
10+
mydb = myclient["Chatbox"]
11+
mycol = mydb["PrivateChatGroups"]
12+
for iterate in mycol.find():
13+
if iterate["GName"] == x:
14+
print(iterate["GName"] + " : " + iterate["Desc"])
15+
print(iterate["Owner"])
16+
admins = ""
17+
for i in iterate["Admins"]["username"]:
18+
admins += i
19+
print("Our Esteemed Admins >> " + admins)
20+
members = ""
21+
for i in iterate["Members"]["username"]:
22+
members += i
23+
print("Our Esteemed Members >> " + members)
24+
print()
25+
print()
26+
for chats in iterate["Chats"]:
27+
print(chats["username"] + " : " + chats["Message"])
28+
29+
def task1():
30+
mydb = myclient["Chatbox"]
31+
mycol = mydb["PrivateChatGroups"]
32+
33+
for change in mycol.watch(full_document='updateLookup'):
34+
print(change["fullDocument"]["Chats"][-1]["username"] + " : " + change["fullDocument"]["Chats"][-1]["Message"])
35+
36+
def task2():
37+
while True:
38+
p = str(input())
39+
if p != "$_":
40+
mydict = {"username": username, "Message": p}
41+
PChat = mydb["PrivateChatGroups"]
42+
document = dict(PChat.find_one({'GName': x}))
43+
document['Chats'].append(mydict)
44+
PChat.update({'GName': x}, document)
45+
else:
46+
break
47+
return 0
48+
49+
t1 = KThread(target=task1)
50+
t1.start()
51+
task2()
52+
t1.kill()
1.68 KB
Binary file not shown.

__pycache__/main.cpython-38.pyc

474 Bytes
Binary file not shown.

main.py

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@
66
import os
77
import subprocess
88
import threading
9-
109
os.system('cls' if os.name == 'nt' else 'clear')
1110
myclient = pymongo.MongoClient(
1211
"mongodb+srv://CodingBlood:[email protected]/myFirstDatabase?retryWrites=true&w=majority")
1312
mydb = myclient["Chatbox"]
1413
mycol = mydb["UserDetails"]
15-
16-
1714
# ======================================================================================================================
1815
# mydict = { "UName": "KahesiBot4", "UPassword": "GrippenBot4" }
1916
# x = mycol.insert_one(mydict)
@@ -30,8 +27,6 @@
3027
# for x in mydoc:
3128
# print(x)
3229
# ======================================================================================================================
33-
34-
3530
def NUser():
3631
print("No personal data required we dont wanna know who and why you are")
3732
print("UserName Or '$-' to go back")
@@ -51,28 +46,21 @@ def NUser():
5146
x = mycol.insert_one(mydict)
5247
print("New User Has Been Created Successfully")
5348
main()
54-
55-
5649
def NewGlobalMessage(username, x):
5750
mydb = myclient["Chatbox"]
5851
GChat = mydb["GlobalChat"]
5952
mydict = {"UName": username, "Message": x}
6053
temperory_variable = GChat.insert_one(mydict)
6154
GlobalChat(username, 1)
62-
63-
6455
def Write_Message(iterate):
6556
print(iterate["UName"].capitalize() + " : " + iterate["Message"])
66-
67-
6857
def GlobalChat(username, ChangeStreamVaraible):
6958
import GlobalChat
7059
GlobalChat.main(username)
7160
# import os
7261
# os.system("exec ChangeStream")
7362
# subprocess.call(['python', 'GlobalChat.py'])
7463
KahesiModeOnn(username)
75-
7664
def PuGrp(username):
7765
print("Heyaaa!!!")
7866
print("Public Chat Groups You have Joined Are As Follows")
@@ -97,12 +85,33 @@ def PuGrp(username):
9785
PublicChats.main(username, x)
9886

9987
KahesiModeOnn(username)
100-
101-
10288
def PriGrp(username):
103-
pass
104-
105-
89+
print("Heyaaa!!!")
90+
print("Private Chat Groups You have Joined Are As Follows")
91+
prg_details = mydb["PrivateChatGroups"]
92+
for iterate in prg_details.find():
93+
print(iterate["GName"] + " : " + iterate["Desc"])
94+
print(iterate["Owner"])
95+
admins = ""
96+
for i in iterate["Admins"]["username"]:
97+
admins += i
98+
print("Our Esteemed Admins >> " + admins)
99+
members = ""
100+
for i in iterate["Members"]["username"]:
101+
members += i
102+
print("Our Esteemed Members >> " + members)
103+
print()
104+
print()
105+
print("Enter 1 To Join a new Group")
106+
print("Enter Group Name To Chat")
107+
x = input()
108+
# for iterate in prg_details.find():
109+
# if iterate["SKey"]:
110+
#
111+
# if x ==
112+
import PrivateChats
113+
PrivateChats.main(username, x)
114+
KahesiModeOnn(username)
106115
def KahesiModeOnn(username):
107116
print("We At ChatBox Welcome you to our Application")
108117
print("We are Continuously working on adding More and more features but till then you can enjoy our Global chat")
@@ -125,8 +134,6 @@ def KahesiModeOnn(username):
125134
NPuGrp(username)
126135
elif x == 6:
127136
NPriGrp(username)
128-
129-
130137
def ULogin():
131138
print("Username:")
132139
username = input()
@@ -143,12 +150,8 @@ def ULogin():
143150
print()
144151
print()
145152
main()
146-
147-
148153
def DUser():
149154
main()
150-
151-
152155
def NSUser():
153156
print("Enter Security Key Now!! >> ")
154157
security_key = str(input())
@@ -173,7 +176,6 @@ def NSUser():
173176
x = mycol.insert_one(mydict)
174177
print("New User Has Been Created Successfully")
175178
main()
176-
177179
def NPuGrp(username):
178180
print("Create A New Public Group Over Here")
179181
print("Enter Name Of Your Group '$-' to go back")
@@ -212,7 +214,6 @@ def NPuGrp(username):
212214
x = mycol.insert_one(mydict)
213215
print("New Group Has Been Created Successfully")
214216
main()
215-
216217
def NPriGrp(username):
217218
print("Create A New Private Group Over Here")
218219
print("Enter Name Of Your Group '$-' to go back")
@@ -241,14 +242,16 @@ def NPriGrp(username):
241242
"Members": {
242243
"username": [username]
243244
},
244-
"Chats": {
245-
username: "Booyahh! Welcome To My Own Public Group"
246-
}
245+
"Chats": [
246+
{
247+
"username": username,
248+
"Message": "Booyahh! Welcome To My Own Public Group"
249+
}
250+
]
247251
}
248252
x = mycol.insert_one(mydict)
249253
print("New Group Has Been Created Successfully")
250254
main()
251-
252255
def FFinder():
253256
mycol = mydb["UserDetails"]
254257
print("Username:")
@@ -260,8 +263,6 @@ def FFinder():
260263
else:
261264
print("Congratulations We Found your User!!!!")
262265
print(mydoc[0]["UName"])
263-
264-
265266
def SuperKahesiModeOnn(username):
266267
print("Welcome Master. What can I show to please you...?")
267268
print("1) User Details")
@@ -314,8 +315,6 @@ def SuperKahesiModeOnn(username):
314315
SuperKahesiModeOnn(username)
315316
else:
316317
main()
317-
318-
319318
def SULogin():
320319
mycol = mydb["SuperUserDetails"]
321320
print("Username:")
@@ -333,8 +332,6 @@ def SULogin():
333332
print()
334333
print()
335334
main()
336-
337-
338335
def main():
339336
os.system('cls' if os.name == 'nt' else 'clear')
340337
print("Hi there Welcome to Online Chatting Room")
@@ -363,6 +360,4 @@ def main():
363360
else:
364361
print("Sorry Wrong Choice, I guess you really like fucking around")
365362
main()
366-
367-
368363
main()

output/main.exe

1.53 KB
Binary file not shown.

0 commit comments

Comments
 (0)