If you are a terminal geek you will always want to do things using terminal ;). And when it comes to Atomic host, YES you will have to do stuffs using terminal.
If you don’t know about Atomic, you must visit http://www.projectatomic.io 🙂
This post will describe how to setup and use IRC client on Atomic host. This will be applicable for any Cloud host also.
Irssi is a terminal based IRC client for Unix/Linux systems. And the best part is we will not need to setup things manually because we have containers :).
Let’s Get Stared:
I am using Fedora Atomic host here. Get Fedora atomic host from here: https://getfedora.org/en/cloud/download/atomic.html
Make Sure you have Docker installed.
Copy the Dockerfile from here: https://github.com/trishnaguha/Fedora-Dockerfiles/blob/irssi/irssi/Dockerfile
docker build -t username/irssi .This will build image.
There after you just need to run the container 🙂
docker run -it username/irssi.
Later on sometime you will be able to do the whole set up only
docker run -it fedora/irssi once Fedora adds Irssi to its Docker hub :).
After you start the container you will see something like this:
Let’s join a channel
You will find the Irssi Commands here: Irssi Commands.
Finally batuli can save the channel’s logs. I can still remember the very first day when I and sanketdg joined the irc channel ##testbot to work for irc bot batuli and I asked sanketdg “Won’t batuli save the logs of the channel as batul does for dgplug?” , sanketdg replied to me “Make it save the logs if you can!”.
I couldn’t ever imagined that making batuli save the logs of the channel could be done in so simple way. Ah yes, I spent my days studying about logging module and twisted log module. And i took help of twisted log module to make batuli save the channel’s log and sent a pull request. But sanketdg told me to make it simple and he suggested me to use logging module, yes he was pretty correct. The script was looking pretty complex. Hence I started working with logging module. On the next morning suddenly an idea came to my mind. I asked myself that why I am using these logging modules to save the channel’s log, I also have other options in Python . Because, Python is such a programming language with what you can do just anything. Coding in Python is nothing but playing with it 😉 . And what I did is just append the message of user to a file. There couldn’t be any simpler way to make your bot save the logs. Let me share it with you 🙂
with open(args.filename,'a') as fobj:
fobj.write('\n' + time.strftime('[%d-%m-%Y %H:%M:%S]') + \
' <' + user + '> ' + msg)
To take command line argument, I have used argparse module instead to sys module to make the command line interface more interactive with user and it was an idea of sanketdg 🙂
So I am really happy that batuli now saves the logs of ##testbot. Join our channel ##testbot on irc.freenode . Fork us on github . Follow README section to know how to use batuli , just give it a try and I am sure that you will love it 😉
The idea came from fhacdroid and SanketDG when we were talking about bots in dgplug. The bot named batul made by dgplug masters works brilliant. Being inspired from this we have also decided to make a bot using Python.
The first initiative was taken by SanketDG. He named a bot batuli. We have just started working on it using Python.
fhacdroid, sanketdg, trishna_g, AbhishekArora (names given as irc nicks) are the current members of this project. We have created a channel for testing bot. On freenode you are free to do /join ##testbot and contribute to this project to make this a better one. You can fork it from here. You can also send pull requests to batuli on github. We are experimenting with various kind of bots in ##testbot. This is really very exciting. We are having too much fun with testing the bots.
To run batuli do the following steps in terminal
git clone firstname.lastname@example.org:SanketDG/batuli.git
pip install -r requirements.txt
We need a lot of modifications for this bot. We have just started 2 days ago. You are welcome to leave comments if you have any doubt/question. Happy to share with you 🙂
Yes, we should spend more time on IRC. Folks share their knowledge there. They come up with their doubts and problems; and I go with mine even if it is not the session time. So there is always a session no matter it’s a formal one or informal one. It’s actually about learning from each other at each and every time.
Well coming to my point, finally there was a midnight informal session from dgplug like they used to do some years before.
We usually have session at 18:30 IST in dgplug. I opened an pull request with three commits in pym. Kushal informed me this evening that I have to remove the last commit as it was not a correct one. Being a beginner to github , what I did is delete the changes from the original file in my local pc, commit and push it again to my own repo and open another pull request to pym again . Hence it results another new commit i.e, the fourth one. And I was stuck here. I became pretty confused since I couldn’t remove the third commit which was also followed by a fourth one, where as Kushal has told me to remove the third commit and do a pull request with only first and second commit.
Thus I pinged Kushal in irc and he told Sayan to help me to solve this. It became quite easy to me when Kushal , Sayan and some other folks in dgplug helped me. So what I did
git reset --hard HEAD~2 #Head is now at the second commit, Deletes last two commits
git push origin master -f #This a forced push, PR is updated automatically
This has removed the last two commits finally!
There after, Sayan took an informal hands on session on github to understand git properly. It was really a useful one. Hence we understood why people should spend more time on IRC. It has been a wonderful midnight session 🙂