And while I'm thinking of all things blather, I've been meaning to post this new version of the blather code for a week or two. This version is just a small refactor which allows for random other python scripts to import blather.py and put messages into the stream of messages to be posted online.
You can find the source here. A sample program to place messages into the blather stream is:
#!/usr/bin/python
import feedparser
import os
import shelve
import sys
plugins_dir = '%s/plugins' % os.getcwd()
print 'Appending %s to module path' % plugins_dir
sys.path.append(plugins_dir)
import blather
data = shelve.open('fetchshared.slf', writeback=True)
ds = blather.DataStore()
changed = False
for feed in data['feeds']:
data.setdefault('guids', {})
data['guids'].setdefault(feed, [])
print
print 'Fetching %s' % feed
d = feedparser.parse(feed)
for ent in d.entries:
if ent.guid not in data['guids'][feed]:
post = ('Mikal shared: <a href="%s">%s</a>'
%(ent.link, ent.title))
print post
ds.AddMessage(post)
data['guids'][feed].append(ent.guid)
changed = True
if changed:
ds.Save()
data.close()
Too easy.
Tags for this post: blather(
posted at: 00:50 | path: /blather | permanent link to this entry
