[cvs-annodex] commit (/annodex): scripts/trunk/ircCMMLBot.py

conrad nobody at lists.annodex.net
Wed Feb 23 18:35:11 EST 2005


Update of /annodex (new revision 932)

Modified files:
   scripts/trunk/ircCMMLBot.py

Log Message:
grep for urls in said messages, and generate <a href="..."/> elements for
them.


Modified: scripts/trunk/ircCMMLBot.py
===================================================================
--- scripts/trunk/ircCMMLBot.py	2005-02-23 06:33:51 UTC (rev 931)
+++ scripts/trunk/ircCMMLBot.py	2005-02-23 07:35:11 UTC (rev 932)
@@ -83,6 +83,16 @@
 	self.file.write('</head>\n')
 	self.got_head = True
 
+    # Totally dodgy URL grabber, probably ok enough for grabbing urls from
+    # irc ... Amazing technique as used by Plone, so it must be good ;-)
+    # This version has been improved by including gopher://
+    def grabURL(self, message):
+        for w in message.split():
+	    for scheme in ['http://', 'https://', 'ftp://', 'gopher://']:
+	      if (w.startswith (scheme)):
+	        return w
+	return None
+
     def log(self, message):
         """Write a message to the file."""
 	if (not self.got_head):
@@ -100,10 +110,14 @@
 	    return
 
         timestamp = self.gettimestamp()
+	url = self.grabURL(message)
         message = escape(message)
-        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('\n<clip start=\"%s\">' % timestamp)
+	self.file.write('<meta name=\"DC.Contributor\" content=\"%s\"/>\n' % user)
+	if (url is not None):
+	    self.file.write('<a href=\"%s\">%s</a>\n' % (url, url))
+	self.file.write('<desc>%s</desc>\n' % message)
 	self.file.write('</clip>\n')
         self.file.flush()
 


-- 
conrad



More information about the cvs-annodex mailing list