Skip to content

Commit

Permalink
linting code
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperFola committed Jan 27, 2021
1 parent e7a3d9c commit 0274438
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/chatserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
out of memory errors.
Please try again later."""


class Message:
def __init__(self, author: str, content: str):
self.author = author
Expand Down Expand Up @@ -89,7 +90,7 @@ def check_command(self, msg: str, ip: str) -> str:
msg = msg.strip()

if msg.startswith("/"):
cmd, *data = msg.split(' ')
cmd, *data = msg.split(" ")
if cmd == "/register":
result = self.register_user(data, ip)
if not result:
Expand All @@ -101,17 +102,15 @@ def check_command(self, msg: str, ip: str) -> str:
return "ERROR Unknown command."
elif msg.startswith("@"):
if len(self.messages) >= MESSAGE_LIMIT:
self.messages = self.messages[-int(MESSAGE_LIMIT / 1000 + 1):]
self.messages = self.messages[-int(MESSAGE_LIMIT / 1000 + 1) :]

usertag, *data = msg.split(' ')
# remove the @
usertag = usertag[1:]
if usertag not in self.users:
return ERROR_UNKNOWN_USERTAG
else:
self.messages.append(
Message(self.users[usertag].name, " ".join(data))
)
self.messages.append(Message(self.users[usertag].name, " ".join(data)))
return "OK."
else:
return ERROR_NOT_REGISTERED
Expand Down

0 comments on commit 0274438

Please sign in to comment.