/usr/lib/gozerbot/mailudp.py is in gozerbot 0.99.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #!/usr/bin/env python
#
#
# copy this to your home dir and make a .forward file like this:
# (bart@r8):~
# $ cat .forward
# \bart
# "|~/mailudp.py"
#
# edit config vars below to match your bot's config
__copyright__ = 'this file is in the public domain'
import socket, sys, re
# config
host = 'gozerbot.org'
port = 5600
passwd = 'mekker'
printto = 'dunk_'
# end config
def out(what):
z = '%s %s %s' % (passwd, printto, what)
z = z[:400]
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(z, (host, port))
fromre = re.compile('^From: (.*)\n', re.M)
subjectre = re.compile('^Subject: (.*)\n', re.M)
frm = ""
subject = ""
a = sys.stdin.readlines()
for i in a:
try:
b = fromre.search(i)
if b:
frm = b.group(0).strip()
c = subjectre.search(i)
if c:
subject = c.group(0).strip()
if frm and subject:
break
except Exception:
pass
if frm and subject:
result = "%s %s" % (frm, subject)
out(result)
|