예제 #1
0
파일: pynotif.py 프로젝트: grodzik/pynotif
def displayNotify(title, text, timeout, type):
    """
    Sends notification to dbus org.freedesktop.Notifications service using
    pynotify python library.
    """
    if not pynotify.init("EkgNotif"):
        ekg.echo("you don't seem to have pynotify installed")
        return 0
    if ekg.config["notify:catch_url"] != "0":
        l = catchURL(text)
        if l[0]:
            text = l[1]
            timeout = int(ekg.config["notify:catch_url_timeout"])
    n = pynotify.Notification(title, text, type)

    n.set_timeout(timeout)
    n.set_urgency(getUrgency(title, text))

    # Most probably glib.GError is:
    # The name org.freedesktop.Notifications was not provided by any
    # .service files
    # Catch this exception and print information in debug window.
    # Sometimes I
    # do not have org.freedesktop.Notifications registered and
    # I do not want
    # error messages in chat window.
    # Or logs buffer has overflowed ;/
    try:
        n.show()
    except glib.GError as e:
        ekg.debug("pynotif: " + str(e))

    return 1
예제 #2
0
파일: sample.py 프로젝트: 11mariom/ekg2
def own_message_handler(session, target, text):
    ekg.debug("[test script] some debug\n")
    ekg.echo("Wysy³am wiadomo¶æ!")
    ekg.echo("Sesja : "+session)
    ekg.echo("Target: "+target)
    ekg.echo("TxtLen: "+str(len(text)))
    return 1
예제 #3
0
파일: sample.py 프로젝트: mati75/ekg2
def own_message_handler(session, target, text):
    ekg.debug("[test script] some debug\n")
    ekg.echo("Wysy³am wiadomo¶æ!")
    ekg.echo("Sesja : " + session)
    ekg.echo("Target: " + target)
    ekg.echo("TxtLen: " + str(len(text)))
    return 1
예제 #4
0
파일: sample.py 프로젝트: 11mariom/ekg2
def message_handler(session, uid, type, text, sent_time, ignore_level):
    ekg.debug("[test script] some debug\n")
    ekg.echo("Dosta³em wiadomo¶æ!")
    ekg.echo("Sesja : "+session)
    ekg.echo("UID   : "+uid)
    if type == ekg.MSGCLASS_MESSAGE:
	ekg.echo("Typ   : msg")
    elif type == ekg.MSGCLASS_CHAT:
	ekg.echo("Typ   : chat")
    ekg.echo("Czas  : "+time.strftime("%a, %d %b %Y %H:%M:%S %Z", time.gmtime(sent_time)))
    ekg.echo("Ign   : "+str(ignore_level))
    ekg.echo("TxtLen: "+str(len(text)))
    if len(text) == 13:
	ekg.echo("Oj, ale pechowa liczba, nie odbieram")
	return 0
    return 1
예제 #5
0
파일: sample.py 프로젝트: mati75/ekg2
def message_handler(session, uid, type, text, sent_time, ignore_level):
    ekg.debug("[test script] some debug\n")
    ekg.echo("Dosta³em wiadomo¶æ!")
    ekg.echo("Sesja : " + session)
    ekg.echo("UID   : " + uid)
    if type == ekg.MSGCLASS_MESSAGE:
        ekg.echo("Typ   : msg")
    elif type == ekg.MSGCLASS_CHAT:
        ekg.echo("Typ   : chat")
    ekg.echo("Czas  : " +
             time.strftime("%a, %d %b %Y %H:%M:%S %Z", time.gmtime(sent_time)))
    ekg.echo("Ign   : " + str(ignore_level))
    ekg.echo("TxtLen: " + str(len(text)))
    if len(text) == 13:
        ekg.echo("Oj, ale pechowa liczba, nie odbieram")
        return 0
    return 1
예제 #6
0
파일: pynotif.py 프로젝트: grodzik/pynotif
def notifyMessage(session, uid, type, text, stime, ignore_level):
    """
    Display message notifications, but first check if message notifications
    are enabled, then check if session and uids match
    ignore_{sessions,uids}_regexp.

    This function is bound to protocol-message handler
    """
    if ekg.config["notify:message_notify"] == "0":
        return 1
    if (ekg.config["notify:ignore_sessions_regexp"]):
      regexp = re.compile(ekg.config["notify:ignore_sessions_regexp"])
      if regexp.match(session):
          return 1
    if (ekg.config["notify:ignore_uids_regexp"]):
      regexp = re.compile(ekg.config["notify:ignore_uids_regexp"])
      if regexp.match(uid):
          return 1
    sesja = ekg.session_get(session)
    try:
        user = sesja.user_get(uid)
    except KeyError:
        ekg.debug("Nie znalazlem uzytkownika %s." % uid)
        user = "******"
    if user == None:
        user = "******"
    if user == "Empty" and ekg.config["notify:message_notify_unknown"] == "0":
        return 1
    if user == "Empty":
        user = uid
    else:
        user = user.nickname
    try:
        title = user
    except KeyError:
        title = uid
    if (ekg.config["notify:show_timestamps"] == "1"):
        title = time.strftime("%H:%M:%S", time.localtime(stime)) + " " + title
    text = removeTextFormatting(text)
    text = parseMeCommand(text, user)
    if len(text) > 200:
        text = text[0:199] + "... >>>\n\n"
    return displayNotify(title, text, TIMEOUT_MSG, ekg.config["notify:icon_msg"])
예제 #7
0
파일: pynotif.py 프로젝트: grodzik/pynotif
def notifyStatus(session, uid, status, descr):
    """
    Display status change notifications, but first check if status change
    notifications are enabled, then check if session and uids match
    ignore_{sessions,uids}_regexp.

    This function is bound to protocol-status handler
    """
    if ekg.config["notify:status_notify"] == "0":
        return 1
    if (ekg.config["notify:ignore_sessions_regexp"]):
      regexp = re.compile(ekg.config["notify:ignore_sessions_regexp"])
      if regexp.match(session):
          return 1
    if (ekg.config["notify:ignore_uids_regexp"]):
      regexp = re.compile(ekg.config["notify:ignore_uids_regexp"])
      if regexp.match(uid):
          return 1
    regexp = re.compile('.*' + session + '.*')
    if regexp.match(uid):
        ekg.debug("Zmienil sie status sesji: %s. Nie zostal on zmieniony przez ten program. Sprawdz to, jesli nie zmieniales statusu jakims innym programem" % session)
        return 1
    sesja = ekg.session_get(session)
    regexp = re.compile('([a-z]{2,4}:[^/]+)')
    regexp = regexp.match(uid)
    regexp = regexp.group()
    try:
        user = sesja.user_get(regexp)
    except KeyError:
        ekg.debug("Nie znalazlem uzytkownika %s." % uid)
        user = "******"
    status = transStatus(status)
    if user == "Empty":
        nick = regexp
    else:
        nick = user.nickname or user.uid or "Empty"
    s = status or "Empty"
    s = removeTextFormatting(s)
    text = "<b>" + nick + "</b> zmienil status na <b>" + s + "</b>"
    if descr:
        descr = removeTextFormatting(descr)
        text = text + ":\n" + descr + "\n"
    return displayNotify(session, text, TIMEOUT_STATUS, ekg.config["notify:icon_status"])