def fetch(obj): global seen counter = 0 for o in get_feed(obj.rss): if o.link in seen.list: continue seen.list.append(o.link) s = slice(o, cfg.rss.keys_list) s.services = "rss" s.prefix = "feeds" s.short = short_date(time.ctime()) if not matching(cfg.rss.nosave, o.link): s.save() for bot in fleet: bot.announce(display(s)) counter += 1 return counter
def mbox(event): if not event.args: return fn = os.path.expanduser(event.args[0]) nr = 0 try: object = mailbox.Maildir(fn, create=False) except: try: object = mailbox.mbox(fn, create=False) except: event.reply("need a mbox or maildir.") ; return for m in object: o = Object() o.update(m.items()) try: sdate = os.sep.join(short_date(o.Date).split()) except AttributeError: sdate = None o.text = bytes() for load in m.walk(): if load.get_content_type() == 'text/plain': o.text += load.get_payload(decode=True) o.text = str(o.text, "latin-1") o.prefix = "email" if sdate: o.save(sdate) else: o.save() nr += 1 event.ok(nr) return nr