Submit your sharing themed repl created by your group

← Back to all posts
python chatroom client
h
sanjaykdragon (171)

py_chatroom - python chat client

created by @sanjaykdragon and @ve123 for the Massively Multiplayer Hackathon. Theme is sharing, so we did a chatroom to "share" messages

description

This is a python chat client written with > 200 lines of code. The code quality here is OK, nothing amazing. This also relies on a php backend, which isn't great code, but it functions fine. I would recode this to support sockets and such, but as far as I know, repl.it doesn't support TCP / UDP sockets (or I don't know how to write them to work with repl's standards). Users can register by entering a username that doesn't exist. There are 2 admin accounts, me and @ve123 's.

technical information

multithreading was used to consistently update the chat messages on your screen. The comments on the functions in chat.py explain basically everything you need to know, such as:

  • call hierarchy (what calls this function, what this function calls)
  • import dependencies (in case you want to shorten / debloat the output, you can look through and find which functions use the most dependencies)
  • function name and args explanation
  • function description

links

php backend - https://repl.it/@sanjaykdragon/pychatroombackend
~170 LOC (although very unclean code, this could probably be shortened way more)
python client - https://repl.it/@sanjaykdragon/pychatroom
more than 200 LOC (nicely commented, pretty clean)

features

  • multithreaded chat system - chat automatically updates every few seconds
  • account registry - register an account so that other people can't be an imposter of you
  • passwords not saved in plaintext - hashed passwords. should be basic security on this site.
  • different message colors depending on admin, normal user, or if you were mentioned in the message! (like discord)
  • code is commented well for future maintainability
  • there is an optional encryption module, this was not used because it used pbkdf2 which is VERY slow, like 20 seconds per decryption / encryption. You are welcome to reimplement it, or find an alternative. The class for encryption is still there.
  • block user option (hides their messages, discord style)
  • unblock user

other credits / mentions

commands

/unblock user - unblocks a user
/block user - blocks a user
/lb - list blocked users

admin commands

/reset or /clear - clear chat

Commentshotnewtop
[deleted]

Very Nice Code, Also Thanks for Helping me Code on Discord.

TaylorLiang (99)

@sanjaykdragon he.. deleted his account. out of curiosity do you know who he is

sanjaykdragon (171)

@TaylorLiang @KelsinJJ was his repl.it name, but he deleted his discord too recently (i guess to focus on school stuff)

Andi_Chin (9)

are you sure you haven't made this project before?

sanjaykdragon (171)

@Andi_Chin You are welcome to compare my prev chatroom to this one. It is completely different

Andi_Chin (9)

@sanjaykdragon my bad, such coincidence

sanjaykdragon (171)

@amasad is this in the right place?

PDanielY (280)

@sanjaykdragon Please don't ping amasad, ping a moderator instead. Amasad said to post it in Challenge board but the board is locked so I guess this is fine. I'll move the board to challenge board if needed.

AllAwesome497 (239)

@PDanielY it's locked because we aren't open for submissions yet.

PDanielY (280)

@AllAwesome497 I thought December 1 was the deadline?

AllAwesome497 (239)

@PDanielY deadline is actually tomorrow. I thought it was later. I'm gonna ask amasad about it.

sanjaykdragon (171)

@AllAwesome497 the deadline for me is 5am, and I am not awake then. Also I asked some people and they said the mods didnt know.

AllAwesome497 (239)

@sanjaykdragon I moved to challenge, don't worry.

amasad (1718)

@AllAwesome497 thanks for taking care of this!