#! /usr/bin/env python

from time import gmtime, strftime
from foaas import foaas
from diaspy_client import Client

import re
import urllib2

client = Client()
notify = client.notifications()
for n in notify:
  if not n.unread: continue
  idm = re.search('href=\\"/posts/(\d+?)\\"', n._data['note_html'])

  if hasattr(idm, 'group'):
    post_id = idm.group(1)
    text = client.getPostText(post_id)
    m = re.search('^\s*\@\{[^\};]+;[^\};]+\}\s+(\/.+?)$', text)
    if hasattr(m, 'group'):
      try:
        command = m.group(1)
        client.post(foaas(command))
      except urllib2.URLError:
        client.comment(post_id, "Fuck this! Something went wrong :\\")

  # mark as read if it
  # is not a mention
  n.mark()

client.logout()

#! /usr/bin/env python

from time import gmtime, strftime
from foaas import foaas
from diaspy_client import Client

import re
import urllib2

client = Client()
notify = client.notifications()
for n in notify:
  if not n.unread: continue
  idm = re.search('href=\\"/posts/(\d+?)\\"', n._data['note_html'])

  if hasattr(idm, 'group'):
    post_id = idm.group(1)
    text = client.getPostText(post_id)
    m = re.search('^\s*\@\{[^\};]+;[^\};]+\}\s+(\/.+?)$', text)
    if hasattr(m, 'group'):
      try:
        command = m.group(1)
        client.post(foaas(command))
      except urllib2.URLError:
        client.comment(post_id, "Fuck this! Something went wrong :\\")
    else:
      client.comment(post_id,
        "Fuck this! Your command is not well-formed.\n"
        "Check my profile description or "
        "[fuck around with him...](/posts/0f99d95040130133bbca14dae9b624ce)")

  # mark as read if it
  # is not a mention
  n.mark()

client.logout()

Add helper on not-well-formed commands