()
| 129 | |
| 130 | # Checks if bots are dead |
| 131 | def ping(): |
| 132 | while 1: |
| 133 | dead_bots = [] |
| 134 | for bot in bots.keys(): |
| 135 | try: |
| 136 | bot.settimeout(3) |
| 137 | send(bot, 'HI?', False, False) |
| 138 | if bot.recv(65536).decode() != 'HELLO_SERVER': |
| 139 | dead_bots.append(bot) |
| 140 | except: |
| 141 | dead_bots.append(bot) |
| 142 | |
| 143 | for bot in dead_bots: |
| 144 | bots.pop(bot) |
| 145 | bot.close() |
| 146 | time.sleep(5) |
| 147 | |
| 148 | # Client handler |
| 149 | def handle_client(client, address): |