File: xtellreply

package info (click to toggle)
xtell 2.9
  • links: PTS
  • area: main
  • in suites: woody
  • size: 188 kB
  • ctags: 73
  • sloc: ansic: 982; sh: 117; makefile: 78; python: 22
file content (31 lines) | stat: -rwxr-xr-x 673 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/python

# try to find out who sent you last xtell message and reply
# to him/her

import sys, os, string

if len(sys.argv)>1:
    os.execvp("xtell", sys.argv)

try:
    f = open(os.path.join(os.environ["HOME"], ".xtell-log"))
except IOError:
    print "Sorry, cannot find out who called you last"
    sys.exit()

f.seek(0, 2) # to the end of file
buf = ""
for i in xrange(2000):
    f.seek(-1,1)
    ch = f.read(1)
    f.seek(-1,1)
    if ch in string.digits+string.letters+"-@.":
        buf = ch + buf
    else:
        if '@' in buf:
            print "Replying to", buf
            os.execvp("xtell", ("xtell", buf))
            sys.exit()
        buf = ''