Beispiel #1
0
def listen_cb(client, nick, msg, **kw):
    """
    Handle pumping a message out.
    """
    msg = expand(nick, msg)
    client.broadcast(msg, **kw)
    for listener in Listener.filter(listening=True):
        name = listener.listener
        if nick != name and name.lower() in client.online_players:
            client.whisper(name, msg)
Beispiel #2
0
def listen(client, nick, crawler):
    """
    .listen [true|false|yes|no] -- Set/get your listening status.
    """
    text = crawler.chain
    do_listen = text[0].lower() in 'yt' if text else None
    
    listener = Listener.get(listener=nick)
    if not listener:
        do_listen = False if do_listen is False else True
        Listener(dict(listener=nick, listening=do_listen)).add()
    elif do_listen is None:
        do_listen = listener.listening
    else:
        listener.listening = do_listen
    
    get_connection().commit()
    close_connection()
    
    return 'You are%s listening.' % ('' if do_listen else 'n\'t')