[cvs-annodex] commit (/annodex): scripts/trunk/ircCMMLBot.py
conrad
nobody at lists.annodex.net
Wed Feb 23 15:44:30 EST 2005
Update of /annodex (new revision 925)
Modified files:
scripts/trunk/ircCMMLBot.py
Log Message:
+ add #!/usr/bin/env python (as suggested by spiv)
+ add Z to end of zulu clock timestamps
+ put user's nick in <meta name="DC.Contributor" .../>
Modified: scripts/trunk/ircCMMLBot.py
===================================================================
--- scripts/trunk/ircCMMLBot.py 2005-02-23 01:52:01 UTC (rev 924)
+++ scripts/trunk/ircCMMLBot.py 2005-02-23 04:44:29 UTC (rev 925)
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+#
# ircCMMLBot.py
# Copyright (C) 2004 CSIRO Australia
#
@@ -71,7 +73,7 @@
self.file.write('<head/>\n')
def gettimestamp(self):
- timestamp = time.strftime("clock:%Y%m%d%H%M%S", time.localtime(time.time()))
+ timestamp = time.strftime("clock:%Y%m%d%H%M%SZ", time.localtime(time.time()))
return timestamp
def log(self, message):
@@ -80,6 +82,15 @@
self.file.write('<clip start=\"%s\"><desc>%s</desc></clip>\n' % (timestamp, message))
self.file.flush()
+ def user_log(self, user, message):
+ """Write a user message to the file."""
+ timestamp = self.gettimestamp()
+ self.file.write('<clip start=\"%s\">' % timestamp)
+ self.file.write('<meta name=\"DC.Contributor\" content=\"%s\"/>' % user)
+ self.file.write('<desc>%s</desc>' % message)
+ self.file.write('</clip>\n')
+ self.file.flush()
+
def close(self):
self.file.write('</cmml>\n')
self.file.close()
@@ -117,12 +128,13 @@
def privmsg(self, user, channel, msg):
"""This will get called when the bot receives a message."""
user = user.split('!', 1)[0]
- self.logger.log("%s: %s" % (user, msg))
+ #self.logger.log("%s: %s" % (user, msg))
+ self.logger.user_log(user, msg)
if msg.startswith("%s:" % self.nickname):
# someone is talking to me, lets respond:
msg = "%s: I am a CMML log bot" % user
self.say(channel, msg)
- self.logger.log("<%s> %s" % (self.nickname, msg))
+ self.logger.user_log(self.nickname, msg)
def action(self, user, channel, msg):
"""This will get called when the bot sees someone do an action."""
--
conrad
More information about the cvs-annodex
mailing list