Skip to content

Commit e974cf3

Browse files
committed
Public Chat Groups Now Live!!
1 parent 712d16f commit e974cf3

File tree

71 files changed

+792
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+792
-6
lines changed
File renamed without changes.

PublicChats.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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["PublicChatGroups"]
12+
for iterate in mycol.find():
13+
if iterate["GName"] == x:
14+
print(iterate["GName"] + " : " + iterate["Desc"])
15+
print(iterate["Owner"] + " --- Origin : " + iterate["Origin"])
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["PublicChatGroups"]
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["PublicChatGroups"]
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+
# print("here")
52+
task2()
53+
# print("here1")
54+
# print("here")
55+
t1.kill()
56+
# t2.start()
57+
# t2.join()
58+
# print(t1.is_alive())
-3.07 KB
Binary file not shown.
1.71 KB
Binary file not shown.

__pycache__/main.cpython-38.pyc

61 Bytes
Binary file not shown.

main.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ def Write_Message(iterate):
6666

6767

6868
def GlobalChat(username, ChangeStreamVaraible):
69-
import ChangeStream
70-
ChangeStream.main(username)
69+
import GlobalChat
70+
GlobalChat.main(username)
7171
# import os
7272
# os.system("exec ChangeStream")
73-
# subprocess.call(['python', 'ChangeStream.py'])
73+
# subprocess.call(['python', 'GlobalChat.py'])
7474
KahesiModeOnn(username)
7575

7676
def PuGrp(username):
@@ -93,6 +93,9 @@ def PuGrp(username):
9393
print("Enter 1 To Join a new Group")
9494
print("Enter Group Name To Chat")
9595
x = input()
96+
import PublicChats
97+
PublicChats.main(username, x)
98+
9699
KahesiModeOnn(username)
97100

98101

@@ -199,9 +202,12 @@ def NPuGrp(username):
199202
"Members": {
200203
"username": [username]
201204
},
202-
"Chats": {
203-
username: "Booyahh! Welcome To My Own Public Group"
204-
}
205+
"Chats": [
206+
{
207+
"username": username,
208+
"Message": "Booyahh! Welcome To My Own Public Group"
209+
}
210+
]
205211
}
206212
x = mycol.insert_one(mydict)
207213
print("New Group Has Been Created Successfully")

output/main.exe

772 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)