コード例 #1
0
ファイル: core.py プロジェクト: progrium/yapper
def receivedResult(stream, x):
    for e in x.elements(): 
        if e.name == 'vCard':
            for ee in e.elements():
                if ee.name == 'PHOTO':
                    for eee in ee.elements():
                        if eee.name == 'BINVAL':
                            image = Image.imageWithData(base64.b64decode(str(eee)))
                            if x['from'] in avatar_cache and isinstance(avatar_cache[x['from']], Deferred):
                                avatar_cache[x['from']].callback(image)
                            avatar_cache[x['from']] = image
コード例 #2
0
ファイル: client.py プロジェクト: abi/notify-io
def sendGrowl(notice):
    def notify(notice, icon=None):
        notifier.notify('notify', 
            notice.get('title', ''), 
            notice['text'], 
            sticky=notice.get('sticky', False), 
            icon=icon)
    if 'icon' in notice:
        client.getPage(notice['icon']) \
            .addCallback(lambda x: notify(notice, Image.imageWithData(x))) \
            .addErrback(lambda x: notify(notice))
    else:
        notify(notice)
コード例 #3
0
ファイル: core.py プロジェクト: progrium/yapper
def receivedMessage(stream, x):
    for e in x.elements():
        if e.name == "body" and x.hasAttribute('type') and x['type'] == 'chat':
            message = str(e)
            avatar_result = getAvatar(stream, x['from'])
            if message.strip()[0] == '{':
                message = simplejson.loads(message)
            if type(message) is dict and 'icon' in message:
                getPage(message['icon']).addCallback(lambda x: sendGrowl(message, Image.imageWithData(x)))
            elif isinstance(avatar_result, Deferred):
                avatar_result.addCallback(lambda x: sendGrowl(message, x))
            else:
                sendGrowl(message, avatar_result)