zephyr_mirror: Split out the main loop into its own function.
(imported from commit 4c5639b3679f7ef0188e622bf7721bd3ee71bddc)
This commit is contained in:
parent
a72111c227
commit
a8fc07c745
|
@ -148,19 +148,26 @@ def process_loop(log):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
process_notice(notice, log)
|
||||||
|
except:
|
||||||
|
print >>sys.stderr, 'Error relaying zephyr'
|
||||||
|
traceback.print_exc()
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
def process_notice(notice, log):
|
||||||
zsig, body = notice.message.split("\x00", 1)
|
zsig, body = notice.message.split("\x00", 1)
|
||||||
is_personal = False
|
is_personal = False
|
||||||
is_huddle = False
|
is_huddle = False
|
||||||
|
|
||||||
if notice.opcode == "PING":
|
if notice.opcode == "PING":
|
||||||
# skip PING messages
|
# skip PING messages
|
||||||
continue
|
return
|
||||||
|
|
||||||
if isinstance(zsig, str):
|
if isinstance(zsig, str):
|
||||||
# Check for width unicode character u'\u200B'.encode("utf-8")
|
# Check for width unicode character u'\u200B'.encode("utf-8")
|
||||||
if u'\u200B'.encode("utf-8") in zsig:
|
if u'\u200B'.encode("utf-8") in zsig:
|
||||||
print "Skipping message from Humbug!"
|
print "Skipping message from Humbug!"
|
||||||
continue
|
return
|
||||||
|
|
||||||
sender = notice.sender.lower().replace("athena.mit.edu", "mit.edu")
|
sender = notice.sender.lower().replace("athena.mit.edu", "mit.edu")
|
||||||
recipient = notice.recipient.lower().replace("athena.mit.edu", "mit.edu")
|
recipient = notice.recipient.lower().replace("athena.mit.edu", "mit.edu")
|
||||||
|
@ -184,7 +191,7 @@ def process_loop(log):
|
||||||
if (notice.cls.lower() not in current_zephyr_subs) and not \
|
if (notice.cls.lower() not in current_zephyr_subs) and not \
|
||||||
(is_personal and options.forward_personals):
|
(is_personal and options.forward_personals):
|
||||||
print "Skipping ...", notice.cls, notice.instance, is_personal
|
print "Skipping ...", notice.cls, notice.instance, is_personal
|
||||||
continue
|
return
|
||||||
|
|
||||||
if is_huddle:
|
if is_huddle:
|
||||||
zeph = { 'type' : 'personal',
|
zeph = { 'type' : 'personal',
|
||||||
|
@ -220,10 +227,6 @@ def process_loop(log):
|
||||||
print >>sys.stderr, 'Error relaying zephyr'
|
print >>sys.stderr, 'Error relaying zephyr'
|
||||||
print zeph
|
print zeph
|
||||||
print res
|
print res
|
||||||
except:
|
|
||||||
print >>sys.stderr, 'Error relaying zephyr'
|
|
||||||
traceback.print_exc()
|
|
||||||
time.sleep(2)
|
|
||||||
|
|
||||||
|
|
||||||
def zephyr_to_humbug(options):
|
def zephyr_to_humbug(options):
|
||||||
|
|
Loading…
Reference in a new issue