@@ -0,0 +1,1634 @@
+# -*- coding: utf-8 -*-%0A%0Aimport urllib, os, subprocess, time%0Afrom daemon import runner%0A%0AURL = 'http://51t.ru/list.txt?h=1&el='%0AECHO = 'ii.14/pipe.2032'%0AMSGS_LST = '/var/tmp/check_new_msgs.lst'%0A#ECHO = '/'.join(os.listdir('echo'))%0A%0Aclass Check():%0A%0A    def __init__(self):%0A        self.stdin_path = '/dev/null'%0A        self.stdout_path = '/dev/null' # or /dev/tty for debug%0A        self.stderr_path = '/dev/null'%0A        self.pidfile_path =  '/tmp/check_new_msgs.pid'%0A        self.pidfile_timeout = 5%0A%0A    def run(self):%0A        while True:%0A            try:%0A                hashes = getf(URL+ECHO)%0A            except:%0A                time.sleep(10)%0A                continue%0A            oldhash = open(MSGS_LST).read().splitlines() if os.path.exists(MSGS_LST) else %5B%5D%0A            check_hashes(hashes, oldhash)%0A            time.sleep(600)%0A%0Adef getf(l):%0A    return urllib.urlopen(l).read()%0A%0A%0Adef sendmessage(message):%0A    subprocess.Popen(%5B'notify-send', message%5D)%0A    return%0A%0A%0A# Check hashes%0Adef check_hashes(hashes, oldhash):%0A    for n in hashes.splitlines():%0A        ea,cnt,hsh = n.split(':',2)%0A        check = %5Bx for x in oldhash if x.startswith(ea + ':')%5D%0A        if check:%0A            echoes = check%5B0%5D.split(':',2)%0A            if not echoes%5B2%5D.startswith('hsh/'):%0A                print 'error hsh: ' %25 ea%0A            elif echoes%5B2%5D != hsh:%0A                print ea%0A                sendmessage(%22ii%5Cn%D0%9D%D0%BE%D0%B2%D1%8B%D0%B5 %D1%81%D0%BE%D0%BE%D0%B1%D1%89%D0%B5%D0%BD%D0%B8%D1%8F %D0%B2%5Cn%22+ea)%0A        else:%0A            print ea%0A            sendmessage(%22ii%5Cn%D0%9D%D0%BE%D0%B2%D1%8B%D0%B5 %D1%81%D0%BE%D0%BE%D0%B1%D1%89%D0%B5%D0%BD%D0%B8%D1%8F %D0%B2%5Cn%22+ea)%0A%0A    open(MSGS_LST,'w').write(hashes)%0A%0Aapp = Check()%0Adaemon_runner = runner.DaemonRunner(app)%0Adaemon_runner.do_action()%0A

Check new messages