Skip to content
← Back to Community
🐍😎 Python Chat! 🐍😎
Profile icon
JBloves27

🐍😎 A fully functional Python Chat! 🐍😎

Made by moi

About

This is a chatting program, used with filing (a bad technique, but I only knew this way for console python). You can chat, but you have to reload the page every few minutes for the messages to load.

Code

The code is actually pretty simple, it uses file opening, and file writing, etc. I added colors, just to make it more fun ^_^

Credits

Credits to @DominicHuieWhit for the datetime! :) Also to @tickedoffsquid for making a suggestion!

Closing

I hope you guys enjoy using this program! IF you haven't already, visit this for more info! Thanks!

NOTE: Please don't ask for editing access, it annoys me and you can just fork it. Thanks!

( o_o)

Update1: I added a automatic time! yay! It's less complicated!

Update2: I added colors and a different login system, and you cant hack >:)

Update3: The quit is fixed! I added a menu, so you can choose if its a message or not!

Update4: I added a more easy and fixed automatic time!


Edit1: Visit here for more about the timezones!

Edit2: Heyo guys! Thanks for making this to trending! :D

Voters
Profile icon
OldWizard209
Profile icon
Brendan23
Profile icon
SilvermoonCat
Profile icon
forceofyoda
Profile icon
RayhanADev
Profile icon
01Glitch
Profile icon
thecrewmate876
Profile icon
elijahbernard
Profile icon
robertoblong
Profile icon
PizzaMan21
Comments
hotnewtop
Profile icon
AphixDev

Poggers.py ... PogChamp.md
I congratulate you for your advanced naming conventions ;)

Profile icon
JBloves27

hahah, thanks! :) XD @AphixDev

Profile icon
FloCal35

P O G

@AphixDev

Profile icon
JBloves27

pog

@FloCal35

Profile icon
FloCal35

P o G g E r S

@JBYT27

Profile icon
JBloves27

pogchamp

@FloCal35

Profile icon
FloCal35

P o G g E r S c H a M p πŸ€·β€β™‚οΈ

@JBYT27

Profile icon
JBloves27
:o

poggggggchamper xd

@FloCal35

Profile icon
FloCal35

I've been beaten xd
@JBYT27

Profile icon
JBloves27

XD lmao @FloCal35

Profile icon
RhinoRunner

@JBYT27

p

o

g
Profile icon
JBloves27
:O

@RhinoRunner

P

O

G
Profile icon
IntellectualGuy

@JBYT27

P

O


G

Profile icon
JBloves27

P

O

G
@IntellectualGuy

Profile icon
ProCatGuy

does not work POG and this is a flaw POG.

Profile icon
JBloves27
Profile icon
Bookie0

Instead of adding the time, you should add automatically add it! :)

Also this isn't really easy to read:

Screen Shot 2021-01-25 at 10.57.15 AM

Perhaps take off the italic?

And you could not need to have to ask the user each time for the time (no pun intended), instead you could add like settings to automatically add the time or not. And there aren't much colors..

Screen Shot 2021-01-25 at 10.58.32 AM

And what if I want to say quit in the text, without actually quitting lol?

:D

Profile icon
JBloves27

lol, ok. so @Bookie0

  1. got it
  2. sure
  3. er, cant you add more words before the word quit? lol
  4. :D
Profile icon
Bookie0

@JBYT27 yes but what if I want to just say 'quit'? :malicious:

Profile icon
JBloves27

hahaha, ok, so how should i make it quit? Because i would like the program to say 'someone left' @Bookie0

Profile icon
Bookie0

@JBYT27 hum...tbh idk lol

Profile icon
Bookie0
Profile icon
Z10n12345

@JBYT27 Maybe !Quit so it's obvious that they're running a command and want to quit?

Profile icon
JBloves27

...awesome! thanks! @Z10n12345

Profile icon
Bookie0

@Z10n12345 perhaps..perhaps..perrrrrhaps

Profile icon
JBloves27

lol, maybe, but then it would kinda look weird, a seperate screen with a console... @Bookie0

Profile icon
Bookie0

@JBYT27 I mean the problem with that (and any other 'commands' like that) is that what if the user wants to write !quit, for example to respond to someone asking how to quit lol

Profile icon
Bookie0

@JBYT27 hum yea

Profile icon
JBloves27

oh, lol @Bookie0

Profile icon
JBloves27

yeah... @Bookie0

Profile icon
Z10n12345

@Bookie0 I would say:
"!quit"
if that were the case or:
say !quit

Profile icon
Bookie0
Profile icon
Z10n12345

@Bookie0 Because if I knew that saying !quit would kick me out, I wouldn't say it, but if someone asked, I would avoid saying it directly or disguise it. kind of like in a game chat, when someone asks how to directly message someone, you would say:
say @username "message"
or whatever it is.

Profile icon
ApoorvAgrawal

@JBYT27 Maybe you should have a menu that pops up when a user types "quit", it would ask them if they were sending quit or if they were trying to leave the chat.

Profile icon
glitchish

@Z10n12345 u know u just pinged someone named username

Profile icon
JBloves27
Profile icon
JBloves27

hmmm, thanks! :) @ApoorvAgrawal

Profile icon
glitchish
Profile icon
JBloves27
Profile icon
JBloves27

I fixed the quit thing! @Bookie0

Profile icon
ProCatGuy

Yes please we need to.

Profile icon
JBloves27

Nah, its ok. ;). Anyways, try est. It seems like only some of them work, and i cant fix the functions of modules. You aren't doing anything wrong, its just the module use is funky xd @YeetsaJr

Profile icon
JBloves27
Profile icon
Z10n12345

Yeah, I knew it would do that, so I checked that that was actually an account before I sent it. Either it isn't an account, or the user is just really, really inactive. @CodingRedpanda

Profile icon
glitchish

@Z10n12345 i think their ** * really * ** inactive

Profile icon
ProCatGuy

See this IS pog.

Profile icon
JBloves27
Profile icon
SilvermoonCat

Whatever I enter it’s always invalid timezone :(

Profile icon
JBloves27

oof, sry. try EST @SilvermoonCat

Profile icon
SilvermoonCat

@JBYT27 k I'm in PST but yea EST works, nice chat!

Profile icon
JBloves27

ok, thanks! @SilvermoonCat

Profile icon
[deleted]

you should have it save the timezone so you do not have to type it each time, just a thought

Profile icon
JBloves27

hmmm, ok! thanks! @tickedoffsquid

Profile icon
JBloves27

Thanks for the suggestion and its done! @tickedoffsquid

Profile icon
RayhanADev

xDxDxD them file names make me laugh
also hiya m8!

Profile icon
JBloves27

Hahahaha, yep! XD
hiya to you too! @RayhanADev

Profile icon
DSAVeronika20

love it πŸ’–

Profile icon
JBloves27
Profile icon
DSAVeronika20

@JBYT27 no prob

Profile icon
OldWizard209

Hey @JBYT27 . I had a question. How did you make it so that i=when u sign up, it automatically saves the username and pas. . Can you give me the code to do that. I will credit you if ever post something containing that code.

Profile icon
JBloves27

Sure, so you do the following: @OldWizard209

import os ... user = os.environ['REPL_OWNER'] print(user)

I hope this helps!

Profile icon
OldWizard209

No, this gives out the username on repl.it. I am talking about the LogIN, SignIn Interface. How does the program know I have an account or not? I need the code for that. thnx @JBYT27

Profile icon
JBloves27

ohhh, ok. here's the code: Note: It works, but there is one error i cant fix.* @OldWizard209

import os, time from replit import db red = "\033[0;31m" green = "\033[0;32m" white = "\033[0;37m" def clear(): os.system('clear') def login2(): # making the login system clear() # the clear() thing print("Account:") yn = input("[1] Login\n[2] Sign Up\n[3] Quit\n>>> ") if yn == "1": clear() print("Login\n") user = input("Username: ") passcode = input("Password: ") try: Password = db[user] if Password == passcode: clear() print(green+"Logged in!"+white) time.sleep(2) # waiting 2 seconds clear() else: clear() print(red+"Incorrect!"+white) time.sleep(2) login2() except: clear() print(red+"That username is not included!"+white) time.sleep(2) login2() elif yn == "2": clear() print("Sign up\n") newuser = input("Username: ") newpasscode = input("Password: ") try: db[newuser] = newpasscode clear() print(green+"Account made!"+white) time.sleep(2) clear() login2() except: clear() print(red+"Account already made!"+white) time.sleep(2) clear() login2() elif yn == "3": clear() print(red+"ByeBye!"+white) time.sleep(2) clear() quit() else: clear() print(red+"Invalid Command!"+white) time.sleep(2) clear() login2()

I hope this helps!

I added some additional stuff you can delete ;)

Profile icon
OldWizard209

OOH thanks a lot. I wish i had put this in the ask section so u cud have got 5 cycles..... @JBYT27

Profile icon
JBloves27

lol, np! xd @OldWizard209

Profile icon
MarcusWeinberger

Dang I never knew about the REPL_OWNER env variable - I was confused for a moment how you knew who I was ahah

Profile icon
JBloves27
Profile icon
SeamusDonahue

it asks if I want to add the time when I say quit but otherwise really cool!

Profile icon
JBloves27

Yeah, so it adds the time when you left. Thanks! @SeamusDonahue

Profile icon
SeamusDonahue

ahh I see, I thought that might have been a glitch so nvm, very cool repl. @JBYT27

Profile icon
SeamusDonahue

oh btw real glitch, I was able to register an account with my username twice... @JBYT27

Profile icon
JBloves27

oh, hmmm, let me look... @SeamusDonahue

Profile icon
JBloves27
Profile icon
SeamusDonahue

okay but now it just says "invalid time zone" what is a valid timezone? @JBYT27

Profile icon
JBloves27

Well, est works, im pretty sure gmt works as well. I havent tested out ALL timezones, but you can try est for now @SeamusDonahue

Profile icon
SeamusDonahue

two things, yes est works but not my timezone (cst) and also i noticed its writing to a file, which on repl.it only applies to the person using it for as long as the page is open, you are the only one that saves changes because you own the repl. @JBYT27

Profile icon
JBloves27

Oh, ok. Hmmm... ill fix that in a few @SeamusDonahue

Profile icon
ProCatGuy

@SeamusDonahue Same for me.

Profile icon
ProCatGuy

@JBYT27 My timezone is PST and it just gives me an error please fix it.

Profile icon
JBloves27

Yeah, i cant fix that because im using a module, sry @AndrewMarkarian

Profile icon
ProCatGuy

And sorry but is this multiplayer or private?

Profile icon
JBloves27
Profile icon
ProCatGuy

@JBYT27 Sorry for late response, but can you talk globally or with friends if you invite them?

Profile icon
JBloves27
Profile icon
ProCatGuy

How do I set it up. The accounting system does not show up and I don't really get how to talk privately or publicly. Sorry I only come once a week. @JBYT27

Profile icon
JBloves27

Uh, so you have a replit account, so it should automatically do it for you. You have to keep checking for messages, also, people may not talk on this... np @AndrewMarkarian

Profile icon
Gh0stHack3r

Wow, this Is awesome I typed a Hi In the chat (^_^)! It saves your password and username... LOL I love It!

Profile icon
ProCatGuy

How did you make an account? I want to do it too.

Profile icon
JBloves27
Profile icon
DominicHuieWhit

cool

Profile icon
JBloves27
Profile icon
DominicHuieWhit

@JBYT27
from datetime import datetime
from pytz import timezone
tz = timezone(input('timezone'))
date = datetime.now(tz)
print(date.strftime("%m/%d/%Y %H:%M:%S"))

you might be able to use that for the time thing

Profile icon
JBloves27

hmmm, ok! Thanks! I'll add that later! @DominicHuieWhit

Profile icon
JBloves27

Thanks a lot! :D @DominicHuieWhit

Profile icon
ClaireLieuallen

how do i do this

Profile icon
JBloves27

Hey @ClaireLieuallen!

This is currently depreciated, and isn't usable. Basically, it doesn't save and doesn't work. Sorry!

Profile icon
Agzamikail

Can you please give the code

Profile icon
JBloves27

? wdym? the code is in a different file. Anyways, I'll just give u it :@Agzamikail

import os, time, sys from datetime import datetime from pytz import timezone def clear(): os.system('clear') italic = "\033[3m" red = "\033[0;31m" green = "\033[0;32m" orange = "\033[0;33m" blue = "\033[0;34m" purple = "\033[0;35m" cyan = "\033[0;36m" white = "\033[0;37m" black = "\033[0;30m" reset='\033[0m' time.sleep(1) clear() print(purple+"Glitch Chat!"+white) time.sleep(3.5) clear() username = os.environ['REPL_OWNER'] try: print(green+'Welcome '+blue+f'{username}'+green+' to the '+purple+'Glitch Chat!'+white) time.sleep(2) clear() except: username = 'Guest' print(green+'Welcome '+blue+f'{username}'+green+'! '+red+f'It also seems like you don\'t have an account yet...\nVisit {sys.exc_info()} for more!') os.environ['REPLIT_DB_URL'] time.sleep(2) clear() text_join=True tz2=True chatting=True while chatting: print(purple+'Glitch Chat!'+white) print(italic+'\n<~> Enter \'quit\' to quit the program\n'+white) file = open('messages.txt','r') file2=file.read() if file2 == '': print(red+'There are no messages yet, you should start one!'+white) else: print(cyan+file2+orange)#This reads and prints everything in the file message=input('\nWhat is your message?\n[:> ') if tz2 == False: clear() pass else: try: tz = timezone(input('What is the timezone?\n[:> ')) tz2 = False except: print(red+"Invalid time zone!"+white) time.sleep(2) clear() continue clear() if message == 'quit': mq = input('Is it a message or do you want to quit? m/q\n[:> ').lower() if mq == 'm': with open('messages.txt','a') as file: date = datetime.now(tz) file.write(f'{username}: {message} -> {date.strftime("%m/%d/%Y %H:%M:%S")}\n') file.close() elif mq == 'q': chatting=False with open('messages.txt','a') as file:#writes in the file the following: date = datetime.now(tz) file.write(f'{username} has left at {date.strftime("%m/%d/%Y %H:%M:%S")}!\n')#writes the following file.close()#closes the file clear() else: clear() else: if text_join == True: with open('messages.txt','a') as file:#this opens the file and appends something date = datetime.now(tz) file.write(f'{username} has joined at {date.strftime("%m/%d/%Y %H:%M:%S")}!\n')#writes in the file file.close()#closes the file. If you dont, you cant create more than one line. with open('messages.txt','a') as file: date = datetime.now(tz) file.write(f'{username}: {message} -> {date.strftime("%m/%d/%Y %H:%M:%S")}\n') file.close()#closes the file text_join=False else: with open('messages.txt','a') as file: date = datetime.now(tz) file.write(f'{username}: {message} -> {date.strftime("%m/%d/%Y %H:%M:%S")}\n') file.close()#closes the file text_join=False

Here you go!

Profile icon
Agzamikail

Can you please give the code

Profile icon
JBloves27

? wdym? the code is in a different file. Anyways, I'll just give u it :@Agzamikail

import os, time, sys from datetime import datetime from pytz import timezone def clear(): os.system('clear') italic = "\033[3m" red = "\033[0;31m" green = "\033[0;32m" orange = "\033[0;33m" blue = "\033[0;34m" purple = "\033[0;35m" cyan = "\033[0;36m" white = "\033[0;37m" black = "\033[0;30m" reset='\033[0m' time.sleep(1) clear() print(purple+"Glitch Chat!"+white) time.sleep(3.5) clear() username = os.environ['REPL_OWNER'] try: print(green+'Welcome '+blue+f'{username}'+green+' to the '+purple+'Glitch Chat!'+white) time.sleep(2) clear() except: username = 'Guest' print(green+'Welcome '+blue+f'{username}'+green+'! '+red+f'It also seems like you don\'t have an account yet...\nVisit {sys.exc_info()} for more!') os.environ['REPLIT_DB_URL'] time.sleep(2) clear() text_join=True tz2=True chatting=True while chatting: print(purple+'Glitch Chat!'+white) print(italic+'\n<~> Enter \'quit\' to quit the program\n'+white) file = open('messages.txt','r') file2=file.read() if file2 == '': print(red+'There are no messages yet, you should start one!'+white) else: print(cyan+file2+orange)#This reads and prints everything in the file message=input('\nWhat is your message?\n[:> ') if tz2 == False: clear() pass else: try: tz = timezone(input('What is the timezone?\n[:> ')) tz2 = False except: print(red+"Invalid time zone!"+white) time.sleep(2) clear() continue clear() if message == 'quit': mq = input('Is it a message or do you want to quit? m/q\n[:> ').lower() if mq == 'm': with open('messages.txt','a') as file: date = datetime.now(tz) file.write(f'{username}: {message} -> {date.strftime("%m/%d/%Y %H:%M:%S")}\n') file.close() elif mq == 'q': chatting=False with open('messages.txt','a') as file:#writes in the file the following: date = datetime.now(tz) file.write(f'{username} has left at {date.strftime("%m/%d/%Y %H:%M:%S")}!\n')#writes the following file.close()#closes the file clear() else: clear() else: if text_join == True: with open('messages.txt','a') as file:#this opens the file and appends something date = datetime.now(tz) file.write(f'{username} has joined at {date.strftime("%m/%d/%Y %H:%M:%S")}!\n')#writes in the file file.close()#closes the file. If you dont, you cant create more than one line. with open('messages.txt','a') as file: date = datetime.now(tz) file.write(f'{username}: {message} -> {date.strftime("%m/%d/%Y %H:%M:%S")}\n') file.close()#closes the file text_join=False else: with open('messages.txt','a') as file: date = datetime.now(tz) file.write(f'{username}: {message} -> {date.strftime("%m/%d/%Y %H:%M:%S")}\n') file.close()#closes the file text_join=False

Here you go! @Agzamikail

Profile icon
Agzamikail

@JBloves27 thanks, but I don't need the code I'm just wondering how chats work

Profile icon
JBloves27
Profile icon
cole525

i congratulate you. GMT actually works

Profile icon
JBloves27

Lol, yay! Thanks! @cole525

Profile icon
cole525

@ me if you want to talk here

Profile icon
JBloves27

Sure, but why? @cole525

Profile icon
hunterc0le

I see theres an option in it for user login. but how can you create a username and password question for more security? I guess i can always do that separately but itd still be cool

Profile icon
JBloves27
Profile icon
hunterc0le

OMG IM SO STUPID. I see it now, my bad.:) It works really well btw! @JBYT27

Profile icon
JBloves27

lol, np! Thanks! :D @hunterc0le

Profile icon
ErrorNoInternet

epikpogger

Profile icon
JBloves27
Profile icon
Hal2006

Mhmmmm P O G G E R :p

Profile icon
JBloves27

Yes, pogger @lisa2006x

Profile icon
Hal2006

hmm nice @JBYT27

Profile icon
JBloves27
Profile icon
Hal2006

Np! I have a question, have you ever hacked something? Like anything.. πŸ€” @JBYT27

Profile icon
JBloves27

Well, not rly. lol @lisa2006x

Profile icon
Hal2006

Oh ok :p @JBYT27

Profile icon
JBloves27
Profile icon
VishnuBharath

only problem is, when someone who doesn't have editing permissions types, it doesn't save. Idk how to fix that, but im sure it's possible

Profile icon
JBloves27
Profile icon
aCactuar

Why is there not a list of timezones? I, personally, cannot get central timezone in, because I don't know how to format it so the program never recognizes it.

Profile icon
JBloves27

Yeah, everyone has been asking the same thing, and I can't fix it because it is a module. However, if you do visit the link above in the desc, you'll get some info. @Jfolh

Profile icon
JBloves27

Also, you should try est @Jfolh

Profile icon
aCactuar

it could just be me but this happens every time

A

Profile icon
JBloves27

yeah, only some time zones are valid @Jfolh

Profile icon
aCactuar

@JBYT27 then which are so i can use?

Profile icon
ProCatGuy

Um, this is POG and im never coming back.

Profile icon
JBloves27
Profile icon
RhinoRunner
Traceback (most recent call last): File "poggers.py", line 76, in <module> date = datetime.now(tz) NameError: name 'tz' is not defined
Profile icon
JBloves27

?oh. ill fix that @RhinoRunner

Profile icon
JBloves27

it should work now @RhinoRunner

Profile icon
ProCatGuy

@JBYT27 it doesn't work. I says my timezone is wrong and i live in Los Angeles with PST timezone. I will vote on this after bug gets fixed.

Profile icon
JBloves27

Hmmm, ok. Ill try my best, however, because it is a module, i may not be able to fix it @AndrewMarkarian

Profile icon
[deleted]

@JBYT27 Sorry bro, I thought this was another project and you were a different person. Hope u can forgive me....UwU

Profile icon
JBloves27

ig, sure @TheDboi141

Profile icon
dontbanmeplz

It’s broken

Profile icon
JBloves27

oh, sry, im doing something rn @dontbanmeplz

Profile icon
dontbanmeplz

Sorry ofc @JBYT27

Profile icon
JBloves27
Profile icon
Z10n12345

It's giving me an error when I try to create an account...

Traceback (most recent call last):
File "poggers.py", line 59, in
if db[new_username]==new_password:
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/replit/database/database.py", line 169, in get item
raise KeyError(key)
KeyError: 'Z10n12345'
exit status 1

And no, I did not use my username as my password.

Profile icon
JBloves27

yeah, try again, I was kinda experimenting at that time, sry @Z10n12345

Profile icon
SixBeeps
Profile icon
JBloves27

oh, sry, let me fix it @SixBeeps

Profile icon
JBloves27

It should work now (kinda) @SixBeeps

Profile icon
k9chelsea2

noice

Profile icon
JBloves27
Profile icon
[deleted]
Profile icon
JBloves27
Profile icon
[deleted]

@JBYT27
It's really cool, you just gotta get it it there so people can use it.

Profile icon
JBloves27

Thanks! yup! :) @TheDboi141