def disconnect(self, reason="You disconnected!"): if not self.__onServer: return User.notOnServer if self in self.server.users: self.server.users.remove(self) self.__onServer = False self.send(Info("You disconnected, because: ") + reason) self.__conn.close() self.join_leave_msg("Disconnected")
def execute(caller, args, ex): if len(args) < 1: return ex.SHOW_USAGE res = ex.server.nick2user(args[0]) if res is ex.server.userNotFound: return ex.server.INVALID_ARG caller.send(Info("User IP: " + res.ip))
def accept_success(self): if self.__onServer: return self.join_leave_msg("Connected") self.send(Info("Connect success! Welcome on IP: ") + self.server.HOST) self.server.users.append(self) User.count += 1 self.__onServer = True self.__th.start()
def execute(self, name, caller, args): if name not in globals().keys(): caller.send(Error("Command not found!")) return cmd = globals()[name] if cmd.isadmin and not caller.admin: caller.send(Error("You haven't enough permissions!")) return if len(args) == 1: if args[0] == "help": caller.send(Info(cmd.help_txt)) return code = cmd.execute(caller, args, self) if code is Executor.INVALID_ARG: caller.send(Error("Invalid argument!")) elif code is Executor.SHOW_USAGE: caller.send(Error("Syntax: ") + cmd.syntax)
def execute(caller, args, ex): nicks = [] for u in ex.server.users: nicks.append(u.nick) caller.send(Info("Online users-> ") + ", ".join(nicks)) nicks.clear()
def execute(caller, args, ex): caller.send(Info("Available commands: " + ", ".join(__all__)))
def accept_canceled(self, reason): if not self.__onServer: return self.send(Info("Connect canceled, because: ") + reason) self.disconnect()