LogBot
This is a simple Python based IRC logging bot I have created using python-irclib and released under the GPL. Logbot logs multiple IRC channels and stores them into separate directories for each channel with logs split by date. It also supports FTP uploading of the files if you wish to run the bot locally. Upload activity is based upon a number of public messages received since last upload. The more channels the bot is in, the higher this limit should be as multiple channels will likely have much more activity. Once the logs overall have achieved that amount of public messages, Logbot will FTP the information if enabled and continue logging.
Instead of hosting the code here on wordpress I have moved it over to my Bitbucket account to keep it under version control and encourage others to fork and improve it.
Known Bugs:
- If the date changes the last few messages may not be uploaded to the FTP because the bot will upload the current date’s file only. Small design issue at the moment. Will fix soon.
- Not 100% sure, but messages might not be logged if FTP takes a while.
Download: http://github.com/excid3/logbot/downloads
Source: http://github.com/excid3/logbot
Includes Python-IRCLib.
Hi, any way to allow it to publish the logs onto your local hard disk, ie running this on a server?
Sure, if you take a look at line 52:
f = open(strftime("%m-%d-%Y"),'a')This line determines the filename of the output file. It is named Month-Day-Year basically. If you wanted this to go to a certain folder:
f = open('' + strftime("%m-%d-%Y"),'a')so you can just replace with something like
../excid3.com/logs/to get:f = open('../excid3.com/logs/' + strftime("%m-%d-%Y"),'a')Depending on your host, if the script was run from your home dir, then this would put it into the website’s logs dir. Also, you would want to comment line 65 to stop it from uploading. Those would be the only 2 changes you would need to make and you should be good to go.
Oh cool, works nice. Only thing that I dislike is if the network connection dies/disconnects, the script just infinite loops there
Ah, I had not tested that. I would have assumed that if it got disconnected it would drop out of the loop but i guess not.
This is just something I threw together in an hour one night for fun. When work lets up a bit and I get back on highspeed internet I’d like to add multi-server/channel and other things to it and some other things.
Wow… You created this JUST in time…
I would like to request one thing: Can you add support for joining multiple channels?
Oh nevermind just add a comma!
Okay sorry for flooding … now if only we can distinguish the different channels (like a few different logs) instead of logging them all to one log file… can we log them all to different files?
like 9-10-2009WELCOME 9-10-2009BOTS
for #WELCOME and #bots
No problem for the flooding, I was free tonight so I went ahead and made the modifications you requested. Enjoy!
Channels are logged locally to logs/channel/channel_date.log now. They are uploaded to the server to the specified directory in the same manner.
But I am not going to ask for anything else.. I love it! Its wonderful!
Thanks, I also packaged it in a nice little tar.gz download that includes python-irclib so you don’t have to manually download and install anything anymore.
EDIT: Okay, I added another variable at the beginning that allows you to select text or html output. Text output goes to .log files as plain text and html goes to html files with br tags at the end of each line so it displays properly. There’s no special formatting done on anything, but at least it displays properly in html. Download tarball and code are up to date with the latest revision.
Hey chris, where is the formatting located so we can spruce it up?
Line 72 is what works with creating HTML output. You can add different tags to wrap the outputs.
[...] who is interested. Source code for the IRC bot can be found on my blog’s project page at http://excid3.com/projects/logbot. Enjoy! [...]