About Archive Tags RSS Feed

 

Entries tagged sift

If you read the TV Guide, you don't need a TV

19 April 2008 21:50

So I've written a quick hack. A client-side filter/utility program for working against IMAP servers.

Consider it a general purpose system which is similar to Procmail, but applied after your remote machine has already done the sorting.

Here's a flavour:


<GMail>
  username somebody.like.me
  password yeah.right
</Gmail>

<Folders>
  <livejournal>
        unread exec /usr/local/bin/notify "Livejournal Comment"
        mark read
  </livejournal>

  <inbox>
        mark read
  </inbox>

</Folder>

What does that do? It first of all logs into GMail with the given username and password, then selects two folders:

=livejournal/

For each unread message in the folder it runs the specified command with STDIN being the message body.

Then it marks each new message as "read".

=inbox/

This simple rule just marks all messages as read.

Why? Well I have a bunch of folders on a bunch of gmail accounts and I don't pay attention to them - but some, specific, mails should result in an SMS being sent to me ... so I need to do something clever.

I'm sure with a bit of effort this could be made IMAP-server independent, and could have a more flexible matching system. The simplicity right now comes about primarily because i dont want to parse a config file.

Anyway, suggestions for potential features are welcome. It does what I need as-is, even if it isn't pretty.

ObQuote: Lost Boys

| 2 comments

 

On the other side of the screen, it all looks so easy

20 April 2008 21:50

I've updated the IMAP utility that I mentioned previously, which has now been given the name sift. It will accept, and process, a much simpler configuration file format keeping state as it goes.

Here's my updated sample file:

username: blah.bah
password: pas.word

#
#  Comments are fine.
#
folder:livejournal status:new subject:temp mark:read exec:~/bin/notify
folder:foo status:new mark:read
folder:bar status:old exec:/usr/local/bin/record delete

Each line consists of a set of tokens, split by whitespace, which is "executed" in order.

So the first line selects the folder "livejournal", finds messages which are "new", then each message containing "temp" in the subject is marked as read, and the program "notify" is executed once for each match.

Essentially we keep a list of messages as "current" as we process each line, that list of messages is then refined as we move through the line. (When a folder is opened all messages are selected by default.)

As a simple example to delete all the messages contained in a folder we'd use this:

folder:foo delete

To refine that to only delete messages from "fred" we'd say:

folder:foo from:fred delete

(If there were no matches the "delete" action wouldn't occur.)

Consider each line of input a collection of filters each operating on the previous result. Simple to understand, simple to extend with more operations, and simple for me to code!

TODO: Add a "move:xxx" to move a message to folder "xxx", and a bit more polish, then release.

ObQuote: Tron.

| No comments

 

I want reliable people, people who aren't going to be carried away

21 April 2008 21:50

OK I'm done with this now, the sift utility has been released.

I think that is a large overlap with imapfilter; but I win because I can write simple rules, rather than any actual code, to perform jobs.

 

In other news I flew my kite today, and I still like eating Pies: Thank God reading Debian Planet isn't mandatory.

ObQuote: The Godfather

| No comments

 

I want to be remembered

26 April 2008 21:50

So I've made a new release of sift, the IMAP client/toy.

I think I named this one after looking up synonyms of "sieve", or "filter". Can't recall now.

The next time I release a toy application, tool, or hack, I will take the time to sit down and write namecheck. (Update: Too easy. Done.)

Here's what it looks like / how it should work:

skx@gold:~$ namecheck namecheck
Testing        freshmeat.net - Available
Testing      sourceforge.net - Available
Testing    alioth.debian.org - Available
Testing      code.google.com - Available
Testing     savannah.gnu.org - Available


Name is currently not claimed

I guess it just comes down to having a list of URLs and patterns to test for:

http://freshmeat.net/projects/%s     | We encounted an error
http://sourceforge.net/projects/%s   | Invalid Project
http://alioth.debian.org/projects/%s | Invalid Project

A tool like that would be useful if you're bad at picking names for projects and want a reasonable chance of uniqueness. Looking up sites by hand is just fiddly and repetitive.

Of course "namecheck" is a provisional title; until it may be used to test that its own name is not in use ;)

Today I shall be mostly smoking, drinking, and trying to fix a dying steam engine. Good times.

ObQuote: Brief Encounter

Update: Quick hack: namecheck | future home in ~/bin/.

| 14 comments

 

I know how to make a Holy Bartender

30 July 2008 21:50

I've made a new release of my sift IMAP utility, which now adds a few new types of rules:

  • Match message bodies against regular expressions.
  • Match recipients against regular expressions.

All the "searching" rules now allow negation too, so that "from:foo@bar.com" and "!from:foo@bar" work as you'd expect.

Finally each of the searching rules, which require the download of the complete IMAP message, will use a local disk-cache to avoid undue overhead.

All in all I'm pretty pleased with the way the tool is being used in the wild. Each of these changes were the result of a direct user request, or suggestion.

ObMovie: Dogma

| No comments