Added timestamp to log. Added start message.

april-welcomebot
Christian P. MOMON 6 years ago committed by root
parent c9d4a64dac
commit 01a5963fad
  1. 6
      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()

Loading…
Cancel
Save