From 01a5963fadcfd6889b6a66836038f92343875cbb Mon Sep 17 00:00:00 2001 From: Christian Pierre MOMON Date: Sat, 15 Oct 2016 03:41:54 +0200 Subject: [PATCH] Added timestamp to log. Added start message. --- bot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) mode change 100644 => 100755 bot.py diff --git a/bot.py b/bot.py old mode 100644 new mode 100755 index 18e16c7..bd256e4 --- a/bot.py +++ b/bot.py @@ -1,9 +1,10 @@ +#!/usr/bin/python # -*- coding: utf-8 -1 -*- # Welcome to WelcomeBot. Find source, documentation, etc here: https://github.com/shaunagm/WelcomeBot/ Licensed https://creativecommons.org/licenses/by-sa/2.0/ # Import some necessary libraries. -import socket, sys, time, csv, Queue, random, re, pdb, select, os.path +import socket, sys, time, csv, Queue, random, re, pdb, select, os.path, datetime from threading import Thread # To configure bot, please make changes in bot_settings.py @@ -82,7 +83,7 @@ def join_irc(ircsock, botnick, channel): def msg_handler(ircsock): # pragma: no cover (this excludes this function from testing) new_msg = ircsock.recv(2048) # receive data from the server new_msg = new_msg.strip('\n\r') # removing any unnecessary linebreaks - print(new_msg) #### Potentially make this a log instead? + print(datetime.datetime.now().isoformat() + " " + new_msg) #### Potentially make this a log instead? return new_msg # Called by bot on startup. Builds a regex that matches one of the options + (space) botnick. @@ -236,6 +237,7 @@ def pong(ircsock, ircmsg): ########################## def main(): + print datetime.datetime.now().isoformat() + " WelcomeBot starting…" ircsock = irc_start(settings.server) join_irc(ircsock, settings.botnick, settings.channel) WelcomeBot = Bot()