Finally the irc bot can save the channel’s logs

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 😉

Advertisements

Let’s make an irc Bot using Python

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.

fhacdroidsanketdgtrishna_gAbhishekArora (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 git@github.com:SanketDG/batuli.git
  • pip install -r requirements.txt
  • python main.py

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 🙂