def connect_handler(session): ekg.echo("Sesja : " + session) sesja = ekg.session_get(session) if sesja.connected(): ekg.echo("Połączony! Silnik i sto turbin poszło w ruch! :)") else: ekg.echo("W tym miejscu jeszcze nie połączony")
def status_handler(session, uid, status, desc): # for sesja in ekg.sessions(): # if sesja.connected(): # ekg.echo("sesja '%s' po³±czona" % (name,)) # ekg.echo("status: "+sesja['status']) # else: # ekg.echo("sesja '%s' nie jest po³±czona" % (name,)) ekg.echo("Dosta³em status!") ekg.echo("Sesja : "+session) ekg.echo("UID : "+uid) ekg.echo("Status: "+status) if desc: ekg.echo("Opis : "+desc) sesja = ekg.session_get(session) # ekg.echo('Lista userów sesji: '+", ".join(sesja.users())) user = sesja.user_get(uid) if user.last_status: ekg.echo(str(user.last_status)) stat, des = user.last_status ekg.echo("Ostatni status: "+stat) if user.last_status[1]: ekg.echo("Ostatni opis : "+des) else: ekg.echo("Nie ma poprzedniego stanu - pewnie dopiero siê ³±czymy...") if user.ip: ekg.echo("IP: "+user.ip) if user.groups: ekg.echo("Grupy: "+", ".join(user.groups())) if status == ekg.STATUS_AWAY: ekg.echo("Chyba go nie ma...") if status == ekg.STATUS_XA: ekg.echo("Chyba bardzo go nie ma, to na grzyb mi taki status?. Po³ykam. *¶lurp*") return 0 return 1
def connect_handler(session): ekg.echo("Po³±czono! Ale super! Mo¿na gadaæ!") ekg.echo("Sesja : "+session) if session[:3] == 'irc': struct = time.gmtime() if struct[3] >= 8 and struct[3] < 17: ekg.echo('£adnie to tak ircowaæ w pracy? ;)') sesja = ekg.session_get(session) if sesja.connected(): ekg.echo('Po³±czony!') else: ekg.echo('W tym miejscu jeszcze nie po³±czony') ekg.echo('Lista userów sesji: '+", ".join(sesja.users()))
def connect_handler(session): ekg.echo("Po³±czono! Ale super! Mo¿na gadaæ!") ekg.echo("Sesja : " + session) if session[:3] == 'irc': struct = time.gmtime() if struct[3] >= 8 and struct[3] < 17: ekg.echo('£adnie to tak ircowaæ w pracy? ;)') sesja = ekg.session_get(session) if sesja.connected(): ekg.echo('Po³±czony!') else: ekg.echo('W tym miejscu jeszcze nie po³±czony') ekg.echo('Lista userów sesji: ' + ", ".join(sesja.users()))
def message_handler(session, uid, type, text, sent_time, ignore_level): current_encoding = ekg.config["console_charset"] or "iso-8859-2" user = ekg.session_get(session).user_get(uid) uname = unicode(user.nickname or uid, current_encoding) htxt = uname + ":" msg = unicode(text[0:127], current_encoding) timeout = 2000 + len(msg) * 50 notif.Notify(dbus.String("ekg2"), dbus.UInt32(0), "", dbus.String(htxt), dbus.String(msg), dbus.String(""), {}, dbus.Int32(timeout)) return 1
def message_handler(session, uid, type, text, sent_time, ignore_level): current_encoding = ekg.config["console_charset"] or "iso-8859-2" user = ekg.session_get(session).user_get(uid) uname = unicode(user.nickname or uid, current_encoding) htxt = uname + ":" msg = unicode(text[0:127], current_encoding) timeout = 2000 + len(msg)*50 notif.Notify (dbus.String("ekg2"), dbus.UInt32(0), "", dbus.String(htxt), dbus.String(msg), dbus.String(""), {}, dbus.Int32(timeout) ) return 1
def get_sessions(self): """ Retrieve watched sessions from config. """ raw = self.ekgconfig['notify:sessions'] names = raw.split() sessions = {} for name in names: try: session = ekg.session_get(name) except KeyError: ekg.echo("Session '%s' doesn't exist" % name) else: sessions[name] = session return sessions
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"])
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"])
def status_handler(session, uid, status, desc): if status == ekg.STATUS_AVAIL: current_encoding = ekg.config["console_charset"] or "iso-8859-2" user = ekg.session_get(session).user_get(uid) uname = unicode(user.nickname or uid, current_encoding) htxt = uname + u" jest dostepn" htxt += (uname[-1] == "a" or uname[-1] == "A") and "a" or "y" if not desc: desc = "" else: desc = unicode(desc, current_encoding) timeout = 2000 + len(desc)*50 # (s appname, u id, s icon, s header, s body, as actions a{sv} hints, i timeout_ms) notif.Notify (dbus.String("ekg2"), dbus.UInt32(0), "", dbus.String(htxt), dbus.String(desc), dbus.String(""), {}, dbus.Int32(timeout) ) return 1
def status_handler(session, uid, status, desc): if status == ekg.STATUS_AVAIL: current_encoding = ekg.config["console_charset"] or "iso-8859-2" user = ekg.session_get(session).user_get(uid) uname = unicode(user.nickname or uid, current_encoding) htxt = uname + u" jest dostepn" htxt += (uname[-1] == "a" or uname[-1] == "A") and "a" or "y" if not desc: desc = "" else: desc = unicode(desc, current_encoding) timeout = 2000 + len(desc) * 50 # (s appname, u id, s icon, s header, s body, as actions a{sv} hints, i timeout_ms) notif.Notify(dbus.String("ekg2"), dbus.UInt32(0), "", dbus.String(htxt), dbus.String(desc), dbus.String(""), {}, dbus.Int32(timeout)) return 1
def status_handler(session, uid, status, desc): # for sesja in ekg.sessions(): # if sesja.connected(): # ekg.echo("sesja '%s' po³±czona" % (name,)) # ekg.echo("status: "+sesja['status']) # else: # ekg.echo("sesja '%s' nie jest po³±czona" % (name,)) ekg.echo("Dosta³em status!") ekg.echo("Sesja : " + session) ekg.echo("UID : " + uid) ekg.echo("Status: " + status) if desc: ekg.echo("Opis : " + desc) sesja = ekg.session_get(session) # ekg.echo('Lista userów sesji: '+", ".join(sesja.users())) user = sesja.user_get(uid) if user.last_status: ekg.echo(str(user.last_status)) stat, des = user.last_status ekg.echo("Ostatni status: " + stat) if user.last_status[1]: ekg.echo("Ostatni opis : " + des) else: ekg.echo( "Nie ma poprzedniego stanu - pewnie dopiero siê ³±czymy...") if user.ip: ekg.echo("IP: " + user.ip) if user.groups: ekg.echo("Grupy: " + ", ".join(user.groups())) if status == ekg.STATUS_AWAY: ekg.echo("Chyba go nie ma...") if status == ekg.STATUS_XA: ekg.echo( "Chyba bardzo go nie ma, to na grzyb mi taki status?. Po³ykam. *¶lurp*" ) return 0 return 1