merged changed from tfi server

This commit is contained in:
Curt Hash 2010-01-19 15:11:59 -07:00
parent 1bd31704e8
commit 1328229708
3 changed files with 19 additions and 8 deletions

View File

@ -179,7 +179,7 @@ class Gyopi(irc.Bot):
self._tellFlag(forum)
elif cmd.startswith('h'):
# Help
forum.msg('Goal: Help me with my math homework, FROM ANOTHER DIMENSION!')
forum.msg('''Goal: Help me with my math homework, FROM ANOTHER DIMENSION! Order of operations is always left to right in that dimension, but the operators are alien.''')
forum.msg('Order of operations is always left to right.')
#forum.msg('Goal: The current winner gets to control the contest music.')
forum.msg('Commands: !help, !flag, !register [TEAM], !solve SOLUTION,!? EQUATION, !ops, !problem, !who')
@ -189,6 +189,8 @@ class Gyopi(irc.Bot):
# Solve
team = self._affiliations.get(who)
lastAttempt = time.time() - self._lastAttempt.get(team, 0)
#UN-COMMENT AFTER NMT CTF
# self._lastAttempt[team] = time.time()
answer = badmath.solve(self._key, self._puzzle)
try:
attempt = int(''.join(args).strip())
@ -227,6 +229,7 @@ class Gyopi(irc.Bot):
if len(tokens) > 3:
forum.msg('%s: You can only test one op at a time.' % who)
return
for num in self._banned:
if num in tokens:
@ -237,8 +240,8 @@ class Gyopi(irc.Bot):
try:
result = badmath.solve(self._key, tokens)
forum.msg('%s: %s -> %d' % (who, ''.join(args), result))
except:
forum.msg("%s: That doesn't work at all." % who)
except Exception as msg:
forum.msg("%s: That doesn't work at all: %s" % (who, msg))
elif cmd == 'birdzerk':
self._saveState()

View File

@ -17,7 +17,7 @@ OPS = [lambda a, b: a + b,
lambda a, b: max(a,b)//2,
lambda a, b: min(a,b)*3,
lambda a, b: a % 2,
lambda a, b: math.degrees(b + a),
lambda a, b: int(math.degrees(b + a)),
lambda a, b: ~(a & b),
lambda a, b: ~(a ^ b),
lambda a, b: a + b - a%b,

View File

@ -140,7 +140,7 @@ POLLS = {
}
ip_re = re.compile('(\d{1,3}\.){3}\d{1,3}')
poll_no = 0
# loop forever
while True:
@ -157,7 +157,11 @@ while True:
continue
# remove the file
os.remove(os.path.join(IP_DIR, ip))
try:
os.remove(os.path.join(IP_DIR, ip))
except Exception as e:
print('pollster: could not remove %s' % os.path.join(IP_DIR, ip))
traceback.print_exc()
results = {}
@ -171,8 +175,9 @@ while True:
# perform polls
for service,func in POLLS.items():
team = func(ip).decode('utf-8')
if team is None:
try:
team = func(ip).decode('utf-8')
except:
team = 'dirtbags'
if DEBUG is True:
@ -189,6 +194,9 @@ while True:
if DEBUG is True:
print('+-----------------------------------------+')
out.write('<p>Poll number: %d</p>' % poll_no)
poll_no += 1
t_end = time.time()
exec_time = int(t_end - t_start)
sleep_time = POLL_INTERVAL - exec_time