Keeping your irccloud client always connected for free
Update 02/Jan/2020 : The issue with heroku scheduler which required a credit card has been circumvented with a newer version of the script. Make sure you pull to the latest version.
If you are a Programmer involved in any sort of open source technology (either as a user of the technology / developer of the technology itself), you definitely know about IRC. The popular opinion among many IRC fans who are also Linux fans was that you don’t need a browser based client for chatting in IRC. This opinion has shifted heavily in the past few years (thanks to IRC Cloud). There was not much interest in a cloud based / browser based IRC client because there was no cloud based IRC client and no good browser based client. Many users were running their own bouncers like ZNC and either using desktop clients like hexchat / terminal based clients like weechat or irssi.
A lot has changed in the past few years though. Due to the popularity of smartphones (especially android), there was a big hole for a good overall irc client and IRC cloud filled that one pretty nicely. They have a very nice and stable android application. IRCCloud
Their web based client is also awesome and it is completely cloud based with features like log retention, theming, emoji’s, inbuilt code pasting and so many more features. IRCCloud
There was a minor setback for free users though. In order to stay connected, you have to keep your client open all the time. If you idled for more than 2 hours, then you will be disconnected automatically. Many developers that i know hardly ever chat and usually just read the logs. They occasionally jump in when they think they can solve another programmers problem. This was the major reason why bouncers like ZNC were written. If you want to circumvent this 2 hour idle limit, you have to pay 50 dollars every year. I know a lot of programmers who can’t afford to pay that. The 50 dollars per year would definitely give you a lot more features though.
Unlimited networks (in free plan, you only get 2 networks other than irccloud network)
Unlimited log retention
Accessing passworded servers (there are ways to circumvent this too. But we won’t go into that since its unfair to irccloud)
Mostly people just idle in freenode and oftc and do not really care about unlimited networks. Unlimited log retention does sound good, but it is not really a feature that i desire a lot (while some may need this).
Before i proceed any further, i would like to state this very clearly :
If you are an end user who can afford to pay 50$ per year, then please do so and help a company like IRC Cloud stay alive forever. Because they deserve every single penny!
You can read this article further if you are under the umbrella of one / multiple scenarios listed below :
You are a student.
You come from a developing country and you can’t afford to pay.
You only use 1 or 2 networks and feel that your money can be used for something else productive (you could perhaps donate that money to a open source project 😃).
Only thing you will need is a free heroku account and a Linux machine with python installed (probably if you wanted to run it locally / on your server / even for testing). If you do not have a heroku account, you can sign up for one here. Heroku
Heroku already has a Python 3.7 runtime available. Hence you do not have to do any pesky workarounds for making it work. If you do not have heroku tool belt installed in your Linux machine, you can follow the instructions here. Heroku CLI
Once you have heroku toolbelt installed, do the following.
WARNING: Tutorial is written in a very detailed and elaborate manner for helping beginners.
Open a terminal and login to your heroku account by entering the command
It will prompt you to enter your username and password. Once you do that, you are successfully logged in to your heroku account.
Clone the Repository
I have put together the entire application in a public github repository. So the next step is to clone the repository to your machine locally.
git clone https://github.com/vijaiaeroastro/irccloud.git
After you have cloned the repository, you can switch to the repository using the following command.
You should see a list of files as shown below.
IRC Cloud Repository (Files listing)
There is no need to edit any of these files. The only thing you have to do is include your irccloud credentials. There are many ways to do this. You could be straightforward and include it in the program directly. But it is never a good practice to include credentials in your code. Thankfully, heroku provides us a very easy to do this in a safer manner. Heroku config vars allows us to do this in a very easy manner. You can read this article for more info.
Create a Heroku Application
As of now, we have a git repository cloned in our local machine. Heroku also version control, it makes use of git. But we have set the remote url of the repository to a heroku application. Let us create a heroku application first.
The above command will create a new heroku application and assign a random name to it. This command would also switch the remote of the current application to a heroku based git repository.
Configure the application
Now we have to add our irccloud credentials to the application. As i previously mentioned, heroku configvars is an excellent way to do this. You can set your irc cloud email and password as follows:
heroku config:set IRCCLOUD_USERNAMEfirstname.lastname@example.org heroku config:set IRCCLOUD_PASSWORD=password123
Make sure to replace the username and password in the above code. This will set the required configuration variables in your heroku account. You can check the same in your heroku dashboard (settings section).
IRC Cloud credentials in Heroku Configvars
Push the application
Now that we have our entire application ready. Push the application to heroku with the following set of commands :
git add -A git commit -m "First push" git push heroku master
This will push the application to heroku server and deploy it automatically. The important thing you have to do after pushing the application is to assign a worker to it. Heroku typically allows you to assign a free worker to every and any application. The process of running the script every 10 minutes was the first approach i took. Unfortunately if you are on heroku, it will eat up all of your free dyno hours very quickly. Hence i have made some changes to the script so that it runs as a one off dyno and it is executed only once in an hour. IRC Cloud gives you an idle time of 2 hours anyway. Hence, you may run it once in an hour and it would still work just fine. It was brought to my attention recently though that the use of heroku’s scheduler add on required people to add a credit card. Since this was a major bottleneck, i am reverting back to the older workflow. However, instead of running every 10 minutes and only run it once using a nifty python library called Timeloop from a fellow medium author.
heroku ps:scale worker=1
After sometime (exactly an hour later), you can check the logs of your application with the following command:
IRC Cloud Heroku logs
You must have noticed that the Timeloop library creates a main master thread for management and starts running the script every hour. Now you can make sure your IRC Cloud client never disconnects from your favorite IRC Networks.
I also request my readers to point me to a reliable free API that can give me a random user agent or a list of random user agents to play with. I know that i can scrape and create my own list but i do not have the time to do this these days. I would appreciate it if someone can leave the info in comments. Thanks in advance :)
Disclaimer : None of the api calls used in the application are illegal / reverse engineered. They have all been taken from irccloud’s RPC calls documentation posted publicly in github (https://github.com/irccloud/irccloud-tools/wiki).