diff --git a/badmath/Gyopi.py b/badmath/Gyopi.py index c36bdce..88ca069 100644 --- a/badmath/Gyopi.py +++ b/badmath/Gyopi.py @@ -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() diff --git a/badmath/badmath.py b/badmath/badmath.py index c9a48d0..e9c90fd 100644 --- a/badmath/badmath.py +++ b/badmath/badmath.py @@ -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, diff --git a/pollster/pollster.py b/pollster/pollster.py index b21921c..4dcd4b6 100755 --- a/pollster/pollster.py +++ b/pollster/pollster.py @@ -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('
Poll number: %d
' % poll_no) + poll_no += 1 + t_end = time.time() exec_time = int(t_end - t_start) sleep_time = POLL_INTERVAL - exec_time