Share your repls and programming experiences

← Back to all posts
Python chatbot
xolyon (346)

Hi everyone this is what you make on 5th day of quarantine

this took way too long as I tried to make it run simultaneously but that didn't work

I also tried to make it encrypted with a separate program I already wrote but for some reason, it wouldn't work here

-- - intro - --

  • if you don't have an 'account' create one then log in
  • don't steal someone's else account
  • Select an option
  • just chat!

-- - how it works - --

  • login just reads line by line until it matches username and password

  • the chat system uses a function which reads the last 5 lines (i had a system which printed every time it got altered but it didn't work)

-- - updates - --
I might add the encryption along with some cool tags and other stuff

1927829 (0)

lol so far I still haven't found a python chat room that works. :|

Anoki21 (31)

Yes, I agree to follow these fules.

Roar123 (443)

Nice! Why were you not able to make simultaneous work?

xolyon (346)

@Roar123 no, it just reloaded so fast there was no time to type, you can help me if you want

Roar123 (443)

@xolyon ok, sure if I have time.

Roar123 (443)

@xolyon I made some minor tweaks to your program and made it simultaneous. First of all, I simplified the while loop at the bottom of to:

while True:

Yep that's it! Some other tweaks you can also make are changing the amount of lines read from chat.txt from 5 to 10 and adding a reset ANSI escape code so the entire chat does not become dim. Btw, I'm using f-string formatting which is really nice and efficient. Check it out! Example:

reset = "\033[0m"
def chat(n):
    chatting = input(f"{Style.DIM}type something in the chat!")
    # everything else . . .
xolyon (346)

@Roar123 yeah I did the dim thingy because I wanted users to have a personnel color tag until I realised that it might not end up in the txt file that way and would be useless so I forgot to get rid of that piece of code - thanks anyway

imcraft (27)

I wish for my account to be deleted please

xolyon (346)

@imcraft don't worry lol it doesn't even work on the post (it would work if it were on a network, however) do the nothings saved apart from the logins already one there

imcraft (27)

@xolyon oh I thought the ones saved were real lol

xolyon (346)

@imcraft nope I had another program which worked but it crashed whenever you typed in anything so...