#!/usr/bin/env python3 'whits.py - by Sean B. Palmer' import sys, os, re, time, getopt import irc3, stream title = 'Gallimaufry of Whits' uri = 'http://inamidst.com/whits/' tag = 'tag:inamidst.com,2006:whits' author = 'Sean B. Palmer' nick = 'sbp' botnick = 'whitsbot' server = 'irc.freenode.net' channel = '#whits' os.chdir('/Users/sbp/web/inamidst.com/www/whits') def process(text): separator = text == '%%' replacement = text.startswith('sub: ') regular = not (separator or replacement) if regular: add_to_homepage(text) elif separator: entry = create_homepage_entry() add_to_feed(entry) elif replacement: substitute_item(text) def nextlabel(line): if not 'class="' in line: return 'a' a, b = line.split('class="', 1) prior = b.split('"', 1)[0] def next(label): if label.endswith('z'): return next(label[:-1]) + 'a' else: return label[:-1] + chr(ord(label[-1]) + 1) return next(prior) def hypertext(text, label): r_hyperlink = re.compile(r'\{([^}]+) (http://[^ }]+)\}') text = r_hyperlink.sub(r'\g<1>', text) return '
%s
' % (label, text) def add_to_homepage(text): with stream.Stream('index.html') as index: def create(text): index.write('