Have you ever had a moment when you desperately needed to talk to someone in the middle of lesson, on the other side of the classroom? Or want to escape from being bored to death in a Computer Science lesson? Well, worry no more.
Welcome to ChitChat – a simple open source chat application in python.
I had this sudden idea of a chat application but for it to be usable in the school environment, I needed to create it differently. On the internet, many people have already written chat applications in python, using sockets but this meant that a server script had to be always running, so that the clients can connect to it. Also, I am not very experienced in socket programming so this wasn’t an option.
I wrote it so that students can talk to each other during lessons, assuming they all had a computer with python installed. However, everybody can use it, anywhere in the world!
Usually, all social media sites are locked down at school however, ChitChat is a simple python program, where whoever wants to chat, just has to run it.
My solution was to send and fetch messages from a gmail account. So lets get started.
To set up ChitChat, you will need to create a new gmail account, as you will need to write your username and password in a simple python script, which is not very secure.
After doing so, you will need to enable IMAP in the gmail settings and allow access from insecure apps, which can be done here. Don’t worry – Google just thinks that the connection between the python script and gmail servers as unsecure.
That’s it! Now, you will need to download my script from here and enter your new username and password in the script – this will be self-explanatory.
Here is a break down of how the script works:
- A new thread is started which fetches new messages from your Inbox, every second, and updates the GUI
- When you send a message, an email containing the message and the username, is sent to your email account
- This means that anyone running the script can send a message, with their username (the account logged into the computer), and this message will update on all the tkinter interfaces
- All messages are sent and fetched from one gmail account – the one you configured – so it is easy to see what anyone has written at any time and date
This way, no server script needs to be running, however a reasonably fast internet connection is required for it to be usable.
You will just need to distribute the script, with your account details, or put it in a shared folder where everybody can access it. I also suggest compiling it so that the account details are hidden. Note that this can be decompiled so it is not secure.
The people should be recognisable from the account names, logged into the computer, but this shouldn’t be a problem if being used in schools as they usually set the usernames in a similar format. This can be used from anywhere in the world, as long as you have an internet connection.
NOTE: Use at your own risk! I will take no responsibility for any detentions or comments! 😀
Have fun ChitChatting! Please post comments or questions below.