source file: p10/commands/server.py
file stats: 29 lines, 29 executed: 100.0% covered
1. #!/usr/bin/env python 2. 3. import genericcommand 4. import p10.base64 5. 6. class server(genericcommand.genericcommand): 7. """ Parses servers being introduced """ 8. 9. _connection = None 10. 11. def __init__(self, state, connection): 12. self._connection = connection 13. genericcommand.genericcommand.__init__(self, state) 14. 15. def handle(self, origin, args): 16. numeric = p10.base64.toInt(args[5][0:2]) 17. name = args[0] 18. maxclients = p10.base64.toInt(args[5][2:5]) 19. boot_ts = int(args[2]) 20. link_ts = int(args[3]) 21. protocol = args[4] 22. hops = int(args[1]) 23. modes = [] 24. flag = "+" 25. for mode in args[6]: 26. if mode == "+" or mode == "-": 27. flag = mode 28. else: 29. modes.append((flag + mode, None)) 30. desc = args[-1] 31. self._state.newServer(origin, numeric, name, maxclients, boot_ts, link_ts, protocol, hops, modes, desc) 32. if self._connection != None: 33. self._connection.registerNumeric(numeric)